From a09236f6b7ce4ee567938c8668779beec64e4a13 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Feb 2026 04:00:02 +0900 Subject: [PATCH 01/51] initial liblzma-rs with sys equivalence tests --- Cargo.toml | 11 +- benches/backend_comparison.rs | 187 + liblzma-rs-sys/Cargo.toml | 21 + liblzma-rs-sys/src/lib.rs | 680 ++ liblzma-rs/Cargo.toml | 12 + liblzma-rs/src/check/check.rs | 162 + liblzma-rs/src/check/crc32_fast.rs | 2143 +++++ liblzma-rs/src/check/crc64_fast.rs | 1100 +++ liblzma-rs/src/check/mod.rs | 4 + liblzma-rs/src/check/sha256.rs | 3434 +++++++ liblzma-rs/src/common/alone_decoder.rs | 601 ++ liblzma-rs/src/common/alone_encoder.rs | 517 ++ liblzma-rs/src/common/auto_decoder.rs | 519 ++ liblzma-rs/src/common/block_buffer_decoder.rs | 246 + liblzma-rs/src/common/block_buffer_encoder.rs | 629 ++ liblzma-rs/src/common/block_decoder.rs | 641 ++ liblzma-rs/src/common/block_encoder.rs | 603 ++ liblzma-rs/src/common/block_header_decoder.rs | 244 + liblzma-rs/src/common/block_header_encoder.rs | 260 + liblzma-rs/src/common/block_util.rs | 157 + liblzma-rs/src/common/common.rs | 690 ++ liblzma-rs/src/common/easy_buffer_encoder.rs | 169 + .../src/common/easy_decoder_memusage.rs | 99 + liblzma-rs/src/common/easy_encoder.rs | 260 + .../src/common/easy_encoder_memusage.rs | 99 + liblzma-rs/src/common/easy_preset.rs | 81 + liblzma-rs/src/common/file_info.rs | 1064 +++ .../src/common/filter_buffer_decoder.rs | 229 + .../src/common/filter_buffer_encoder.rs | 200 + liblzma-rs/src/common/filter_common.rs | 599 ++ liblzma-rs/src/common/filter_decoder.rs | 688 ++ liblzma-rs/src/common/filter_encoder.rs | 838 ++ liblzma-rs/src/common/filter_flags_decoder.rs | 118 + liblzma-rs/src/common/filter_flags_encoder.rs | 125 + liblzma-rs/src/common/hardware_cputhreads.rs | 8 + liblzma-rs/src/common/hardware_physmem.rs | 8 + liblzma-rs/src/common/index.rs | 1252 +++ liblzma-rs/src/common/index_decoder.rs | 662 ++ liblzma-rs/src/common/index_encoder.rs | 637 ++ liblzma-rs/src/common/index_hash.rs | 482 + liblzma-rs/src/common/lzip_decoder.rs | 787 ++ liblzma-rs/src/common/microlzma_decoder.rs | 574 ++ liblzma-rs/src/common/microlzma_encoder.rs | 465 + liblzma-rs/src/common/mod.rs | 45 + liblzma-rs/src/common/outqueue.rs | 317 + .../src/common/stream_buffer_decoder.rs | 225 + .../src/common/stream_buffer_encoder.rs | 321 + liblzma-rs/src/common/stream_decoder.rs | 871 ++ liblzma-rs/src/common/stream_encoder.rs | 813 ++ liblzma-rs/src/common/stream_flags_common.rs | 112 + liblzma-rs/src/common/stream_flags_decoder.rs | 185 + liblzma-rs/src/common/stream_flags_encoder.rs | 173 + liblzma-rs/src/common/string_conversion.rs | 1807 ++++ liblzma-rs/src/common/vli_decoder.rs | 96 + liblzma-rs/src/common/vli_encoder.rs | 80 + liblzma-rs/src/common/vli_size.rs | 22 + liblzma-rs/src/delta/delta_common.rs | 265 + liblzma-rs/src/delta/delta_decoder.rs | 274 + liblzma-rs/src/delta/delta_encoder.rs | 346 + liblzma-rs/src/delta/mod.rs | 3 + liblzma-rs/src/lib.rs | 22 + liblzma-rs/src/lz/lz_decoder.rs | 552 ++ liblzma-rs/src/lz/lz_encoder.rs | 921 ++ liblzma-rs/src/lz/lz_encoder_mf.rs | 1001 ++ liblzma-rs/src/lz/mod.rs | 3 + liblzma-rs/src/lzma/fastpos_table.rs | 8196 +++++++++++++++++ liblzma-rs/src/lzma/lzma2_decoder.rs | 641 ++ liblzma-rs/src/lzma/lzma2_encoder.rs | 846 ++ liblzma-rs/src/lzma/lzma_decoder.rs | 4528 +++++++++ liblzma-rs/src/lzma/lzma_encoder.rs | 1759 ++++ .../src/lzma/lzma_encoder_optimum_fast.rs | 366 + .../src/lzma/lzma_encoder_optimum_normal.rs | 1541 ++++ liblzma-rs/src/lzma/lzma_encoder_presets.rs | 128 + liblzma-rs/src/lzma/mod.rs | 8 + liblzma-rs/src/rangecoder/mod.rs | 1 + liblzma-rs/src/rangecoder/price_table.rs | 132 + liblzma-rs/src/simple/arm.rs | 242 + liblzma-rs/src/simple/arm64.rs | 262 + liblzma-rs/src/simple/armthumb.rs | 252 + liblzma-rs/src/simple/ia64.rs | 314 + liblzma-rs/src/simple/mod.rs | 11 + liblzma-rs/src/simple/powerpc.rs | 245 + liblzma-rs/src/simple/riscv.rs | 479 + liblzma-rs/src/simple/simple_coder.rs | 540 ++ liblzma-rs/src/simple/simple_decoder.rs | 99 + liblzma-rs/src/simple/simple_encoder.rs | 68 + liblzma-rs/src/simple/sparc.rs | 250 + liblzma-rs/src/simple/x86.rs | 393 + liblzma-rs/src/tuklib/mod.rs | 2 + liblzma-rs/src/tuklib/tuklib_cpucores.rs | 9 + liblzma-rs/src/tuklib/tuklib_physmem.rs | 45 + systest/Cargo.toml | 8 +- systest/build.rs | 24 +- systest/src/main.rs | 11 +- tests/sys_equivalence.rs | 584 ++ 95 files changed, 52735 insertions(+), 8 deletions(-) create mode 100644 benches/backend_comparison.rs create mode 100644 liblzma-rs-sys/Cargo.toml create mode 100644 liblzma-rs-sys/src/lib.rs create mode 100644 liblzma-rs/Cargo.toml create mode 100644 liblzma-rs/src/check/check.rs create mode 100644 liblzma-rs/src/check/crc32_fast.rs create mode 100644 liblzma-rs/src/check/crc64_fast.rs create mode 100644 liblzma-rs/src/check/mod.rs create mode 100644 liblzma-rs/src/check/sha256.rs create mode 100644 liblzma-rs/src/common/alone_decoder.rs create mode 100644 liblzma-rs/src/common/alone_encoder.rs create mode 100644 liblzma-rs/src/common/auto_decoder.rs create mode 100644 liblzma-rs/src/common/block_buffer_decoder.rs create mode 100644 liblzma-rs/src/common/block_buffer_encoder.rs create mode 100644 liblzma-rs/src/common/block_decoder.rs create mode 100644 liblzma-rs/src/common/block_encoder.rs create mode 100644 liblzma-rs/src/common/block_header_decoder.rs create mode 100644 liblzma-rs/src/common/block_header_encoder.rs create mode 100644 liblzma-rs/src/common/block_util.rs create mode 100644 liblzma-rs/src/common/common.rs create mode 100644 liblzma-rs/src/common/easy_buffer_encoder.rs create mode 100644 liblzma-rs/src/common/easy_decoder_memusage.rs create mode 100644 liblzma-rs/src/common/easy_encoder.rs create mode 100644 liblzma-rs/src/common/easy_encoder_memusage.rs create mode 100644 liblzma-rs/src/common/easy_preset.rs create mode 100644 liblzma-rs/src/common/file_info.rs create mode 100644 liblzma-rs/src/common/filter_buffer_decoder.rs create mode 100644 liblzma-rs/src/common/filter_buffer_encoder.rs create mode 100644 liblzma-rs/src/common/filter_common.rs create mode 100644 liblzma-rs/src/common/filter_decoder.rs create mode 100644 liblzma-rs/src/common/filter_encoder.rs create mode 100644 liblzma-rs/src/common/filter_flags_decoder.rs create mode 100644 liblzma-rs/src/common/filter_flags_encoder.rs create mode 100644 liblzma-rs/src/common/hardware_cputhreads.rs create mode 100644 liblzma-rs/src/common/hardware_physmem.rs create mode 100644 liblzma-rs/src/common/index.rs create mode 100644 liblzma-rs/src/common/index_decoder.rs create mode 100644 liblzma-rs/src/common/index_encoder.rs create mode 100644 liblzma-rs/src/common/index_hash.rs create mode 100644 liblzma-rs/src/common/lzip_decoder.rs create mode 100644 liblzma-rs/src/common/microlzma_decoder.rs create mode 100644 liblzma-rs/src/common/microlzma_encoder.rs create mode 100644 liblzma-rs/src/common/mod.rs create mode 100644 liblzma-rs/src/common/outqueue.rs create mode 100644 liblzma-rs/src/common/stream_buffer_decoder.rs create mode 100644 liblzma-rs/src/common/stream_buffer_encoder.rs create mode 100644 liblzma-rs/src/common/stream_decoder.rs create mode 100644 liblzma-rs/src/common/stream_encoder.rs create mode 100644 liblzma-rs/src/common/stream_flags_common.rs create mode 100644 liblzma-rs/src/common/stream_flags_decoder.rs create mode 100644 liblzma-rs/src/common/stream_flags_encoder.rs create mode 100644 liblzma-rs/src/common/string_conversion.rs create mode 100644 liblzma-rs/src/common/vli_decoder.rs create mode 100644 liblzma-rs/src/common/vli_encoder.rs create mode 100644 liblzma-rs/src/common/vli_size.rs create mode 100644 liblzma-rs/src/delta/delta_common.rs create mode 100644 liblzma-rs/src/delta/delta_decoder.rs create mode 100644 liblzma-rs/src/delta/delta_encoder.rs create mode 100644 liblzma-rs/src/delta/mod.rs create mode 100644 liblzma-rs/src/lib.rs create mode 100644 liblzma-rs/src/lz/lz_decoder.rs create mode 100644 liblzma-rs/src/lz/lz_encoder.rs create mode 100644 liblzma-rs/src/lz/lz_encoder_mf.rs create mode 100644 liblzma-rs/src/lz/mod.rs create mode 100644 liblzma-rs/src/lzma/fastpos_table.rs create mode 100644 liblzma-rs/src/lzma/lzma2_decoder.rs create mode 100644 liblzma-rs/src/lzma/lzma2_encoder.rs create mode 100644 liblzma-rs/src/lzma/lzma_decoder.rs create mode 100644 liblzma-rs/src/lzma/lzma_encoder.rs create mode 100644 liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs create mode 100644 liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs create mode 100644 liblzma-rs/src/lzma/lzma_encoder_presets.rs create mode 100644 liblzma-rs/src/lzma/mod.rs create mode 100644 liblzma-rs/src/rangecoder/mod.rs create mode 100644 liblzma-rs/src/rangecoder/price_table.rs create mode 100644 liblzma-rs/src/simple/arm.rs create mode 100644 liblzma-rs/src/simple/arm64.rs create mode 100644 liblzma-rs/src/simple/armthumb.rs create mode 100644 liblzma-rs/src/simple/ia64.rs create mode 100644 liblzma-rs/src/simple/mod.rs create mode 100644 liblzma-rs/src/simple/powerpc.rs create mode 100644 liblzma-rs/src/simple/riscv.rs create mode 100644 liblzma-rs/src/simple/simple_coder.rs create mode 100644 liblzma-rs/src/simple/simple_decoder.rs create mode 100644 liblzma-rs/src/simple/simple_encoder.rs create mode 100644 liblzma-rs/src/simple/sparc.rs create mode 100644 liblzma-rs/src/simple/x86.rs create mode 100644 liblzma-rs/src/tuklib/mod.rs create mode 100644 liblzma-rs/src/tuklib/tuklib_cpucores.rs create mode 100644 liblzma-rs/src/tuklib/tuklib_physmem.rs create mode 100644 tests/sys_equivalence.rs diff --git a/Cargo.toml b/Cargo.toml index a62c4917..24998498 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,15 +17,22 @@ rust-version = "1.60" exclude = [".github/"] [workspace] -members = ["systest"] +members = ["systest", "liblzma-rs", "liblzma-rs-sys"] [dependencies] -liblzma-sys = { path = "liblzma-sys", version = "0.4.3", default-features = false } +liblzma-sys = { package = "liblzma-rs-sys", path = "liblzma-rs-sys" } +liblzma-c-sys = { package = "liblzma-sys", path = "liblzma-sys", version = "0.4.3", default-features = false, optional = true } num_cpus = { version = "1.16.0", optional = true } [dev-dependencies] rand = "0.8.0" quickcheck = "1.0.1" +criterion = { version = "0.5", features = ["html_reports"] } +liblzma-c-sys-test = { package = "liblzma-sys", path = "liblzma-sys", version = "0.4.5", default-features = false, features = ["bindgen"] } + +[[bench]] +name = "backend_comparison" +harness = false [target.'cfg(target_arch = "wasm32")'.dev-dependencies] getrandom = { version = "0.2", features = ["js"] } diff --git a/benches/backend_comparison.rs b/benches/backend_comparison.rs new file mode 100644 index 00000000..371ef7cd --- /dev/null +++ b/benches/backend_comparison.rs @@ -0,0 +1,187 @@ +use std::ptr; + +use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; + +use liblzma_c_sys_test as c_sys; +use liblzma_sys as rs_sys; + +fn make_payload(size: usize) -> Vec { + let mut x: u64 = 0x9E3779B97F4A7C15; + let mut out = Vec::with_capacity(size); + for _ in 0..size { + x ^= x >> 12; + x ^= x << 25; + x ^= x >> 27; + out.push((x.wrapping_mul(0x2545F4914F6CDD1D) >> 56) as u8); + } + out +} + +unsafe fn c_encode(input: &[u8]) -> Vec { + let bound = c_sys::lzma_stream_buffer_bound(input.len()); + let mut out = vec![0u8; bound]; + let mut out_pos: usize = 0; + c_sys::lzma_easy_buffer_encode( + 6, + c_sys::LZMA_CHECK_CRC64, + ptr::null(), + input.as_ptr(), + input.len(), + out.as_mut_ptr(), + &mut out_pos, + out.len(), + ); + out.truncate(out_pos); + out +} + +unsafe fn rs_encode(input: &[u8]) -> Vec { + let bound = rs_sys::lzma_stream_buffer_bound(input.len()); + let mut out = vec![0u8; bound]; + let mut out_pos: usize = 0; + rs_sys::lzma_easy_buffer_encode( + 6, + rs_sys::LZMA_CHECK_CRC64, + ptr::null(), + input.as_ptr(), + input.len(), + out.as_mut_ptr(), + &mut out_pos, + out.len(), + ); + out.truncate(out_pos); + out +} + +unsafe fn c_decode(compressed: &[u8], out_size: usize) -> Vec { + let mut out = vec![0u8; out_size]; + let mut memlimit = u64::MAX; + let mut in_pos = 0usize; + let mut out_pos = 0usize; + c_sys::lzma_stream_buffer_decode( + &mut memlimit, + 0, + ptr::null(), + compressed.as_ptr(), + &mut in_pos, + compressed.len(), + out.as_mut_ptr(), + &mut out_pos, + out.len(), + ); + out.truncate(out_pos); + out +} + +unsafe fn rs_decode(compressed: &[u8], out_size: usize) -> Vec { + let mut out = vec![0u8; out_size]; + let mut memlimit = u64::MAX; + let mut in_pos = 0usize; + let mut out_pos = 0usize; + rs_sys::lzma_stream_buffer_decode( + &mut memlimit, + 0, + ptr::null(), + compressed.as_ptr(), + &mut in_pos, + compressed.len(), + out.as_mut_ptr(), + &mut out_pos, + out.len(), + ); + out.truncate(out_pos); + out +} + +fn bench_encode(c: &mut Criterion) { + let sizes: &[(usize, &str)] = &[ + (1024, "1KB"), + (64 * 1024, "64KB"), + (1024 * 1024, "1MB"), + ]; + + let mut group = c.benchmark_group("encode"); + for &(size, label) in sizes { + let input = make_payload(size); + group.throughput(Throughput::Bytes(size as u64)); + + group.bench_with_input(BenchmarkId::new("c", label), &input, |b, input| { + b.iter(|| unsafe { c_encode(black_box(input)) }) + }); + group.bench_with_input(BenchmarkId::new("rust", label), &input, |b, input| { + b.iter(|| unsafe { rs_encode(black_box(input)) }) + }); + } + group.finish(); +} + +fn bench_decode(c: &mut Criterion) { + let sizes: &[(usize, &str)] = &[ + (1024, "1KB"), + (64 * 1024, "64KB"), + (1024 * 1024, "1MB"), + ]; + + let mut group = c.benchmark_group("decode"); + for &(size, label) in sizes { + let input = make_payload(size); + let c_compressed = unsafe { c_encode(&input) }; + let rs_compressed = unsafe { rs_encode(&input) }; + group.throughput(Throughput::Bytes(size as u64)); + + group.bench_with_input(BenchmarkId::new("c", label), &c_compressed, |b, data| { + b.iter(|| unsafe { c_decode(black_box(data), size) }) + }); + group.bench_with_input(BenchmarkId::new("rust", label), &rs_compressed, |b, data| { + b.iter(|| unsafe { rs_decode(black_box(data), size) }) + }); + } + group.finish(); +} + +fn bench_crc32(c: &mut Criterion) { + let sizes: &[(usize, &str)] = &[ + (1024, "1KB"), + (64 * 1024, "64KB"), + (1024 * 1024, "1MB"), + ]; + + let mut group = c.benchmark_group("crc32"); + for &(size, label) in sizes { + let data = make_payload(size); + group.throughput(Throughput::Bytes(size as u64)); + + group.bench_with_input(BenchmarkId::new("c", label), &data, |b, data| { + b.iter(|| unsafe { c_sys::lzma_crc32(black_box(data.as_ptr()), data.len(), 0) }) + }); + group.bench_with_input(BenchmarkId::new("rust", label), &data, |b, data| { + b.iter(|| unsafe { rs_sys::lzma_crc32(black_box(data.as_ptr()), data.len(), 0) }) + }); + } + group.finish(); +} + +fn bench_crc64(c: &mut Criterion) { + let sizes: &[(usize, &str)] = &[ + (1024, "1KB"), + (64 * 1024, "64KB"), + (1024 * 1024, "1MB"), + ]; + + let mut group = c.benchmark_group("crc64"); + for &(size, label) in sizes { + let data = make_payload(size); + group.throughput(Throughput::Bytes(size as u64)); + + group.bench_with_input(BenchmarkId::new("c", label), &data, |b, data| { + b.iter(|| unsafe { c_sys::lzma_crc64(black_box(data.as_ptr()), data.len(), 0) }) + }); + group.bench_with_input(BenchmarkId::new("rust", label), &data, |b, data| { + b.iter(|| unsafe { rs_sys::lzma_crc64(black_box(data.as_ptr()), data.len(), 0) }) + }); + } + group.finish(); +} + +criterion_group!(benches, bench_encode, bench_decode, bench_crc32, bench_crc64); +criterion_main!(benches); diff --git a/liblzma-rs-sys/Cargo.toml b/liblzma-rs-sys/Cargo.toml new file mode 100644 index 00000000..46ce6e1d --- /dev/null +++ b/liblzma-rs-sys/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "liblzma-rs-sys" +version = "0.1.0" +edition = "2021" +license = "MIT OR Apache-2.0" +description = "liblzma-sys compatible API layer backed by pure Rust liblzma-rs" + +[features] +default = ["bindgen"] +# Feature stubs matching liblzma-sys for smooth migration +static = [] +parallel = [] +bindgen = [] +wasm = ["static", "bindgen"] +uncheck_liblzma_version = [] +fat-lto = [] +thin-lto = [] + +[dependencies] +liblzma-rs = { path = "../liblzma-rs" } +libc = "0.2" diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs new file mode 100644 index 00000000..150aa277 --- /dev/null +++ b/liblzma-rs-sys/src/lib.rs @@ -0,0 +1,680 @@ +//! liblzma-sys compatible API layer backed by pure Rust liblzma-rs +//! +//! Re-exports symbols from liblzma-rs with the same names and signatures +//! as liblzma-sys, enabling drop-in replacement. +//! +//! Because c2rust generates per-file type definitions, this layer provides +//! canonical types and thin wrapper functions that cast between structurally +//! identical `#[repr(C)]` types. + +#![allow( + non_camel_case_types, + non_snake_case, + non_upper_case_globals, + unused_imports, + clippy::all, +)] + +use core::ffi::{c_char, c_uchar, c_uint, c_void}; +use libc::size_t; + +// === Canonical type aliases === +// On MSVC, C enums are c_int; elsewhere c_uint (matching liblzma-sys manual.rs) +#[cfg(target_env = "msvc")] +#[doc(hidden)] +pub type __enum_ty = core::ffi::c_int; +#[cfg(not(target_env = "msvc"))] +#[doc(hidden)] +pub type __enum_ty = c_uint; + +pub type lzma_ret = __enum_ty; +pub type lzma_action = __enum_ty; +pub type lzma_check = __enum_ty; +pub type lzma_mode = __enum_ty; +pub type lzma_match_finder = __enum_ty; +pub type lzma_bool = c_uchar; +pub type lzma_vli = u64; + +// === Canonical struct re-exports === +pub use liblzma_rs::common::common::lzma_stream; +pub use liblzma_rs::common::common::lzma_allocator; +pub use liblzma_rs::common::filter_common::lzma_options_lzma; +pub use liblzma_rs::delta::delta_common::lzma_filter; +pub use liblzma_rs::common::index_decoder::lzma_index; +pub use liblzma_rs::common::stream_flags_decoder::lzma_stream_flags; + +#[repr(C)] +pub struct lzma_options_bcj { + pub start_offset: u32, +} + +pub enum lzma_internal {} + +// ========================================================================= +// Constants +// ========================================================================= + +// --- Return codes / actions --- +pub const LZMA_OK: lzma_ret = liblzma_rs::common::common::LZMA_OK as lzma_ret; +pub const LZMA_STREAM_END: lzma_ret = liblzma_rs::common::common::LZMA_STREAM_END as lzma_ret; +pub const LZMA_NO_CHECK: lzma_ret = liblzma_rs::common::common::LZMA_NO_CHECK as lzma_ret; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = + liblzma_rs::common::common::LZMA_UNSUPPORTED_CHECK as lzma_ret; +pub const LZMA_GET_CHECK: lzma_ret = liblzma_rs::common::common::LZMA_GET_CHECK as lzma_ret; +pub const LZMA_MEM_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_MEM_ERROR as lzma_ret; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = + liblzma_rs::common::common::LZMA_MEMLIMIT_ERROR as lzma_ret; +pub const LZMA_FORMAT_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_FORMAT_ERROR as lzma_ret; +pub const LZMA_OPTIONS_ERROR: lzma_ret = + liblzma_rs::common::common::LZMA_OPTIONS_ERROR as lzma_ret; +pub const LZMA_DATA_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_DATA_ERROR as lzma_ret; +pub const LZMA_BUF_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_BUF_ERROR as lzma_ret; +pub const LZMA_PROG_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_PROG_ERROR as lzma_ret; +pub const LZMA_SEEK_NEEDED: lzma_ret = liblzma_rs::common::common::LZMA_SEEK_NEEDED as lzma_ret; + +pub const LZMA_RUN: lzma_action = liblzma_rs::common::common::LZMA_RUN as lzma_action; +pub const LZMA_SYNC_FLUSH: lzma_action = + liblzma_rs::common::common::LZMA_SYNC_FLUSH as lzma_action; +pub const LZMA_FULL_FLUSH: lzma_action = + liblzma_rs::common::common::LZMA_FULL_FLUSH as lzma_action; +pub const LZMA_FULL_BARRIER: lzma_action = + liblzma_rs::common::common::LZMA_FULL_BARRIER as lzma_action; +pub const LZMA_FINISH: lzma_action = liblzma_rs::common::common::LZMA_FINISH as lzma_action; + +// --- Check types --- +pub const LZMA_CHECK_NONE: lzma_check = liblzma_rs::check::check::LZMA_CHECK_NONE as lzma_check; +pub const LZMA_CHECK_CRC32: lzma_check = liblzma_rs::check::check::LZMA_CHECK_CRC32 as lzma_check; +pub const LZMA_CHECK_CRC64: lzma_check = liblzma_rs::check::check::LZMA_CHECK_CRC64 as lzma_check; +pub const LZMA_CHECK_SHA256: lzma_check = + liblzma_rs::check::check::LZMA_CHECK_SHA256 as lzma_check; + +// --- Modes / match finders / filter IDs --- +pub const LZMA_MODE_FAST: lzma_mode = + liblzma_rs::common::filter_common::LZMA_MODE_FAST as lzma_mode; +pub const LZMA_MODE_NORMAL: lzma_mode = + liblzma_rs::common::filter_common::LZMA_MODE_NORMAL as lzma_mode; +pub const LZMA_MF_HC3: lzma_match_finder = + liblzma_rs::common::filter_common::LZMA_MF_HC3 as lzma_match_finder; +pub const LZMA_MF_HC4: lzma_match_finder = + liblzma_rs::common::filter_common::LZMA_MF_HC4 as lzma_match_finder; +pub const LZMA_MF_BT2: lzma_match_finder = + liblzma_rs::common::filter_common::LZMA_MF_BT2 as lzma_match_finder; +pub const LZMA_MF_BT3: lzma_match_finder = + liblzma_rs::common::filter_common::LZMA_MF_BT3 as lzma_match_finder; +pub const LZMA_MF_BT4: lzma_match_finder = + liblzma_rs::common::filter_common::LZMA_MF_BT4 as lzma_match_finder; + +pub const LZMA_FILTER_X86: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_X86 as lzma_vli; +pub const LZMA_FILTER_POWERPC: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_POWERPC as lzma_vli; +pub const LZMA_FILTER_IA64: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_IA64 as lzma_vli; +pub const LZMA_FILTER_ARM: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_ARM as lzma_vli; +pub const LZMA_FILTER_ARMTHUMB: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_ARMTHUMB as lzma_vli; +pub const LZMA_FILTER_SPARC: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_SPARC as lzma_vli; +pub const LZMA_FILTER_ARM64: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_ARM64 as lzma_vli; +pub const LZMA_FILTER_DELTA: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_DELTA as lzma_vli; +pub const LZMA_FILTER_RISCV: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_RISCV as lzma_vli; +pub const LZMA_FILTER_LZMA1: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_LZMA1 as lzma_vli; +pub const LZMA_FILTER_LZMA2: lzma_vli = + liblzma_rs::common::filter_common::LZMA_FILTER_LZMA2 as lzma_vli; + +// --- Decoder flags --- +pub const LZMA_TELL_NO_CHECK: u32 = + liblzma_rs::common::auto_decoder::LZMA_TELL_NO_CHECK as u32; +pub const LZMA_TELL_UNSUPPORTED_CHECK: u32 = + liblzma_rs::common::auto_decoder::LZMA_TELL_UNSUPPORTED_CHECK as u32; +pub const LZMA_TELL_ANY_CHECK: u32 = liblzma_rs::common::auto_decoder::LZMA_TELL_ANY_CHECK as u32; +pub const LZMA_IGNORE_CHECK: u32 = liblzma_rs::common::auto_decoder::LZMA_IGNORE_CHECK as u32; +pub const LZMA_CONCATENATED: u32 = liblzma_rs::common::auto_decoder::LZMA_CONCATENATED as u32; + +// --- Presets / option limits --- +pub const LZMA_PRESET_DEFAULT: u32 = + liblzma_rs::common::string_conversion::LZMA_PRESET_DEFAULT as u32; +pub const LZMA_PRESET_LEVEL_MASK: u32 = + liblzma_rs::lzma::lzma_encoder_presets::LZMA_PRESET_LEVEL_MASK as u32; +pub const LZMA_PRESET_EXTREME: u32 = + liblzma_rs::common::string_conversion::LZMA_PRESET_EXTREME as u32; +pub const LZMA_DICT_SIZE_MIN: u32 = + liblzma_rs::common::string_conversion::LZMA_DICT_SIZE_MIN as u32; +pub const LZMA_DICT_SIZE_DEFAULT: u32 = + liblzma_rs::common::string_conversion::LZMA_DICT_SIZE_DEFAULT as u32; +pub const LZMA_LCLP_MIN: u32 = liblzma_rs::common::string_conversion::LZMA_LCLP_MIN as u32; +pub const LZMA_LCLP_MAX: u32 = liblzma_rs::common::string_conversion::LZMA_LCLP_MAX as u32; +pub const LZMA_LC_DEFAULT: u32 = + liblzma_rs::lzma::lzma_encoder_presets::LZMA_LC_DEFAULT as u32; +pub const LZMA_LP_DEFAULT: u32 = + liblzma_rs::lzma::lzma_encoder_presets::LZMA_LP_DEFAULT as u32; +pub const LZMA_PB_MIN: u32 = liblzma_rs::common::string_conversion::LZMA_PB_MIN as u32; +pub const LZMA_PB_MAX: u32 = liblzma_rs::common::string_conversion::LZMA_PB_MAX as u32; +pub const LZMA_PB_DEFAULT: u32 = + liblzma_rs::lzma::lzma_encoder_presets::LZMA_PB_DEFAULT as u32; + +// --- Backward size / VLI --- +pub const LZMA_BACKWARD_SIZE_MIN: lzma_vli = + liblzma_rs::common::stream_flags_common::LZMA_BACKWARD_SIZE_MIN as lzma_vli; +pub const LZMA_BACKWARD_SIZE_MAX: lzma_vli = + liblzma_rs::common::stream_flags_common::LZMA_BACKWARD_SIZE_MAX as lzma_vli; +pub const LZMA_VLI_MAX: lzma_vli = liblzma_rs::common::vli_encoder::LZMA_VLI_MAX as lzma_vli; +pub const LZMA_VLI_UNKNOWN: lzma_vli = liblzma_rs::common::common::LZMA_VLI_UNKNOWN as lzma_vli; +pub const LZMA_VLI_BYTES_MAX: usize = liblzma_rs::common::vli_encoder::LZMA_VLI_BYTES_MAX as usize; + +// --- Stream header size --- +pub const LZMA_STREAM_HEADER_SIZE: u32 = liblzma_rs::common::index::LZMA_STREAM_HEADER_SIZE as u32; + +// ========================================================================= +// Functions +// ========================================================================= +// +// Functions defined in common::common use the canonical lzma_stream type, +// so they can be re-exported directly. Functions in other modules use +// module-local struct definitions that are structurally identical (#[repr(C)]) +// but nominally different, so we provide thin wrappers with pointer casts. + +// --- Direct re-exports (canonical types from common::common) --- +pub use liblzma_rs::common::common::{ + lzma_code, lzma_end, lzma_memlimit_get, lzma_memlimit_set, +}; + +// --- Version --- + +#[inline] +pub unsafe fn lzma_version_number() -> u32 { + liblzma_rs::common::common::lzma_version_number() +} + +#[inline] +pub unsafe fn lzma_version_string() -> *const c_char { + liblzma_rs::common::common::lzma_version_string() +} + +// --- Progress / memusage --- + +#[inline] +pub unsafe fn lzma_get_progress( + strm: *mut lzma_stream, + progress_in: *mut u64, + progress_out: *mut u64, +) { + liblzma_rs::common::common::lzma_get_progress(strm.cast(), progress_in, progress_out) +} + +#[inline] +pub unsafe fn lzma_memusage(strm: *const lzma_stream) -> u64 { + liblzma_rs::common::common::lzma_memusage(strm.cast()) +} + +#[inline] +pub unsafe fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { + liblzma_rs::common::common::lzma_get_check(strm.cast()) +} + +// --- Check --- + +#[inline] +pub unsafe fn lzma_check_is_supported(check: lzma_check) -> lzma_bool { + liblzma_rs::check::check::lzma_check_is_supported(check) +} + +#[inline] +pub unsafe fn lzma_check_size(check: lzma_check) -> u32 { + liblzma_rs::check::check::lzma_check_size(check) +} + +#[inline] +pub unsafe fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32 { + liblzma_rs::check::crc32_fast::lzma_crc32(buf, size, crc) +} + +#[inline] +pub unsafe fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64 { + liblzma_rs::check::crc64_fast::lzma_crc64(buf, size, crc) +} + +// --- Easy encoder --- + +#[inline] +pub unsafe fn lzma_easy_encoder_memusage(preset: u32) -> u64 { + liblzma_rs::common::easy_encoder_memusage::lzma_easy_encoder_memusage(preset) +} + +#[inline] +pub unsafe fn lzma_easy_decoder_memusage(preset: u32) -> u64 { + liblzma_rs::common::easy_decoder_memusage::lzma_easy_decoder_memusage(preset) +} + +#[inline] +pub unsafe fn lzma_easy_encoder( + strm: *mut lzma_stream, + preset: u32, + check: lzma_check, +) -> lzma_ret { + liblzma_rs::common::easy_encoder::lzma_easy_encoder(strm.cast(), preset, check) +} + +#[inline] +pub unsafe fn lzma_easy_buffer_encode( + preset: u32, + check: lzma_check, + allocator: *const lzma_allocator, + input: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::easy_buffer_encoder::lzma_easy_buffer_encode( + preset, check, allocator.cast(), input, in_size, out, out_pos, out_size, + ) +} + +// --- Stream encoder/decoder --- + +#[inline] +pub unsafe fn lzma_stream_encoder( + strm: *mut lzma_stream, + filters: *const lzma_filter, + check: lzma_check, +) -> lzma_ret { + liblzma_rs::common::stream_encoder::lzma_stream_encoder(strm.cast(), filters.cast(), check) +} + +#[inline] +pub unsafe fn lzma_stream_decoder( + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, +) -> lzma_ret { + liblzma_rs::common::stream_decoder::lzma_stream_decoder(strm.cast(), memlimit, flags) +} + +// --- Alone encoder/decoder --- + +#[inline] +pub unsafe fn lzma_alone_encoder( + strm: *mut lzma_stream, + options: *const lzma_options_lzma, +) -> lzma_ret { + liblzma_rs::common::alone_encoder::lzma_alone_encoder(strm.cast(), options.cast()) +} + +#[inline] +pub unsafe fn lzma_alone_decoder( + strm: *mut lzma_stream, + memlimit: u64, +) -> lzma_ret { + liblzma_rs::common::alone_decoder::lzma_alone_decoder(strm.cast(), memlimit) +} + +// --- Auto/lzip decoder --- + +#[inline] +pub unsafe fn lzma_auto_decoder( + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, +) -> lzma_ret { + liblzma_rs::common::auto_decoder::lzma_auto_decoder(strm.cast(), memlimit, flags) +} + +#[inline] +pub unsafe fn lzma_lzip_decoder( + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, +) -> lzma_ret { + liblzma_rs::common::lzip_decoder::lzma_lzip_decoder(strm.cast(), memlimit, flags) +} + +// --- Stream buffer --- + +#[inline] +pub unsafe fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { + liblzma_rs::common::stream_buffer_encoder::lzma_stream_buffer_bound(uncompressed_size) +} + +#[inline] +pub unsafe fn lzma_stream_buffer_encode( + filters: *mut lzma_filter, + check: lzma_check, + allocator: *const lzma_allocator, + input: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::stream_buffer_encoder::lzma_stream_buffer_encode( + filters.cast(), check, allocator.cast(), input, in_size, out, out_pos, out_size, + ) +} + +#[inline] +pub unsafe fn lzma_stream_buffer_decode( + memlimit: *mut u64, + flags: u32, + allocator: *const lzma_allocator, + input: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::stream_buffer_decoder::lzma_stream_buffer_decode( + memlimit, flags, allocator.cast(), input, in_pos, in_size, out, out_pos, out_size, + ) +} + +// --- Filter --- + +#[inline] +pub unsafe fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { + liblzma_rs::common::filter_encoder::lzma_filter_encoder_is_supported(id) +} + +#[inline] +pub unsafe fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { + liblzma_rs::common::filter_decoder::lzma_filter_decoder_is_supported(id) +} + +#[inline] +pub unsafe fn lzma_filters_copy( + src: *const lzma_filter, + dest: *mut lzma_filter, + allocator: *const lzma_allocator, +) -> lzma_ret { + liblzma_rs::common::filter_common::lzma_filters_copy( + src.cast(), dest.cast(), allocator.cast(), + ) +} + +#[inline] +pub unsafe fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64 { + liblzma_rs::common::filter_encoder::lzma_raw_encoder_memusage(filters.cast()) +} + +#[inline] +pub unsafe fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { + liblzma_rs::common::filter_decoder::lzma_raw_decoder_memusage(filters.cast()) +} + +#[inline] +pub unsafe fn lzma_raw_encoder( + strm: *mut lzma_stream, + filters: *const lzma_filter, +) -> lzma_ret { + liblzma_rs::common::filter_encoder::lzma_raw_encoder(strm.cast(), filters.cast()) +} + +#[inline] +pub unsafe fn lzma_raw_decoder( + strm: *mut lzma_stream, + filters: *const lzma_filter, +) -> lzma_ret { + liblzma_rs::common::filter_decoder::lzma_raw_decoder(strm.cast(), filters.cast()) +} + +#[inline] +pub unsafe fn lzma_filters_update( + strm: *mut lzma_stream, + filters: *const lzma_filter, +) -> lzma_ret { + liblzma_rs::common::filter_encoder::lzma_filters_update(strm.cast(), filters.cast()) +} + +// --- Raw buffer --- + +#[inline] +pub unsafe fn lzma_raw_buffer_encode( + filters: *const lzma_filter, + allocator: *const lzma_allocator, + input: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::filter_buffer_encoder::lzma_raw_buffer_encode( + filters.cast(), allocator.cast(), input, in_size, out, out_pos, out_size, + ) +} + +#[inline] +pub unsafe fn lzma_raw_buffer_decode( + filters: *const lzma_filter, + allocator: *const lzma_allocator, + input: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::filter_buffer_decoder::lzma_raw_buffer_decode( + filters.cast(), allocator.cast(), input, in_pos, in_size, out, out_pos, out_size, + ) +} + +// --- Properties --- + +#[inline] +pub unsafe fn lzma_properties_size( + size: *mut u32, + filter: *const lzma_filter, +) -> lzma_ret { + liblzma_rs::common::filter_encoder::lzma_properties_size(size, filter.cast()) +} + +#[inline] +pub unsafe fn lzma_properties_encode( + filter: *const lzma_filter, + props: *mut u8, +) -> lzma_ret { + liblzma_rs::common::filter_encoder::lzma_properties_encode(filter.cast(), props) +} + +#[inline] +pub unsafe fn lzma_properties_decode( + filter: *mut lzma_filter, + allocator: *const lzma_allocator, + props: *const u8, + props_size: size_t, +) -> lzma_ret { + liblzma_rs::common::filter_decoder::lzma_properties_decode( + filter.cast(), allocator.cast(), props, props_size, + ) +} + +#[inline] +pub unsafe fn lzma_mt_block_size( + filters: *const lzma_filter, +) -> u64 { + liblzma_rs::common::filter_encoder::lzma_mt_block_size(filters.cast()) +} + +// --- LZMA preset --- + +#[inline] +pub unsafe fn lzma_lzma_preset( + options: *mut lzma_options_lzma, + preset: u32, +) -> lzma_bool { + liblzma_rs::lzma::lzma_encoder_presets::lzma_lzma_preset(options.cast(), preset) +} + +#[inline] +pub unsafe fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { + liblzma_rs::lz::lz_encoder::lzma_mf_is_supported(mf) +} + +// --- Stream header/footer --- + +#[inline] +pub unsafe fn lzma_stream_header_encode( + options: *const lzma_stream_flags, + out: *mut u8, +) -> lzma_ret { + liblzma_rs::common::stream_flags_encoder::lzma_stream_header_encode(options.cast(), out) +} + +#[inline] +pub unsafe fn lzma_stream_footer_encode( + options: *const lzma_stream_flags, + out: *mut u8, +) -> lzma_ret { + liblzma_rs::common::stream_flags_encoder::lzma_stream_footer_encode(options.cast(), out) +} + +#[inline] +pub unsafe fn lzma_stream_header_decode( + options: *mut lzma_stream_flags, + input: *const u8, +) -> lzma_ret { + liblzma_rs::common::stream_flags_decoder::lzma_stream_header_decode(options.cast(), input) +} + +#[inline] +pub unsafe fn lzma_stream_footer_decode( + options: *mut lzma_stream_flags, + input: *const u8, +) -> lzma_ret { + liblzma_rs::common::stream_flags_decoder::lzma_stream_footer_decode(options.cast(), input) +} + +#[inline] +pub unsafe fn lzma_stream_flags_compare( + a: *const lzma_stream_flags, + b: *const lzma_stream_flags, +) -> lzma_ret { + liblzma_rs::common::stream_flags_common::lzma_stream_flags_compare(a.cast(), b.cast()) +} + +// --- VLI --- + +#[inline] +pub unsafe fn lzma_vli_encode( + vli: lzma_vli, + vli_pos: *mut size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::vli_encoder::lzma_vli_encode(vli, vli_pos, out, out_pos, out_size) +} + +#[inline] +pub unsafe fn lzma_vli_decode( + vli: *mut lzma_vli, + vli_pos: *mut size_t, + input: *const u8, + in_pos: *mut size_t, + in_size: size_t, +) -> lzma_ret { + liblzma_rs::common::vli_decoder::lzma_vli_decode(vli, vli_pos, input, in_pos, in_size) +} + +#[inline] +pub unsafe fn lzma_vli_size(vli: lzma_vli) -> u32 { + liblzma_rs::common::vli_size::lzma_vli_size(vli) +} + +// --- Hardware --- + +#[inline] +pub unsafe fn lzma_physmem() -> u64 { + liblzma_rs::common::hardware_physmem::lzma_physmem() +} + +#[inline] +pub unsafe fn lzma_cputhreads() -> u32 { + liblzma_rs::common::hardware_cputhreads::lzma_cputhreads() +} + +// --- Index --- + +#[inline] +pub unsafe fn lzma_index_buffer_decode( + i: *mut *mut lzma_index, + memlimit: *mut u64, + allocator: *const lzma_allocator, + input: *const u8, + in_pos: *mut size_t, + in_size: size_t, +) -> lzma_ret { + liblzma_rs::common::index_decoder::lzma_index_buffer_decode( + i.cast(), memlimit, allocator.cast(), input, in_pos, in_size, + ) +} + +#[inline] +pub unsafe fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { + liblzma_rs::common::index::lzma_index_uncompressed_size(i.cast()) +} + +#[inline] +pub unsafe fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { + liblzma_rs::common::index::lzma_index_end(i.cast(), allocator.cast()) +} + +// ========================================================================= +// Multithreaded (stubs - _mt files not yet transpiled) +// ========================================================================= + +#[cfg(feature = "parallel")] +#[repr(C)] +pub struct lzma_mt { + pub flags: u32, + pub threads: u32, + pub block_size: u64, + pub timeout: u32, + pub preset: u32, + pub filters: *const lzma_filter, + pub check: lzma_check, + _reserved_enum1: __enum_ty, + _reserved_enum2: __enum_ty, + _reserved_enum3: __enum_ty, + _reserved_int1: u32, + _reserved_int2: u32, + _reserved_int3: u32, + _reserved_int4: u32, + pub memlimit_threading: u64, + pub memlimit_stop: u64, + _reserved_int7: u64, + _reserved_int8: u64, + _reserved_ptr1: *mut c_void, + _reserved_ptr2: *mut c_void, + _reserved_ptr3: *mut c_void, + _reserved_ptr4: *mut c_void, +} + +#[cfg(feature = "parallel")] +pub unsafe fn lzma_stream_encoder_mt( + _strm: *mut lzma_stream, + _options: *const lzma_mt, +) -> lzma_ret { + unimplemented!("lzma_stream_encoder_mt not yet available in liblzma-rs") +} + +#[cfg(feature = "parallel")] +pub unsafe fn lzma_stream_decoder_mt( + _strm: *mut lzma_stream, + _options: *const lzma_mt, +) -> lzma_ret { + unimplemented!("lzma_stream_decoder_mt not yet available in liblzma-rs") +} + +#[cfg(feature = "parallel")] +pub unsafe fn lzma_stream_encoder_mt_memusage( + _options: *const lzma_mt, +) -> u64 { + unimplemented!("lzma_stream_encoder_mt_memusage not yet available in liblzma-rs") +} diff --git a/liblzma-rs/Cargo.toml b/liblzma-rs/Cargo.toml new file mode 100644 index 00000000..f53564c3 --- /dev/null +++ b/liblzma-rs/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "liblzma-rs" +version = "0.1.0" +edition = "2021" +license = "MIT OR Apache-2.0" +description = "Pure Rust implementation of liblzma (transpiled from C via c2rust)" + +[features] +default = [] + +[dependencies] +libc = "0.2" diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs new file mode 100644 index 00000000..493f2033 --- /dev/null +++ b/liblzma-rs/src/check/check.rs @@ -0,0 +1,162 @@ +extern "C" { + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_crc64(buf: *const uint8_t, size: size_t, crc: uint64_t) -> uint64_t; + fn lzma_sha256_init(check: *mut lzma_check_state); + fn lzma_sha256_update( + buf: *const uint8_t, + size: size_t, + check: *mut lzma_check_state, + ); + fn lzma_sha256_finish(check: *mut lzma_check_state); +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_sha256_state { + pub state: [uint32_t; 8], + pub size: uint64_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_check_state { + pub buffer: C2RustUnnamed_0, + pub state: C2RustUnnamed, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub crc32: uint32_t, + pub crc64: uint64_t, + pub sha256: lzma_sha256_state, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub u8_0: [uint8_t; 64], + pub u32_0: [uint32_t; 16], + pub u64_0: [uint64_t; 8], +} +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_check_is_supported(mut type_0: lzma_check) -> lzma_bool { + if type_0 as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint { + return false_0 as lzma_bool; + } + static mut available_checks: [lzma_bool; 16] = [ + true_0 as lzma_bool, + true_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + true_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + true_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + false_0 as lzma_bool, + ]; + return available_checks[type_0 as ::core::ffi::c_uint as usize]; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_check_size(mut type_0: lzma_check) -> uint32_t { + if type_0 as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint { + return UINT32_MAX as uint32_t; + } + static mut check_sizes: [uint8_t; 16] = [ + 0 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 32 as ::core::ffi::c_int as uint8_t, + 32 as ::core::ffi::c_int as uint8_t, + 32 as ::core::ffi::c_int as uint8_t, + 64 as ::core::ffi::c_int as uint8_t, + 64 as ::core::ffi::c_int as uint8_t, + 64 as ::core::ffi::c_int as uint8_t, + ]; + return check_sizes[type_0 as ::core::ffi::c_uint as usize] as uint32_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_check_init( + mut check: *mut lzma_check_state, + mut type_0: lzma_check, +) { + match type_0 as ::core::ffi::c_uint { + 1 => { + (*check).state.crc32 = 0 as uint32_t; + } + 4 => { + (*check).state.crc64 = 0 as uint64_t; + } + 10 => { + lzma_sha256_init(check); + } + 0 | _ => {} + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_check_update( + mut check: *mut lzma_check_state, + mut type_0: lzma_check, + mut buf: *const uint8_t, + mut size: size_t, +) { + match type_0 as ::core::ffi::c_uint { + 1 => { + (*check).state.crc32 = lzma_crc32(buf, size, (*check).state.crc32); + } + 4 => { + (*check).state.crc64 = lzma_crc64(buf, size, (*check).state.crc64); + } + 10 => { + lzma_sha256_update(buf, size, check); + } + _ => {} + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_check_finish( + mut check: *mut lzma_check_state, + mut type_0: lzma_check, +) { + match type_0 as ::core::ffi::c_uint { + 1 => { + (*check).buffer.u32_0[0 as ::core::ffi::c_int as usize] = (*check) + .state + .crc32; + } + 4 => { + (*check).buffer.u64_0[0 as ::core::ffi::c_int as usize] = (*check) + .state + .crc64; + } + 10 => { + lzma_sha256_finish(check); + } + _ => {} + }; +} diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs new file mode 100644 index 00000000..eab475cf --- /dev/null +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -0,0 +1,2143 @@ +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +#[inline] +unsafe extern "C" fn aligned_read32ne(mut buf: *const uint8_t) -> uint32_t { + return *(buf as *const uint32_t); +} +#[no_mangle] +pub static mut lzma_crc32_table: [[uint32_t; 256]; 8] = [ + [ + 0 as ::core::ffi::c_int as uint32_t, + 0x77073096 as ::core::ffi::c_int as uint32_t, + 0xee0e612c as ::core::ffi::c_uint, + 0x990951ba as ::core::ffi::c_uint, + 0x76dc419 as ::core::ffi::c_int as uint32_t, + 0x706af48f as ::core::ffi::c_int as uint32_t, + 0xe963a535 as ::core::ffi::c_uint, + 0x9e6495a3 as ::core::ffi::c_uint, + 0xedb8832 as ::core::ffi::c_int as uint32_t, + 0x79dcb8a4 as ::core::ffi::c_int as uint32_t, + 0xe0d5e91e as ::core::ffi::c_uint, + 0x97d2d988 as ::core::ffi::c_uint, + 0x9b64c2b as ::core::ffi::c_int as uint32_t, + 0x7eb17cbd as ::core::ffi::c_int as uint32_t, + 0xe7b82d07 as ::core::ffi::c_uint, + 0x90bf1d91 as ::core::ffi::c_uint, + 0x1db71064 as ::core::ffi::c_int as uint32_t, + 0x6ab020f2 as ::core::ffi::c_int as uint32_t, + 0xf3b97148 as ::core::ffi::c_uint, + 0x84be41de as ::core::ffi::c_uint, + 0x1adad47d as ::core::ffi::c_int as uint32_t, + 0x6ddde4eb as ::core::ffi::c_int as uint32_t, + 0xf4d4b551 as ::core::ffi::c_uint, + 0x83d385c7 as ::core::ffi::c_uint, + 0x136c9856 as ::core::ffi::c_int as uint32_t, + 0x646ba8c0 as ::core::ffi::c_int as uint32_t, + 0xfd62f97a as ::core::ffi::c_uint, + 0x8a65c9ec as ::core::ffi::c_uint, + 0x14015c4f as ::core::ffi::c_int as uint32_t, + 0x63066cd9 as ::core::ffi::c_int as uint32_t, + 0xfa0f3d63 as ::core::ffi::c_uint, + 0x8d080df5 as ::core::ffi::c_uint, + 0x3b6e20c8 as ::core::ffi::c_int as uint32_t, + 0x4c69105e as ::core::ffi::c_int as uint32_t, + 0xd56041e4 as ::core::ffi::c_uint, + 0xa2677172 as ::core::ffi::c_uint, + 0x3c03e4d1 as ::core::ffi::c_int as uint32_t, + 0x4b04d447 as ::core::ffi::c_int as uint32_t, + 0xd20d85fd as ::core::ffi::c_uint, + 0xa50ab56b as ::core::ffi::c_uint, + 0x35b5a8fa as ::core::ffi::c_int as uint32_t, + 0x42b2986c as ::core::ffi::c_int as uint32_t, + 0xdbbbc9d6 as ::core::ffi::c_uint, + 0xacbcf940 as ::core::ffi::c_uint, + 0x32d86ce3 as ::core::ffi::c_int as uint32_t, + 0x45df5c75 as ::core::ffi::c_int as uint32_t, + 0xdcd60dcf as ::core::ffi::c_uint, + 0xabd13d59 as ::core::ffi::c_uint, + 0x26d930ac as ::core::ffi::c_int as uint32_t, + 0x51de003a as ::core::ffi::c_int as uint32_t, + 0xc8d75180 as ::core::ffi::c_uint, + 0xbfd06116 as ::core::ffi::c_uint, + 0x21b4f4b5 as ::core::ffi::c_int as uint32_t, + 0x56b3c423 as ::core::ffi::c_int as uint32_t, + 0xcfba9599 as ::core::ffi::c_uint, + 0xb8bda50f as ::core::ffi::c_uint, + 0x2802b89e as ::core::ffi::c_int as uint32_t, + 0x5f058808 as ::core::ffi::c_int as uint32_t, + 0xc60cd9b2 as ::core::ffi::c_uint, + 0xb10be924 as ::core::ffi::c_uint, + 0x2f6f7c87 as ::core::ffi::c_int as uint32_t, + 0x58684c11 as ::core::ffi::c_int as uint32_t, + 0xc1611dab as ::core::ffi::c_uint, + 0xb6662d3d as ::core::ffi::c_uint, + 0x76dc4190 as ::core::ffi::c_int as uint32_t, + 0x1db7106 as ::core::ffi::c_int as uint32_t, + 0x98d220bc as ::core::ffi::c_uint, + 0xefd5102a as ::core::ffi::c_uint, + 0x71b18589 as ::core::ffi::c_int as uint32_t, + 0x6b6b51f as ::core::ffi::c_int as uint32_t, + 0x9fbfe4a5 as ::core::ffi::c_uint, + 0xe8b8d433 as ::core::ffi::c_uint, + 0x7807c9a2 as ::core::ffi::c_int as uint32_t, + 0xf00f934 as ::core::ffi::c_int as uint32_t, + 0x9609a88e as ::core::ffi::c_uint, + 0xe10e9818 as ::core::ffi::c_uint, + 0x7f6a0dbb as ::core::ffi::c_int as uint32_t, + 0x86d3d2d as ::core::ffi::c_int as uint32_t, + 0x91646c97 as ::core::ffi::c_uint, + 0xe6635c01 as ::core::ffi::c_uint, + 0x6b6b51f4 as ::core::ffi::c_int as uint32_t, + 0x1c6c6162 as ::core::ffi::c_int as uint32_t, + 0x856530d8 as ::core::ffi::c_uint, + 0xf262004e as ::core::ffi::c_uint, + 0x6c0695ed as ::core::ffi::c_int as uint32_t, + 0x1b01a57b as ::core::ffi::c_int as uint32_t, + 0x8208f4c1 as ::core::ffi::c_uint, + 0xf50fc457 as ::core::ffi::c_uint, + 0x65b0d9c6 as ::core::ffi::c_int as uint32_t, + 0x12b7e950 as ::core::ffi::c_int as uint32_t, + 0x8bbeb8ea as ::core::ffi::c_uint, + 0xfcb9887c as ::core::ffi::c_uint, + 0x62dd1ddf as ::core::ffi::c_int as uint32_t, + 0x15da2d49 as ::core::ffi::c_int as uint32_t, + 0x8cd37cf3 as ::core::ffi::c_uint, + 0xfbd44c65 as ::core::ffi::c_uint, + 0x4db26158 as ::core::ffi::c_int as uint32_t, + 0x3ab551ce as ::core::ffi::c_int as uint32_t, + 0xa3bc0074 as ::core::ffi::c_uint, + 0xd4bb30e2 as ::core::ffi::c_uint, + 0x4adfa541 as ::core::ffi::c_int as uint32_t, + 0x3dd895d7 as ::core::ffi::c_int as uint32_t, + 0xa4d1c46d as ::core::ffi::c_uint, + 0xd3d6f4fb as ::core::ffi::c_uint, + 0x4369e96a as ::core::ffi::c_int as uint32_t, + 0x346ed9fc as ::core::ffi::c_int as uint32_t, + 0xad678846 as ::core::ffi::c_uint, + 0xda60b8d0 as ::core::ffi::c_uint, + 0x44042d73 as ::core::ffi::c_int as uint32_t, + 0x33031de5 as ::core::ffi::c_int as uint32_t, + 0xaa0a4c5f as ::core::ffi::c_uint, + 0xdd0d7cc9 as ::core::ffi::c_uint, + 0x5005713c as ::core::ffi::c_int as uint32_t, + 0x270241aa as ::core::ffi::c_int as uint32_t, + 0xbe0b1010 as ::core::ffi::c_uint, + 0xc90c2086 as ::core::ffi::c_uint, + 0x5768b525 as ::core::ffi::c_int as uint32_t, + 0x206f85b3 as ::core::ffi::c_int as uint32_t, + 0xb966d409 as ::core::ffi::c_uint, + 0xce61e49f as ::core::ffi::c_uint, + 0x5edef90e as ::core::ffi::c_int as uint32_t, + 0x29d9c998 as ::core::ffi::c_int as uint32_t, + 0xb0d09822 as ::core::ffi::c_uint, + 0xc7d7a8b4 as ::core::ffi::c_uint, + 0x59b33d17 as ::core::ffi::c_int as uint32_t, + 0x2eb40d81 as ::core::ffi::c_int as uint32_t, + 0xb7bd5c3b as ::core::ffi::c_uint, + 0xc0ba6cad as ::core::ffi::c_uint, + 0xedb88320 as ::core::ffi::c_uint, + 0x9abfb3b6 as ::core::ffi::c_uint, + 0x3b6e20c as ::core::ffi::c_int as uint32_t, + 0x74b1d29a as ::core::ffi::c_int as uint32_t, + 0xead54739 as ::core::ffi::c_uint, + 0x9dd277af as ::core::ffi::c_uint, + 0x4db2615 as ::core::ffi::c_int as uint32_t, + 0x73dc1683 as ::core::ffi::c_int as uint32_t, + 0xe3630b12 as ::core::ffi::c_uint, + 0x94643b84 as ::core::ffi::c_uint, + 0xd6d6a3e as ::core::ffi::c_int as uint32_t, + 0x7a6a5aa8 as ::core::ffi::c_int as uint32_t, + 0xe40ecf0b as ::core::ffi::c_uint, + 0x9309ff9d as ::core::ffi::c_uint, + 0xa00ae27 as ::core::ffi::c_int as uint32_t, + 0x7d079eb1 as ::core::ffi::c_int as uint32_t, + 0xf00f9344 as ::core::ffi::c_uint, + 0x8708a3d2 as ::core::ffi::c_uint, + 0x1e01f268 as ::core::ffi::c_int as uint32_t, + 0x6906c2fe as ::core::ffi::c_int as uint32_t, + 0xf762575d as ::core::ffi::c_uint, + 0x806567cb as ::core::ffi::c_uint, + 0x196c3671 as ::core::ffi::c_int as uint32_t, + 0x6e6b06e7 as ::core::ffi::c_int as uint32_t, + 0xfed41b76 as ::core::ffi::c_uint, + 0x89d32be0 as ::core::ffi::c_uint, + 0x10da7a5a as ::core::ffi::c_int as uint32_t, + 0x67dd4acc as ::core::ffi::c_int as uint32_t, + 0xf9b9df6f as ::core::ffi::c_uint, + 0x8ebeeff9 as ::core::ffi::c_uint, + 0x17b7be43 as ::core::ffi::c_int as uint32_t, + 0x60b08ed5 as ::core::ffi::c_int as uint32_t, + 0xd6d6a3e8 as ::core::ffi::c_uint, + 0xa1d1937e as ::core::ffi::c_uint, + 0x38d8c2c4 as ::core::ffi::c_int as uint32_t, + 0x4fdff252 as ::core::ffi::c_int as uint32_t, + 0xd1bb67f1 as ::core::ffi::c_uint, + 0xa6bc5767 as ::core::ffi::c_uint, + 0x3fb506dd as ::core::ffi::c_int as uint32_t, + 0x48b2364b as ::core::ffi::c_int as uint32_t, + 0xd80d2bda as ::core::ffi::c_uint, + 0xaf0a1b4c as ::core::ffi::c_uint, + 0x36034af6 as ::core::ffi::c_int as uint32_t, + 0x41047a60 as ::core::ffi::c_int as uint32_t, + 0xdf60efc3 as ::core::ffi::c_uint, + 0xa867df55 as ::core::ffi::c_uint, + 0x316e8eef as ::core::ffi::c_int as uint32_t, + 0x4669be79 as ::core::ffi::c_int as uint32_t, + 0xcb61b38c as ::core::ffi::c_uint, + 0xbc66831a as ::core::ffi::c_uint, + 0x256fd2a0 as ::core::ffi::c_int as uint32_t, + 0x5268e236 as ::core::ffi::c_int as uint32_t, + 0xcc0c7795 as ::core::ffi::c_uint, + 0xbb0b4703 as ::core::ffi::c_uint, + 0x220216b9 as ::core::ffi::c_int as uint32_t, + 0x5505262f as ::core::ffi::c_int as uint32_t, + 0xc5ba3bbe as ::core::ffi::c_uint, + 0xb2bd0b28 as ::core::ffi::c_uint, + 0x2bb45a92 as ::core::ffi::c_int as uint32_t, + 0x5cb36a04 as ::core::ffi::c_int as uint32_t, + 0xc2d7ffa7 as ::core::ffi::c_uint, + 0xb5d0cf31 as ::core::ffi::c_uint, + 0x2cd99e8b as ::core::ffi::c_int as uint32_t, + 0x5bdeae1d as ::core::ffi::c_int as uint32_t, + 0x9b64c2b0 as ::core::ffi::c_uint, + 0xec63f226 as ::core::ffi::c_uint, + 0x756aa39c as ::core::ffi::c_int as uint32_t, + 0x26d930a as ::core::ffi::c_int as uint32_t, + 0x9c0906a9 as ::core::ffi::c_uint, + 0xeb0e363f as ::core::ffi::c_uint, + 0x72076785 as ::core::ffi::c_int as uint32_t, + 0x5005713 as ::core::ffi::c_int as uint32_t, + 0x95bf4a82 as ::core::ffi::c_uint, + 0xe2b87a14 as ::core::ffi::c_uint, + 0x7bb12bae as ::core::ffi::c_int as uint32_t, + 0xcb61b38 as ::core::ffi::c_int as uint32_t, + 0x92d28e9b as ::core::ffi::c_uint, + 0xe5d5be0d as ::core::ffi::c_uint, + 0x7cdcefb7 as ::core::ffi::c_int as uint32_t, + 0xbdbdf21 as ::core::ffi::c_int as uint32_t, + 0x86d3d2d4 as ::core::ffi::c_uint, + 0xf1d4e242 as ::core::ffi::c_uint, + 0x68ddb3f8 as ::core::ffi::c_int as uint32_t, + 0x1fda836e as ::core::ffi::c_int as uint32_t, + 0x81be16cd as ::core::ffi::c_uint, + 0xf6b9265b as ::core::ffi::c_uint, + 0x6fb077e1 as ::core::ffi::c_int as uint32_t, + 0x18b74777 as ::core::ffi::c_int as uint32_t, + 0x88085ae6 as ::core::ffi::c_uint, + 0xff0f6a70 as ::core::ffi::c_uint, + 0x66063bca as ::core::ffi::c_int as uint32_t, + 0x11010b5c as ::core::ffi::c_int as uint32_t, + 0x8f659eff as ::core::ffi::c_uint, + 0xf862ae69 as ::core::ffi::c_uint, + 0x616bffd3 as ::core::ffi::c_int as uint32_t, + 0x166ccf45 as ::core::ffi::c_int as uint32_t, + 0xa00ae278 as ::core::ffi::c_uint, + 0xd70dd2ee as ::core::ffi::c_uint, + 0x4e048354 as ::core::ffi::c_int as uint32_t, + 0x3903b3c2 as ::core::ffi::c_int as uint32_t, + 0xa7672661 as ::core::ffi::c_uint, + 0xd06016f7 as ::core::ffi::c_uint, + 0x4969474d as ::core::ffi::c_int as uint32_t, + 0x3e6e77db as ::core::ffi::c_int as uint32_t, + 0xaed16a4a as ::core::ffi::c_uint, + 0xd9d65adc as ::core::ffi::c_uint, + 0x40df0b66 as ::core::ffi::c_int as uint32_t, + 0x37d83bf0 as ::core::ffi::c_int as uint32_t, + 0xa9bcae53 as ::core::ffi::c_uint, + 0xdebb9ec5 as ::core::ffi::c_uint, + 0x47b2cf7f as ::core::ffi::c_int as uint32_t, + 0x30b5ffe9 as ::core::ffi::c_int as uint32_t, + 0xbdbdf21c as ::core::ffi::c_uint, + 0xcabac28a as ::core::ffi::c_uint, + 0x53b39330 as ::core::ffi::c_int as uint32_t, + 0x24b4a3a6 as ::core::ffi::c_int as uint32_t, + 0xbad03605 as ::core::ffi::c_uint, + 0xcdd70693 as ::core::ffi::c_uint, + 0x54de5729 as ::core::ffi::c_int as uint32_t, + 0x23d967bf as ::core::ffi::c_int as uint32_t, + 0xb3667a2e as ::core::ffi::c_uint, + 0xc4614ab8 as ::core::ffi::c_uint, + 0x5d681b02 as ::core::ffi::c_int as uint32_t, + 0x2a6f2b94 as ::core::ffi::c_int as uint32_t, + 0xb40bbe37 as ::core::ffi::c_uint, + 0xc30c8ea1 as ::core::ffi::c_uint, + 0x5a05df1b as ::core::ffi::c_int as uint32_t, + 0x2d02ef8d as ::core::ffi::c_int as uint32_t, + ], + [ + 0 as ::core::ffi::c_int as uint32_t, + 0x191b3141 as ::core::ffi::c_int as uint32_t, + 0x32366282 as ::core::ffi::c_int as uint32_t, + 0x2b2d53c3 as ::core::ffi::c_int as uint32_t, + 0x646cc504 as ::core::ffi::c_int as uint32_t, + 0x7d77f445 as ::core::ffi::c_int as uint32_t, + 0x565aa786 as ::core::ffi::c_int as uint32_t, + 0x4f4196c7 as ::core::ffi::c_int as uint32_t, + 0xc8d98a08 as ::core::ffi::c_uint, + 0xd1c2bb49 as ::core::ffi::c_uint, + 0xfaefe88a as ::core::ffi::c_uint, + 0xe3f4d9cb as ::core::ffi::c_uint, + 0xacb54f0c as ::core::ffi::c_uint, + 0xb5ae7e4d as ::core::ffi::c_uint, + 0x9e832d8e as ::core::ffi::c_uint, + 0x87981ccf as ::core::ffi::c_uint, + 0x4ac21251 as ::core::ffi::c_int as uint32_t, + 0x53d92310 as ::core::ffi::c_int as uint32_t, + 0x78f470d3 as ::core::ffi::c_int as uint32_t, + 0x61ef4192 as ::core::ffi::c_int as uint32_t, + 0x2eaed755 as ::core::ffi::c_int as uint32_t, + 0x37b5e614 as ::core::ffi::c_int as uint32_t, + 0x1c98b5d7 as ::core::ffi::c_int as uint32_t, + 0x5838496 as ::core::ffi::c_int as uint32_t, + 0x821b9859 as ::core::ffi::c_uint, + 0x9b00a918 as ::core::ffi::c_uint, + 0xb02dfadb as ::core::ffi::c_uint, + 0xa936cb9a as ::core::ffi::c_uint, + 0xe6775d5d as ::core::ffi::c_uint, + 0xff6c6c1c as ::core::ffi::c_uint, + 0xd4413fdf as ::core::ffi::c_uint, + 0xcd5a0e9e as ::core::ffi::c_uint, + 0x958424a2 as ::core::ffi::c_uint, + 0x8c9f15e3 as ::core::ffi::c_uint, + 0xa7b24620 as ::core::ffi::c_uint, + 0xbea97761 as ::core::ffi::c_uint, + 0xf1e8e1a6 as ::core::ffi::c_uint, + 0xe8f3d0e7 as ::core::ffi::c_uint, + 0xc3de8324 as ::core::ffi::c_uint, + 0xdac5b265 as ::core::ffi::c_uint, + 0x5d5daeaa as ::core::ffi::c_int as uint32_t, + 0x44469feb as ::core::ffi::c_int as uint32_t, + 0x6f6bcc28 as ::core::ffi::c_int as uint32_t, + 0x7670fd69 as ::core::ffi::c_int as uint32_t, + 0x39316bae as ::core::ffi::c_int as uint32_t, + 0x202a5aef as ::core::ffi::c_int as uint32_t, + 0xb07092c as ::core::ffi::c_int as uint32_t, + 0x121c386d as ::core::ffi::c_int as uint32_t, + 0xdf4636f3 as ::core::ffi::c_uint, + 0xc65d07b2 as ::core::ffi::c_uint, + 0xed705471 as ::core::ffi::c_uint, + 0xf46b6530 as ::core::ffi::c_uint, + 0xbb2af3f7 as ::core::ffi::c_uint, + 0xa231c2b6 as ::core::ffi::c_uint, + 0x891c9175 as ::core::ffi::c_uint, + 0x9007a034 as ::core::ffi::c_uint, + 0x179fbcfb as ::core::ffi::c_int as uint32_t, + 0xe848dba as ::core::ffi::c_int as uint32_t, + 0x25a9de79 as ::core::ffi::c_int as uint32_t, + 0x3cb2ef38 as ::core::ffi::c_int as uint32_t, + 0x73f379ff as ::core::ffi::c_int as uint32_t, + 0x6ae848be as ::core::ffi::c_int as uint32_t, + 0x41c51b7d as ::core::ffi::c_int as uint32_t, + 0x58de2a3c as ::core::ffi::c_int as uint32_t, + 0xf0794f05 as ::core::ffi::c_uint, + 0xe9627e44 as ::core::ffi::c_uint, + 0xc24f2d87 as ::core::ffi::c_uint, + 0xdb541cc6 as ::core::ffi::c_uint, + 0x94158a01 as ::core::ffi::c_uint, + 0x8d0ebb40 as ::core::ffi::c_uint, + 0xa623e883 as ::core::ffi::c_uint, + 0xbf38d9c2 as ::core::ffi::c_uint, + 0x38a0c50d as ::core::ffi::c_int as uint32_t, + 0x21bbf44c as ::core::ffi::c_int as uint32_t, + 0xa96a78f as ::core::ffi::c_int as uint32_t, + 0x138d96ce as ::core::ffi::c_int as uint32_t, + 0x5ccc0009 as ::core::ffi::c_int as uint32_t, + 0x45d73148 as ::core::ffi::c_int as uint32_t, + 0x6efa628b as ::core::ffi::c_int as uint32_t, + 0x77e153ca as ::core::ffi::c_int as uint32_t, + 0xbabb5d54 as ::core::ffi::c_uint, + 0xa3a06c15 as ::core::ffi::c_uint, + 0x888d3fd6 as ::core::ffi::c_uint, + 0x91960e97 as ::core::ffi::c_uint, + 0xded79850 as ::core::ffi::c_uint, + 0xc7cca911 as ::core::ffi::c_uint, + 0xece1fad2 as ::core::ffi::c_uint, + 0xf5facb93 as ::core::ffi::c_uint, + 0x7262d75c as ::core::ffi::c_int as uint32_t, + 0x6b79e61d as ::core::ffi::c_int as uint32_t, + 0x4054b5de as ::core::ffi::c_int as uint32_t, + 0x594f849f as ::core::ffi::c_int as uint32_t, + 0x160e1258 as ::core::ffi::c_int as uint32_t, + 0xf152319 as ::core::ffi::c_int as uint32_t, + 0x243870da as ::core::ffi::c_int as uint32_t, + 0x3d23419b as ::core::ffi::c_int as uint32_t, + 0x65fd6ba7 as ::core::ffi::c_int as uint32_t, + 0x7ce65ae6 as ::core::ffi::c_int as uint32_t, + 0x57cb0925 as ::core::ffi::c_int as uint32_t, + 0x4ed03864 as ::core::ffi::c_int as uint32_t, + 0x191aea3 as ::core::ffi::c_int as uint32_t, + 0x188a9fe2 as ::core::ffi::c_int as uint32_t, + 0x33a7cc21 as ::core::ffi::c_int as uint32_t, + 0x2abcfd60 as ::core::ffi::c_int as uint32_t, + 0xad24e1af as ::core::ffi::c_uint, + 0xb43fd0ee as ::core::ffi::c_uint, + 0x9f12832d as ::core::ffi::c_uint, + 0x8609b26c as ::core::ffi::c_uint, + 0xc94824ab as ::core::ffi::c_uint, + 0xd05315ea as ::core::ffi::c_uint, + 0xfb7e4629 as ::core::ffi::c_uint, + 0xe2657768 as ::core::ffi::c_uint, + 0x2f3f79f6 as ::core::ffi::c_int as uint32_t, + 0x362448b7 as ::core::ffi::c_int as uint32_t, + 0x1d091b74 as ::core::ffi::c_int as uint32_t, + 0x4122a35 as ::core::ffi::c_int as uint32_t, + 0x4b53bcf2 as ::core::ffi::c_int as uint32_t, + 0x52488db3 as ::core::ffi::c_int as uint32_t, + 0x7965de70 as ::core::ffi::c_int as uint32_t, + 0x607eef31 as ::core::ffi::c_int as uint32_t, + 0xe7e6f3fe as ::core::ffi::c_uint, + 0xfefdc2bf as ::core::ffi::c_uint, + 0xd5d0917c as ::core::ffi::c_uint, + 0xcccba03d as ::core::ffi::c_uint, + 0x838a36fa as ::core::ffi::c_uint, + 0x9a9107bb as ::core::ffi::c_uint, + 0xb1bc5478 as ::core::ffi::c_uint, + 0xa8a76539 as ::core::ffi::c_uint, + 0x3b83984b as ::core::ffi::c_int as uint32_t, + 0x2298a90a as ::core::ffi::c_int as uint32_t, + 0x9b5fac9 as ::core::ffi::c_int as uint32_t, + 0x10aecb88 as ::core::ffi::c_int as uint32_t, + 0x5fef5d4f as ::core::ffi::c_int as uint32_t, + 0x46f46c0e as ::core::ffi::c_int as uint32_t, + 0x6dd93fcd as ::core::ffi::c_int as uint32_t, + 0x74c20e8c as ::core::ffi::c_int as uint32_t, + 0xf35a1243 as ::core::ffi::c_uint, + 0xea412302 as ::core::ffi::c_uint, + 0xc16c70c1 as ::core::ffi::c_uint, + 0xd8774180 as ::core::ffi::c_uint, + 0x9736d747 as ::core::ffi::c_uint, + 0x8e2de606 as ::core::ffi::c_uint, + 0xa500b5c5 as ::core::ffi::c_uint, + 0xbc1b8484 as ::core::ffi::c_uint, + 0x71418a1a as ::core::ffi::c_int as uint32_t, + 0x685abb5b as ::core::ffi::c_int as uint32_t, + 0x4377e898 as ::core::ffi::c_int as uint32_t, + 0x5a6cd9d9 as ::core::ffi::c_int as uint32_t, + 0x152d4f1e as ::core::ffi::c_int as uint32_t, + 0xc367e5f as ::core::ffi::c_int as uint32_t, + 0x271b2d9c as ::core::ffi::c_int as uint32_t, + 0x3e001cdd as ::core::ffi::c_int as uint32_t, + 0xb9980012 as ::core::ffi::c_uint, + 0xa0833153 as ::core::ffi::c_uint, + 0x8bae6290 as ::core::ffi::c_uint, + 0x92b553d1 as ::core::ffi::c_uint, + 0xddf4c516 as ::core::ffi::c_uint, + 0xc4eff457 as ::core::ffi::c_uint, + 0xefc2a794 as ::core::ffi::c_uint, + 0xf6d996d5 as ::core::ffi::c_uint, + 0xae07bce9 as ::core::ffi::c_uint, + 0xb71c8da8 as ::core::ffi::c_uint, + 0x9c31de6b as ::core::ffi::c_uint, + 0x852aef2a as ::core::ffi::c_uint, + 0xca6b79ed as ::core::ffi::c_uint, + 0xd37048ac as ::core::ffi::c_uint, + 0xf85d1b6f as ::core::ffi::c_uint, + 0xe1462a2e as ::core::ffi::c_uint, + 0x66de36e1 as ::core::ffi::c_int as uint32_t, + 0x7fc507a0 as ::core::ffi::c_int as uint32_t, + 0x54e85463 as ::core::ffi::c_int as uint32_t, + 0x4df36522 as ::core::ffi::c_int as uint32_t, + 0x2b2f3e5 as ::core::ffi::c_int as uint32_t, + 0x1ba9c2a4 as ::core::ffi::c_int as uint32_t, + 0x30849167 as ::core::ffi::c_int as uint32_t, + 0x299fa026 as ::core::ffi::c_int as uint32_t, + 0xe4c5aeb8 as ::core::ffi::c_uint, + 0xfdde9ff9 as ::core::ffi::c_uint, + 0xd6f3cc3a as ::core::ffi::c_uint, + 0xcfe8fd7b as ::core::ffi::c_uint, + 0x80a96bbc as ::core::ffi::c_uint, + 0x99b25afd as ::core::ffi::c_uint, + 0xb29f093e as ::core::ffi::c_uint, + 0xab84387f as ::core::ffi::c_uint, + 0x2c1c24b0 as ::core::ffi::c_int as uint32_t, + 0x350715f1 as ::core::ffi::c_int as uint32_t, + 0x1e2a4632 as ::core::ffi::c_int as uint32_t, + 0x7317773 as ::core::ffi::c_int as uint32_t, + 0x4870e1b4 as ::core::ffi::c_int as uint32_t, + 0x516bd0f5 as ::core::ffi::c_int as uint32_t, + 0x7a468336 as ::core::ffi::c_int as uint32_t, + 0x635db277 as ::core::ffi::c_int as uint32_t, + 0xcbfad74e as ::core::ffi::c_uint, + 0xd2e1e60f as ::core::ffi::c_uint, + 0xf9ccb5cc as ::core::ffi::c_uint, + 0xe0d7848d as ::core::ffi::c_uint, + 0xaf96124a as ::core::ffi::c_uint, + 0xb68d230b as ::core::ffi::c_uint, + 0x9da070c8 as ::core::ffi::c_uint, + 0x84bb4189 as ::core::ffi::c_uint, + 0x3235d46 as ::core::ffi::c_int as uint32_t, + 0x1a386c07 as ::core::ffi::c_int as uint32_t, + 0x31153fc4 as ::core::ffi::c_int as uint32_t, + 0x280e0e85 as ::core::ffi::c_int as uint32_t, + 0x674f9842 as ::core::ffi::c_int as uint32_t, + 0x7e54a903 as ::core::ffi::c_int as uint32_t, + 0x5579fac0 as ::core::ffi::c_int as uint32_t, + 0x4c62cb81 as ::core::ffi::c_int as uint32_t, + 0x8138c51f as ::core::ffi::c_uint, + 0x9823f45e as ::core::ffi::c_uint, + 0xb30ea79d as ::core::ffi::c_uint, + 0xaa1596dc as ::core::ffi::c_uint, + 0xe554001b as ::core::ffi::c_uint, + 0xfc4f315a as ::core::ffi::c_uint, + 0xd7626299 as ::core::ffi::c_uint, + 0xce7953d8 as ::core::ffi::c_uint, + 0x49e14f17 as ::core::ffi::c_int as uint32_t, + 0x50fa7e56 as ::core::ffi::c_int as uint32_t, + 0x7bd72d95 as ::core::ffi::c_int as uint32_t, + 0x62cc1cd4 as ::core::ffi::c_int as uint32_t, + 0x2d8d8a13 as ::core::ffi::c_int as uint32_t, + 0x3496bb52 as ::core::ffi::c_int as uint32_t, + 0x1fbbe891 as ::core::ffi::c_int as uint32_t, + 0x6a0d9d0 as ::core::ffi::c_int as uint32_t, + 0x5e7ef3ec as ::core::ffi::c_int as uint32_t, + 0x4765c2ad as ::core::ffi::c_int as uint32_t, + 0x6c48916e as ::core::ffi::c_int as uint32_t, + 0x7553a02f as ::core::ffi::c_int as uint32_t, + 0x3a1236e8 as ::core::ffi::c_int as uint32_t, + 0x230907a9 as ::core::ffi::c_int as uint32_t, + 0x824546a as ::core::ffi::c_int as uint32_t, + 0x113f652b as ::core::ffi::c_int as uint32_t, + 0x96a779e4 as ::core::ffi::c_uint, + 0x8fbc48a5 as ::core::ffi::c_uint, + 0xa4911b66 as ::core::ffi::c_uint, + 0xbd8a2a27 as ::core::ffi::c_uint, + 0xf2cbbce0 as ::core::ffi::c_uint, + 0xebd08da1 as ::core::ffi::c_uint, + 0xc0fdde62 as ::core::ffi::c_uint, + 0xd9e6ef23 as ::core::ffi::c_uint, + 0x14bce1bd as ::core::ffi::c_int as uint32_t, + 0xda7d0fc as ::core::ffi::c_int as uint32_t, + 0x268a833f as ::core::ffi::c_int as uint32_t, + 0x3f91b27e as ::core::ffi::c_int as uint32_t, + 0x70d024b9 as ::core::ffi::c_int as uint32_t, + 0x69cb15f8 as ::core::ffi::c_int as uint32_t, + 0x42e6463b as ::core::ffi::c_int as uint32_t, + 0x5bfd777a as ::core::ffi::c_int as uint32_t, + 0xdc656bb5 as ::core::ffi::c_uint, + 0xc57e5af4 as ::core::ffi::c_uint, + 0xee530937 as ::core::ffi::c_uint, + 0xf7483876 as ::core::ffi::c_uint, + 0xb809aeb1 as ::core::ffi::c_uint, + 0xa1129ff0 as ::core::ffi::c_uint, + 0x8a3fcc33 as ::core::ffi::c_uint, + 0x9324fd72 as ::core::ffi::c_uint, + ], + [ + 0 as ::core::ffi::c_int as uint32_t, + 0x1c26a37 as ::core::ffi::c_int as uint32_t, + 0x384d46e as ::core::ffi::c_int as uint32_t, + 0x246be59 as ::core::ffi::c_int as uint32_t, + 0x709a8dc as ::core::ffi::c_int as uint32_t, + 0x6cbc2eb as ::core::ffi::c_int as uint32_t, + 0x48d7cb2 as ::core::ffi::c_int as uint32_t, + 0x54f1685 as ::core::ffi::c_int as uint32_t, + 0xe1351b8 as ::core::ffi::c_int as uint32_t, + 0xfd13b8f as ::core::ffi::c_int as uint32_t, + 0xd9785d6 as ::core::ffi::c_int as uint32_t, + 0xc55efe1 as ::core::ffi::c_int as uint32_t, + 0x91af964 as ::core::ffi::c_int as uint32_t, + 0x8d89353 as ::core::ffi::c_int as uint32_t, + 0xa9e2d0a as ::core::ffi::c_int as uint32_t, + 0xb5c473d as ::core::ffi::c_int as uint32_t, + 0x1c26a370 as ::core::ffi::c_int as uint32_t, + 0x1de4c947 as ::core::ffi::c_int as uint32_t, + 0x1fa2771e as ::core::ffi::c_int as uint32_t, + 0x1e601d29 as ::core::ffi::c_int as uint32_t, + 0x1b2f0bac as ::core::ffi::c_int as uint32_t, + 0x1aed619b as ::core::ffi::c_int as uint32_t, + 0x18abdfc2 as ::core::ffi::c_int as uint32_t, + 0x1969b5f5 as ::core::ffi::c_int as uint32_t, + 0x1235f2c8 as ::core::ffi::c_int as uint32_t, + 0x13f798ff as ::core::ffi::c_int as uint32_t, + 0x11b126a6 as ::core::ffi::c_int as uint32_t, + 0x10734c91 as ::core::ffi::c_int as uint32_t, + 0x153c5a14 as ::core::ffi::c_int as uint32_t, + 0x14fe3023 as ::core::ffi::c_int as uint32_t, + 0x16b88e7a as ::core::ffi::c_int as uint32_t, + 0x177ae44d as ::core::ffi::c_int as uint32_t, + 0x384d46e0 as ::core::ffi::c_int as uint32_t, + 0x398f2cd7 as ::core::ffi::c_int as uint32_t, + 0x3bc9928e as ::core::ffi::c_int as uint32_t, + 0x3a0bf8b9 as ::core::ffi::c_int as uint32_t, + 0x3f44ee3c as ::core::ffi::c_int as uint32_t, + 0x3e86840b as ::core::ffi::c_int as uint32_t, + 0x3cc03a52 as ::core::ffi::c_int as uint32_t, + 0x3d025065 as ::core::ffi::c_int as uint32_t, + 0x365e1758 as ::core::ffi::c_int as uint32_t, + 0x379c7d6f as ::core::ffi::c_int as uint32_t, + 0x35dac336 as ::core::ffi::c_int as uint32_t, + 0x3418a901 as ::core::ffi::c_int as uint32_t, + 0x3157bf84 as ::core::ffi::c_int as uint32_t, + 0x3095d5b3 as ::core::ffi::c_int as uint32_t, + 0x32d36bea as ::core::ffi::c_int as uint32_t, + 0x331101dd as ::core::ffi::c_int as uint32_t, + 0x246be590 as ::core::ffi::c_int as uint32_t, + 0x25a98fa7 as ::core::ffi::c_int as uint32_t, + 0x27ef31fe as ::core::ffi::c_int as uint32_t, + 0x262d5bc9 as ::core::ffi::c_int as uint32_t, + 0x23624d4c as ::core::ffi::c_int as uint32_t, + 0x22a0277b as ::core::ffi::c_int as uint32_t, + 0x20e69922 as ::core::ffi::c_int as uint32_t, + 0x2124f315 as ::core::ffi::c_int as uint32_t, + 0x2a78b428 as ::core::ffi::c_int as uint32_t, + 0x2bbade1f as ::core::ffi::c_int as uint32_t, + 0x29fc6046 as ::core::ffi::c_int as uint32_t, + 0x283e0a71 as ::core::ffi::c_int as uint32_t, + 0x2d711cf4 as ::core::ffi::c_int as uint32_t, + 0x2cb376c3 as ::core::ffi::c_int as uint32_t, + 0x2ef5c89a as ::core::ffi::c_int as uint32_t, + 0x2f37a2ad as ::core::ffi::c_int as uint32_t, + 0x709a8dc0 as ::core::ffi::c_int as uint32_t, + 0x7158e7f7 as ::core::ffi::c_int as uint32_t, + 0x731e59ae as ::core::ffi::c_int as uint32_t, + 0x72dc3399 as ::core::ffi::c_int as uint32_t, + 0x7793251c as ::core::ffi::c_int as uint32_t, + 0x76514f2b as ::core::ffi::c_int as uint32_t, + 0x7417f172 as ::core::ffi::c_int as uint32_t, + 0x75d59b45 as ::core::ffi::c_int as uint32_t, + 0x7e89dc78 as ::core::ffi::c_int as uint32_t, + 0x7f4bb64f as ::core::ffi::c_int as uint32_t, + 0x7d0d0816 as ::core::ffi::c_int as uint32_t, + 0x7ccf6221 as ::core::ffi::c_int as uint32_t, + 0x798074a4 as ::core::ffi::c_int as uint32_t, + 0x78421e93 as ::core::ffi::c_int as uint32_t, + 0x7a04a0ca as ::core::ffi::c_int as uint32_t, + 0x7bc6cafd as ::core::ffi::c_int as uint32_t, + 0x6cbc2eb0 as ::core::ffi::c_int as uint32_t, + 0x6d7e4487 as ::core::ffi::c_int as uint32_t, + 0x6f38fade as ::core::ffi::c_int as uint32_t, + 0x6efa90e9 as ::core::ffi::c_int as uint32_t, + 0x6bb5866c as ::core::ffi::c_int as uint32_t, + 0x6a77ec5b as ::core::ffi::c_int as uint32_t, + 0x68315202 as ::core::ffi::c_int as uint32_t, + 0x69f33835 as ::core::ffi::c_int as uint32_t, + 0x62af7f08 as ::core::ffi::c_int as uint32_t, + 0x636d153f as ::core::ffi::c_int as uint32_t, + 0x612bab66 as ::core::ffi::c_int as uint32_t, + 0x60e9c151 as ::core::ffi::c_int as uint32_t, + 0x65a6d7d4 as ::core::ffi::c_int as uint32_t, + 0x6464bde3 as ::core::ffi::c_int as uint32_t, + 0x662203ba as ::core::ffi::c_int as uint32_t, + 0x67e0698d as ::core::ffi::c_int as uint32_t, + 0x48d7cb20 as ::core::ffi::c_int as uint32_t, + 0x4915a117 as ::core::ffi::c_int as uint32_t, + 0x4b531f4e as ::core::ffi::c_int as uint32_t, + 0x4a917579 as ::core::ffi::c_int as uint32_t, + 0x4fde63fc as ::core::ffi::c_int as uint32_t, + 0x4e1c09cb as ::core::ffi::c_int as uint32_t, + 0x4c5ab792 as ::core::ffi::c_int as uint32_t, + 0x4d98dda5 as ::core::ffi::c_int as uint32_t, + 0x46c49a98 as ::core::ffi::c_int as uint32_t, + 0x4706f0af as ::core::ffi::c_int as uint32_t, + 0x45404ef6 as ::core::ffi::c_int as uint32_t, + 0x448224c1 as ::core::ffi::c_int as uint32_t, + 0x41cd3244 as ::core::ffi::c_int as uint32_t, + 0x400f5873 as ::core::ffi::c_int as uint32_t, + 0x4249e62a as ::core::ffi::c_int as uint32_t, + 0x438b8c1d as ::core::ffi::c_int as uint32_t, + 0x54f16850 as ::core::ffi::c_int as uint32_t, + 0x55330267 as ::core::ffi::c_int as uint32_t, + 0x5775bc3e as ::core::ffi::c_int as uint32_t, + 0x56b7d609 as ::core::ffi::c_int as uint32_t, + 0x53f8c08c as ::core::ffi::c_int as uint32_t, + 0x523aaabb as ::core::ffi::c_int as uint32_t, + 0x507c14e2 as ::core::ffi::c_int as uint32_t, + 0x51be7ed5 as ::core::ffi::c_int as uint32_t, + 0x5ae239e8 as ::core::ffi::c_int as uint32_t, + 0x5b2053df as ::core::ffi::c_int as uint32_t, + 0x5966ed86 as ::core::ffi::c_int as uint32_t, + 0x58a487b1 as ::core::ffi::c_int as uint32_t, + 0x5deb9134 as ::core::ffi::c_int as uint32_t, + 0x5c29fb03 as ::core::ffi::c_int as uint32_t, + 0x5e6f455a as ::core::ffi::c_int as uint32_t, + 0x5fad2f6d as ::core::ffi::c_int as uint32_t, + 0xe1351b80 as ::core::ffi::c_uint, + 0xe0f771b7 as ::core::ffi::c_uint, + 0xe2b1cfee as ::core::ffi::c_uint, + 0xe373a5d9 as ::core::ffi::c_uint, + 0xe63cb35c as ::core::ffi::c_uint, + 0xe7fed96b as ::core::ffi::c_uint, + 0xe5b86732 as ::core::ffi::c_uint, + 0xe47a0d05 as ::core::ffi::c_uint, + 0xef264a38 as ::core::ffi::c_uint, + 0xeee4200f as ::core::ffi::c_uint, + 0xeca29e56 as ::core::ffi::c_uint, + 0xed60f461 as ::core::ffi::c_uint, + 0xe82fe2e4 as ::core::ffi::c_uint, + 0xe9ed88d3 as ::core::ffi::c_uint, + 0xebab368a as ::core::ffi::c_uint, + 0xea695cbd as ::core::ffi::c_uint, + 0xfd13b8f0 as ::core::ffi::c_uint, + 0xfcd1d2c7 as ::core::ffi::c_uint, + 0xfe976c9e as ::core::ffi::c_uint, + 0xff5506a9 as ::core::ffi::c_uint, + 0xfa1a102c as ::core::ffi::c_uint, + 0xfbd87a1b as ::core::ffi::c_uint, + 0xf99ec442 as ::core::ffi::c_uint, + 0xf85cae75 as ::core::ffi::c_uint, + 0xf300e948 as ::core::ffi::c_uint, + 0xf2c2837f as ::core::ffi::c_uint, + 0xf0843d26 as ::core::ffi::c_uint, + 0xf1465711 as ::core::ffi::c_uint, + 0xf4094194 as ::core::ffi::c_uint, + 0xf5cb2ba3 as ::core::ffi::c_uint, + 0xf78d95fa as ::core::ffi::c_uint, + 0xf64fffcd as ::core::ffi::c_uint, + 0xd9785d60 as ::core::ffi::c_uint, + 0xd8ba3757 as ::core::ffi::c_uint, + 0xdafc890e as ::core::ffi::c_uint, + 0xdb3ee339 as ::core::ffi::c_uint, + 0xde71f5bc as ::core::ffi::c_uint, + 0xdfb39f8b as ::core::ffi::c_uint, + 0xddf521d2 as ::core::ffi::c_uint, + 0xdc374be5 as ::core::ffi::c_uint, + 0xd76b0cd8 as ::core::ffi::c_uint, + 0xd6a966ef as ::core::ffi::c_uint, + 0xd4efd8b6 as ::core::ffi::c_uint, + 0xd52db281 as ::core::ffi::c_uint, + 0xd062a404 as ::core::ffi::c_uint, + 0xd1a0ce33 as ::core::ffi::c_uint, + 0xd3e6706a as ::core::ffi::c_uint, + 0xd2241a5d as ::core::ffi::c_uint, + 0xc55efe10 as ::core::ffi::c_uint, + 0xc49c9427 as ::core::ffi::c_uint, + 0xc6da2a7e as ::core::ffi::c_uint, + 0xc7184049 as ::core::ffi::c_uint, + 0xc25756cc as ::core::ffi::c_uint, + 0xc3953cfb as ::core::ffi::c_uint, + 0xc1d382a2 as ::core::ffi::c_uint, + 0xc011e895 as ::core::ffi::c_uint, + 0xcb4dafa8 as ::core::ffi::c_uint, + 0xca8fc59f as ::core::ffi::c_uint, + 0xc8c97bc6 as ::core::ffi::c_uint, + 0xc90b11f1 as ::core::ffi::c_uint, + 0xcc440774 as ::core::ffi::c_uint, + 0xcd866d43 as ::core::ffi::c_uint, + 0xcfc0d31a as ::core::ffi::c_uint, + 0xce02b92d as ::core::ffi::c_uint, + 0x91af9640 as ::core::ffi::c_uint, + 0x906dfc77 as ::core::ffi::c_uint, + 0x922b422e as ::core::ffi::c_uint, + 0x93e92819 as ::core::ffi::c_uint, + 0x96a63e9c as ::core::ffi::c_uint, + 0x976454ab as ::core::ffi::c_uint, + 0x9522eaf2 as ::core::ffi::c_uint, + 0x94e080c5 as ::core::ffi::c_uint, + 0x9fbcc7f8 as ::core::ffi::c_uint, + 0x9e7eadcf as ::core::ffi::c_uint, + 0x9c381396 as ::core::ffi::c_uint, + 0x9dfa79a1 as ::core::ffi::c_uint, + 0x98b56f24 as ::core::ffi::c_uint, + 0x99770513 as ::core::ffi::c_uint, + 0x9b31bb4a as ::core::ffi::c_uint, + 0x9af3d17d as ::core::ffi::c_uint, + 0x8d893530 as ::core::ffi::c_uint, + 0x8c4b5f07 as ::core::ffi::c_uint, + 0x8e0de15e as ::core::ffi::c_uint, + 0x8fcf8b69 as ::core::ffi::c_uint, + 0x8a809dec as ::core::ffi::c_uint, + 0x8b42f7db as ::core::ffi::c_uint, + 0x89044982 as ::core::ffi::c_uint, + 0x88c623b5 as ::core::ffi::c_uint, + 0x839a6488 as ::core::ffi::c_uint, + 0x82580ebf as ::core::ffi::c_uint, + 0x801eb0e6 as ::core::ffi::c_uint, + 0x81dcdad1 as ::core::ffi::c_uint, + 0x8493cc54 as ::core::ffi::c_uint, + 0x8551a663 as ::core::ffi::c_uint, + 0x8717183a as ::core::ffi::c_uint, + 0x86d5720d as ::core::ffi::c_uint, + 0xa9e2d0a0 as ::core::ffi::c_uint, + 0xa820ba97 as ::core::ffi::c_uint, + 0xaa6604ce as ::core::ffi::c_uint, + 0xaba46ef9 as ::core::ffi::c_uint, + 0xaeeb787c as ::core::ffi::c_uint, + 0xaf29124b as ::core::ffi::c_uint, + 0xad6fac12 as ::core::ffi::c_uint, + 0xacadc625 as ::core::ffi::c_uint, + 0xa7f18118 as ::core::ffi::c_uint, + 0xa633eb2f as ::core::ffi::c_uint, + 0xa4755576 as ::core::ffi::c_uint, + 0xa5b73f41 as ::core::ffi::c_uint, + 0xa0f829c4 as ::core::ffi::c_uint, + 0xa13a43f3 as ::core::ffi::c_uint, + 0xa37cfdaa as ::core::ffi::c_uint, + 0xa2be979d as ::core::ffi::c_uint, + 0xb5c473d0 as ::core::ffi::c_uint, + 0xb40619e7 as ::core::ffi::c_uint, + 0xb640a7be as ::core::ffi::c_uint, + 0xb782cd89 as ::core::ffi::c_uint, + 0xb2cddb0c as ::core::ffi::c_uint, + 0xb30fb13b as ::core::ffi::c_uint, + 0xb1490f62 as ::core::ffi::c_uint, + 0xb08b6555 as ::core::ffi::c_uint, + 0xbbd72268 as ::core::ffi::c_uint, + 0xba15485f as ::core::ffi::c_uint, + 0xb853f606 as ::core::ffi::c_uint, + 0xb9919c31 as ::core::ffi::c_uint, + 0xbcde8ab4 as ::core::ffi::c_uint, + 0xbd1ce083 as ::core::ffi::c_uint, + 0xbf5a5eda as ::core::ffi::c_uint, + 0xbe9834ed as ::core::ffi::c_uint, + ], + [ + 0 as ::core::ffi::c_int as uint32_t, + 0xb8bc6765 as ::core::ffi::c_uint, + 0xaa09c88b as ::core::ffi::c_uint, + 0x12b5afee as ::core::ffi::c_int as uint32_t, + 0x8f629757 as ::core::ffi::c_uint, + 0x37def032 as ::core::ffi::c_int as uint32_t, + 0x256b5fdc as ::core::ffi::c_int as uint32_t, + 0x9dd738b9 as ::core::ffi::c_uint, + 0xc5b428ef as ::core::ffi::c_uint, + 0x7d084f8a as ::core::ffi::c_int as uint32_t, + 0x6fbde064 as ::core::ffi::c_int as uint32_t, + 0xd7018701 as ::core::ffi::c_uint, + 0x4ad6bfb8 as ::core::ffi::c_int as uint32_t, + 0xf26ad8dd as ::core::ffi::c_uint, + 0xe0df7733 as ::core::ffi::c_uint, + 0x58631056 as ::core::ffi::c_int as uint32_t, + 0x5019579f as ::core::ffi::c_int as uint32_t, + 0xe8a530fa as ::core::ffi::c_uint, + 0xfa109f14 as ::core::ffi::c_uint, + 0x42acf871 as ::core::ffi::c_int as uint32_t, + 0xdf7bc0c8 as ::core::ffi::c_uint, + 0x67c7a7ad as ::core::ffi::c_int as uint32_t, + 0x75720843 as ::core::ffi::c_int as uint32_t, + 0xcdce6f26 as ::core::ffi::c_uint, + 0x95ad7f70 as ::core::ffi::c_uint, + 0x2d111815 as ::core::ffi::c_int as uint32_t, + 0x3fa4b7fb as ::core::ffi::c_int as uint32_t, + 0x8718d09e as ::core::ffi::c_uint, + 0x1acfe827 as ::core::ffi::c_int as uint32_t, + 0xa2738f42 as ::core::ffi::c_uint, + 0xb0c620ac as ::core::ffi::c_uint, + 0x87a47c9 as ::core::ffi::c_int as uint32_t, + 0xa032af3e as ::core::ffi::c_uint, + 0x188ec85b as ::core::ffi::c_int as uint32_t, + 0xa3b67b5 as ::core::ffi::c_int as uint32_t, + 0xb28700d0 as ::core::ffi::c_uint, + 0x2f503869 as ::core::ffi::c_int as uint32_t, + 0x97ec5f0c as ::core::ffi::c_uint, + 0x8559f0e2 as ::core::ffi::c_uint, + 0x3de59787 as ::core::ffi::c_int as uint32_t, + 0x658687d1 as ::core::ffi::c_int as uint32_t, + 0xdd3ae0b4 as ::core::ffi::c_uint, + 0xcf8f4f5a as ::core::ffi::c_uint, + 0x7733283f as ::core::ffi::c_int as uint32_t, + 0xeae41086 as ::core::ffi::c_uint, + 0x525877e3 as ::core::ffi::c_int as uint32_t, + 0x40edd80d as ::core::ffi::c_int as uint32_t, + 0xf851bf68 as ::core::ffi::c_uint, + 0xf02bf8a1 as ::core::ffi::c_uint, + 0x48979fc4 as ::core::ffi::c_int as uint32_t, + 0x5a22302a as ::core::ffi::c_int as uint32_t, + 0xe29e574f as ::core::ffi::c_uint, + 0x7f496ff6 as ::core::ffi::c_int as uint32_t, + 0xc7f50893 as ::core::ffi::c_uint, + 0xd540a77d as ::core::ffi::c_uint, + 0x6dfcc018 as ::core::ffi::c_int as uint32_t, + 0x359fd04e as ::core::ffi::c_int as uint32_t, + 0x8d23b72b as ::core::ffi::c_uint, + 0x9f9618c5 as ::core::ffi::c_uint, + 0x272a7fa0 as ::core::ffi::c_int as uint32_t, + 0xbafd4719 as ::core::ffi::c_uint, + 0x241207c as ::core::ffi::c_int as uint32_t, + 0x10f48f92 as ::core::ffi::c_int as uint32_t, + 0xa848e8f7 as ::core::ffi::c_uint, + 0x9b14583d as ::core::ffi::c_uint, + 0x23a83f58 as ::core::ffi::c_int as uint32_t, + 0x311d90b6 as ::core::ffi::c_int as uint32_t, + 0x89a1f7d3 as ::core::ffi::c_uint, + 0x1476cf6a as ::core::ffi::c_int as uint32_t, + 0xaccaa80f as ::core::ffi::c_uint, + 0xbe7f07e1 as ::core::ffi::c_uint, + 0x6c36084 as ::core::ffi::c_int as uint32_t, + 0x5ea070d2 as ::core::ffi::c_int as uint32_t, + 0xe61c17b7 as ::core::ffi::c_uint, + 0xf4a9b859 as ::core::ffi::c_uint, + 0x4c15df3c as ::core::ffi::c_int as uint32_t, + 0xd1c2e785 as ::core::ffi::c_uint, + 0x697e80e0 as ::core::ffi::c_int as uint32_t, + 0x7bcb2f0e as ::core::ffi::c_int as uint32_t, + 0xc377486b as ::core::ffi::c_uint, + 0xcb0d0fa2 as ::core::ffi::c_uint, + 0x73b168c7 as ::core::ffi::c_int as uint32_t, + 0x6104c729 as ::core::ffi::c_int as uint32_t, + 0xd9b8a04c as ::core::ffi::c_uint, + 0x446f98f5 as ::core::ffi::c_int as uint32_t, + 0xfcd3ff90 as ::core::ffi::c_uint, + 0xee66507e as ::core::ffi::c_uint, + 0x56da371b as ::core::ffi::c_int as uint32_t, + 0xeb9274d as ::core::ffi::c_int as uint32_t, + 0xb6054028 as ::core::ffi::c_uint, + 0xa4b0efc6 as ::core::ffi::c_uint, + 0x1c0c88a3 as ::core::ffi::c_int as uint32_t, + 0x81dbb01a as ::core::ffi::c_uint, + 0x3967d77f as ::core::ffi::c_int as uint32_t, + 0x2bd27891 as ::core::ffi::c_int as uint32_t, + 0x936e1ff4 as ::core::ffi::c_uint, + 0x3b26f703 as ::core::ffi::c_int as uint32_t, + 0x839a9066 as ::core::ffi::c_uint, + 0x912f3f88 as ::core::ffi::c_uint, + 0x299358ed as ::core::ffi::c_int as uint32_t, + 0xb4446054 as ::core::ffi::c_uint, + 0xcf80731 as ::core::ffi::c_int as uint32_t, + 0x1e4da8df as ::core::ffi::c_int as uint32_t, + 0xa6f1cfba as ::core::ffi::c_uint, + 0xfe92dfec as ::core::ffi::c_uint, + 0x462eb889 as ::core::ffi::c_int as uint32_t, + 0x549b1767 as ::core::ffi::c_int as uint32_t, + 0xec277002 as ::core::ffi::c_uint, + 0x71f048bb as ::core::ffi::c_int as uint32_t, + 0xc94c2fde as ::core::ffi::c_uint, + 0xdbf98030 as ::core::ffi::c_uint, + 0x6345e755 as ::core::ffi::c_int as uint32_t, + 0x6b3fa09c as ::core::ffi::c_int as uint32_t, + 0xd383c7f9 as ::core::ffi::c_uint, + 0xc1366817 as ::core::ffi::c_uint, + 0x798a0f72 as ::core::ffi::c_int as uint32_t, + 0xe45d37cb as ::core::ffi::c_uint, + 0x5ce150ae as ::core::ffi::c_int as uint32_t, + 0x4e54ff40 as ::core::ffi::c_int as uint32_t, + 0xf6e89825 as ::core::ffi::c_uint, + 0xae8b8873 as ::core::ffi::c_uint, + 0x1637ef16 as ::core::ffi::c_int as uint32_t, + 0x48240f8 as ::core::ffi::c_int as uint32_t, + 0xbc3e279d as ::core::ffi::c_uint, + 0x21e91f24 as ::core::ffi::c_int as uint32_t, + 0x99557841 as ::core::ffi::c_uint, + 0x8be0d7af as ::core::ffi::c_uint, + 0x335cb0ca as ::core::ffi::c_int as uint32_t, + 0xed59b63b as ::core::ffi::c_uint, + 0x55e5d15e as ::core::ffi::c_int as uint32_t, + 0x47507eb0 as ::core::ffi::c_int as uint32_t, + 0xffec19d5 as ::core::ffi::c_uint, + 0x623b216c as ::core::ffi::c_int as uint32_t, + 0xda874609 as ::core::ffi::c_uint, + 0xc832e9e7 as ::core::ffi::c_uint, + 0x708e8e82 as ::core::ffi::c_int as uint32_t, + 0x28ed9ed4 as ::core::ffi::c_int as uint32_t, + 0x9051f9b1 as ::core::ffi::c_uint, + 0x82e4565f as ::core::ffi::c_uint, + 0x3a58313a as ::core::ffi::c_int as uint32_t, + 0xa78f0983 as ::core::ffi::c_uint, + 0x1f336ee6 as ::core::ffi::c_int as uint32_t, + 0xd86c108 as ::core::ffi::c_int as uint32_t, + 0xb53aa66d as ::core::ffi::c_uint, + 0xbd40e1a4 as ::core::ffi::c_uint, + 0x5fc86c1 as ::core::ffi::c_int as uint32_t, + 0x1749292f as ::core::ffi::c_int as uint32_t, + 0xaff54e4a as ::core::ffi::c_uint, + 0x322276f3 as ::core::ffi::c_int as uint32_t, + 0x8a9e1196 as ::core::ffi::c_uint, + 0x982bbe78 as ::core::ffi::c_uint, + 0x2097d91d as ::core::ffi::c_int as uint32_t, + 0x78f4c94b as ::core::ffi::c_int as uint32_t, + 0xc048ae2e as ::core::ffi::c_uint, + 0xd2fd01c0 as ::core::ffi::c_uint, + 0x6a4166a5 as ::core::ffi::c_int as uint32_t, + 0xf7965e1c as ::core::ffi::c_uint, + 0x4f2a3979 as ::core::ffi::c_int as uint32_t, + 0x5d9f9697 as ::core::ffi::c_int as uint32_t, + 0xe523f1f2 as ::core::ffi::c_uint, + 0x4d6b1905 as ::core::ffi::c_int as uint32_t, + 0xf5d77e60 as ::core::ffi::c_uint, + 0xe762d18e as ::core::ffi::c_uint, + 0x5fdeb6eb as ::core::ffi::c_int as uint32_t, + 0xc2098e52 as ::core::ffi::c_uint, + 0x7ab5e937 as ::core::ffi::c_int as uint32_t, + 0x680046d9 as ::core::ffi::c_int as uint32_t, + 0xd0bc21bc as ::core::ffi::c_uint, + 0x88df31ea as ::core::ffi::c_uint, + 0x3063568f as ::core::ffi::c_int as uint32_t, + 0x22d6f961 as ::core::ffi::c_int as uint32_t, + 0x9a6a9e04 as ::core::ffi::c_uint, + 0x7bda6bd as ::core::ffi::c_int as uint32_t, + 0xbf01c1d8 as ::core::ffi::c_uint, + 0xadb46e36 as ::core::ffi::c_uint, + 0x15080953 as ::core::ffi::c_int as uint32_t, + 0x1d724e9a as ::core::ffi::c_int as uint32_t, + 0xa5ce29ff as ::core::ffi::c_uint, + 0xb77b8611 as ::core::ffi::c_uint, + 0xfc7e174 as ::core::ffi::c_int as uint32_t, + 0x9210d9cd as ::core::ffi::c_uint, + 0x2aacbea8 as ::core::ffi::c_int as uint32_t, + 0x38191146 as ::core::ffi::c_int as uint32_t, + 0x80a57623 as ::core::ffi::c_uint, + 0xd8c66675 as ::core::ffi::c_uint, + 0x607a0110 as ::core::ffi::c_int as uint32_t, + 0x72cfaefe as ::core::ffi::c_int as uint32_t, + 0xca73c99b as ::core::ffi::c_uint, + 0x57a4f122 as ::core::ffi::c_int as uint32_t, + 0xef189647 as ::core::ffi::c_uint, + 0xfdad39a9 as ::core::ffi::c_uint, + 0x45115ecc as ::core::ffi::c_int as uint32_t, + 0x764dee06 as ::core::ffi::c_int as uint32_t, + 0xcef18963 as ::core::ffi::c_uint, + 0xdc44268d as ::core::ffi::c_uint, + 0x64f841e8 as ::core::ffi::c_int as uint32_t, + 0xf92f7951 as ::core::ffi::c_uint, + 0x41931e34 as ::core::ffi::c_int as uint32_t, + 0x5326b1da as ::core::ffi::c_int as uint32_t, + 0xeb9ad6bf as ::core::ffi::c_uint, + 0xb3f9c6e9 as ::core::ffi::c_uint, + 0xb45a18c as ::core::ffi::c_int as uint32_t, + 0x19f00e62 as ::core::ffi::c_int as uint32_t, + 0xa14c6907 as ::core::ffi::c_uint, + 0x3c9b51be as ::core::ffi::c_int as uint32_t, + 0x842736db as ::core::ffi::c_uint, + 0x96929935 as ::core::ffi::c_uint, + 0x2e2efe50 as ::core::ffi::c_int as uint32_t, + 0x2654b999 as ::core::ffi::c_int as uint32_t, + 0x9ee8defc as ::core::ffi::c_uint, + 0x8c5d7112 as ::core::ffi::c_uint, + 0x34e11677 as ::core::ffi::c_int as uint32_t, + 0xa9362ece as ::core::ffi::c_uint, + 0x118a49ab as ::core::ffi::c_int as uint32_t, + 0x33fe645 as ::core::ffi::c_int as uint32_t, + 0xbb838120 as ::core::ffi::c_uint, + 0xe3e09176 as ::core::ffi::c_uint, + 0x5b5cf613 as ::core::ffi::c_int as uint32_t, + 0x49e959fd as ::core::ffi::c_int as uint32_t, + 0xf1553e98 as ::core::ffi::c_uint, + 0x6c820621 as ::core::ffi::c_int as uint32_t, + 0xd43e6144 as ::core::ffi::c_uint, + 0xc68bceaa as ::core::ffi::c_uint, + 0x7e37a9cf as ::core::ffi::c_int as uint32_t, + 0xd67f4138 as ::core::ffi::c_uint, + 0x6ec3265d as ::core::ffi::c_int as uint32_t, + 0x7c7689b3 as ::core::ffi::c_int as uint32_t, + 0xc4caeed6 as ::core::ffi::c_uint, + 0x591dd66f as ::core::ffi::c_int as uint32_t, + 0xe1a1b10a as ::core::ffi::c_uint, + 0xf3141ee4 as ::core::ffi::c_uint, + 0x4ba87981 as ::core::ffi::c_int as uint32_t, + 0x13cb69d7 as ::core::ffi::c_int as uint32_t, + 0xab770eb2 as ::core::ffi::c_uint, + 0xb9c2a15c as ::core::ffi::c_uint, + 0x17ec639 as ::core::ffi::c_int as uint32_t, + 0x9ca9fe80 as ::core::ffi::c_uint, + 0x241599e5 as ::core::ffi::c_int as uint32_t, + 0x36a0360b as ::core::ffi::c_int as uint32_t, + 0x8e1c516e as ::core::ffi::c_uint, + 0x866616a7 as ::core::ffi::c_uint, + 0x3eda71c2 as ::core::ffi::c_int as uint32_t, + 0x2c6fde2c as ::core::ffi::c_int as uint32_t, + 0x94d3b949 as ::core::ffi::c_uint, + 0x90481f0 as ::core::ffi::c_int as uint32_t, + 0xb1b8e695 as ::core::ffi::c_uint, + 0xa30d497b as ::core::ffi::c_uint, + 0x1bb12e1e as ::core::ffi::c_int as uint32_t, + 0x43d23e48 as ::core::ffi::c_int as uint32_t, + 0xfb6e592d as ::core::ffi::c_uint, + 0xe9dbf6c3 as ::core::ffi::c_uint, + 0x516791a6 as ::core::ffi::c_int as uint32_t, + 0xccb0a91f as ::core::ffi::c_uint, + 0x740cce7a as ::core::ffi::c_int as uint32_t, + 0x66b96194 as ::core::ffi::c_int as uint32_t, + 0xde0506f1 as ::core::ffi::c_uint, + ], + [ + 0 as ::core::ffi::c_int as uint32_t, + 0x3d6029b0 as ::core::ffi::c_int as uint32_t, + 0x7ac05360 as ::core::ffi::c_int as uint32_t, + 0x47a07ad0 as ::core::ffi::c_int as uint32_t, + 0xf580a6c0 as ::core::ffi::c_uint, + 0xc8e08f70 as ::core::ffi::c_uint, + 0x8f40f5a0 as ::core::ffi::c_uint, + 0xb220dc10 as ::core::ffi::c_uint, + 0x30704bc1 as ::core::ffi::c_int as uint32_t, + 0xd106271 as ::core::ffi::c_int as uint32_t, + 0x4ab018a1 as ::core::ffi::c_int as uint32_t, + 0x77d03111 as ::core::ffi::c_int as uint32_t, + 0xc5f0ed01 as ::core::ffi::c_uint, + 0xf890c4b1 as ::core::ffi::c_uint, + 0xbf30be61 as ::core::ffi::c_uint, + 0x825097d1 as ::core::ffi::c_uint, + 0x60e09782 as ::core::ffi::c_int as uint32_t, + 0x5d80be32 as ::core::ffi::c_int as uint32_t, + 0x1a20c4e2 as ::core::ffi::c_int as uint32_t, + 0x2740ed52 as ::core::ffi::c_int as uint32_t, + 0x95603142 as ::core::ffi::c_uint, + 0xa80018f2 as ::core::ffi::c_uint, + 0xefa06222 as ::core::ffi::c_uint, + 0xd2c04b92 as ::core::ffi::c_uint, + 0x5090dc43 as ::core::ffi::c_int as uint32_t, + 0x6df0f5f3 as ::core::ffi::c_int as uint32_t, + 0x2a508f23 as ::core::ffi::c_int as uint32_t, + 0x1730a693 as ::core::ffi::c_int as uint32_t, + 0xa5107a83 as ::core::ffi::c_uint, + 0x98705333 as ::core::ffi::c_uint, + 0xdfd029e3 as ::core::ffi::c_uint, + 0xe2b00053 as ::core::ffi::c_uint, + 0xc1c12f04 as ::core::ffi::c_uint, + 0xfca106b4 as ::core::ffi::c_uint, + 0xbb017c64 as ::core::ffi::c_uint, + 0x866155d4 as ::core::ffi::c_uint, + 0x344189c4 as ::core::ffi::c_int as uint32_t, + 0x921a074 as ::core::ffi::c_int as uint32_t, + 0x4e81daa4 as ::core::ffi::c_int as uint32_t, + 0x73e1f314 as ::core::ffi::c_int as uint32_t, + 0xf1b164c5 as ::core::ffi::c_uint, + 0xccd14d75 as ::core::ffi::c_uint, + 0x8b7137a5 as ::core::ffi::c_uint, + 0xb6111e15 as ::core::ffi::c_uint, + 0x431c205 as ::core::ffi::c_int as uint32_t, + 0x3951ebb5 as ::core::ffi::c_int as uint32_t, + 0x7ef19165 as ::core::ffi::c_int as uint32_t, + 0x4391b8d5 as ::core::ffi::c_int as uint32_t, + 0xa121b886 as ::core::ffi::c_uint, + 0x9c419136 as ::core::ffi::c_uint, + 0xdbe1ebe6 as ::core::ffi::c_uint, + 0xe681c256 as ::core::ffi::c_uint, + 0x54a11e46 as ::core::ffi::c_int as uint32_t, + 0x69c137f6 as ::core::ffi::c_int as uint32_t, + 0x2e614d26 as ::core::ffi::c_int as uint32_t, + 0x13016496 as ::core::ffi::c_int as uint32_t, + 0x9151f347 as ::core::ffi::c_uint, + 0xac31daf7 as ::core::ffi::c_uint, + 0xeb91a027 as ::core::ffi::c_uint, + 0xd6f18997 as ::core::ffi::c_uint, + 0x64d15587 as ::core::ffi::c_int as uint32_t, + 0x59b17c37 as ::core::ffi::c_int as uint32_t, + 0x1e1106e7 as ::core::ffi::c_int as uint32_t, + 0x23712f57 as ::core::ffi::c_int as uint32_t, + 0x58f35849 as ::core::ffi::c_int as uint32_t, + 0x659371f9 as ::core::ffi::c_int as uint32_t, + 0x22330b29 as ::core::ffi::c_int as uint32_t, + 0x1f532299 as ::core::ffi::c_int as uint32_t, + 0xad73fe89 as ::core::ffi::c_uint, + 0x9013d739 as ::core::ffi::c_uint, + 0xd7b3ade9 as ::core::ffi::c_uint, + 0xead38459 as ::core::ffi::c_uint, + 0x68831388 as ::core::ffi::c_int as uint32_t, + 0x55e33a38 as ::core::ffi::c_int as uint32_t, + 0x124340e8 as ::core::ffi::c_int as uint32_t, + 0x2f236958 as ::core::ffi::c_int as uint32_t, + 0x9d03b548 as ::core::ffi::c_uint, + 0xa0639cf8 as ::core::ffi::c_uint, + 0xe7c3e628 as ::core::ffi::c_uint, + 0xdaa3cf98 as ::core::ffi::c_uint, + 0x3813cfcb as ::core::ffi::c_int as uint32_t, + 0x573e67b as ::core::ffi::c_int as uint32_t, + 0x42d39cab as ::core::ffi::c_int as uint32_t, + 0x7fb3b51b as ::core::ffi::c_int as uint32_t, + 0xcd93690b as ::core::ffi::c_uint, + 0xf0f340bb as ::core::ffi::c_uint, + 0xb7533a6b as ::core::ffi::c_uint, + 0x8a3313db as ::core::ffi::c_uint, + 0x863840a as ::core::ffi::c_int as uint32_t, + 0x3503adba as ::core::ffi::c_int as uint32_t, + 0x72a3d76a as ::core::ffi::c_int as uint32_t, + 0x4fc3feda as ::core::ffi::c_int as uint32_t, + 0xfde322ca as ::core::ffi::c_uint, + 0xc0830b7a as ::core::ffi::c_uint, + 0x872371aa as ::core::ffi::c_uint, + 0xba43581a as ::core::ffi::c_uint, + 0x9932774d as ::core::ffi::c_uint, + 0xa4525efd as ::core::ffi::c_uint, + 0xe3f2242d as ::core::ffi::c_uint, + 0xde920d9d as ::core::ffi::c_uint, + 0x6cb2d18d as ::core::ffi::c_int as uint32_t, + 0x51d2f83d as ::core::ffi::c_int as uint32_t, + 0x167282ed as ::core::ffi::c_int as uint32_t, + 0x2b12ab5d as ::core::ffi::c_int as uint32_t, + 0xa9423c8c as ::core::ffi::c_uint, + 0x9422153c as ::core::ffi::c_uint, + 0xd3826fec as ::core::ffi::c_uint, + 0xeee2465c as ::core::ffi::c_uint, + 0x5cc29a4c as ::core::ffi::c_int as uint32_t, + 0x61a2b3fc as ::core::ffi::c_int as uint32_t, + 0x2602c92c as ::core::ffi::c_int as uint32_t, + 0x1b62e09c as ::core::ffi::c_int as uint32_t, + 0xf9d2e0cf as ::core::ffi::c_uint, + 0xc4b2c97f as ::core::ffi::c_uint, + 0x8312b3af as ::core::ffi::c_uint, + 0xbe729a1f as ::core::ffi::c_uint, + 0xc52460f as ::core::ffi::c_int as uint32_t, + 0x31326fbf as ::core::ffi::c_int as uint32_t, + 0x7692156f as ::core::ffi::c_int as uint32_t, + 0x4bf23cdf as ::core::ffi::c_int as uint32_t, + 0xc9a2ab0e as ::core::ffi::c_uint, + 0xf4c282be as ::core::ffi::c_uint, + 0xb362f86e as ::core::ffi::c_uint, + 0x8e02d1de as ::core::ffi::c_uint, + 0x3c220dce as ::core::ffi::c_int as uint32_t, + 0x142247e as ::core::ffi::c_int as uint32_t, + 0x46e25eae as ::core::ffi::c_int as uint32_t, + 0x7b82771e as ::core::ffi::c_int as uint32_t, + 0xb1e6b092 as ::core::ffi::c_uint, + 0x8c869922 as ::core::ffi::c_uint, + 0xcb26e3f2 as ::core::ffi::c_uint, + 0xf646ca42 as ::core::ffi::c_uint, + 0x44661652 as ::core::ffi::c_int as uint32_t, + 0x79063fe2 as ::core::ffi::c_int as uint32_t, + 0x3ea64532 as ::core::ffi::c_int as uint32_t, + 0x3c66c82 as ::core::ffi::c_int as uint32_t, + 0x8196fb53 as ::core::ffi::c_uint, + 0xbcf6d2e3 as ::core::ffi::c_uint, + 0xfb56a833 as ::core::ffi::c_uint, + 0xc6368183 as ::core::ffi::c_uint, + 0x74165d93 as ::core::ffi::c_int as uint32_t, + 0x49767423 as ::core::ffi::c_int as uint32_t, + 0xed60ef3 as ::core::ffi::c_int as uint32_t, + 0x33b62743 as ::core::ffi::c_int as uint32_t, + 0xd1062710 as ::core::ffi::c_uint, + 0xec660ea0 as ::core::ffi::c_uint, + 0xabc67470 as ::core::ffi::c_uint, + 0x96a65dc0 as ::core::ffi::c_uint, + 0x248681d0 as ::core::ffi::c_int as uint32_t, + 0x19e6a860 as ::core::ffi::c_int as uint32_t, + 0x5e46d2b0 as ::core::ffi::c_int as uint32_t, + 0x6326fb00 as ::core::ffi::c_int as uint32_t, + 0xe1766cd1 as ::core::ffi::c_uint, + 0xdc164561 as ::core::ffi::c_uint, + 0x9bb63fb1 as ::core::ffi::c_uint, + 0xa6d61601 as ::core::ffi::c_uint, + 0x14f6ca11 as ::core::ffi::c_int as uint32_t, + 0x2996e3a1 as ::core::ffi::c_int as uint32_t, + 0x6e369971 as ::core::ffi::c_int as uint32_t, + 0x5356b0c1 as ::core::ffi::c_int as uint32_t, + 0x70279f96 as ::core::ffi::c_int as uint32_t, + 0x4d47b626 as ::core::ffi::c_int as uint32_t, + 0xae7ccf6 as ::core::ffi::c_int as uint32_t, + 0x3787e546 as ::core::ffi::c_int as uint32_t, + 0x85a73956 as ::core::ffi::c_uint, + 0xb8c710e6 as ::core::ffi::c_uint, + 0xff676a36 as ::core::ffi::c_uint, + 0xc2074386 as ::core::ffi::c_uint, + 0x4057d457 as ::core::ffi::c_int as uint32_t, + 0x7d37fde7 as ::core::ffi::c_int as uint32_t, + 0x3a978737 as ::core::ffi::c_int as uint32_t, + 0x7f7ae87 as ::core::ffi::c_int as uint32_t, + 0xb5d77297 as ::core::ffi::c_uint, + 0x88b75b27 as ::core::ffi::c_uint, + 0xcf1721f7 as ::core::ffi::c_uint, + 0xf2770847 as ::core::ffi::c_uint, + 0x10c70814 as ::core::ffi::c_int as uint32_t, + 0x2da721a4 as ::core::ffi::c_int as uint32_t, + 0x6a075b74 as ::core::ffi::c_int as uint32_t, + 0x576772c4 as ::core::ffi::c_int as uint32_t, + 0xe547aed4 as ::core::ffi::c_uint, + 0xd8278764 as ::core::ffi::c_uint, + 0x9f87fdb4 as ::core::ffi::c_uint, + 0xa2e7d404 as ::core::ffi::c_uint, + 0x20b743d5 as ::core::ffi::c_int as uint32_t, + 0x1dd76a65 as ::core::ffi::c_int as uint32_t, + 0x5a7710b5 as ::core::ffi::c_int as uint32_t, + 0x67173905 as ::core::ffi::c_int as uint32_t, + 0xd537e515 as ::core::ffi::c_uint, + 0xe857cca5 as ::core::ffi::c_uint, + 0xaff7b675 as ::core::ffi::c_uint, + 0x92979fc5 as ::core::ffi::c_uint, + 0xe915e8db as ::core::ffi::c_uint, + 0xd475c16b as ::core::ffi::c_uint, + 0x93d5bbbb as ::core::ffi::c_uint, + 0xaeb5920b as ::core::ffi::c_uint, + 0x1c954e1b as ::core::ffi::c_int as uint32_t, + 0x21f567ab as ::core::ffi::c_int as uint32_t, + 0x66551d7b as ::core::ffi::c_int as uint32_t, + 0x5b3534cb as ::core::ffi::c_int as uint32_t, + 0xd965a31a as ::core::ffi::c_uint, + 0xe4058aaa as ::core::ffi::c_uint, + 0xa3a5f07a as ::core::ffi::c_uint, + 0x9ec5d9ca as ::core::ffi::c_uint, + 0x2ce505da as ::core::ffi::c_int as uint32_t, + 0x11852c6a as ::core::ffi::c_int as uint32_t, + 0x562556ba as ::core::ffi::c_int as uint32_t, + 0x6b457f0a as ::core::ffi::c_int as uint32_t, + 0x89f57f59 as ::core::ffi::c_uint, + 0xb49556e9 as ::core::ffi::c_uint, + 0xf3352c39 as ::core::ffi::c_uint, + 0xce550589 as ::core::ffi::c_uint, + 0x7c75d999 as ::core::ffi::c_int as uint32_t, + 0x4115f029 as ::core::ffi::c_int as uint32_t, + 0x6b58af9 as ::core::ffi::c_int as uint32_t, + 0x3bd5a349 as ::core::ffi::c_int as uint32_t, + 0xb9853498 as ::core::ffi::c_uint, + 0x84e51d28 as ::core::ffi::c_uint, + 0xc34567f8 as ::core::ffi::c_uint, + 0xfe254e48 as ::core::ffi::c_uint, + 0x4c059258 as ::core::ffi::c_int as uint32_t, + 0x7165bbe8 as ::core::ffi::c_int as uint32_t, + 0x36c5c138 as ::core::ffi::c_int as uint32_t, + 0xba5e888 as ::core::ffi::c_int as uint32_t, + 0x28d4c7df as ::core::ffi::c_int as uint32_t, + 0x15b4ee6f as ::core::ffi::c_int as uint32_t, + 0x521494bf as ::core::ffi::c_int as uint32_t, + 0x6f74bd0f as ::core::ffi::c_int as uint32_t, + 0xdd54611f as ::core::ffi::c_uint, + 0xe03448af as ::core::ffi::c_uint, + 0xa794327f as ::core::ffi::c_uint, + 0x9af41bcf as ::core::ffi::c_uint, + 0x18a48c1e as ::core::ffi::c_int as uint32_t, + 0x25c4a5ae as ::core::ffi::c_int as uint32_t, + 0x6264df7e as ::core::ffi::c_int as uint32_t, + 0x5f04f6ce as ::core::ffi::c_int as uint32_t, + 0xed242ade as ::core::ffi::c_uint, + 0xd044036e as ::core::ffi::c_uint, + 0x97e479be as ::core::ffi::c_uint, + 0xaa84500e as ::core::ffi::c_uint, + 0x4834505d as ::core::ffi::c_int as uint32_t, + 0x755479ed as ::core::ffi::c_int as uint32_t, + 0x32f4033d as ::core::ffi::c_int as uint32_t, + 0xf942a8d as ::core::ffi::c_int as uint32_t, + 0xbdb4f69d as ::core::ffi::c_uint, + 0x80d4df2d as ::core::ffi::c_uint, + 0xc774a5fd as ::core::ffi::c_uint, + 0xfa148c4d as ::core::ffi::c_uint, + 0x78441b9c as ::core::ffi::c_int as uint32_t, + 0x4524322c as ::core::ffi::c_int as uint32_t, + 0x28448fc as ::core::ffi::c_int as uint32_t, + 0x3fe4614c as ::core::ffi::c_int as uint32_t, + 0x8dc4bd5c as ::core::ffi::c_uint, + 0xb0a494ec as ::core::ffi::c_uint, + 0xf704ee3c as ::core::ffi::c_uint, + 0xca64c78c as ::core::ffi::c_uint, + ], + [ + 0 as ::core::ffi::c_int as uint32_t, + 0xcb5cd3a5 as ::core::ffi::c_uint, + 0x4dc8a10b as ::core::ffi::c_int as uint32_t, + 0x869472ae as ::core::ffi::c_uint, + 0x9b914216 as ::core::ffi::c_uint, + 0x50cd91b3 as ::core::ffi::c_int as uint32_t, + 0xd659e31d as ::core::ffi::c_uint, + 0x1d0530b8 as ::core::ffi::c_int as uint32_t, + 0xec53826d as ::core::ffi::c_uint, + 0x270f51c8 as ::core::ffi::c_int as uint32_t, + 0xa19b2366 as ::core::ffi::c_uint, + 0x6ac7f0c3 as ::core::ffi::c_int as uint32_t, + 0x77c2c07b as ::core::ffi::c_int as uint32_t, + 0xbc9e13de as ::core::ffi::c_uint, + 0x3a0a6170 as ::core::ffi::c_int as uint32_t, + 0xf156b2d5 as ::core::ffi::c_uint, + 0x3d6029b as ::core::ffi::c_int as uint32_t, + 0xc88ad13e as ::core::ffi::c_uint, + 0x4e1ea390 as ::core::ffi::c_int as uint32_t, + 0x85427035 as ::core::ffi::c_uint, + 0x9847408d as ::core::ffi::c_uint, + 0x531b9328 as ::core::ffi::c_int as uint32_t, + 0xd58fe186 as ::core::ffi::c_uint, + 0x1ed33223 as ::core::ffi::c_int as uint32_t, + 0xef8580f6 as ::core::ffi::c_uint, + 0x24d95353 as ::core::ffi::c_int as uint32_t, + 0xa24d21fd as ::core::ffi::c_uint, + 0x6911f258 as ::core::ffi::c_int as uint32_t, + 0x7414c2e0 as ::core::ffi::c_int as uint32_t, + 0xbf481145 as ::core::ffi::c_uint, + 0x39dc63eb as ::core::ffi::c_int as uint32_t, + 0xf280b04e as ::core::ffi::c_uint, + 0x7ac0536 as ::core::ffi::c_int as uint32_t, + 0xccf0d693 as ::core::ffi::c_uint, + 0x4a64a43d as ::core::ffi::c_int as uint32_t, + 0x81387798 as ::core::ffi::c_uint, + 0x9c3d4720 as ::core::ffi::c_uint, + 0x57619485 as ::core::ffi::c_int as uint32_t, + 0xd1f5e62b as ::core::ffi::c_uint, + 0x1aa9358e as ::core::ffi::c_int as uint32_t, + 0xebff875b as ::core::ffi::c_uint, + 0x20a354fe as ::core::ffi::c_int as uint32_t, + 0xa6372650 as ::core::ffi::c_uint, + 0x6d6bf5f5 as ::core::ffi::c_int as uint32_t, + 0x706ec54d as ::core::ffi::c_int as uint32_t, + 0xbb3216e8 as ::core::ffi::c_uint, + 0x3da66446 as ::core::ffi::c_int as uint32_t, + 0xf6fab7e3 as ::core::ffi::c_uint, + 0x47a07ad as ::core::ffi::c_int as uint32_t, + 0xcf26d408 as ::core::ffi::c_uint, + 0x49b2a6a6 as ::core::ffi::c_int as uint32_t, + 0x82ee7503 as ::core::ffi::c_uint, + 0x9feb45bb as ::core::ffi::c_uint, + 0x54b7961e as ::core::ffi::c_int as uint32_t, + 0xd223e4b0 as ::core::ffi::c_uint, + 0x197f3715 as ::core::ffi::c_int as uint32_t, + 0xe82985c0 as ::core::ffi::c_uint, + 0x23755665 as ::core::ffi::c_int as uint32_t, + 0xa5e124cb as ::core::ffi::c_uint, + 0x6ebdf76e as ::core::ffi::c_int as uint32_t, + 0x73b8c7d6 as ::core::ffi::c_int as uint32_t, + 0xb8e41473 as ::core::ffi::c_uint, + 0x3e7066dd as ::core::ffi::c_int as uint32_t, + 0xf52cb578 as ::core::ffi::c_uint, + 0xf580a6c as ::core::ffi::c_int as uint32_t, + 0xc404d9c9 as ::core::ffi::c_uint, + 0x4290ab67 as ::core::ffi::c_int as uint32_t, + 0x89cc78c2 as ::core::ffi::c_uint, + 0x94c9487a as ::core::ffi::c_uint, + 0x5f959bdf as ::core::ffi::c_int as uint32_t, + 0xd901e971 as ::core::ffi::c_uint, + 0x125d3ad4 as ::core::ffi::c_int as uint32_t, + 0xe30b8801 as ::core::ffi::c_uint, + 0x28575ba4 as ::core::ffi::c_int as uint32_t, + 0xaec3290a as ::core::ffi::c_uint, + 0x659ffaaf as ::core::ffi::c_int as uint32_t, + 0x789aca17 as ::core::ffi::c_int as uint32_t, + 0xb3c619b2 as ::core::ffi::c_uint, + 0x35526b1c as ::core::ffi::c_int as uint32_t, + 0xfe0eb8b9 as ::core::ffi::c_uint, + 0xc8e08f7 as ::core::ffi::c_int as uint32_t, + 0xc7d2db52 as ::core::ffi::c_uint, + 0x4146a9fc as ::core::ffi::c_int as uint32_t, + 0x8a1a7a59 as ::core::ffi::c_uint, + 0x971f4ae1 as ::core::ffi::c_uint, + 0x5c439944 as ::core::ffi::c_int as uint32_t, + 0xdad7ebea as ::core::ffi::c_uint, + 0x118b384f as ::core::ffi::c_int as uint32_t, + 0xe0dd8a9a as ::core::ffi::c_uint, + 0x2b81593f as ::core::ffi::c_int as uint32_t, + 0xad152b91 as ::core::ffi::c_uint, + 0x6649f834 as ::core::ffi::c_int as uint32_t, + 0x7b4cc88c as ::core::ffi::c_int as uint32_t, + 0xb0101b29 as ::core::ffi::c_uint, + 0x36846987 as ::core::ffi::c_int as uint32_t, + 0xfdd8ba22 as ::core::ffi::c_uint, + 0x8f40f5a as ::core::ffi::c_int as uint32_t, + 0xc3a8dcff as ::core::ffi::c_uint, + 0x453cae51 as ::core::ffi::c_int as uint32_t, + 0x8e607df4 as ::core::ffi::c_uint, + 0x93654d4c as ::core::ffi::c_uint, + 0x58399ee9 as ::core::ffi::c_int as uint32_t, + 0xdeadec47 as ::core::ffi::c_uint, + 0x15f13fe2 as ::core::ffi::c_int as uint32_t, + 0xe4a78d37 as ::core::ffi::c_uint, + 0x2ffb5e92 as ::core::ffi::c_int as uint32_t, + 0xa96f2c3c as ::core::ffi::c_uint, + 0x6233ff99 as ::core::ffi::c_int as uint32_t, + 0x7f36cf21 as ::core::ffi::c_int as uint32_t, + 0xb46a1c84 as ::core::ffi::c_uint, + 0x32fe6e2a as ::core::ffi::c_int as uint32_t, + 0xf9a2bd8f as ::core::ffi::c_uint, + 0xb220dc1 as ::core::ffi::c_int as uint32_t, + 0xc07ede64 as ::core::ffi::c_uint, + 0x46eaacca as ::core::ffi::c_int as uint32_t, + 0x8db67f6f as ::core::ffi::c_uint, + 0x90b34fd7 as ::core::ffi::c_uint, + 0x5bef9c72 as ::core::ffi::c_int as uint32_t, + 0xdd7beedc as ::core::ffi::c_uint, + 0x16273d79 as ::core::ffi::c_int as uint32_t, + 0xe7718fac as ::core::ffi::c_uint, + 0x2c2d5c09 as ::core::ffi::c_int as uint32_t, + 0xaab92ea7 as ::core::ffi::c_uint, + 0x61e5fd02 as ::core::ffi::c_int as uint32_t, + 0x7ce0cdba as ::core::ffi::c_int as uint32_t, + 0xb7bc1e1f as ::core::ffi::c_uint, + 0x31286cb1 as ::core::ffi::c_int as uint32_t, + 0xfa74bf14 as ::core::ffi::c_uint, + 0x1eb014d8 as ::core::ffi::c_int as uint32_t, + 0xd5ecc77d as ::core::ffi::c_uint, + 0x5378b5d3 as ::core::ffi::c_int as uint32_t, + 0x98246676 as ::core::ffi::c_uint, + 0x852156ce as ::core::ffi::c_uint, + 0x4e7d856b as ::core::ffi::c_int as uint32_t, + 0xc8e9f7c5 as ::core::ffi::c_uint, + 0x3b52460 as ::core::ffi::c_int as uint32_t, + 0xf2e396b5 as ::core::ffi::c_uint, + 0x39bf4510 as ::core::ffi::c_int as uint32_t, + 0xbf2b37be as ::core::ffi::c_uint, + 0x7477e41b as ::core::ffi::c_int as uint32_t, + 0x6972d4a3 as ::core::ffi::c_int as uint32_t, + 0xa22e0706 as ::core::ffi::c_uint, + 0x24ba75a8 as ::core::ffi::c_int as uint32_t, + 0xefe6a60d as ::core::ffi::c_uint, + 0x1d661643 as ::core::ffi::c_int as uint32_t, + 0xd63ac5e6 as ::core::ffi::c_uint, + 0x50aeb748 as ::core::ffi::c_int as uint32_t, + 0x9bf264ed as ::core::ffi::c_uint, + 0x86f75455 as ::core::ffi::c_uint, + 0x4dab87f0 as ::core::ffi::c_int as uint32_t, + 0xcb3ff55e as ::core::ffi::c_uint, + 0x6326fb as ::core::ffi::c_int as uint32_t, + 0xf135942e as ::core::ffi::c_uint, + 0x3a69478b as ::core::ffi::c_int as uint32_t, + 0xbcfd3525 as ::core::ffi::c_uint, + 0x77a1e680 as ::core::ffi::c_int as uint32_t, + 0x6aa4d638 as ::core::ffi::c_int as uint32_t, + 0xa1f8059d as ::core::ffi::c_uint, + 0x276c7733 as ::core::ffi::c_int as uint32_t, + 0xec30a496 as ::core::ffi::c_uint, + 0x191c11ee as ::core::ffi::c_int as uint32_t, + 0xd240c24b as ::core::ffi::c_uint, + 0x54d4b0e5 as ::core::ffi::c_int as uint32_t, + 0x9f886340 as ::core::ffi::c_uint, + 0x828d53f8 as ::core::ffi::c_uint, + 0x49d1805d as ::core::ffi::c_int as uint32_t, + 0xcf45f2f3 as ::core::ffi::c_uint, + 0x4192156 as ::core::ffi::c_int as uint32_t, + 0xf54f9383 as ::core::ffi::c_uint, + 0x3e134026 as ::core::ffi::c_int as uint32_t, + 0xb8873288 as ::core::ffi::c_uint, + 0x73dbe12d as ::core::ffi::c_int as uint32_t, + 0x6eded195 as ::core::ffi::c_int as uint32_t, + 0xa5820230 as ::core::ffi::c_uint, + 0x2316709e as ::core::ffi::c_int as uint32_t, + 0xe84aa33b as ::core::ffi::c_uint, + 0x1aca1375 as ::core::ffi::c_int as uint32_t, + 0xd196c0d0 as ::core::ffi::c_uint, + 0x5702b27e as ::core::ffi::c_int as uint32_t, + 0x9c5e61db as ::core::ffi::c_uint, + 0x815b5163 as ::core::ffi::c_uint, + 0x4a0782c6 as ::core::ffi::c_int as uint32_t, + 0xcc93f068 as ::core::ffi::c_uint, + 0x7cf23cd as ::core::ffi::c_int as uint32_t, + 0xf6999118 as ::core::ffi::c_uint, + 0x3dc542bd as ::core::ffi::c_int as uint32_t, + 0xbb513013 as ::core::ffi::c_uint, + 0x700de3b6 as ::core::ffi::c_int as uint32_t, + 0x6d08d30e as ::core::ffi::c_int as uint32_t, + 0xa65400ab as ::core::ffi::c_uint, + 0x20c07205 as ::core::ffi::c_int as uint32_t, + 0xeb9ca1a0 as ::core::ffi::c_uint, + 0x11e81eb4 as ::core::ffi::c_int as uint32_t, + 0xdab4cd11 as ::core::ffi::c_uint, + 0x5c20bfbf as ::core::ffi::c_int as uint32_t, + 0x977c6c1a as ::core::ffi::c_uint, + 0x8a795ca2 as ::core::ffi::c_uint, + 0x41258f07 as ::core::ffi::c_int as uint32_t, + 0xc7b1fda9 as ::core::ffi::c_uint, + 0xced2e0c as ::core::ffi::c_int as uint32_t, + 0xfdbb9cd9 as ::core::ffi::c_uint, + 0x36e74f7c as ::core::ffi::c_int as uint32_t, + 0xb0733dd2 as ::core::ffi::c_uint, + 0x7b2fee77 as ::core::ffi::c_int as uint32_t, + 0x662adecf as ::core::ffi::c_int as uint32_t, + 0xad760d6a as ::core::ffi::c_uint, + 0x2be27fc4 as ::core::ffi::c_int as uint32_t, + 0xe0beac61 as ::core::ffi::c_uint, + 0x123e1c2f as ::core::ffi::c_int as uint32_t, + 0xd962cf8a as ::core::ffi::c_uint, + 0x5ff6bd24 as ::core::ffi::c_int as uint32_t, + 0x94aa6e81 as ::core::ffi::c_uint, + 0x89af5e39 as ::core::ffi::c_uint, + 0x42f38d9c as ::core::ffi::c_int as uint32_t, + 0xc467ff32 as ::core::ffi::c_uint, + 0xf3b2c97 as ::core::ffi::c_int as uint32_t, + 0xfe6d9e42 as ::core::ffi::c_uint, + 0x35314de7 as ::core::ffi::c_int as uint32_t, + 0xb3a53f49 as ::core::ffi::c_uint, + 0x78f9ecec as ::core::ffi::c_int as uint32_t, + 0x65fcdc54 as ::core::ffi::c_int as uint32_t, + 0xaea00ff1 as ::core::ffi::c_uint, + 0x28347d5f as ::core::ffi::c_int as uint32_t, + 0xe368aefa as ::core::ffi::c_uint, + 0x16441b82 as ::core::ffi::c_int as uint32_t, + 0xdd18c827 as ::core::ffi::c_uint, + 0x5b8cba89 as ::core::ffi::c_int as uint32_t, + 0x90d0692c as ::core::ffi::c_uint, + 0x8dd55994 as ::core::ffi::c_uint, + 0x46898a31 as ::core::ffi::c_int as uint32_t, + 0xc01df89f as ::core::ffi::c_uint, + 0xb412b3a as ::core::ffi::c_int as uint32_t, + 0xfa1799ef as ::core::ffi::c_uint, + 0x314b4a4a as ::core::ffi::c_int as uint32_t, + 0xb7df38e4 as ::core::ffi::c_uint, + 0x7c83eb41 as ::core::ffi::c_int as uint32_t, + 0x6186dbf9 as ::core::ffi::c_int as uint32_t, + 0xaada085c as ::core::ffi::c_uint, + 0x2c4e7af2 as ::core::ffi::c_int as uint32_t, + 0xe712a957 as ::core::ffi::c_uint, + 0x15921919 as ::core::ffi::c_int as uint32_t, + 0xdececabc as ::core::ffi::c_uint, + 0x585ab812 as ::core::ffi::c_int as uint32_t, + 0x93066bb7 as ::core::ffi::c_uint, + 0x8e035b0f as ::core::ffi::c_uint, + 0x455f88aa as ::core::ffi::c_int as uint32_t, + 0xc3cbfa04 as ::core::ffi::c_uint, + 0x89729a1 as ::core::ffi::c_int as uint32_t, + 0xf9c19b74 as ::core::ffi::c_uint, + 0x329d48d1 as ::core::ffi::c_int as uint32_t, + 0xb4093a7f as ::core::ffi::c_uint, + 0x7f55e9da as ::core::ffi::c_int as uint32_t, + 0x6250d962 as ::core::ffi::c_int as uint32_t, + 0xa90c0ac7 as ::core::ffi::c_uint, + 0x2f987869 as ::core::ffi::c_int as uint32_t, + 0xe4c4abcc as ::core::ffi::c_uint, + ], + [ + 0 as ::core::ffi::c_int as uint32_t, + 0xa6770bb4 as ::core::ffi::c_uint, + 0x979f1129 as ::core::ffi::c_uint, + 0x31e81a9d as ::core::ffi::c_int as uint32_t, + 0xf44f2413 as ::core::ffi::c_uint, + 0x52382fa7 as ::core::ffi::c_int as uint32_t, + 0x63d0353a as ::core::ffi::c_int as uint32_t, + 0xc5a73e8e as ::core::ffi::c_uint, + 0x33ef4e67 as ::core::ffi::c_int as uint32_t, + 0x959845d3 as ::core::ffi::c_uint, + 0xa4705f4e as ::core::ffi::c_uint, + 0x20754fa as ::core::ffi::c_int as uint32_t, + 0xc7a06a74 as ::core::ffi::c_uint, + 0x61d761c0 as ::core::ffi::c_int as uint32_t, + 0x503f7b5d as ::core::ffi::c_int as uint32_t, + 0xf64870e9 as ::core::ffi::c_uint, + 0x67de9cce as ::core::ffi::c_int as uint32_t, + 0xc1a9977a as ::core::ffi::c_uint, + 0xf0418de7 as ::core::ffi::c_uint, + 0x56368653 as ::core::ffi::c_int as uint32_t, + 0x9391b8dd as ::core::ffi::c_uint, + 0x35e6b369 as ::core::ffi::c_int as uint32_t, + 0x40ea9f4 as ::core::ffi::c_int as uint32_t, + 0xa279a240 as ::core::ffi::c_uint, + 0x5431d2a9 as ::core::ffi::c_int as uint32_t, + 0xf246d91d as ::core::ffi::c_uint, + 0xc3aec380 as ::core::ffi::c_uint, + 0x65d9c834 as ::core::ffi::c_int as uint32_t, + 0xa07ef6ba as ::core::ffi::c_uint, + 0x609fd0e as ::core::ffi::c_int as uint32_t, + 0x37e1e793 as ::core::ffi::c_int as uint32_t, + 0x9196ec27 as ::core::ffi::c_uint, + 0xcfbd399c as ::core::ffi::c_uint, + 0x69ca3228 as ::core::ffi::c_int as uint32_t, + 0x582228b5 as ::core::ffi::c_int as uint32_t, + 0xfe552301 as ::core::ffi::c_uint, + 0x3bf21d8f as ::core::ffi::c_int as uint32_t, + 0x9d85163b as ::core::ffi::c_uint, + 0xac6d0ca6 as ::core::ffi::c_uint, + 0xa1a0712 as ::core::ffi::c_int as uint32_t, + 0xfc5277fb as ::core::ffi::c_uint, + 0x5a257c4f as ::core::ffi::c_int as uint32_t, + 0x6bcd66d2 as ::core::ffi::c_int as uint32_t, + 0xcdba6d66 as ::core::ffi::c_uint, + 0x81d53e8 as ::core::ffi::c_int as uint32_t, + 0xae6a585c as ::core::ffi::c_uint, + 0x9f8242c1 as ::core::ffi::c_uint, + 0x39f54975 as ::core::ffi::c_int as uint32_t, + 0xa863a552 as ::core::ffi::c_uint, + 0xe14aee6 as ::core::ffi::c_int as uint32_t, + 0x3ffcb47b as ::core::ffi::c_int as uint32_t, + 0x998bbfcf as ::core::ffi::c_uint, + 0x5c2c8141 as ::core::ffi::c_int as uint32_t, + 0xfa5b8af5 as ::core::ffi::c_uint, + 0xcbb39068 as ::core::ffi::c_uint, + 0x6dc49bdc as ::core::ffi::c_int as uint32_t, + 0x9b8ceb35 as ::core::ffi::c_uint, + 0x3dfbe081 as ::core::ffi::c_int as uint32_t, + 0xc13fa1c as ::core::ffi::c_int as uint32_t, + 0xaa64f1a8 as ::core::ffi::c_uint, + 0x6fc3cf26 as ::core::ffi::c_int as uint32_t, + 0xc9b4c492 as ::core::ffi::c_uint, + 0xf85cde0f as ::core::ffi::c_uint, + 0x5e2bd5bb as ::core::ffi::c_int as uint32_t, + 0x440b7579 as ::core::ffi::c_int as uint32_t, + 0xe27c7ecd as ::core::ffi::c_uint, + 0xd3946450 as ::core::ffi::c_uint, + 0x75e36fe4 as ::core::ffi::c_int as uint32_t, + 0xb044516a as ::core::ffi::c_uint, + 0x16335ade as ::core::ffi::c_int as uint32_t, + 0x27db4043 as ::core::ffi::c_int as uint32_t, + 0x81ac4bf7 as ::core::ffi::c_uint, + 0x77e43b1e as ::core::ffi::c_int as uint32_t, + 0xd19330aa as ::core::ffi::c_uint, + 0xe07b2a37 as ::core::ffi::c_uint, + 0x460c2183 as ::core::ffi::c_int as uint32_t, + 0x83ab1f0d as ::core::ffi::c_uint, + 0x25dc14b9 as ::core::ffi::c_int as uint32_t, + 0x14340e24 as ::core::ffi::c_int as uint32_t, + 0xb2430590 as ::core::ffi::c_uint, + 0x23d5e9b7 as ::core::ffi::c_int as uint32_t, + 0x85a2e203 as ::core::ffi::c_uint, + 0xb44af89e as ::core::ffi::c_uint, + 0x123df32a as ::core::ffi::c_int as uint32_t, + 0xd79acda4 as ::core::ffi::c_uint, + 0x71edc610 as ::core::ffi::c_int as uint32_t, + 0x4005dc8d as ::core::ffi::c_int as uint32_t, + 0xe672d739 as ::core::ffi::c_uint, + 0x103aa7d0 as ::core::ffi::c_int as uint32_t, + 0xb64dac64 as ::core::ffi::c_uint, + 0x87a5b6f9 as ::core::ffi::c_uint, + 0x21d2bd4d as ::core::ffi::c_int as uint32_t, + 0xe47583c3 as ::core::ffi::c_uint, + 0x42028877 as ::core::ffi::c_int as uint32_t, + 0x73ea92ea as ::core::ffi::c_int as uint32_t, + 0xd59d995e as ::core::ffi::c_uint, + 0x8bb64ce5 as ::core::ffi::c_uint, + 0x2dc14751 as ::core::ffi::c_int as uint32_t, + 0x1c295dcc as ::core::ffi::c_int as uint32_t, + 0xba5e5678 as ::core::ffi::c_uint, + 0x7ff968f6 as ::core::ffi::c_int as uint32_t, + 0xd98e6342 as ::core::ffi::c_uint, + 0xe86679df as ::core::ffi::c_uint, + 0x4e11726b as ::core::ffi::c_int as uint32_t, + 0xb8590282 as ::core::ffi::c_uint, + 0x1e2e0936 as ::core::ffi::c_int as uint32_t, + 0x2fc613ab as ::core::ffi::c_int as uint32_t, + 0x89b1181f as ::core::ffi::c_uint, + 0x4c162691 as ::core::ffi::c_int as uint32_t, + 0xea612d25 as ::core::ffi::c_uint, + 0xdb8937b8 as ::core::ffi::c_uint, + 0x7dfe3c0c as ::core::ffi::c_int as uint32_t, + 0xec68d02b as ::core::ffi::c_uint, + 0x4a1fdb9f as ::core::ffi::c_int as uint32_t, + 0x7bf7c102 as ::core::ffi::c_int as uint32_t, + 0xdd80cab6 as ::core::ffi::c_uint, + 0x1827f438 as ::core::ffi::c_int as uint32_t, + 0xbe50ff8c as ::core::ffi::c_uint, + 0x8fb8e511 as ::core::ffi::c_uint, + 0x29cfeea5 as ::core::ffi::c_int as uint32_t, + 0xdf879e4c as ::core::ffi::c_uint, + 0x79f095f8 as ::core::ffi::c_int as uint32_t, + 0x48188f65 as ::core::ffi::c_int as uint32_t, + 0xee6f84d1 as ::core::ffi::c_uint, + 0x2bc8ba5f as ::core::ffi::c_int as uint32_t, + 0x8dbfb1eb as ::core::ffi::c_uint, + 0xbc57ab76 as ::core::ffi::c_uint, + 0x1a20a0c2 as ::core::ffi::c_int as uint32_t, + 0x8816eaf2 as ::core::ffi::c_uint, + 0x2e61e146 as ::core::ffi::c_int as uint32_t, + 0x1f89fbdb as ::core::ffi::c_int as uint32_t, + 0xb9fef06f as ::core::ffi::c_uint, + 0x7c59cee1 as ::core::ffi::c_int as uint32_t, + 0xda2ec555 as ::core::ffi::c_uint, + 0xebc6dfc8 as ::core::ffi::c_uint, + 0x4db1d47c as ::core::ffi::c_int as uint32_t, + 0xbbf9a495 as ::core::ffi::c_uint, + 0x1d8eaf21 as ::core::ffi::c_int as uint32_t, + 0x2c66b5bc as ::core::ffi::c_int as uint32_t, + 0x8a11be08 as ::core::ffi::c_uint, + 0x4fb68086 as ::core::ffi::c_int as uint32_t, + 0xe9c18b32 as ::core::ffi::c_uint, + 0xd82991af as ::core::ffi::c_uint, + 0x7e5e9a1b as ::core::ffi::c_int as uint32_t, + 0xefc8763c as ::core::ffi::c_uint, + 0x49bf7d88 as ::core::ffi::c_int as uint32_t, + 0x78576715 as ::core::ffi::c_int as uint32_t, + 0xde206ca1 as ::core::ffi::c_uint, + 0x1b87522f as ::core::ffi::c_int as uint32_t, + 0xbdf0599b as ::core::ffi::c_uint, + 0x8c184306 as ::core::ffi::c_uint, + 0x2a6f48b2 as ::core::ffi::c_int as uint32_t, + 0xdc27385b as ::core::ffi::c_uint, + 0x7a5033ef as ::core::ffi::c_int as uint32_t, + 0x4bb82972 as ::core::ffi::c_int as uint32_t, + 0xedcf22c6 as ::core::ffi::c_uint, + 0x28681c48 as ::core::ffi::c_int as uint32_t, + 0x8e1f17fc as ::core::ffi::c_uint, + 0xbff70d61 as ::core::ffi::c_uint, + 0x198006d5 as ::core::ffi::c_int as uint32_t, + 0x47abd36e as ::core::ffi::c_int as uint32_t, + 0xe1dcd8da as ::core::ffi::c_uint, + 0xd034c247 as ::core::ffi::c_uint, + 0x7643c9f3 as ::core::ffi::c_int as uint32_t, + 0xb3e4f77d as ::core::ffi::c_uint, + 0x1593fcc9 as ::core::ffi::c_int as uint32_t, + 0x247be654 as ::core::ffi::c_int as uint32_t, + 0x820cede0 as ::core::ffi::c_uint, + 0x74449d09 as ::core::ffi::c_int as uint32_t, + 0xd23396bd as ::core::ffi::c_uint, + 0xe3db8c20 as ::core::ffi::c_uint, + 0x45ac8794 as ::core::ffi::c_int as uint32_t, + 0x800bb91a as ::core::ffi::c_uint, + 0x267cb2ae as ::core::ffi::c_int as uint32_t, + 0x1794a833 as ::core::ffi::c_int as uint32_t, + 0xb1e3a387 as ::core::ffi::c_uint, + 0x20754fa0 as ::core::ffi::c_int as uint32_t, + 0x86024414 as ::core::ffi::c_uint, + 0xb7ea5e89 as ::core::ffi::c_uint, + 0x119d553d as ::core::ffi::c_int as uint32_t, + 0xd43a6bb3 as ::core::ffi::c_uint, + 0x724d6007 as ::core::ffi::c_int as uint32_t, + 0x43a57a9a as ::core::ffi::c_int as uint32_t, + 0xe5d2712e as ::core::ffi::c_uint, + 0x139a01c7 as ::core::ffi::c_int as uint32_t, + 0xb5ed0a73 as ::core::ffi::c_uint, + 0x840510ee as ::core::ffi::c_uint, + 0x22721b5a as ::core::ffi::c_int as uint32_t, + 0xe7d525d4 as ::core::ffi::c_uint, + 0x41a22e60 as ::core::ffi::c_int as uint32_t, + 0x704a34fd as ::core::ffi::c_int as uint32_t, + 0xd63d3f49 as ::core::ffi::c_uint, + 0xcc1d9f8b as ::core::ffi::c_uint, + 0x6a6a943f as ::core::ffi::c_int as uint32_t, + 0x5b828ea2 as ::core::ffi::c_int as uint32_t, + 0xfdf58516 as ::core::ffi::c_uint, + 0x3852bb98 as ::core::ffi::c_int as uint32_t, + 0x9e25b02c as ::core::ffi::c_uint, + 0xafcdaab1 as ::core::ffi::c_uint, + 0x9baa105 as ::core::ffi::c_int as uint32_t, + 0xfff2d1ec as ::core::ffi::c_uint, + 0x5985da58 as ::core::ffi::c_int as uint32_t, + 0x686dc0c5 as ::core::ffi::c_int as uint32_t, + 0xce1acb71 as ::core::ffi::c_uint, + 0xbbdf5ff as ::core::ffi::c_int as uint32_t, + 0xadcafe4b as ::core::ffi::c_uint, + 0x9c22e4d6 as ::core::ffi::c_uint, + 0x3a55ef62 as ::core::ffi::c_int as uint32_t, + 0xabc30345 as ::core::ffi::c_uint, + 0xdb408f1 as ::core::ffi::c_int as uint32_t, + 0x3c5c126c as ::core::ffi::c_int as uint32_t, + 0x9a2b19d8 as ::core::ffi::c_uint, + 0x5f8c2756 as ::core::ffi::c_int as uint32_t, + 0xf9fb2ce2 as ::core::ffi::c_uint, + 0xc813367f as ::core::ffi::c_uint, + 0x6e643dcb as ::core::ffi::c_int as uint32_t, + 0x982c4d22 as ::core::ffi::c_uint, + 0x3e5b4696 as ::core::ffi::c_int as uint32_t, + 0xfb35c0b as ::core::ffi::c_int as uint32_t, + 0xa9c457bf as ::core::ffi::c_uint, + 0x6c636931 as ::core::ffi::c_int as uint32_t, + 0xca146285 as ::core::ffi::c_uint, + 0xfbfc7818 as ::core::ffi::c_uint, + 0x5d8b73ac as ::core::ffi::c_int as uint32_t, + 0x3a0a617 as ::core::ffi::c_int as uint32_t, + 0xa5d7ada3 as ::core::ffi::c_uint, + 0x943fb73e as ::core::ffi::c_uint, + 0x3248bc8a as ::core::ffi::c_int as uint32_t, + 0xf7ef8204 as ::core::ffi::c_uint, + 0x519889b0 as ::core::ffi::c_int as uint32_t, + 0x6070932d as ::core::ffi::c_int as uint32_t, + 0xc6079899 as ::core::ffi::c_uint, + 0x304fe870 as ::core::ffi::c_int as uint32_t, + 0x9638e3c4 as ::core::ffi::c_uint, + 0xa7d0f959 as ::core::ffi::c_uint, + 0x1a7f2ed as ::core::ffi::c_int as uint32_t, + 0xc400cc63 as ::core::ffi::c_uint, + 0x6277c7d7 as ::core::ffi::c_int as uint32_t, + 0x539fdd4a as ::core::ffi::c_int as uint32_t, + 0xf5e8d6fe as ::core::ffi::c_uint, + 0x647e3ad9 as ::core::ffi::c_int as uint32_t, + 0xc209316d as ::core::ffi::c_uint, + 0xf3e12bf0 as ::core::ffi::c_uint, + 0x55962044 as ::core::ffi::c_int as uint32_t, + 0x90311eca as ::core::ffi::c_uint, + 0x3646157e as ::core::ffi::c_int as uint32_t, + 0x7ae0fe3 as ::core::ffi::c_int as uint32_t, + 0xa1d90457 as ::core::ffi::c_uint, + 0x579174be as ::core::ffi::c_int as uint32_t, + 0xf1e67f0a as ::core::ffi::c_uint, + 0xc00e6597 as ::core::ffi::c_uint, + 0x66796e23 as ::core::ffi::c_int as uint32_t, + 0xa3de50ad as ::core::ffi::c_uint, + 0x5a95b19 as ::core::ffi::c_int as uint32_t, + 0x34414184 as ::core::ffi::c_int as uint32_t, + 0x92364a30 as ::core::ffi::c_uint, + ], + [ + 0 as ::core::ffi::c_int as uint32_t, + 0xccaa009e as ::core::ffi::c_uint, + 0x4225077d as ::core::ffi::c_int as uint32_t, + 0x8e8f07e3 as ::core::ffi::c_uint, + 0x844a0efa as ::core::ffi::c_uint, + 0x48e00e64 as ::core::ffi::c_int as uint32_t, + 0xc66f0987 as ::core::ffi::c_uint, + 0xac50919 as ::core::ffi::c_int as uint32_t, + 0xd3e51bb5 as ::core::ffi::c_uint, + 0x1f4f1b2b as ::core::ffi::c_int as uint32_t, + 0x91c01cc8 as ::core::ffi::c_uint, + 0x5d6a1c56 as ::core::ffi::c_int as uint32_t, + 0x57af154f as ::core::ffi::c_int as uint32_t, + 0x9b0515d1 as ::core::ffi::c_uint, + 0x158a1232 as ::core::ffi::c_int as uint32_t, + 0xd92012ac as ::core::ffi::c_uint, + 0x7cbb312b as ::core::ffi::c_int as uint32_t, + 0xb01131b5 as ::core::ffi::c_uint, + 0x3e9e3656 as ::core::ffi::c_int as uint32_t, + 0xf23436c8 as ::core::ffi::c_uint, + 0xf8f13fd1 as ::core::ffi::c_uint, + 0x345b3f4f as ::core::ffi::c_int as uint32_t, + 0xbad438ac as ::core::ffi::c_uint, + 0x767e3832 as ::core::ffi::c_int as uint32_t, + 0xaf5e2a9e as ::core::ffi::c_uint, + 0x63f42a00 as ::core::ffi::c_int as uint32_t, + 0xed7b2de3 as ::core::ffi::c_uint, + 0x21d12d7d as ::core::ffi::c_int as uint32_t, + 0x2b142464 as ::core::ffi::c_int as uint32_t, + 0xe7be24fa as ::core::ffi::c_uint, + 0x69312319 as ::core::ffi::c_int as uint32_t, + 0xa59b2387 as ::core::ffi::c_uint, + 0xf9766256 as ::core::ffi::c_uint, + 0x35dc62c8 as ::core::ffi::c_int as uint32_t, + 0xbb53652b as ::core::ffi::c_uint, + 0x77f965b5 as ::core::ffi::c_int as uint32_t, + 0x7d3c6cac as ::core::ffi::c_int as uint32_t, + 0xb1966c32 as ::core::ffi::c_uint, + 0x3f196bd1 as ::core::ffi::c_int as uint32_t, + 0xf3b36b4f as ::core::ffi::c_uint, + 0x2a9379e3 as ::core::ffi::c_int as uint32_t, + 0xe639797d as ::core::ffi::c_uint, + 0x68b67e9e as ::core::ffi::c_int as uint32_t, + 0xa41c7e00 as ::core::ffi::c_uint, + 0xaed97719 as ::core::ffi::c_uint, + 0x62737787 as ::core::ffi::c_int as uint32_t, + 0xecfc7064 as ::core::ffi::c_uint, + 0x205670fa as ::core::ffi::c_int as uint32_t, + 0x85cd537d as ::core::ffi::c_uint, + 0x496753e3 as ::core::ffi::c_int as uint32_t, + 0xc7e85400 as ::core::ffi::c_uint, + 0xb42549e as ::core::ffi::c_int as uint32_t, + 0x1875d87 as ::core::ffi::c_int as uint32_t, + 0xcd2d5d19 as ::core::ffi::c_uint, + 0x43a25afa as ::core::ffi::c_int as uint32_t, + 0x8f085a64 as ::core::ffi::c_uint, + 0x562848c8 as ::core::ffi::c_int as uint32_t, + 0x9a824856 as ::core::ffi::c_uint, + 0x140d4fb5 as ::core::ffi::c_int as uint32_t, + 0xd8a74f2b as ::core::ffi::c_uint, + 0xd2624632 as ::core::ffi::c_uint, + 0x1ec846ac as ::core::ffi::c_int as uint32_t, + 0x9047414f as ::core::ffi::c_uint, + 0x5ced41d1 as ::core::ffi::c_int as uint32_t, + 0x299dc2ed as ::core::ffi::c_int as uint32_t, + 0xe537c273 as ::core::ffi::c_uint, + 0x6bb8c590 as ::core::ffi::c_int as uint32_t, + 0xa712c50e as ::core::ffi::c_uint, + 0xadd7cc17 as ::core::ffi::c_uint, + 0x617dcc89 as ::core::ffi::c_int as uint32_t, + 0xeff2cb6a as ::core::ffi::c_uint, + 0x2358cbf4 as ::core::ffi::c_int as uint32_t, + 0xfa78d958 as ::core::ffi::c_uint, + 0x36d2d9c6 as ::core::ffi::c_int as uint32_t, + 0xb85dde25 as ::core::ffi::c_uint, + 0x74f7debb as ::core::ffi::c_int as uint32_t, + 0x7e32d7a2 as ::core::ffi::c_int as uint32_t, + 0xb298d73c as ::core::ffi::c_uint, + 0x3c17d0df as ::core::ffi::c_int as uint32_t, + 0xf0bdd041 as ::core::ffi::c_uint, + 0x5526f3c6 as ::core::ffi::c_int as uint32_t, + 0x998cf358 as ::core::ffi::c_uint, + 0x1703f4bb as ::core::ffi::c_int as uint32_t, + 0xdba9f425 as ::core::ffi::c_uint, + 0xd16cfd3c as ::core::ffi::c_uint, + 0x1dc6fda2 as ::core::ffi::c_int as uint32_t, + 0x9349fa41 as ::core::ffi::c_uint, + 0x5fe3fadf as ::core::ffi::c_int as uint32_t, + 0x86c3e873 as ::core::ffi::c_uint, + 0x4a69e8ed as ::core::ffi::c_int as uint32_t, + 0xc4e6ef0e as ::core::ffi::c_uint, + 0x84cef90 as ::core::ffi::c_int as uint32_t, + 0x289e689 as ::core::ffi::c_int as uint32_t, + 0xce23e617 as ::core::ffi::c_uint, + 0x40ace1f4 as ::core::ffi::c_int as uint32_t, + 0x8c06e16a as ::core::ffi::c_uint, + 0xd0eba0bb as ::core::ffi::c_uint, + 0x1c41a025 as ::core::ffi::c_int as uint32_t, + 0x92cea7c6 as ::core::ffi::c_uint, + 0x5e64a758 as ::core::ffi::c_int as uint32_t, + 0x54a1ae41 as ::core::ffi::c_int as uint32_t, + 0x980baedf as ::core::ffi::c_uint, + 0x1684a93c as ::core::ffi::c_int as uint32_t, + 0xda2ea9a2 as ::core::ffi::c_uint, + 0x30ebb0e as ::core::ffi::c_int as uint32_t, + 0xcfa4bb90 as ::core::ffi::c_uint, + 0x412bbc73 as ::core::ffi::c_int as uint32_t, + 0x8d81bced as ::core::ffi::c_uint, + 0x8744b5f4 as ::core::ffi::c_uint, + 0x4beeb56a as ::core::ffi::c_int as uint32_t, + 0xc561b289 as ::core::ffi::c_uint, + 0x9cbb217 as ::core::ffi::c_int as uint32_t, + 0xac509190 as ::core::ffi::c_uint, + 0x60fa910e as ::core::ffi::c_int as uint32_t, + 0xee7596ed as ::core::ffi::c_uint, + 0x22df9673 as ::core::ffi::c_int as uint32_t, + 0x281a9f6a as ::core::ffi::c_int as uint32_t, + 0xe4b09ff4 as ::core::ffi::c_uint, + 0x6a3f9817 as ::core::ffi::c_int as uint32_t, + 0xa6959889 as ::core::ffi::c_uint, + 0x7fb58a25 as ::core::ffi::c_int as uint32_t, + 0xb31f8abb as ::core::ffi::c_uint, + 0x3d908d58 as ::core::ffi::c_int as uint32_t, + 0xf13a8dc6 as ::core::ffi::c_uint, + 0xfbff84df as ::core::ffi::c_uint, + 0x37558441 as ::core::ffi::c_int as uint32_t, + 0xb9da83a2 as ::core::ffi::c_uint, + 0x7570833c as ::core::ffi::c_int as uint32_t, + 0x533b85da as ::core::ffi::c_int as uint32_t, + 0x9f918544 as ::core::ffi::c_uint, + 0x111e82a7 as ::core::ffi::c_int as uint32_t, + 0xddb48239 as ::core::ffi::c_uint, + 0xd7718b20 as ::core::ffi::c_uint, + 0x1bdb8bbe as ::core::ffi::c_int as uint32_t, + 0x95548c5d as ::core::ffi::c_uint, + 0x59fe8cc3 as ::core::ffi::c_int as uint32_t, + 0x80de9e6f as ::core::ffi::c_uint, + 0x4c749ef1 as ::core::ffi::c_int as uint32_t, + 0xc2fb9912 as ::core::ffi::c_uint, + 0xe51998c as ::core::ffi::c_int as uint32_t, + 0x4949095 as ::core::ffi::c_int as uint32_t, + 0xc83e900b as ::core::ffi::c_uint, + 0x46b197e8 as ::core::ffi::c_int as uint32_t, + 0x8a1b9776 as ::core::ffi::c_uint, + 0x2f80b4f1 as ::core::ffi::c_int as uint32_t, + 0xe32ab46f as ::core::ffi::c_uint, + 0x6da5b38c as ::core::ffi::c_int as uint32_t, + 0xa10fb312 as ::core::ffi::c_uint, + 0xabcaba0b as ::core::ffi::c_uint, + 0x6760ba95 as ::core::ffi::c_int as uint32_t, + 0xe9efbd76 as ::core::ffi::c_uint, + 0x2545bde8 as ::core::ffi::c_int as uint32_t, + 0xfc65af44 as ::core::ffi::c_uint, + 0x30cfafda as ::core::ffi::c_int as uint32_t, + 0xbe40a839 as ::core::ffi::c_uint, + 0x72eaa8a7 as ::core::ffi::c_int as uint32_t, + 0x782fa1be as ::core::ffi::c_int as uint32_t, + 0xb485a120 as ::core::ffi::c_uint, + 0x3a0aa6c3 as ::core::ffi::c_int as uint32_t, + 0xf6a0a65d as ::core::ffi::c_uint, + 0xaa4de78c as ::core::ffi::c_uint, + 0x66e7e712 as ::core::ffi::c_int as uint32_t, + 0xe868e0f1 as ::core::ffi::c_uint, + 0x24c2e06f as ::core::ffi::c_int as uint32_t, + 0x2e07e976 as ::core::ffi::c_int as uint32_t, + 0xe2ade9e8 as ::core::ffi::c_uint, + 0x6c22ee0b as ::core::ffi::c_int as uint32_t, + 0xa088ee95 as ::core::ffi::c_uint, + 0x79a8fc39 as ::core::ffi::c_int as uint32_t, + 0xb502fca7 as ::core::ffi::c_uint, + 0x3b8dfb44 as ::core::ffi::c_int as uint32_t, + 0xf727fbda as ::core::ffi::c_uint, + 0xfde2f2c3 as ::core::ffi::c_uint, + 0x3148f25d as ::core::ffi::c_int as uint32_t, + 0xbfc7f5be as ::core::ffi::c_uint, + 0x736df520 as ::core::ffi::c_int as uint32_t, + 0xd6f6d6a7 as ::core::ffi::c_uint, + 0x1a5cd639 as ::core::ffi::c_int as uint32_t, + 0x94d3d1da as ::core::ffi::c_uint, + 0x5879d144 as ::core::ffi::c_int as uint32_t, + 0x52bcd85d as ::core::ffi::c_int as uint32_t, + 0x9e16d8c3 as ::core::ffi::c_uint, + 0x1099df20 as ::core::ffi::c_int as uint32_t, + 0xdc33dfbe as ::core::ffi::c_uint, + 0x513cd12 as ::core::ffi::c_int as uint32_t, + 0xc9b9cd8c as ::core::ffi::c_uint, + 0x4736ca6f as ::core::ffi::c_int as uint32_t, + 0x8b9ccaf1 as ::core::ffi::c_uint, + 0x8159c3e8 as ::core::ffi::c_uint, + 0x4df3c376 as ::core::ffi::c_int as uint32_t, + 0xc37cc495 as ::core::ffi::c_uint, + 0xfd6c40b as ::core::ffi::c_int as uint32_t, + 0x7aa64737 as ::core::ffi::c_int as uint32_t, + 0xb60c47a9 as ::core::ffi::c_uint, + 0x3883404a as ::core::ffi::c_int as uint32_t, + 0xf42940d4 as ::core::ffi::c_uint, + 0xfeec49cd as ::core::ffi::c_uint, + 0x32464953 as ::core::ffi::c_int as uint32_t, + 0xbcc94eb0 as ::core::ffi::c_uint, + 0x70634e2e as ::core::ffi::c_int as uint32_t, + 0xa9435c82 as ::core::ffi::c_uint, + 0x65e95c1c as ::core::ffi::c_int as uint32_t, + 0xeb665bff as ::core::ffi::c_uint, + 0x27cc5b61 as ::core::ffi::c_int as uint32_t, + 0x2d095278 as ::core::ffi::c_int as uint32_t, + 0xe1a352e6 as ::core::ffi::c_uint, + 0x6f2c5505 as ::core::ffi::c_int as uint32_t, + 0xa386559b as ::core::ffi::c_uint, + 0x61d761c as ::core::ffi::c_int as uint32_t, + 0xcab77682 as ::core::ffi::c_uint, + 0x44387161 as ::core::ffi::c_int as uint32_t, + 0x889271ff as ::core::ffi::c_uint, + 0x825778e6 as ::core::ffi::c_uint, + 0x4efd7878 as ::core::ffi::c_int as uint32_t, + 0xc0727f9b as ::core::ffi::c_uint, + 0xcd87f05 as ::core::ffi::c_int as uint32_t, + 0xd5f86da9 as ::core::ffi::c_uint, + 0x19526d37 as ::core::ffi::c_int as uint32_t, + 0x97dd6ad4 as ::core::ffi::c_uint, + 0x5b776a4a as ::core::ffi::c_int as uint32_t, + 0x51b26353 as ::core::ffi::c_int as uint32_t, + 0x9d1863cd as ::core::ffi::c_uint, + 0x1397642e as ::core::ffi::c_int as uint32_t, + 0xdf3d64b0 as ::core::ffi::c_uint, + 0x83d02561 as ::core::ffi::c_uint, + 0x4f7a25ff as ::core::ffi::c_int as uint32_t, + 0xc1f5221c as ::core::ffi::c_uint, + 0xd5f2282 as ::core::ffi::c_int as uint32_t, + 0x79a2b9b as ::core::ffi::c_int as uint32_t, + 0xcb302b05 as ::core::ffi::c_uint, + 0x45bf2ce6 as ::core::ffi::c_int as uint32_t, + 0x89152c78 as ::core::ffi::c_uint, + 0x50353ed4 as ::core::ffi::c_int as uint32_t, + 0x9c9f3e4a as ::core::ffi::c_uint, + 0x121039a9 as ::core::ffi::c_int as uint32_t, + 0xdeba3937 as ::core::ffi::c_uint, + 0xd47f302e as ::core::ffi::c_uint, + 0x18d530b0 as ::core::ffi::c_int as uint32_t, + 0x965a3753 as ::core::ffi::c_uint, + 0x5af037cd as ::core::ffi::c_int as uint32_t, + 0xff6b144a as ::core::ffi::c_uint, + 0x33c114d4 as ::core::ffi::c_int as uint32_t, + 0xbd4e1337 as ::core::ffi::c_uint, + 0x71e413a9 as ::core::ffi::c_int as uint32_t, + 0x7b211ab0 as ::core::ffi::c_int as uint32_t, + 0xb78b1a2e as ::core::ffi::c_uint, + 0x39041dcd as ::core::ffi::c_int as uint32_t, + 0xf5ae1d53 as ::core::ffi::c_uint, + 0x2c8e0fff as ::core::ffi::c_int as uint32_t, + 0xe0240f61 as ::core::ffi::c_uint, + 0x6eab0882 as ::core::ffi::c_int as uint32_t, + 0xa201081c as ::core::ffi::c_uint, + 0xa8c40105 as ::core::ffi::c_uint, + 0x646e019b as ::core::ffi::c_int as uint32_t, + 0xeae10678 as ::core::ffi::c_uint, + 0x264b06e6 as ::core::ffi::c_int as uint32_t, + ], +]; +unsafe extern "C" fn lzma_crc32_generic( + mut buf: *const uint8_t, + mut size: size_t, + mut crc: uint32_t, +) -> uint32_t { + crc = !crc; + if size > 8 as size_t { + while buf as uintptr_t & 7 as ::core::ffi::c_int as uintptr_t != 0 { + let fresh0 = buf; + buf = buf.offset(1); + crc = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][(*fresh0 as uint32_t ^ crc & 0xff as uint32_t) as usize] + ^ crc >> 8 as ::core::ffi::c_int; + size = size.wrapping_sub(1); + } + let limit: *const uint8_t = buf + .offset((size & !(7 as ::core::ffi::c_int as size_t)) as isize); + size &= 7 as ::core::ffi::c_int as size_t; + while buf < limit { + crc ^= aligned_read32ne(buf); + buf = buf.offset(4 as ::core::ffi::c_int as isize); + crc = lzma_crc32_table[7 as ::core::ffi::c_int + as usize][(crc & 0xff as uint32_t) as usize] + ^ lzma_crc32_table[6 as ::core::ffi::c_int + as usize][(crc >> 8 as ::core::ffi::c_int & 0xff as uint32_t) + as usize] + ^ lzma_crc32_table[5 as ::core::ffi::c_int + as usize][(crc >> 16 as ::core::ffi::c_int & 0xff as uint32_t) + as usize] + ^ lzma_crc32_table[4 as ::core::ffi::c_int + as usize][(crc >> 24 as ::core::ffi::c_int) as usize]; + let tmp: uint32_t = aligned_read32ne(buf) as uint32_t; + buf = buf.offset(4 as ::core::ffi::c_int as isize); + crc = lzma_crc32_table[3 as ::core::ffi::c_int + as usize][(tmp & 0xff as uint32_t) as usize] + ^ lzma_crc32_table[2 as ::core::ffi::c_int + as usize][(tmp >> 8 as ::core::ffi::c_int & 0xff as uint32_t) + as usize] ^ crc + ^ lzma_crc32_table[1 as ::core::ffi::c_int + as usize][(tmp >> 16 as ::core::ffi::c_int & 0xff as uint32_t) + as usize] + ^ lzma_crc32_table[0 as ::core::ffi::c_int + as usize][(tmp >> 24 as ::core::ffi::c_int) as usize]; + } + } + loop { + let fresh1 = size; + size = size.wrapping_sub(1); + if !(fresh1 != 0 as size_t) { + break; + } + let fresh2 = buf; + buf = buf.offset(1); + crc = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][(*fresh2 as uint32_t ^ crc & 0xff as uint32_t) as usize] + ^ crc >> 8 as ::core::ffi::c_int; + } + return !crc; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_crc32( + mut buf: *const uint8_t, + mut size: size_t, + mut crc: uint32_t, +) -> uint32_t { + return lzma_crc32_generic(buf, size, crc); +} diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs new file mode 100644 index 00000000..325a15c3 --- /dev/null +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -0,0 +1,1100 @@ +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +#[inline] +unsafe extern "C" fn aligned_read32ne(mut buf: *const uint8_t) -> uint32_t { + return *(buf as *const uint32_t); +} +#[no_mangle] +pub static mut lzma_crc64_table: [[uint64_t; 256]; 4] = [ + [ + 0 as ::core::ffi::c_ulonglong, + 0xb32e4cbe03a75f6f as ::core::ffi::c_ulonglong, + 0xf4843657a840a05b as ::core::ffi::c_ulonglong, + 0x47aa7ae9abe7ff34 as ::core::ffi::c_ulonglong, + 0x7bd0c384ff8f5e33 as ::core::ffi::c_ulonglong, + 0xc8fe8f3afc28015c as ::core::ffi::c_ulonglong, + 0x8f54f5d357cffe68 as ::core::ffi::c_ulonglong, + 0x3c7ab96d5468a107 as ::core::ffi::c_ulonglong, + 0xf7a18709ff1ebc66 as ::core::ffi::c_ulonglong, + 0x448fcbb7fcb9e309 as ::core::ffi::c_ulonglong, + 0x325b15e575e1c3d as ::core::ffi::c_ulonglong, + 0xb00bfde054f94352 as ::core::ffi::c_ulonglong, + 0x8c71448d0091e255 as ::core::ffi::c_ulonglong, + 0x3f5f08330336bd3a as ::core::ffi::c_ulonglong, + 0x78f572daa8d1420e as ::core::ffi::c_ulonglong, + 0xcbdb3e64ab761d61 as ::core::ffi::c_ulonglong, + 0x7d9ba13851336649 as ::core::ffi::c_ulonglong, + 0xceb5ed8652943926 as ::core::ffi::c_ulonglong, + 0x891f976ff973c612 as ::core::ffi::c_ulonglong, + 0x3a31dbd1fad4997d as ::core::ffi::c_ulonglong, + 0x64b62bcaebc387a as ::core::ffi::c_ulonglong, + 0xb5652e02ad1b6715 as ::core::ffi::c_ulonglong, + 0xf2cf54eb06fc9821 as ::core::ffi::c_ulonglong, + 0x41e11855055bc74e as ::core::ffi::c_ulonglong, + 0x8a3a2631ae2dda2f as ::core::ffi::c_ulonglong, + 0x39146a8fad8a8540 as ::core::ffi::c_ulonglong, + 0x7ebe1066066d7a74 as ::core::ffi::c_ulonglong, + 0xcd905cd805ca251b as ::core::ffi::c_ulonglong, + 0xf1eae5b551a2841c as ::core::ffi::c_ulonglong, + 0x42c4a90b5205db73 as ::core::ffi::c_ulonglong, + 0x56ed3e2f9e22447 as ::core::ffi::c_ulonglong, + 0xb6409f5cfa457b28 as ::core::ffi::c_ulonglong, + 0xfb374270a266cc92 as ::core::ffi::c_ulonglong, + 0x48190ecea1c193fd as ::core::ffi::c_ulonglong, + 0xfb374270a266cc9 as ::core::ffi::c_ulonglong, + 0xbc9d3899098133a6 as ::core::ffi::c_ulonglong, + 0x80e781f45de992a1 as ::core::ffi::c_ulonglong, + 0x33c9cd4a5e4ecdce as ::core::ffi::c_ulonglong, + 0x7463b7a3f5a932fa as ::core::ffi::c_ulonglong, + 0xc74dfb1df60e6d95 as ::core::ffi::c_ulonglong, + 0xc96c5795d7870f4 as ::core::ffi::c_ulonglong, + 0xbfb889c75edf2f9b as ::core::ffi::c_ulonglong, + 0xf812f32ef538d0af as ::core::ffi::c_ulonglong, + 0x4b3cbf90f69f8fc0 as ::core::ffi::c_ulonglong, + 0x774606fda2f72ec7 as ::core::ffi::c_ulonglong, + 0xc4684a43a15071a8 as ::core::ffi::c_ulonglong, + 0x83c230aa0ab78e9c as ::core::ffi::c_ulonglong, + 0x30ec7c140910d1f3 as ::core::ffi::c_ulonglong, + 0x86ace348f355aadb as ::core::ffi::c_ulonglong, + 0x3582aff6f0f2f5b4 as ::core::ffi::c_ulonglong, + 0x7228d51f5b150a80 as ::core::ffi::c_ulonglong, + 0xc10699a158b255ef as ::core::ffi::c_ulonglong, + 0xfd7c20cc0cdaf4e8 as ::core::ffi::c_ulonglong, + 0x4e526c720f7dab87 as ::core::ffi::c_ulonglong, + 0x9f8169ba49a54b3 as ::core::ffi::c_ulonglong, + 0xbad65a25a73d0bdc as ::core::ffi::c_ulonglong, + 0x710d64410c4b16bd as ::core::ffi::c_ulonglong, + 0xc22328ff0fec49d2 as ::core::ffi::c_ulonglong, + 0x85895216a40bb6e6 as ::core::ffi::c_ulonglong, + 0x36a71ea8a7ace989 as ::core::ffi::c_ulonglong, + 0xadda7c5f3c4488e as ::core::ffi::c_ulonglong, + 0xb9f3eb7bf06317e1 as ::core::ffi::c_ulonglong, + 0xfe5991925b84e8d5 as ::core::ffi::c_ulonglong, + 0x4d77dd2c5823b7ba as ::core::ffi::c_ulonglong, + 0x64b62bcaebc387a1 as ::core::ffi::c_ulonglong, + 0xd7986774e864d8ce as ::core::ffi::c_ulonglong, + 0x90321d9d438327fa as ::core::ffi::c_ulonglong, + 0x231c512340247895 as ::core::ffi::c_ulonglong, + 0x1f66e84e144cd992 as ::core::ffi::c_ulonglong, + 0xac48a4f017eb86fd as ::core::ffi::c_ulonglong, + 0xebe2de19bc0c79c9 as ::core::ffi::c_ulonglong, + 0x58cc92a7bfab26a6 as ::core::ffi::c_ulonglong, + 0x9317acc314dd3bc7 as ::core::ffi::c_ulonglong, + 0x2039e07d177a64a8 as ::core::ffi::c_ulonglong, + 0x67939a94bc9d9b9c as ::core::ffi::c_ulonglong, + 0xd4bdd62abf3ac4f3 as ::core::ffi::c_ulonglong, + 0xe8c76f47eb5265f4 as ::core::ffi::c_ulonglong, + 0x5be923f9e8f53a9b as ::core::ffi::c_ulonglong, + 0x1c4359104312c5af as ::core::ffi::c_ulonglong, + 0xaf6d15ae40b59ac0 as ::core::ffi::c_ulonglong, + 0x192d8af2baf0e1e8 as ::core::ffi::c_ulonglong, + 0xaa03c64cb957be87 as ::core::ffi::c_ulonglong, + 0xeda9bca512b041b3 as ::core::ffi::c_ulonglong, + 0x5e87f01b11171edc as ::core::ffi::c_ulonglong, + 0x62fd4976457fbfdb as ::core::ffi::c_ulonglong, + 0xd1d305c846d8e0b4 as ::core::ffi::c_ulonglong, + 0x96797f21ed3f1f80 as ::core::ffi::c_ulonglong, + 0x2557339fee9840ef as ::core::ffi::c_ulonglong, + 0xee8c0dfb45ee5d8e as ::core::ffi::c_ulonglong, + 0x5da24145464902e1 as ::core::ffi::c_ulonglong, + 0x1a083bacedaefdd5 as ::core::ffi::c_ulonglong, + 0xa9267712ee09a2ba as ::core::ffi::c_ulonglong, + 0x955cce7fba6103bd as ::core::ffi::c_ulonglong, + 0x267282c1b9c65cd2 as ::core::ffi::c_ulonglong, + 0x61d8f8281221a3e6 as ::core::ffi::c_ulonglong, + 0xd2f6b4961186fc89 as ::core::ffi::c_ulonglong, + 0x9f8169ba49a54b33 as ::core::ffi::c_ulonglong, + 0x2caf25044a02145c as ::core::ffi::c_ulonglong, + 0x6b055fede1e5eb68 as ::core::ffi::c_ulonglong, + 0xd82b1353e242b407 as ::core::ffi::c_ulonglong, + 0xe451aa3eb62a1500 as ::core::ffi::c_ulonglong, + 0x577fe680b58d4a6f as ::core::ffi::c_ulonglong, + 0x10d59c691e6ab55b as ::core::ffi::c_ulonglong, + 0xa3fbd0d71dcdea34 as ::core::ffi::c_ulonglong, + 0x6820eeb3b6bbf755 as ::core::ffi::c_ulonglong, + 0xdb0ea20db51ca83a as ::core::ffi::c_ulonglong, + 0x9ca4d8e41efb570e as ::core::ffi::c_ulonglong, + 0x2f8a945a1d5c0861 as ::core::ffi::c_ulonglong, + 0x13f02d374934a966 as ::core::ffi::c_ulonglong, + 0xa0de61894a93f609 as ::core::ffi::c_ulonglong, + 0xe7741b60e174093d as ::core::ffi::c_ulonglong, + 0x545a57dee2d35652 as ::core::ffi::c_ulonglong, + 0xe21ac88218962d7a as ::core::ffi::c_ulonglong, + 0x5134843c1b317215 as ::core::ffi::c_ulonglong, + 0x169efed5b0d68d21 as ::core::ffi::c_ulonglong, + 0xa5b0b26bb371d24e as ::core::ffi::c_ulonglong, + 0x99ca0b06e7197349 as ::core::ffi::c_ulonglong, + 0x2ae447b8e4be2c26 as ::core::ffi::c_ulonglong, + 0x6d4e3d514f59d312 as ::core::ffi::c_ulonglong, + 0xde6071ef4cfe8c7d as ::core::ffi::c_ulonglong, + 0x15bb4f8be788911c as ::core::ffi::c_ulonglong, + 0xa6950335e42fce73 as ::core::ffi::c_ulonglong, + 0xe13f79dc4fc83147 as ::core::ffi::c_ulonglong, + 0x521135624c6f6e28 as ::core::ffi::c_ulonglong, + 0x6e6b8c0f1807cf2f as ::core::ffi::c_ulonglong, + 0xdd45c0b11ba09040 as ::core::ffi::c_ulonglong, + 0x9aefba58b0476f74 as ::core::ffi::c_ulonglong, + 0x29c1f6e6b3e0301b as ::core::ffi::c_ulonglong, + 0xc96c5795d7870f42 as ::core::ffi::c_ulonglong, + 0x7a421b2bd420502d as ::core::ffi::c_ulonglong, + 0x3de861c27fc7af19 as ::core::ffi::c_ulonglong, + 0x8ec62d7c7c60f076 as ::core::ffi::c_ulonglong, + 0xb2bc941128085171 as ::core::ffi::c_ulonglong, + 0x192d8af2baf0e1e as ::core::ffi::c_ulonglong, + 0x4638a2468048f12a as ::core::ffi::c_ulonglong, + 0xf516eef883efae45 as ::core::ffi::c_ulonglong, + 0x3ecdd09c2899b324 as ::core::ffi::c_ulonglong, + 0x8de39c222b3eec4b as ::core::ffi::c_ulonglong, + 0xca49e6cb80d9137f as ::core::ffi::c_ulonglong, + 0x7967aa75837e4c10 as ::core::ffi::c_ulonglong, + 0x451d1318d716ed17 as ::core::ffi::c_ulonglong, + 0xf6335fa6d4b1b278 as ::core::ffi::c_ulonglong, + 0xb199254f7f564d4c as ::core::ffi::c_ulonglong, + 0x2b769f17cf11223 as ::core::ffi::c_ulonglong, + 0xb4f7f6ad86b4690b as ::core::ffi::c_ulonglong, + 0x7d9ba1385133664 as ::core::ffi::c_ulonglong, + 0x4073c0fa2ef4c950 as ::core::ffi::c_ulonglong, + 0xf35d8c442d53963f as ::core::ffi::c_ulonglong, + 0xcf273529793b3738 as ::core::ffi::c_ulonglong, + 0x7c0979977a9c6857 as ::core::ffi::c_ulonglong, + 0x3ba3037ed17b9763 as ::core::ffi::c_ulonglong, + 0x888d4fc0d2dcc80c as ::core::ffi::c_ulonglong, + 0x435671a479aad56d as ::core::ffi::c_ulonglong, + 0xf0783d1a7a0d8a02 as ::core::ffi::c_ulonglong, + 0xb7d247f3d1ea7536 as ::core::ffi::c_ulonglong, + 0x4fc0b4dd24d2a59 as ::core::ffi::c_ulonglong, + 0x3886b22086258b5e as ::core::ffi::c_ulonglong, + 0x8ba8fe9e8582d431 as ::core::ffi::c_ulonglong, + 0xcc0284772e652b05 as ::core::ffi::c_ulonglong, + 0x7f2cc8c92dc2746a as ::core::ffi::c_ulonglong, + 0x325b15e575e1c3d0 as ::core::ffi::c_ulonglong, + 0x8175595b76469cbf as ::core::ffi::c_ulonglong, + 0xc6df23b2dda1638b as ::core::ffi::c_ulonglong, + 0x75f16f0cde063ce4 as ::core::ffi::c_ulonglong, + 0x498bd6618a6e9de3 as ::core::ffi::c_ulonglong, + 0xfaa59adf89c9c28c as ::core::ffi::c_ulonglong, + 0xbd0fe036222e3db8 as ::core::ffi::c_ulonglong, + 0xe21ac88218962d7 as ::core::ffi::c_ulonglong, + 0xc5fa92ec8aff7fb6 as ::core::ffi::c_ulonglong, + 0x76d4de52895820d9 as ::core::ffi::c_ulonglong, + 0x317ea4bb22bfdfed as ::core::ffi::c_ulonglong, + 0x8250e80521188082 as ::core::ffi::c_ulonglong, + 0xbe2a516875702185 as ::core::ffi::c_ulonglong, + 0xd041dd676d77eea as ::core::ffi::c_ulonglong, + 0x4aae673fdd3081de as ::core::ffi::c_ulonglong, + 0xf9802b81de97deb1 as ::core::ffi::c_ulonglong, + 0x4fc0b4dd24d2a599 as ::core::ffi::c_ulonglong, + 0xfceef8632775faf6 as ::core::ffi::c_ulonglong, + 0xbb44828a8c9205c2 as ::core::ffi::c_ulonglong, + 0x86ace348f355aad as ::core::ffi::c_ulonglong, + 0x34107759db5dfbaa as ::core::ffi::c_ulonglong, + 0x873e3be7d8faa4c5 as ::core::ffi::c_ulonglong, + 0xc094410e731d5bf1 as ::core::ffi::c_ulonglong, + 0x73ba0db070ba049e as ::core::ffi::c_ulonglong, + 0xb86133d4dbcc19ff as ::core::ffi::c_ulonglong, + 0xb4f7f6ad86b4690 as ::core::ffi::c_ulonglong, + 0x4ce50583738cb9a4 as ::core::ffi::c_ulonglong, + 0xffcb493d702be6cb as ::core::ffi::c_ulonglong, + 0xc3b1f050244347cc as ::core::ffi::c_ulonglong, + 0x709fbcee27e418a3 as ::core::ffi::c_ulonglong, + 0x3735c6078c03e797 as ::core::ffi::c_ulonglong, + 0x841b8ab98fa4b8f8 as ::core::ffi::c_ulonglong, + 0xadda7c5f3c4488e3 as ::core::ffi::c_ulonglong, + 0x1ef430e13fe3d78c as ::core::ffi::c_ulonglong, + 0x595e4a08940428b8 as ::core::ffi::c_ulonglong, + 0xea7006b697a377d7 as ::core::ffi::c_ulonglong, + 0xd60abfdbc3cbd6d0 as ::core::ffi::c_ulonglong, + 0x6524f365c06c89bf as ::core::ffi::c_ulonglong, + 0x228e898c6b8b768b as ::core::ffi::c_ulonglong, + 0x91a0c532682c29e4 as ::core::ffi::c_ulonglong, + 0x5a7bfb56c35a3485 as ::core::ffi::c_ulonglong, + 0xe955b7e8c0fd6bea as ::core::ffi::c_ulonglong, + 0xaeffcd016b1a94de as ::core::ffi::c_ulonglong, + 0x1dd181bf68bdcbb1 as ::core::ffi::c_ulonglong, + 0x21ab38d23cd56ab6 as ::core::ffi::c_ulonglong, + 0x9285746c3f7235d9 as ::core::ffi::c_ulonglong, + 0xd52f0e859495caed as ::core::ffi::c_ulonglong, + 0x6601423b97329582 as ::core::ffi::c_ulonglong, + 0xd041dd676d77eeaa as ::core::ffi::c_ulonglong, + 0x636f91d96ed0b1c5 as ::core::ffi::c_ulonglong, + 0x24c5eb30c5374ef1 as ::core::ffi::c_ulonglong, + 0x97eba78ec690119e as ::core::ffi::c_ulonglong, + 0xab911ee392f8b099 as ::core::ffi::c_ulonglong, + 0x18bf525d915feff6 as ::core::ffi::c_ulonglong, + 0x5f1528b43ab810c2 as ::core::ffi::c_ulonglong, + 0xec3b640a391f4fad as ::core::ffi::c_ulonglong, + 0x27e05a6e926952cc as ::core::ffi::c_ulonglong, + 0x94ce16d091ce0da3 as ::core::ffi::c_ulonglong, + 0xd3646c393a29f297 as ::core::ffi::c_ulonglong, + 0x604a2087398eadf8 as ::core::ffi::c_ulonglong, + 0x5c3099ea6de60cff as ::core::ffi::c_ulonglong, + 0xef1ed5546e415390 as ::core::ffi::c_ulonglong, + 0xa8b4afbdc5a6aca4 as ::core::ffi::c_ulonglong, + 0x1b9ae303c601f3cb as ::core::ffi::c_ulonglong, + 0x56ed3e2f9e224471 as ::core::ffi::c_ulonglong, + 0xe5c372919d851b1e as ::core::ffi::c_ulonglong, + 0xa26908783662e42a as ::core::ffi::c_ulonglong, + 0x114744c635c5bb45 as ::core::ffi::c_ulonglong, + 0x2d3dfdab61ad1a42 as ::core::ffi::c_ulonglong, + 0x9e13b115620a452d as ::core::ffi::c_ulonglong, + 0xd9b9cbfcc9edba19 as ::core::ffi::c_ulonglong, + 0x6a978742ca4ae576 as ::core::ffi::c_ulonglong, + 0xa14cb926613cf817 as ::core::ffi::c_ulonglong, + 0x1262f598629ba778 as ::core::ffi::c_ulonglong, + 0x55c88f71c97c584c as ::core::ffi::c_ulonglong, + 0xe6e6c3cfcadb0723 as ::core::ffi::c_ulonglong, + 0xda9c7aa29eb3a624 as ::core::ffi::c_ulonglong, + 0x69b2361c9d14f94b as ::core::ffi::c_ulonglong, + 0x2e184cf536f3067f as ::core::ffi::c_ulonglong, + 0x9d36004b35545910 as ::core::ffi::c_ulonglong, + 0x2b769f17cf112238 as ::core::ffi::c_ulonglong, + 0x9858d3a9ccb67d57 as ::core::ffi::c_ulonglong, + 0xdff2a94067518263 as ::core::ffi::c_ulonglong, + 0x6cdce5fe64f6dd0c as ::core::ffi::c_ulonglong, + 0x50a65c93309e7c0b as ::core::ffi::c_ulonglong, + 0xe388102d33392364 as ::core::ffi::c_ulonglong, + 0xa4226ac498dedc50 as ::core::ffi::c_ulonglong, + 0x170c267a9b79833f as ::core::ffi::c_ulonglong, + 0xdcd7181e300f9e5e as ::core::ffi::c_ulonglong, + 0x6ff954a033a8c131 as ::core::ffi::c_ulonglong, + 0x28532e49984f3e05 as ::core::ffi::c_ulonglong, + 0x9b7d62f79be8616a as ::core::ffi::c_ulonglong, + 0xa707db9acf80c06d as ::core::ffi::c_ulonglong, + 0x14299724cc279f02 as ::core::ffi::c_ulonglong, + 0x5383edcd67c06036 as ::core::ffi::c_ulonglong, + 0xe0ada17364673f59 as ::core::ffi::c_ulonglong, + ], + [ + 0 as ::core::ffi::c_ulonglong, + 0x54e979925cd0f10d as ::core::ffi::c_ulonglong, + 0xa9d2f324b9a1e21a as ::core::ffi::c_ulonglong, + 0xfd3b8ab6e5711317 as ::core::ffi::c_ulonglong, + 0xc17d4962dc4ddab1 as ::core::ffi::c_ulonglong, + 0x959430f0809d2bbc as ::core::ffi::c_ulonglong, + 0x68afba4665ec38ab as ::core::ffi::c_ulonglong, + 0x3c46c3d4393cc9a6 as ::core::ffi::c_ulonglong, + 0x10223dee1795abe7 as ::core::ffi::c_ulonglong, + 0x44cb447c4b455aea as ::core::ffi::c_ulonglong, + 0xb9f0cecaae3449fd as ::core::ffi::c_ulonglong, + 0xed19b758f2e4b8f0 as ::core::ffi::c_ulonglong, + 0xd15f748ccbd87156 as ::core::ffi::c_ulonglong, + 0x85b60d1e9708805b as ::core::ffi::c_ulonglong, + 0x788d87a87279934c as ::core::ffi::c_ulonglong, + 0x2c64fe3a2ea96241 as ::core::ffi::c_ulonglong, + 0x20447bdc2f2b57ce as ::core::ffi::c_ulonglong, + 0x74ad024e73fba6c3 as ::core::ffi::c_ulonglong, + 0x899688f8968ab5d4 as ::core::ffi::c_ulonglong, + 0xdd7ff16aca5a44d9 as ::core::ffi::c_ulonglong, + 0xe13932bef3668d7f as ::core::ffi::c_ulonglong, + 0xb5d04b2cafb67c72 as ::core::ffi::c_ulonglong, + 0x48ebc19a4ac76f65 as ::core::ffi::c_ulonglong, + 0x1c02b80816179e68 as ::core::ffi::c_ulonglong, + 0x3066463238befc29 as ::core::ffi::c_ulonglong, + 0x648f3fa0646e0d24 as ::core::ffi::c_ulonglong, + 0x99b4b516811f1e33 as ::core::ffi::c_ulonglong, + 0xcd5dcc84ddcfef3e as ::core::ffi::c_ulonglong, + 0xf11b0f50e4f32698 as ::core::ffi::c_ulonglong, + 0xa5f276c2b823d795 as ::core::ffi::c_ulonglong, + 0x58c9fc745d52c482 as ::core::ffi::c_ulonglong, + 0xc2085e60182358f as ::core::ffi::c_ulonglong, + 0x4088f7b85e56af9c as ::core::ffi::c_ulonglong, + 0x14618e2a02865e91 as ::core::ffi::c_ulonglong, + 0xe95a049ce7f74d86 as ::core::ffi::c_ulonglong, + 0xbdb37d0ebb27bc8b as ::core::ffi::c_ulonglong, + 0x81f5beda821b752d as ::core::ffi::c_ulonglong, + 0xd51cc748decb8420 as ::core::ffi::c_ulonglong, + 0x28274dfe3bba9737 as ::core::ffi::c_ulonglong, + 0x7cce346c676a663a as ::core::ffi::c_ulonglong, + 0x50aaca5649c3047b as ::core::ffi::c_ulonglong, + 0x443b3c41513f576 as ::core::ffi::c_ulonglong, + 0xf9783972f062e661 as ::core::ffi::c_ulonglong, + 0xad9140e0acb2176c as ::core::ffi::c_ulonglong, + 0x91d78334958edeca as ::core::ffi::c_ulonglong, + 0xc53efaa6c95e2fc7 as ::core::ffi::c_ulonglong, + 0x380570102c2f3cd0 as ::core::ffi::c_ulonglong, + 0x6cec098270ffcddd as ::core::ffi::c_ulonglong, + 0x60cc8c64717df852 as ::core::ffi::c_ulonglong, + 0x3425f5f62dad095f as ::core::ffi::c_ulonglong, + 0xc91e7f40c8dc1a48 as ::core::ffi::c_ulonglong, + 0x9df706d2940ceb45 as ::core::ffi::c_ulonglong, + 0xa1b1c506ad3022e3 as ::core::ffi::c_ulonglong, + 0xf558bc94f1e0d3ee as ::core::ffi::c_ulonglong, + 0x86336221491c0f9 as ::core::ffi::c_ulonglong, + 0x5c8a4fb0484131f4 as ::core::ffi::c_ulonglong, + 0x70eeb18a66e853b5 as ::core::ffi::c_ulonglong, + 0x2407c8183a38a2b8 as ::core::ffi::c_ulonglong, + 0xd93c42aedf49b1af as ::core::ffi::c_ulonglong, + 0x8dd53b3c839940a2 as ::core::ffi::c_ulonglong, + 0xb193f8e8baa58904 as ::core::ffi::c_ulonglong, + 0xe57a817ae6757809 as ::core::ffi::c_ulonglong, + 0x18410bcc03046b1e as ::core::ffi::c_ulonglong, + 0x4ca8725e5fd49a13 as ::core::ffi::c_ulonglong, + 0x8111ef70bcad5f38 as ::core::ffi::c_ulonglong, + 0xd5f896e2e07dae35 as ::core::ffi::c_ulonglong, + 0x28c31c54050cbd22 as ::core::ffi::c_ulonglong, + 0x7c2a65c659dc4c2f as ::core::ffi::c_ulonglong, + 0x406ca61260e08589 as ::core::ffi::c_ulonglong, + 0x1485df803c307484 as ::core::ffi::c_ulonglong, + 0xe9be5536d9416793 as ::core::ffi::c_ulonglong, + 0xbd572ca48591969e as ::core::ffi::c_ulonglong, + 0x9133d29eab38f4df as ::core::ffi::c_ulonglong, + 0xc5daab0cf7e805d2 as ::core::ffi::c_ulonglong, + 0x38e121ba129916c5 as ::core::ffi::c_ulonglong, + 0x6c0858284e49e7c8 as ::core::ffi::c_ulonglong, + 0x504e9bfc77752e6e as ::core::ffi::c_ulonglong, + 0x4a7e26e2ba5df63 as ::core::ffi::c_ulonglong, + 0xf99c68d8ced4cc74 as ::core::ffi::c_ulonglong, + 0xad75114a92043d79 as ::core::ffi::c_ulonglong, + 0xa15594ac938608f6 as ::core::ffi::c_ulonglong, + 0xf5bced3ecf56f9fb as ::core::ffi::c_ulonglong, + 0x88767882a27eaec as ::core::ffi::c_ulonglong, + 0x5c6e1e1a76f71be1 as ::core::ffi::c_ulonglong, + 0x6028ddce4fcbd247 as ::core::ffi::c_ulonglong, + 0x34c1a45c131b234a as ::core::ffi::c_ulonglong, + 0xc9fa2eeaf66a305d as ::core::ffi::c_ulonglong, + 0x9d135778aabac150 as ::core::ffi::c_ulonglong, + 0xb177a9428413a311 as ::core::ffi::c_ulonglong, + 0xe59ed0d0d8c3521c as ::core::ffi::c_ulonglong, + 0x18a55a663db2410b as ::core::ffi::c_ulonglong, + 0x4c4c23f46162b006 as ::core::ffi::c_ulonglong, + 0x700ae020585e79a0 as ::core::ffi::c_ulonglong, + 0x24e399b2048e88ad as ::core::ffi::c_ulonglong, + 0xd9d81304e1ff9bba as ::core::ffi::c_ulonglong, + 0x8d316a96bd2f6ab7 as ::core::ffi::c_ulonglong, + 0xc19918c8e2fbf0a4 as ::core::ffi::c_ulonglong, + 0x9570615abe2b01a9 as ::core::ffi::c_ulonglong, + 0x684bebec5b5a12be as ::core::ffi::c_ulonglong, + 0x3ca2927e078ae3b3 as ::core::ffi::c_ulonglong, + 0xe451aa3eb62a15 as ::core::ffi::c_ulonglong, + 0x540d28386266db18 as ::core::ffi::c_ulonglong, + 0xa936a28e8717c80f as ::core::ffi::c_ulonglong, + 0xfddfdb1cdbc73902 as ::core::ffi::c_ulonglong, + 0xd1bb2526f56e5b43 as ::core::ffi::c_ulonglong, + 0x85525cb4a9beaa4e as ::core::ffi::c_ulonglong, + 0x7869d6024ccfb959 as ::core::ffi::c_ulonglong, + 0x2c80af90101f4854 as ::core::ffi::c_ulonglong, + 0x10c66c44292381f2 as ::core::ffi::c_ulonglong, + 0x442f15d675f370ff as ::core::ffi::c_ulonglong, + 0xb9149f60908263e8 as ::core::ffi::c_ulonglong, + 0xedfde6f2cc5292e5 as ::core::ffi::c_ulonglong, + 0xe1dd6314cdd0a76a as ::core::ffi::c_ulonglong, + 0xb5341a8691005667 as ::core::ffi::c_ulonglong, + 0x480f903074714570 as ::core::ffi::c_ulonglong, + 0x1ce6e9a228a1b47d as ::core::ffi::c_ulonglong, + 0x20a02a76119d7ddb as ::core::ffi::c_ulonglong, + 0x744953e44d4d8cd6 as ::core::ffi::c_ulonglong, + 0x8972d952a83c9fc1 as ::core::ffi::c_ulonglong, + 0xdd9ba0c0f4ec6ecc as ::core::ffi::c_ulonglong, + 0xf1ff5efada450c8d as ::core::ffi::c_ulonglong, + 0xa51627688695fd80 as ::core::ffi::c_ulonglong, + 0x582dadde63e4ee97 as ::core::ffi::c_ulonglong, + 0xcc4d44c3f341f9a as ::core::ffi::c_ulonglong, + 0x308217980608d63c as ::core::ffi::c_ulonglong, + 0x646b6e0a5ad82731 as ::core::ffi::c_ulonglong, + 0x9950e4bcbfa93426 as ::core::ffi::c_ulonglong, + 0xcdb99d2ee379c52b as ::core::ffi::c_ulonglong, + 0x90fb71cad654a0f5 as ::core::ffi::c_ulonglong, + 0xc41208588a8451f8 as ::core::ffi::c_ulonglong, + 0x392982ee6ff542ef as ::core::ffi::c_ulonglong, + 0x6dc0fb7c3325b3e2 as ::core::ffi::c_ulonglong, + 0x518638a80a197a44 as ::core::ffi::c_ulonglong, + 0x56f413a56c98b49 as ::core::ffi::c_ulonglong, + 0xf854cb8cb3b8985e as ::core::ffi::c_ulonglong, + 0xacbdb21eef686953 as ::core::ffi::c_ulonglong, + 0x80d94c24c1c10b12 as ::core::ffi::c_ulonglong, + 0xd43035b69d11fa1f as ::core::ffi::c_ulonglong, + 0x290bbf007860e908 as ::core::ffi::c_ulonglong, + 0x7de2c69224b01805 as ::core::ffi::c_ulonglong, + 0x41a405461d8cd1a3 as ::core::ffi::c_ulonglong, + 0x154d7cd4415c20ae as ::core::ffi::c_ulonglong, + 0xe876f662a42d33b9 as ::core::ffi::c_ulonglong, + 0xbc9f8ff0f8fdc2b4 as ::core::ffi::c_ulonglong, + 0xb0bf0a16f97ff73b as ::core::ffi::c_ulonglong, + 0xe4567384a5af0636 as ::core::ffi::c_ulonglong, + 0x196df93240de1521 as ::core::ffi::c_ulonglong, + 0x4d8480a01c0ee42c as ::core::ffi::c_ulonglong, + 0x71c2437425322d8a as ::core::ffi::c_ulonglong, + 0x252b3ae679e2dc87 as ::core::ffi::c_ulonglong, + 0xd810b0509c93cf90 as ::core::ffi::c_ulonglong, + 0x8cf9c9c2c0433e9d as ::core::ffi::c_ulonglong, + 0xa09d37f8eeea5cdc as ::core::ffi::c_ulonglong, + 0xf4744e6ab23aadd1 as ::core::ffi::c_ulonglong, + 0x94fc4dc574bbec6 as ::core::ffi::c_ulonglong, + 0x5da6bd4e0b9b4fcb as ::core::ffi::c_ulonglong, + 0x61e07e9a32a7866d as ::core::ffi::c_ulonglong, + 0x350907086e777760 as ::core::ffi::c_ulonglong, + 0xc8328dbe8b066477 as ::core::ffi::c_ulonglong, + 0x9cdbf42cd7d6957a as ::core::ffi::c_ulonglong, + 0xd073867288020f69 as ::core::ffi::c_ulonglong, + 0x849affe0d4d2fe64 as ::core::ffi::c_ulonglong, + 0x79a1755631a3ed73 as ::core::ffi::c_ulonglong, + 0x2d480cc46d731c7e as ::core::ffi::c_ulonglong, + 0x110ecf10544fd5d8 as ::core::ffi::c_ulonglong, + 0x45e7b682089f24d5 as ::core::ffi::c_ulonglong, + 0xb8dc3c34edee37c2 as ::core::ffi::c_ulonglong, + 0xec3545a6b13ec6cf as ::core::ffi::c_ulonglong, + 0xc051bb9c9f97a48e as ::core::ffi::c_ulonglong, + 0x94b8c20ec3475583 as ::core::ffi::c_ulonglong, + 0x698348b826364694 as ::core::ffi::c_ulonglong, + 0x3d6a312a7ae6b799 as ::core::ffi::c_ulonglong, + 0x12cf2fe43da7e3f as ::core::ffi::c_ulonglong, + 0x55c58b6c1f0a8f32 as ::core::ffi::c_ulonglong, + 0xa8fe01dafa7b9c25 as ::core::ffi::c_ulonglong, + 0xfc177848a6ab6d28 as ::core::ffi::c_ulonglong, + 0xf037fdaea72958a7 as ::core::ffi::c_ulonglong, + 0xa4de843cfbf9a9aa as ::core::ffi::c_ulonglong, + 0x59e50e8a1e88babd as ::core::ffi::c_ulonglong, + 0xd0c771842584bb0 as ::core::ffi::c_ulonglong, + 0x314ab4cc7b648216 as ::core::ffi::c_ulonglong, + 0x65a3cd5e27b4731b as ::core::ffi::c_ulonglong, + 0x989847e8c2c5600c as ::core::ffi::c_ulonglong, + 0xcc713e7a9e159101 as ::core::ffi::c_ulonglong, + 0xe015c040b0bcf340 as ::core::ffi::c_ulonglong, + 0xb4fcb9d2ec6c024d as ::core::ffi::c_ulonglong, + 0x49c73364091d115a as ::core::ffi::c_ulonglong, + 0x1d2e4af655cde057 as ::core::ffi::c_ulonglong, + 0x216889226cf129f1 as ::core::ffi::c_ulonglong, + 0x7581f0b03021d8fc as ::core::ffi::c_ulonglong, + 0x88ba7a06d550cbeb as ::core::ffi::c_ulonglong, + 0xdc53039489803ae6 as ::core::ffi::c_ulonglong, + 0x11ea9eba6af9ffcd as ::core::ffi::c_ulonglong, + 0x4503e72836290ec0 as ::core::ffi::c_ulonglong, + 0xb8386d9ed3581dd7 as ::core::ffi::c_ulonglong, + 0xecd1140c8f88ecda as ::core::ffi::c_ulonglong, + 0xd097d7d8b6b4257c as ::core::ffi::c_ulonglong, + 0x847eae4aea64d471 as ::core::ffi::c_ulonglong, + 0x794524fc0f15c766 as ::core::ffi::c_ulonglong, + 0x2dac5d6e53c5366b as ::core::ffi::c_ulonglong, + 0x1c8a3547d6c542a as ::core::ffi::c_ulonglong, + 0x5521dac621bca527 as ::core::ffi::c_ulonglong, + 0xa81a5070c4cdb630 as ::core::ffi::c_ulonglong, + 0xfcf329e2981d473d as ::core::ffi::c_ulonglong, + 0xc0b5ea36a1218e9b as ::core::ffi::c_ulonglong, + 0x945c93a4fdf17f96 as ::core::ffi::c_ulonglong, + 0x6967191218806c81 as ::core::ffi::c_ulonglong, + 0x3d8e608044509d8c as ::core::ffi::c_ulonglong, + 0x31aee56645d2a803 as ::core::ffi::c_ulonglong, + 0x65479cf41902590e as ::core::ffi::c_ulonglong, + 0x987c1642fc734a19 as ::core::ffi::c_ulonglong, + 0xcc956fd0a0a3bb14 as ::core::ffi::c_ulonglong, + 0xf0d3ac04999f72b2 as ::core::ffi::c_ulonglong, + 0xa43ad596c54f83bf as ::core::ffi::c_ulonglong, + 0x59015f20203e90a8 as ::core::ffi::c_ulonglong, + 0xde826b27cee61a5 as ::core::ffi::c_ulonglong, + 0x218cd888524703e4 as ::core::ffi::c_ulonglong, + 0x7565a11a0e97f2e9 as ::core::ffi::c_ulonglong, + 0x885e2bacebe6e1fe as ::core::ffi::c_ulonglong, + 0xdcb7523eb73610f3 as ::core::ffi::c_ulonglong, + 0xe0f191ea8e0ad955 as ::core::ffi::c_ulonglong, + 0xb418e878d2da2858 as ::core::ffi::c_ulonglong, + 0x492362ce37ab3b4f as ::core::ffi::c_ulonglong, + 0x1dca1b5c6b7bca42 as ::core::ffi::c_ulonglong, + 0x5162690234af5051 as ::core::ffi::c_ulonglong, + 0x58b1090687fa15c as ::core::ffi::c_ulonglong, + 0xf8b09a268d0eb24b as ::core::ffi::c_ulonglong, + 0xac59e3b4d1de4346 as ::core::ffi::c_ulonglong, + 0x901f2060e8e28ae0 as ::core::ffi::c_ulonglong, + 0xc4f659f2b4327bed as ::core::ffi::c_ulonglong, + 0x39cdd344514368fa as ::core::ffi::c_ulonglong, + 0x6d24aad60d9399f7 as ::core::ffi::c_ulonglong, + 0x414054ec233afbb6 as ::core::ffi::c_ulonglong, + 0x15a92d7e7fea0abb as ::core::ffi::c_ulonglong, + 0xe892a7c89a9b19ac as ::core::ffi::c_ulonglong, + 0xbc7bde5ac64be8a1 as ::core::ffi::c_ulonglong, + 0x803d1d8eff772107 as ::core::ffi::c_ulonglong, + 0xd4d4641ca3a7d00a as ::core::ffi::c_ulonglong, + 0x29efeeaa46d6c31d as ::core::ffi::c_ulonglong, + 0x7d0697381a063210 as ::core::ffi::c_ulonglong, + 0x712612de1b84079f as ::core::ffi::c_ulonglong, + 0x25cf6b4c4754f692 as ::core::ffi::c_ulonglong, + 0xd8f4e1faa225e585 as ::core::ffi::c_ulonglong, + 0x8c1d9868fef51488 as ::core::ffi::c_ulonglong, + 0xb05b5bbcc7c9dd2e as ::core::ffi::c_ulonglong, + 0xe4b2222e9b192c23 as ::core::ffi::c_ulonglong, + 0x1989a8987e683f34 as ::core::ffi::c_ulonglong, + 0x4d60d10a22b8ce39 as ::core::ffi::c_ulonglong, + 0x61042f300c11ac78 as ::core::ffi::c_ulonglong, + 0x35ed56a250c15d75 as ::core::ffi::c_ulonglong, + 0xc8d6dc14b5b04e62 as ::core::ffi::c_ulonglong, + 0x9c3fa586e960bf6f as ::core::ffi::c_ulonglong, + 0xa0796652d05c76c9 as ::core::ffi::c_ulonglong, + 0xf4901fc08c8c87c4 as ::core::ffi::c_ulonglong, + 0x9ab957669fd94d3 as ::core::ffi::c_ulonglong, + 0x5d42ece4352d65de as ::core::ffi::c_ulonglong, + ], + [ + 0 as ::core::ffi::c_ulonglong, + 0x3f0be14a916a6dcb as ::core::ffi::c_ulonglong, + 0x7e17c29522d4db96 as ::core::ffi::c_ulonglong, + 0x411c23dfb3beb65d as ::core::ffi::c_ulonglong, + 0xfc2f852a45a9b72c as ::core::ffi::c_ulonglong, + 0xc3246460d4c3dae7 as ::core::ffi::c_ulonglong, + 0x823847bf677d6cba as ::core::ffi::c_ulonglong, + 0xbd33a6f5f6170171 as ::core::ffi::c_ulonglong, + 0x6a87a57f245d70dd as ::core::ffi::c_ulonglong, + 0x558c4435b5371d16 as ::core::ffi::c_ulonglong, + 0x149067ea0689ab4b as ::core::ffi::c_ulonglong, + 0x2b9b86a097e3c680 as ::core::ffi::c_ulonglong, + 0x96a8205561f4c7f1 as ::core::ffi::c_ulonglong, + 0xa9a3c11ff09eaa3a as ::core::ffi::c_ulonglong, + 0xe8bfe2c043201c67 as ::core::ffi::c_ulonglong, + 0xd7b4038ad24a71ac as ::core::ffi::c_ulonglong, + 0xd50f4afe48bae1ba as ::core::ffi::c_ulonglong, + 0xea04abb4d9d08c71 as ::core::ffi::c_ulonglong, + 0xab18886b6a6e3a2c as ::core::ffi::c_ulonglong, + 0x94136921fb0457e7 as ::core::ffi::c_ulonglong, + 0x2920cfd40d135696 as ::core::ffi::c_ulonglong, + 0x162b2e9e9c793b5d as ::core::ffi::c_ulonglong, + 0x57370d412fc78d00 as ::core::ffi::c_ulonglong, + 0x683cec0bbeade0cb as ::core::ffi::c_ulonglong, + 0xbf88ef816ce79167 as ::core::ffi::c_ulonglong, + 0x80830ecbfd8dfcac as ::core::ffi::c_ulonglong, + 0xc19f2d144e334af1 as ::core::ffi::c_ulonglong, + 0xfe94cc5edf59273a as ::core::ffi::c_ulonglong, + 0x43a76aab294e264b as ::core::ffi::c_ulonglong, + 0x7cac8be1b8244b80 as ::core::ffi::c_ulonglong, + 0x3db0a83e0b9afddd as ::core::ffi::c_ulonglong, + 0x2bb49749af09016 as ::core::ffi::c_ulonglong, + 0x38c63ad73e7bddf1 as ::core::ffi::c_ulonglong, + 0x7cddb9daf11b03a as ::core::ffi::c_ulonglong, + 0x46d1f8421caf0667 as ::core::ffi::c_ulonglong, + 0x79da19088dc56bac as ::core::ffi::c_ulonglong, + 0xc4e9bffd7bd26add as ::core::ffi::c_ulonglong, + 0xfbe25eb7eab80716 as ::core::ffi::c_ulonglong, + 0xbafe7d685906b14b as ::core::ffi::c_ulonglong, + 0x85f59c22c86cdc80 as ::core::ffi::c_ulonglong, + 0x52419fa81a26ad2c as ::core::ffi::c_ulonglong, + 0x6d4a7ee28b4cc0e7 as ::core::ffi::c_ulonglong, + 0x2c565d3d38f276ba as ::core::ffi::c_ulonglong, + 0x135dbc77a9981b71 as ::core::ffi::c_ulonglong, + 0xae6e1a825f8f1a00 as ::core::ffi::c_ulonglong, + 0x9165fbc8cee577cb as ::core::ffi::c_ulonglong, + 0xd079d8177d5bc196 as ::core::ffi::c_ulonglong, + 0xef72395dec31ac5d as ::core::ffi::c_ulonglong, + 0xedc9702976c13c4b as ::core::ffi::c_ulonglong, + 0xd2c29163e7ab5180 as ::core::ffi::c_ulonglong, + 0x93deb2bc5415e7dd as ::core::ffi::c_ulonglong, + 0xacd553f6c57f8a16 as ::core::ffi::c_ulonglong, + 0x11e6f50333688b67 as ::core::ffi::c_ulonglong, + 0x2eed1449a202e6ac as ::core::ffi::c_ulonglong, + 0x6ff1379611bc50f1 as ::core::ffi::c_ulonglong, + 0x50fad6dc80d63d3a as ::core::ffi::c_ulonglong, + 0x874ed556529c4c96 as ::core::ffi::c_ulonglong, + 0xb845341cc3f6215d as ::core::ffi::c_ulonglong, + 0xf95917c370489700 as ::core::ffi::c_ulonglong, + 0xc652f689e122facb as ::core::ffi::c_ulonglong, + 0x7b61507c1735fbba as ::core::ffi::c_ulonglong, + 0x446ab136865f9671 as ::core::ffi::c_ulonglong, + 0x57692e935e1202c as ::core::ffi::c_ulonglong, + 0x3a7d73a3a48b4de7 as ::core::ffi::c_ulonglong, + 0x718c75ae7cf7bbe2 as ::core::ffi::c_ulonglong, + 0x4e8794e4ed9dd629 as ::core::ffi::c_ulonglong, + 0xf9bb73b5e236074 as ::core::ffi::c_ulonglong, + 0x30905671cf490dbf as ::core::ffi::c_ulonglong, + 0x8da3f084395e0cce as ::core::ffi::c_ulonglong, + 0xb2a811cea8346105 as ::core::ffi::c_ulonglong, + 0xf3b432111b8ad758 as ::core::ffi::c_ulonglong, + 0xccbfd35b8ae0ba93 as ::core::ffi::c_ulonglong, + 0x1b0bd0d158aacb3f as ::core::ffi::c_ulonglong, + 0x2400319bc9c0a6f4 as ::core::ffi::c_ulonglong, + 0x651c12447a7e10a9 as ::core::ffi::c_ulonglong, + 0x5a17f30eeb147d62 as ::core::ffi::c_ulonglong, + 0xe72455fb1d037c13 as ::core::ffi::c_ulonglong, + 0xd82fb4b18c6911d8 as ::core::ffi::c_ulonglong, + 0x9933976e3fd7a785 as ::core::ffi::c_ulonglong, + 0xa6387624aebdca4e as ::core::ffi::c_ulonglong, + 0xa4833f50344d5a58 as ::core::ffi::c_ulonglong, + 0x9b88de1aa5273793 as ::core::ffi::c_ulonglong, + 0xda94fdc5169981ce as ::core::ffi::c_ulonglong, + 0xe59f1c8f87f3ec05 as ::core::ffi::c_ulonglong, + 0x58acba7a71e4ed74 as ::core::ffi::c_ulonglong, + 0x67a75b30e08e80bf as ::core::ffi::c_ulonglong, + 0x26bb78ef533036e2 as ::core::ffi::c_ulonglong, + 0x19b099a5c25a5b29 as ::core::ffi::c_ulonglong, + 0xce049a2f10102a85 as ::core::ffi::c_ulonglong, + 0xf10f7b65817a474e as ::core::ffi::c_ulonglong, + 0xb01358ba32c4f113 as ::core::ffi::c_ulonglong, + 0x8f18b9f0a3ae9cd8 as ::core::ffi::c_ulonglong, + 0x322b1f0555b99da9 as ::core::ffi::c_ulonglong, + 0xd20fe4fc4d3f062 as ::core::ffi::c_ulonglong, + 0x4c3cdd90776d463f as ::core::ffi::c_ulonglong, + 0x73373cdae6072bf4 as ::core::ffi::c_ulonglong, + 0x494a4f79428c6613 as ::core::ffi::c_ulonglong, + 0x7641ae33d3e60bd8 as ::core::ffi::c_ulonglong, + 0x375d8dec6058bd85 as ::core::ffi::c_ulonglong, + 0x8566ca6f132d04e as ::core::ffi::c_ulonglong, + 0xb565ca530725d13f as ::core::ffi::c_ulonglong, + 0x8a6e2b19964fbcf4 as ::core::ffi::c_ulonglong, + 0xcb7208c625f10aa9 as ::core::ffi::c_ulonglong, + 0xf479e98cb49b6762 as ::core::ffi::c_ulonglong, + 0x23cdea0666d116ce as ::core::ffi::c_ulonglong, + 0x1cc60b4cf7bb7b05 as ::core::ffi::c_ulonglong, + 0x5dda28934405cd58 as ::core::ffi::c_ulonglong, + 0x62d1c9d9d56fa093 as ::core::ffi::c_ulonglong, + 0xdfe26f2c2378a1e2 as ::core::ffi::c_ulonglong, + 0xe0e98e66b212cc29 as ::core::ffi::c_ulonglong, + 0xa1f5adb901ac7a74 as ::core::ffi::c_ulonglong, + 0x9efe4cf390c617bf as ::core::ffi::c_ulonglong, + 0x9c4505870a3687a9 as ::core::ffi::c_ulonglong, + 0xa34ee4cd9b5cea62 as ::core::ffi::c_ulonglong, + 0xe252c71228e25c3f as ::core::ffi::c_ulonglong, + 0xdd592658b98831f4 as ::core::ffi::c_ulonglong, + 0x606a80ad4f9f3085 as ::core::ffi::c_ulonglong, + 0x5f6161e7def55d4e as ::core::ffi::c_ulonglong, + 0x1e7d42386d4beb13 as ::core::ffi::c_ulonglong, + 0x2176a372fc2186d8 as ::core::ffi::c_ulonglong, + 0xf6c2a0f82e6bf774 as ::core::ffi::c_ulonglong, + 0xc9c941b2bf019abf as ::core::ffi::c_ulonglong, + 0x88d5626d0cbf2ce2 as ::core::ffi::c_ulonglong, + 0xb7de83279dd54129 as ::core::ffi::c_ulonglong, + 0xaed25d26bc24058 as ::core::ffi::c_ulonglong, + 0x35e6c498faa82d93 as ::core::ffi::c_ulonglong, + 0x74fae74749169bce as ::core::ffi::c_ulonglong, + 0x4bf1060dd87cf605 as ::core::ffi::c_ulonglong, + 0xe318eb5cf9ef77c4 as ::core::ffi::c_ulonglong, + 0xdc130a1668851a0f as ::core::ffi::c_ulonglong, + 0x9d0f29c9db3bac52 as ::core::ffi::c_ulonglong, + 0xa204c8834a51c199 as ::core::ffi::c_ulonglong, + 0x1f376e76bc46c0e8 as ::core::ffi::c_ulonglong, + 0x203c8f3c2d2cad23 as ::core::ffi::c_ulonglong, + 0x6120ace39e921b7e as ::core::ffi::c_ulonglong, + 0x5e2b4da90ff876b5 as ::core::ffi::c_ulonglong, + 0x899f4e23ddb20719 as ::core::ffi::c_ulonglong, + 0xb694af694cd86ad2 as ::core::ffi::c_ulonglong, + 0xf7888cb6ff66dc8f as ::core::ffi::c_ulonglong, + 0xc8836dfc6e0cb144 as ::core::ffi::c_ulonglong, + 0x75b0cb09981bb035 as ::core::ffi::c_ulonglong, + 0x4abb2a430971ddfe as ::core::ffi::c_ulonglong, + 0xba7099cbacf6ba3 as ::core::ffi::c_ulonglong, + 0x34ace8d62ba50668 as ::core::ffi::c_ulonglong, + 0x3617a1a2b155967e as ::core::ffi::c_ulonglong, + 0x91c40e8203ffbb5 as ::core::ffi::c_ulonglong, + 0x4800633793814de8 as ::core::ffi::c_ulonglong, + 0x770b827d02eb2023 as ::core::ffi::c_ulonglong, + 0xca382488f4fc2152 as ::core::ffi::c_ulonglong, + 0xf533c5c265964c99 as ::core::ffi::c_ulonglong, + 0xb42fe61dd628fac4 as ::core::ffi::c_ulonglong, + 0x8b2407574742970f as ::core::ffi::c_ulonglong, + 0x5c9004dd9508e6a3 as ::core::ffi::c_ulonglong, + 0x639be59704628b68 as ::core::ffi::c_ulonglong, + 0x2287c648b7dc3d35 as ::core::ffi::c_ulonglong, + 0x1d8c270226b650fe as ::core::ffi::c_ulonglong, + 0xa0bf81f7d0a1518f as ::core::ffi::c_ulonglong, + 0x9fb460bd41cb3c44 as ::core::ffi::c_ulonglong, + 0xdea84362f2758a19 as ::core::ffi::c_ulonglong, + 0xe1a3a228631fe7d2 as ::core::ffi::c_ulonglong, + 0xdbded18bc794aa35 as ::core::ffi::c_ulonglong, + 0xe4d530c156fec7fe as ::core::ffi::c_ulonglong, + 0xa5c9131ee54071a3 as ::core::ffi::c_ulonglong, + 0x9ac2f254742a1c68 as ::core::ffi::c_ulonglong, + 0x27f154a1823d1d19 as ::core::ffi::c_ulonglong, + 0x18fab5eb135770d2 as ::core::ffi::c_ulonglong, + 0x59e69634a0e9c68f as ::core::ffi::c_ulonglong, + 0x66ed777e3183ab44 as ::core::ffi::c_ulonglong, + 0xb15974f4e3c9dae8 as ::core::ffi::c_ulonglong, + 0x8e5295be72a3b723 as ::core::ffi::c_ulonglong, + 0xcf4eb661c11d017e as ::core::ffi::c_ulonglong, + 0xf045572b50776cb5 as ::core::ffi::c_ulonglong, + 0x4d76f1dea6606dc4 as ::core::ffi::c_ulonglong, + 0x727d1094370a000f as ::core::ffi::c_ulonglong, + 0x3361334b84b4b652 as ::core::ffi::c_ulonglong, + 0xc6ad20115dedb99 as ::core::ffi::c_ulonglong, + 0xed19b758f2e4b8f as ::core::ffi::c_ulonglong, + 0x31da7a3f1e442644 as ::core::ffi::c_ulonglong, + 0x70c659e0adfa9019 as ::core::ffi::c_ulonglong, + 0x4fcdb8aa3c90fdd2 as ::core::ffi::c_ulonglong, + 0xf2fe1e5fca87fca3 as ::core::ffi::c_ulonglong, + 0xcdf5ff155bed9168 as ::core::ffi::c_ulonglong, + 0x8ce9dccae8532735 as ::core::ffi::c_ulonglong, + 0xb3e23d8079394afe as ::core::ffi::c_ulonglong, + 0x64563e0aab733b52 as ::core::ffi::c_ulonglong, + 0x5b5ddf403a195699 as ::core::ffi::c_ulonglong, + 0x1a41fc9f89a7e0c4 as ::core::ffi::c_ulonglong, + 0x254a1dd518cd8d0f as ::core::ffi::c_ulonglong, + 0x9879bb20eeda8c7e as ::core::ffi::c_ulonglong, + 0xa7725a6a7fb0e1b5 as ::core::ffi::c_ulonglong, + 0xe66e79b5cc0e57e8 as ::core::ffi::c_ulonglong, + 0xd96598ff5d643a23 as ::core::ffi::c_ulonglong, + 0x92949ef28518cc26 as ::core::ffi::c_ulonglong, + 0xad9f7fb81472a1ed as ::core::ffi::c_ulonglong, + 0xec835c67a7cc17b0 as ::core::ffi::c_ulonglong, + 0xd388bd2d36a67a7b as ::core::ffi::c_ulonglong, + 0x6ebb1bd8c0b17b0a as ::core::ffi::c_ulonglong, + 0x51b0fa9251db16c1 as ::core::ffi::c_ulonglong, + 0x10acd94de265a09c as ::core::ffi::c_ulonglong, + 0x2fa73807730fcd57 as ::core::ffi::c_ulonglong, + 0xf8133b8da145bcfb as ::core::ffi::c_ulonglong, + 0xc718dac7302fd130 as ::core::ffi::c_ulonglong, + 0x8604f9188391676d as ::core::ffi::c_ulonglong, + 0xb90f185212fb0aa6 as ::core::ffi::c_ulonglong, + 0x43cbea7e4ec0bd7 as ::core::ffi::c_ulonglong, + 0x3b375fed7586661c as ::core::ffi::c_ulonglong, + 0x7a2b7c32c638d041 as ::core::ffi::c_ulonglong, + 0x45209d785752bd8a as ::core::ffi::c_ulonglong, + 0x479bd40ccda22d9c as ::core::ffi::c_ulonglong, + 0x789035465cc84057 as ::core::ffi::c_ulonglong, + 0x398c1699ef76f60a as ::core::ffi::c_ulonglong, + 0x687f7d37e1c9bc1 as ::core::ffi::c_ulonglong, + 0xbbb45126880b9ab0 as ::core::ffi::c_ulonglong, + 0x84bfb06c1961f77b as ::core::ffi::c_ulonglong, + 0xc5a393b3aadf4126 as ::core::ffi::c_ulonglong, + 0xfaa872f93bb52ced as ::core::ffi::c_ulonglong, + 0x2d1c7173e9ff5d41 as ::core::ffi::c_ulonglong, + 0x121790397895308a as ::core::ffi::c_ulonglong, + 0x530bb3e6cb2b86d7 as ::core::ffi::c_ulonglong, + 0x6c0052ac5a41eb1c as ::core::ffi::c_ulonglong, + 0xd133f459ac56ea6d as ::core::ffi::c_ulonglong, + 0xee3815133d3c87a6 as ::core::ffi::c_ulonglong, + 0xaf2436cc8e8231fb as ::core::ffi::c_ulonglong, + 0x902fd7861fe85c30 as ::core::ffi::c_ulonglong, + 0xaa52a425bb6311d7 as ::core::ffi::c_ulonglong, + 0x9559456f2a097c1c as ::core::ffi::c_ulonglong, + 0xd44566b099b7ca41 as ::core::ffi::c_ulonglong, + 0xeb4e87fa08dda78a as ::core::ffi::c_ulonglong, + 0x567d210ffecaa6fb as ::core::ffi::c_ulonglong, + 0x6976c0456fa0cb30 as ::core::ffi::c_ulonglong, + 0x286ae39adc1e7d6d as ::core::ffi::c_ulonglong, + 0x176102d04d7410a6 as ::core::ffi::c_ulonglong, + 0xc0d5015a9f3e610a as ::core::ffi::c_ulonglong, + 0xffdee0100e540cc1 as ::core::ffi::c_ulonglong, + 0xbec2c3cfbdeaba9c as ::core::ffi::c_ulonglong, + 0x81c922852c80d757 as ::core::ffi::c_ulonglong, + 0x3cfa8470da97d626 as ::core::ffi::c_ulonglong, + 0x3f1653a4bfdbbed as ::core::ffi::c_ulonglong, + 0x42ed46e5f8430db0 as ::core::ffi::c_ulonglong, + 0x7de6a7af6929607b as ::core::ffi::c_ulonglong, + 0x7f5deedbf3d9f06d as ::core::ffi::c_ulonglong, + 0x40560f9162b39da6 as ::core::ffi::c_ulonglong, + 0x14a2c4ed10d2bfb as ::core::ffi::c_ulonglong, + 0x3e41cd0440674630 as ::core::ffi::c_ulonglong, + 0x83726bf1b6704741 as ::core::ffi::c_ulonglong, + 0xbc798abb271a2a8a as ::core::ffi::c_ulonglong, + 0xfd65a96494a49cd7 as ::core::ffi::c_ulonglong, + 0xc26e482e05cef11c as ::core::ffi::c_ulonglong, + 0x15da4ba4d78480b0 as ::core::ffi::c_ulonglong, + 0x2ad1aaee46eeed7b as ::core::ffi::c_ulonglong, + 0x6bcd8931f5505b26 as ::core::ffi::c_ulonglong, + 0x54c6687b643a36ed as ::core::ffi::c_ulonglong, + 0xe9f5ce8e922d379c as ::core::ffi::c_ulonglong, + 0xd6fe2fc403475a57 as ::core::ffi::c_ulonglong, + 0x97e20c1bb0f9ec0a as ::core::ffi::c_ulonglong, + 0xa8e9ed51219381c1 as ::core::ffi::c_ulonglong, + ], + [ + 0 as ::core::ffi::c_ulonglong, + 0x1dee8a5e222ca1dc as ::core::ffi::c_ulonglong, + 0x3bdd14bc445943b8 as ::core::ffi::c_ulonglong, + 0x26339ee26675e264 as ::core::ffi::c_ulonglong, + 0x77ba297888b28770 as ::core::ffi::c_ulonglong, + 0x6a54a326aa9e26ac as ::core::ffi::c_ulonglong, + 0x4c673dc4ccebc4c8 as ::core::ffi::c_ulonglong, + 0x5189b79aeec76514 as ::core::ffi::c_ulonglong, + 0xef7452f111650ee0 as ::core::ffi::c_ulonglong, + 0xf29ad8af3349af3c as ::core::ffi::c_ulonglong, + 0xd4a9464d553c4d58 as ::core::ffi::c_ulonglong, + 0xc947cc137710ec84 as ::core::ffi::c_ulonglong, + 0x98ce7b8999d78990 as ::core::ffi::c_ulonglong, + 0x8520f1d7bbfb284c as ::core::ffi::c_ulonglong, + 0xa3136f35dd8eca28 as ::core::ffi::c_ulonglong, + 0xbefde56bffa26bf4 as ::core::ffi::c_ulonglong, + 0x4c300ac98dc40345 as ::core::ffi::c_ulonglong, + 0x51de8097afe8a299 as ::core::ffi::c_ulonglong, + 0x77ed1e75c99d40fd as ::core::ffi::c_ulonglong, + 0x6a03942bebb1e121 as ::core::ffi::c_ulonglong, + 0x3b8a23b105768435 as ::core::ffi::c_ulonglong, + 0x2664a9ef275a25e9 as ::core::ffi::c_ulonglong, + 0x57370d412fc78d as ::core::ffi::c_ulonglong, + 0x1db9bd5363036651 as ::core::ffi::c_ulonglong, + 0xa34458389ca10da5 as ::core::ffi::c_ulonglong, + 0xbeaad266be8dac79 as ::core::ffi::c_ulonglong, + 0x98994c84d8f84e1d as ::core::ffi::c_ulonglong, + 0x8577c6dafad4efc1 as ::core::ffi::c_ulonglong, + 0xd4fe714014138ad5 as ::core::ffi::c_ulonglong, + 0xc910fb1e363f2b09 as ::core::ffi::c_ulonglong, + 0xef2365fc504ac96d as ::core::ffi::c_ulonglong, + 0xf2cdefa2726668b1 as ::core::ffi::c_ulonglong, + 0x986015931b88068a as ::core::ffi::c_ulonglong, + 0x858e9fcd39a4a756 as ::core::ffi::c_ulonglong, + 0xa3bd012f5fd14532 as ::core::ffi::c_ulonglong, + 0xbe538b717dfde4ee as ::core::ffi::c_ulonglong, + 0xefda3ceb933a81fa as ::core::ffi::c_ulonglong, + 0xf234b6b5b1162026 as ::core::ffi::c_ulonglong, + 0xd4072857d763c242 as ::core::ffi::c_ulonglong, + 0xc9e9a209f54f639e as ::core::ffi::c_ulonglong, + 0x771447620aed086a as ::core::ffi::c_ulonglong, + 0x6afacd3c28c1a9b6 as ::core::ffi::c_ulonglong, + 0x4cc953de4eb44bd2 as ::core::ffi::c_ulonglong, + 0x5127d9806c98ea0e as ::core::ffi::c_ulonglong, + 0xae6e1a825f8f1a as ::core::ffi::c_ulonglong, + 0x1d40e444a0732ec6 as ::core::ffi::c_ulonglong, + 0x3b737aa6c606cca2 as ::core::ffi::c_ulonglong, + 0x269df0f8e42a6d7e as ::core::ffi::c_ulonglong, + 0xd4501f5a964c05cf as ::core::ffi::c_ulonglong, + 0xc9be9504b460a413 as ::core::ffi::c_ulonglong, + 0xef8d0be6d2154677 as ::core::ffi::c_ulonglong, + 0xf26381b8f039e7ab as ::core::ffi::c_ulonglong, + 0xa3ea36221efe82bf as ::core::ffi::c_ulonglong, + 0xbe04bc7c3cd22363 as ::core::ffi::c_ulonglong, + 0x9837229e5aa7c107 as ::core::ffi::c_ulonglong, + 0x85d9a8c0788b60db as ::core::ffi::c_ulonglong, + 0x3b244dab87290b2f as ::core::ffi::c_ulonglong, + 0x26cac7f5a505aaf3 as ::core::ffi::c_ulonglong, + 0xf95917c3704897 as ::core::ffi::c_ulonglong, + 0x1d17d349e15ce94b as ::core::ffi::c_ulonglong, + 0x4c9e64d30f9b8c5f as ::core::ffi::c_ulonglong, + 0x5170ee8d2db72d83 as ::core::ffi::c_ulonglong, + 0x7743706f4bc2cfe7 as ::core::ffi::c_ulonglong, + 0x6aadfa3169ee6e3b as ::core::ffi::c_ulonglong, + 0xa218840d981e1391 as ::core::ffi::c_ulonglong, + 0xbff60e53ba32b24d as ::core::ffi::c_ulonglong, + 0x99c590b1dc475029 as ::core::ffi::c_ulonglong, + 0x842b1aeffe6bf1f5 as ::core::ffi::c_ulonglong, + 0xd5a2ad7510ac94e1 as ::core::ffi::c_ulonglong, + 0xc84c272b3280353d as ::core::ffi::c_ulonglong, + 0xee7fb9c954f5d759 as ::core::ffi::c_ulonglong, + 0xf391339776d97685 as ::core::ffi::c_ulonglong, + 0x4d6cd6fc897b1d71 as ::core::ffi::c_ulonglong, + 0x50825ca2ab57bcad as ::core::ffi::c_ulonglong, + 0x76b1c240cd225ec9 as ::core::ffi::c_ulonglong, + 0x6b5f481eef0eff15 as ::core::ffi::c_ulonglong, + 0x3ad6ff8401c99a01 as ::core::ffi::c_ulonglong, + 0x273875da23e53bdd as ::core::ffi::c_ulonglong, + 0x10beb384590d9b9 as ::core::ffi::c_ulonglong, + 0x1ce5616667bc7865 as ::core::ffi::c_ulonglong, + 0xee288ec415da10d4 as ::core::ffi::c_ulonglong, + 0xf3c6049a37f6b108 as ::core::ffi::c_ulonglong, + 0xd5f59a785183536c as ::core::ffi::c_ulonglong, + 0xc81b102673aff2b0 as ::core::ffi::c_ulonglong, + 0x9992a7bc9d6897a4 as ::core::ffi::c_ulonglong, + 0x847c2de2bf443678 as ::core::ffi::c_ulonglong, + 0xa24fb300d931d41c as ::core::ffi::c_ulonglong, + 0xbfa1395efb1d75c0 as ::core::ffi::c_ulonglong, + 0x15cdc3504bf1e34 as ::core::ffi::c_ulonglong, + 0x1cb2566b2693bfe8 as ::core::ffi::c_ulonglong, + 0x3a81c88940e65d8c as ::core::ffi::c_ulonglong, + 0x276f42d762cafc50 as ::core::ffi::c_ulonglong, + 0x76e6f54d8c0d9944 as ::core::ffi::c_ulonglong, + 0x6b087f13ae213898 as ::core::ffi::c_ulonglong, + 0x4d3be1f1c854dafc as ::core::ffi::c_ulonglong, + 0x50d56bafea787b20 as ::core::ffi::c_ulonglong, + 0x3a78919e8396151b as ::core::ffi::c_ulonglong, + 0x27961bc0a1bab4c7 as ::core::ffi::c_ulonglong, + 0x1a58522c7cf56a3 as ::core::ffi::c_ulonglong, + 0x1c4b0f7ce5e3f77f as ::core::ffi::c_ulonglong, + 0x4dc2b8e60b24926b as ::core::ffi::c_ulonglong, + 0x502c32b8290833b7 as ::core::ffi::c_ulonglong, + 0x761fac5a4f7dd1d3 as ::core::ffi::c_ulonglong, + 0x6bf126046d51700f as ::core::ffi::c_ulonglong, + 0xd50cc36f92f31bfb as ::core::ffi::c_ulonglong, + 0xc8e24931b0dfba27 as ::core::ffi::c_ulonglong, + 0xeed1d7d3d6aa5843 as ::core::ffi::c_ulonglong, + 0xf33f5d8df486f99f as ::core::ffi::c_ulonglong, + 0xa2b6ea171a419c8b as ::core::ffi::c_ulonglong, + 0xbf586049386d3d57 as ::core::ffi::c_ulonglong, + 0x996bfeab5e18df33 as ::core::ffi::c_ulonglong, + 0x848574f57c347eef as ::core::ffi::c_ulonglong, + 0x76489b570e52165e as ::core::ffi::c_ulonglong, + 0x6ba611092c7eb782 as ::core::ffi::c_ulonglong, + 0x4d958feb4a0b55e6 as ::core::ffi::c_ulonglong, + 0x507b05b56827f43a as ::core::ffi::c_ulonglong, + 0x1f2b22f86e0912e as ::core::ffi::c_ulonglong, + 0x1c1c3871a4cc30f2 as ::core::ffi::c_ulonglong, + 0x3a2fa693c2b9d296 as ::core::ffi::c_ulonglong, + 0x27c12ccde095734a as ::core::ffi::c_ulonglong, + 0x993cc9a61f3718be as ::core::ffi::c_ulonglong, + 0x84d243f83d1bb962 as ::core::ffi::c_ulonglong, + 0xa2e1dd1a5b6e5b06 as ::core::ffi::c_ulonglong, + 0xbf0f57447942fada as ::core::ffi::c_ulonglong, + 0xee86e0de97859fce as ::core::ffi::c_ulonglong, + 0xf3686a80b5a93e12 as ::core::ffi::c_ulonglong, + 0xd55bf462d3dcdc76 as ::core::ffi::c_ulonglong, + 0xc8b57e3cf1f07daa as ::core::ffi::c_ulonglong, + 0xd6e9a7309f3239a7 as ::core::ffi::c_ulonglong, + 0xcb072d6ebd1e987b as ::core::ffi::c_ulonglong, + 0xed34b38cdb6b7a1f as ::core::ffi::c_ulonglong, + 0xf0da39d2f947dbc3 as ::core::ffi::c_ulonglong, + 0xa1538e481780bed7 as ::core::ffi::c_ulonglong, + 0xbcbd041635ac1f0b as ::core::ffi::c_ulonglong, + 0x9a8e9af453d9fd6f as ::core::ffi::c_ulonglong, + 0x876010aa71f55cb3 as ::core::ffi::c_ulonglong, + 0x399df5c18e573747 as ::core::ffi::c_ulonglong, + 0x24737f9fac7b969b as ::core::ffi::c_ulonglong, + 0x240e17dca0e74ff as ::core::ffi::c_ulonglong, + 0x1fae6b23e822d523 as ::core::ffi::c_ulonglong, + 0x4e27dcb906e5b037 as ::core::ffi::c_ulonglong, + 0x53c956e724c911eb as ::core::ffi::c_ulonglong, + 0x75fac80542bcf38f as ::core::ffi::c_ulonglong, + 0x6814425b60905253 as ::core::ffi::c_ulonglong, + 0x9ad9adf912f63ae2 as ::core::ffi::c_ulonglong, + 0x873727a730da9b3e as ::core::ffi::c_ulonglong, + 0xa104b94556af795a as ::core::ffi::c_ulonglong, + 0xbcea331b7483d886 as ::core::ffi::c_ulonglong, + 0xed6384819a44bd92 as ::core::ffi::c_ulonglong, + 0xf08d0edfb8681c4e as ::core::ffi::c_ulonglong, + 0xd6be903dde1dfe2a as ::core::ffi::c_ulonglong, + 0xcb501a63fc315ff6 as ::core::ffi::c_ulonglong, + 0x75adff0803933402 as ::core::ffi::c_ulonglong, + 0x6843755621bf95de as ::core::ffi::c_ulonglong, + 0x4e70ebb447ca77ba as ::core::ffi::c_ulonglong, + 0x539e61ea65e6d666 as ::core::ffi::c_ulonglong, + 0x217d6708b21b372 as ::core::ffi::c_ulonglong, + 0x1ff95c2ea90d12ae as ::core::ffi::c_ulonglong, + 0x39cac2cccf78f0ca as ::core::ffi::c_ulonglong, + 0x24244892ed545116 as ::core::ffi::c_ulonglong, + 0x4e89b2a384ba3f2d as ::core::ffi::c_ulonglong, + 0x536738fda6969ef1 as ::core::ffi::c_ulonglong, + 0x7554a61fc0e37c95 as ::core::ffi::c_ulonglong, + 0x68ba2c41e2cfdd49 as ::core::ffi::c_ulonglong, + 0x39339bdb0c08b85d as ::core::ffi::c_ulonglong, + 0x24dd11852e241981 as ::core::ffi::c_ulonglong, + 0x2ee8f674851fbe5 as ::core::ffi::c_ulonglong, + 0x1f0005396a7d5a39 as ::core::ffi::c_ulonglong, + 0xa1fde05295df31cd as ::core::ffi::c_ulonglong, + 0xbc136a0cb7f39011 as ::core::ffi::c_ulonglong, + 0x9a20f4eed1867275 as ::core::ffi::c_ulonglong, + 0x87ce7eb0f3aad3a9 as ::core::ffi::c_ulonglong, + 0xd647c92a1d6db6bd as ::core::ffi::c_ulonglong, + 0xcba943743f411761 as ::core::ffi::c_ulonglong, + 0xed9add965934f505 as ::core::ffi::c_ulonglong, + 0xf07457c87b1854d9 as ::core::ffi::c_ulonglong, + 0x2b9b86a097e3c68 as ::core::ffi::c_ulonglong, + 0x1f5732342b529db4 as ::core::ffi::c_ulonglong, + 0x3964acd64d277fd0 as ::core::ffi::c_ulonglong, + 0x248a26886f0bde0c as ::core::ffi::c_ulonglong, + 0x7503911281ccbb18 as ::core::ffi::c_ulonglong, + 0x68ed1b4ca3e01ac4 as ::core::ffi::c_ulonglong, + 0x4ede85aec595f8a0 as ::core::ffi::c_ulonglong, + 0x53300ff0e7b9597c as ::core::ffi::c_ulonglong, + 0xedcdea9b181b3288 as ::core::ffi::c_ulonglong, + 0xf02360c53a379354 as ::core::ffi::c_ulonglong, + 0xd610fe275c427130 as ::core::ffi::c_ulonglong, + 0xcbfe74797e6ed0ec as ::core::ffi::c_ulonglong, + 0x9a77c3e390a9b5f8 as ::core::ffi::c_ulonglong, + 0x879949bdb2851424 as ::core::ffi::c_ulonglong, + 0xa1aad75fd4f0f640 as ::core::ffi::c_ulonglong, + 0xbc445d01f6dc579c as ::core::ffi::c_ulonglong, + 0x74f1233d072c2a36 as ::core::ffi::c_ulonglong, + 0x691fa96325008bea as ::core::ffi::c_ulonglong, + 0x4f2c37814375698e as ::core::ffi::c_ulonglong, + 0x52c2bddf6159c852 as ::core::ffi::c_ulonglong, + 0x34b0a458f9ead46 as ::core::ffi::c_ulonglong, + 0x1ea5801badb20c9a as ::core::ffi::c_ulonglong, + 0x38961ef9cbc7eefe as ::core::ffi::c_ulonglong, + 0x257894a7e9eb4f22 as ::core::ffi::c_ulonglong, + 0x9b8571cc164924d6 as ::core::ffi::c_ulonglong, + 0x866bfb923465850a as ::core::ffi::c_ulonglong, + 0xa05865705210676e as ::core::ffi::c_ulonglong, + 0xbdb6ef2e703cc6b2 as ::core::ffi::c_ulonglong, + 0xec3f58b49efba3a6 as ::core::ffi::c_ulonglong, + 0xf1d1d2eabcd7027a as ::core::ffi::c_ulonglong, + 0xd7e24c08daa2e01e as ::core::ffi::c_ulonglong, + 0xca0cc656f88e41c2 as ::core::ffi::c_ulonglong, + 0x38c129f48ae82973 as ::core::ffi::c_ulonglong, + 0x252fa3aaa8c488af as ::core::ffi::c_ulonglong, + 0x31c3d48ceb16acb as ::core::ffi::c_ulonglong, + 0x1ef2b716ec9dcb17 as ::core::ffi::c_ulonglong, + 0x4f7b008c025aae03 as ::core::ffi::c_ulonglong, + 0x52958ad220760fdf as ::core::ffi::c_ulonglong, + 0x74a614304603edbb as ::core::ffi::c_ulonglong, + 0x69489e6e642f4c67 as ::core::ffi::c_ulonglong, + 0xd7b57b059b8d2793 as ::core::ffi::c_ulonglong, + 0xca5bf15bb9a1864f as ::core::ffi::c_ulonglong, + 0xec686fb9dfd4642b as ::core::ffi::c_ulonglong, + 0xf186e5e7fdf8c5f7 as ::core::ffi::c_ulonglong, + 0xa00f527d133fa0e3 as ::core::ffi::c_ulonglong, + 0xbde1d8233113013f as ::core::ffi::c_ulonglong, + 0x9bd246c15766e35b as ::core::ffi::c_ulonglong, + 0x863ccc9f754a4287 as ::core::ffi::c_ulonglong, + 0xec9136ae1ca42cbc as ::core::ffi::c_ulonglong, + 0xf17fbcf03e888d60 as ::core::ffi::c_ulonglong, + 0xd74c221258fd6f04 as ::core::ffi::c_ulonglong, + 0xcaa2a84c7ad1ced8 as ::core::ffi::c_ulonglong, + 0x9b2b1fd69416abcc as ::core::ffi::c_ulonglong, + 0x86c59588b63a0a10 as ::core::ffi::c_ulonglong, + 0xa0f60b6ad04fe874 as ::core::ffi::c_ulonglong, + 0xbd188134f26349a8 as ::core::ffi::c_ulonglong, + 0x3e5645f0dc1225c as ::core::ffi::c_ulonglong, + 0x1e0bee012fed8380 as ::core::ffi::c_ulonglong, + 0x383870e3499861e4 as ::core::ffi::c_ulonglong, + 0x25d6fabd6bb4c038 as ::core::ffi::c_ulonglong, + 0x745f4d278573a52c as ::core::ffi::c_ulonglong, + 0x69b1c779a75f04f0 as ::core::ffi::c_ulonglong, + 0x4f82599bc12ae694 as ::core::ffi::c_ulonglong, + 0x526cd3c5e3064748 as ::core::ffi::c_ulonglong, + 0xa0a13c6791602ff9 as ::core::ffi::c_ulonglong, + 0xbd4fb639b34c8e25 as ::core::ffi::c_ulonglong, + 0x9b7c28dbd5396c41 as ::core::ffi::c_ulonglong, + 0x8692a285f715cd9d as ::core::ffi::c_ulonglong, + 0xd71b151f19d2a889 as ::core::ffi::c_ulonglong, + 0xcaf59f413bfe0955 as ::core::ffi::c_ulonglong, + 0xecc601a35d8beb31 as ::core::ffi::c_ulonglong, + 0xf1288bfd7fa74aed as ::core::ffi::c_ulonglong, + 0x4fd56e9680052119 as ::core::ffi::c_ulonglong, + 0x523be4c8a22980c5 as ::core::ffi::c_ulonglong, + 0x74087a2ac45c62a1 as ::core::ffi::c_ulonglong, + 0x69e6f074e670c37d as ::core::ffi::c_ulonglong, + 0x386f47ee08b7a669 as ::core::ffi::c_ulonglong, + 0x2581cdb02a9b07b5 as ::core::ffi::c_ulonglong, + 0x3b253524ceee5d1 as ::core::ffi::c_ulonglong, + 0x1e5cd90c6ec2440d as ::core::ffi::c_ulonglong, + ], +]; +unsafe extern "C" fn lzma_crc64_generic( + mut buf: *const uint8_t, + mut size: size_t, + mut crc: uint64_t, +) -> uint64_t { + crc = !crc; + if size > 4 as size_t { + while buf as uintptr_t & 3 as ::core::ffi::c_int as uintptr_t != 0 { + let fresh0 = buf; + buf = buf.offset(1); + crc = lzma_crc64_table[0 as ::core::ffi::c_int + as usize][(*fresh0 as uint64_t ^ crc & 0xff as uint64_t) as usize] + ^ crc >> 8 as ::core::ffi::c_int; + size = size.wrapping_sub(1); + } + let limit: *const uint8_t = buf + .offset((size & !(3 as ::core::ffi::c_int as size_t)) as isize); + size &= 3 as ::core::ffi::c_int as size_t; + while buf < limit { + let tmp: uint32_t = crc as uint32_t ^ aligned_read32ne(buf) as uint32_t; + buf = buf.offset(4 as ::core::ffi::c_int as isize); + crc = lzma_crc64_table[3 as ::core::ffi::c_int + as usize][(tmp & 0xff as uint32_t) as usize] + ^ lzma_crc64_table[2 as ::core::ffi::c_int + as usize][(tmp >> 8 as ::core::ffi::c_int & 0xff as uint32_t) + as usize] ^ crc >> 32 as ::core::ffi::c_int + ^ lzma_crc64_table[1 as ::core::ffi::c_int + as usize][(tmp >> 16 as ::core::ffi::c_int & 0xff as uint32_t) + as usize] + ^ lzma_crc64_table[0 as ::core::ffi::c_int + as usize][(tmp >> 24 as ::core::ffi::c_int) as usize]; + } + } + loop { + let fresh1 = size; + size = size.wrapping_sub(1); + if !(fresh1 != 0 as size_t) { + break; + } + let fresh2 = buf; + buf = buf.offset(1); + crc = lzma_crc64_table[0 as ::core::ffi::c_int + as usize][(*fresh2 as uint64_t ^ crc & 0xff as uint64_t) as usize] + ^ crc >> 8 as ::core::ffi::c_int; + } + return !crc; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_crc64( + mut buf: *const uint8_t, + mut size: size_t, + mut crc: uint64_t, +) -> uint64_t { + return lzma_crc64_generic(buf, size, crc); +} diff --git a/liblzma-rs/src/check/mod.rs b/liblzma-rs/src/check/mod.rs new file mode 100644 index 00000000..e9d694a4 --- /dev/null +++ b/liblzma-rs/src/check/mod.rs @@ -0,0 +1,4 @@ +pub mod check; +pub mod crc32_fast; +pub mod crc64_fast; +pub mod sha256; diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs new file mode 100644 index 00000000..7bc296a4 --- /dev/null +++ b/liblzma-rs/src/check/sha256.rs @@ -0,0 +1,3434 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_sha256_state { + pub state: [uint32_t; 8], + pub size: uint64_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_check_state { + pub buffer: C2RustUnnamed_0, + pub state: C2RustUnnamed, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub crc32: uint32_t, + pub crc64: uint64_t, + pub sha256: lzma_sha256_state, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub u8_0: [uint8_t; 64], + pub u32_0: [uint32_t; 16], + pub u64_0: [uint64_t; 8], +} +#[inline] +unsafe extern "C" fn rotr_32( + mut num: uint32_t, + mut amount: ::core::ffi::c_uint, +) -> uint32_t { + return num >> amount | num << (32 as ::core::ffi::c_uint).wrapping_sub(amount); +} +static mut SHA256_K: [uint32_t; 64] = [ + 0x428a2f98 as ::core::ffi::c_int as uint32_t, + 0x71374491 as ::core::ffi::c_int as uint32_t, + 0xb5c0fbcf as ::core::ffi::c_uint, + 0xe9b5dba5 as ::core::ffi::c_uint, + 0x3956c25b as ::core::ffi::c_int as uint32_t, + 0x59f111f1 as ::core::ffi::c_int as uint32_t, + 0x923f82a4 as ::core::ffi::c_uint, + 0xab1c5ed5 as ::core::ffi::c_uint, + 0xd807aa98 as ::core::ffi::c_uint, + 0x12835b01 as ::core::ffi::c_int as uint32_t, + 0x243185be as ::core::ffi::c_int as uint32_t, + 0x550c7dc3 as ::core::ffi::c_int as uint32_t, + 0x72be5d74 as ::core::ffi::c_int as uint32_t, + 0x80deb1fe as ::core::ffi::c_uint, + 0x9bdc06a7 as ::core::ffi::c_uint, + 0xc19bf174 as ::core::ffi::c_uint, + 0xe49b69c1 as ::core::ffi::c_uint, + 0xefbe4786 as ::core::ffi::c_uint, + 0xfc19dc6 as ::core::ffi::c_int as uint32_t, + 0x240ca1cc as ::core::ffi::c_int as uint32_t, + 0x2de92c6f as ::core::ffi::c_int as uint32_t, + 0x4a7484aa as ::core::ffi::c_int as uint32_t, + 0x5cb0a9dc as ::core::ffi::c_int as uint32_t, + 0x76f988da as ::core::ffi::c_int as uint32_t, + 0x983e5152 as ::core::ffi::c_uint, + 0xa831c66d as ::core::ffi::c_uint, + 0xb00327c8 as ::core::ffi::c_uint, + 0xbf597fc7 as ::core::ffi::c_uint, + 0xc6e00bf3 as ::core::ffi::c_uint, + 0xd5a79147 as ::core::ffi::c_uint, + 0x6ca6351 as ::core::ffi::c_int as uint32_t, + 0x14292967 as ::core::ffi::c_int as uint32_t, + 0x27b70a85 as ::core::ffi::c_int as uint32_t, + 0x2e1b2138 as ::core::ffi::c_int as uint32_t, + 0x4d2c6dfc as ::core::ffi::c_int as uint32_t, + 0x53380d13 as ::core::ffi::c_int as uint32_t, + 0x650a7354 as ::core::ffi::c_int as uint32_t, + 0x766a0abb as ::core::ffi::c_int as uint32_t, + 0x81c2c92e as ::core::ffi::c_uint, + 0x92722c85 as ::core::ffi::c_uint, + 0xa2bfe8a1 as ::core::ffi::c_uint, + 0xa81a664b as ::core::ffi::c_uint, + 0xc24b8b70 as ::core::ffi::c_uint, + 0xc76c51a3 as ::core::ffi::c_uint, + 0xd192e819 as ::core::ffi::c_uint, + 0xd6990624 as ::core::ffi::c_uint, + 0xf40e3585 as ::core::ffi::c_uint, + 0x106aa070 as ::core::ffi::c_int as uint32_t, + 0x19a4c116 as ::core::ffi::c_int as uint32_t, + 0x1e376c08 as ::core::ffi::c_int as uint32_t, + 0x2748774c as ::core::ffi::c_int as uint32_t, + 0x34b0bcb5 as ::core::ffi::c_int as uint32_t, + 0x391c0cb3 as ::core::ffi::c_int as uint32_t, + 0x4ed8aa4a as ::core::ffi::c_int as uint32_t, + 0x5b9cca4f as ::core::ffi::c_int as uint32_t, + 0x682e6ff3 as ::core::ffi::c_int as uint32_t, + 0x748f82ee as ::core::ffi::c_int as uint32_t, + 0x78a5636f as ::core::ffi::c_int as uint32_t, + 0x84c87814 as ::core::ffi::c_uint, + 0x8cc70208 as ::core::ffi::c_uint, + 0x90befffa as ::core::ffi::c_uint, + 0xa4506ceb as ::core::ffi::c_uint, + 0xbef9a3f7 as ::core::ffi::c_uint, + 0xc67178f2 as ::core::ffi::c_uint, +]; +unsafe extern "C" fn transform(mut state: *mut uint32_t, mut data: *const uint32_t) { + let mut W: [uint32_t; 16] = [0; 16]; + let mut T: [uint32_t; 8] = [0; 8]; + memcpy( + &raw mut T as *mut uint32_t as *mut ::core::ffi::c_void, + state as *const ::core::ffi::c_void, + ::core::mem::size_of::<[uint32_t; 8]>() as size_t, + ); + W[0 as ::core::ffi::c_int as usize] = (*data.offset(0 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(0 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(0 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(0 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(0 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[0 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[1 as ::core::ffi::c_int as usize] = (*data.offset(1 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(1 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(1 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(1 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(1 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[1 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[2 as ::core::ffi::c_int as usize] = (*data.offset(2 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(2 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(2 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(2 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(2 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[2 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[3 as ::core::ffi::c_int as usize] = (*data.offset(3 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(3 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(3 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(3 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(3 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[3 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[4 as ::core::ffi::c_int as usize] = (*data.offset(4 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(4 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(4 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(4 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(4 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[4 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[5 as ::core::ffi::c_int as usize] = (*data.offset(5 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(5 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(5 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(5 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(5 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[5 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[6 as ::core::ffi::c_int as usize] = (*data.offset(6 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(6 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(6 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(6 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(6 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[6 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[7 as ::core::ffi::c_int as usize] = (*data.offset(7 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(7 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(7 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(7 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(7 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[7 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[8 as ::core::ffi::c_int as usize] = (*data.offset(8 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(8 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(8 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(8 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(8 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[8 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[9 as ::core::ffi::c_int as usize] = (*data.offset(9 as ::core::ffi::c_int as isize) + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | (*data.offset(9 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(9 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(9 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(9 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[9 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[10 as ::core::ffi::c_int as usize] = (*data + .offset(10 as ::core::ffi::c_int as isize) & 0xff as uint32_t) + << 24 as ::core::ffi::c_int + | (*data.offset(10 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(10 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(10 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(10 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[10 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[11 as ::core::ffi::c_int as usize] = (*data + .offset(11 as ::core::ffi::c_int as isize) & 0xff as uint32_t) + << 24 as ::core::ffi::c_int + | (*data.offset(11 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(11 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(11 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(11 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[11 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[12 as ::core::ffi::c_int as usize] = (*data + .offset(12 as ::core::ffi::c_int as isize) & 0xff as uint32_t) + << 24 as ::core::ffi::c_int + | (*data.offset(12 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(12 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(12 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(12 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[12 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[13 as ::core::ffi::c_int as usize] = (*data + .offset(13 as ::core::ffi::c_int as isize) & 0xff as uint32_t) + << 24 as ::core::ffi::c_int + | (*data.offset(13 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(13 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(13 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(13 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[13 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[14 as ::core::ffi::c_int as usize] = (*data + .offset(14 as ::core::ffi::c_int as isize) & 0xff as uint32_t) + << 24 as ::core::ffi::c_int + | (*data.offset(14 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(14 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(14 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(14 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[14 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[15 as ::core::ffi::c_int as usize] = (*data + .offset(15 as ::core::ffi::c_int as isize) & 0xff as uint32_t) + << 24 as ::core::ffi::c_int + | (*data.offset(15 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | (*data.offset(15 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | (*data.offset(15 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(15 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) + as usize], + ) + .wrapping_add(W[15 as ::core::ffi::c_int as usize]), + ); + T[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + let mut j: ::core::ffi::c_uint = 16 as ::core::ffi::c_uint; + while j < 64 as ::core::ffi::c_uint { + W[(0 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(0 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(0 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(0 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(1 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(1 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(1 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(1 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(2 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(2 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(2 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(2 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(3 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(3 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(3 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(3 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 3 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(4 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(4 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(4 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(4 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 4 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(5 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(5 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(5 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(5 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(5 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 5 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(6 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(6 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(6 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(6 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 6 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(7 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(7 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(7 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(7 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(8 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(8 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(8 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(8 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(8 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(8 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(8 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(8 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 8 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(9 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(9 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(9 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(9 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(9 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(9 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(9 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(9 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(9 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(9 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(9 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 9 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(10 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(10 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(10 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(10 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(10 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(10 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(10 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(10 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(10 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(10 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(10 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 10 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(11 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(11 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(11 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(11 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(11 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(11 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(11 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(11 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(11 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(11 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(11 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 11 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(12 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(12 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(12 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(12 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(12 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(12 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(12 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(12 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(12 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(12 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(12 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 12 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(13 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(13 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(13 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(13 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(13 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(13 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(13 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(13 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(13 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(13 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(13 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 13 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(14 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(14 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(14 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(14 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(14 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(14 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(14 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(14 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(14 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(14 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(14 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 14 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + W[(15 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(15 + as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + .wrapping_add( + (rotr_32( + W[(15 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(15 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 2 as ::core::ffi::c_uint, + ), + 17 as ::core::ffi::c_uint, + ) + ^ W[(15 as ::core::ffi::c_int - 2 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 10 as ::core::ffi::c_int) + .wrapping_add( + W[(15 as ::core::ffi::c_int - 7 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + ) + .wrapping_add( + rotr_32( + W[(15 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + ^ rotr_32( + W[(15 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize], + 11 as ::core::ffi::c_uint, + ), + 7 as ::core::ffi::c_uint, + ) + ^ W[(15 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 15 as ::core::ffi::c_int) as usize] + >> 3 as ::core::ffi::c_int, + ), + ); + T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 14 as ::core::ffi::c_uint, + ), + 5 as ::core::ffi::c_uint, + ), + 6 as ::core::ffi::c_uint, + ) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize]), + ) + .wrapping_add( + SHA256_K[(15 as ::core::ffi::c_uint).wrapping_add(j) as usize], + ) + .wrapping_add( + W[(15 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], + ), + ); + T[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) + as usize] = T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + .wrapping_add( + rotr_32( + T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ rotr_32( + T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + 9 as ::core::ffi::c_uint, + ), + 11 as ::core::ffi::c_uint, + ), + 2 as ::core::ffi::c_uint, + ) + .wrapping_add( + (T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & (T[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + ^ T[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize])) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize] + & T[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ), + ), + ); + j = j.wrapping_add(16 as ::core::ffi::c_uint); + } + let ref mut fresh0 = *state.offset(0 as ::core::ffi::c_int as isize); + *fresh0 = (*fresh0) + .wrapping_add( + T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + let ref mut fresh1 = *state.offset(1 as ::core::ffi::c_int as isize); + *fresh1 = (*fresh1) + .wrapping_add( + T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + let ref mut fresh2 = *state.offset(2 as ::core::ffi::c_int as isize); + *fresh2 = (*fresh2) + .wrapping_add( + T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + let ref mut fresh3 = *state.offset(3 as ::core::ffi::c_int as isize); + *fresh3 = (*fresh3) + .wrapping_add( + T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + let ref mut fresh4 = *state.offset(4 as ::core::ffi::c_int as isize); + *fresh4 = (*fresh4) + .wrapping_add( + T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + let ref mut fresh5 = *state.offset(5 as ::core::ffi::c_int as isize); + *fresh5 = (*fresh5) + .wrapping_add( + T[(5 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + let ref mut fresh6 = *state.offset(6 as ::core::ffi::c_int as isize); + *fresh6 = (*fresh6) + .wrapping_add( + T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); + let ref mut fresh7 = *state.offset(7 as ::core::ffi::c_int as isize); + *fresh7 = (*fresh7) + .wrapping_add( + T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int + & 7 as ::core::ffi::c_int) as usize], + ); +} +unsafe extern "C" fn process(mut check: *mut lzma_check_state) { + transform( + &raw mut (*check).state.sha256.state as *mut uint32_t, + &raw mut (*check).buffer.u32_0 as *mut uint32_t as *const uint32_t, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_sha256_init(mut check: *mut lzma_check_state) { + static mut s: [uint32_t; 8] = [ + 0x6a09e667 as ::core::ffi::c_int as uint32_t, + 0xbb67ae85 as ::core::ffi::c_uint, + 0x3c6ef372 as ::core::ffi::c_int as uint32_t, + 0xa54ff53a as ::core::ffi::c_uint, + 0x510e527f as ::core::ffi::c_int as uint32_t, + 0x9b05688c as ::core::ffi::c_uint, + 0x1f83d9ab as ::core::ffi::c_int as uint32_t, + 0x5be0cd19 as ::core::ffi::c_int as uint32_t, + ]; + memcpy( + &raw mut (*check).state.sha256.state as *mut uint32_t + as *mut ::core::ffi::c_void, + &raw const s as *const uint32_t as *const ::core::ffi::c_void, + ::core::mem::size_of::<[uint32_t; 8]>() as size_t, + ); + (*check).state.sha256.size = 0 as uint64_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_sha256_update( + mut buf: *const uint8_t, + mut size: size_t, + mut check: *mut lzma_check_state, +) { + while size > 0 as size_t { + let copy_start: size_t = ((*check).state.sha256.size & 0x3f as uint64_t) + as size_t; + let mut copy_size: size_t = (64 as size_t).wrapping_sub(copy_start); + if copy_size > size { + copy_size = size; + } + memcpy( + (&raw mut (*check).buffer.u8_0 as *mut uint8_t).offset(copy_start as isize) + as *mut ::core::ffi::c_void, + buf as *const ::core::ffi::c_void, + copy_size, + ); + buf = buf.offset(copy_size as isize); + size = size.wrapping_sub(copy_size); + (*check).state.sha256.size = (*check) + .state + .sha256 + .size + .wrapping_add(copy_size as uint64_t); + if (*check).state.sha256.size & 0x3f as uint64_t == 0 as uint64_t { + process(check); + } + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_sha256_finish(mut check: *mut lzma_check_state) { + let mut pos: size_t = ((*check).state.sha256.size & 0x3f as uint64_t) as size_t; + let fresh8 = pos; + pos = pos.wrapping_add(1); + (*check).buffer.u8_0[fresh8 as usize] = 0x80 as uint8_t; + while pos != (64 as ::core::ffi::c_int - 8 as ::core::ffi::c_int) as size_t { + if pos == 64 as size_t { + process(check); + pos = 0 as size_t; + } + let fresh9 = pos; + pos = pos.wrapping_add(1); + (*check).buffer.u8_0[fresh9 as usize] = 0 as uint8_t; + } + (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8 as uint64_t); + (*check) + .buffer + .u64_0[((64 as ::core::ffi::c_int - 8 as ::core::ffi::c_int) + / 8 as ::core::ffi::c_int) as usize] = ((*check).state.sha256.size + & 0xff as uint64_t) << 56 as ::core::ffi::c_int + | ((*check).state.sha256.size & 0xff00 as uint64_t) << 40 as ::core::ffi::c_int + | ((*check).state.sha256.size & 0xff0000 as uint64_t) << 24 as ::core::ffi::c_int + | ((*check).state.sha256.size & 0xff000000 as uint64_t) + << 8 as ::core::ffi::c_int + | ((*check).state.sha256.size & 0xff00000000 as uint64_t) + >> 8 as ::core::ffi::c_int + | ((*check).state.sha256.size & 0xff0000000000 as uint64_t) + >> 24 as ::core::ffi::c_int + | ((*check).state.sha256.size & 0xff000000000000 as uint64_t) + >> 40 as ::core::ffi::c_int + | ((*check).state.sha256.size & 0xff00000000000000 as uint64_t) + >> 56 as ::core::ffi::c_int; + process(check); + let mut i: size_t = 0 as size_t; + while i < 8 as size_t { + (*check).buffer.u32_0[i as usize] = ((*check).state.sha256.state[i as usize] + & 0xff as uint32_t) << 24 as ::core::ffi::c_int + | ((*check).state.sha256.state[i as usize] & 0xff00 as uint32_t) + << 8 as ::core::ffi::c_int + | ((*check).state.sha256.state[i as usize] & 0xff0000 as uint32_t) + >> 8 as ::core::ffi::c_int + | ((*check).state.sha256.state[i as usize] & 0xff000000 as uint32_t) + >> 24 as ::core::ffi::c_int; + i = i.wrapping_add(1); + } +} diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs new file mode 100644 index 00000000..21384166 --- /dev/null +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -0,0 +1,601 @@ +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_lzma_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma_decoder_memusage_nocheck( + options: *const ::core::ffi::c_void, + ) -> uint64_t; + fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: uint8_t) -> bool; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_alone_coder { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed_0, + pub picky: bool, + pub pos: size_t, + pub uncompressed_size: lzma_vli, + pub memlimit: uint64_t, + pub memusage: uint64_t, + pub options: lzma_options_lzma, +} +pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub const SEQ_CODE: C2RustUnnamed_0 = 4; +pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; +pub const SEQ_UNCOMPRESSED_SIZE: C2RustUnnamed_0 = 2; +pub const SEQ_DICTIONARY_SIZE: C2RustUnnamed_0 = 1; +pub const SEQ_PROPERTIES: C2RustUnnamed_0 = 0; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 + as ::core::ffi::c_ulonglong; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; +pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) + << 15 as ::core::ffi::c_int; +unsafe extern "C" fn alone_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; + while *out_pos < out_size + && ((*coder).sequence as ::core::ffi::c_uint + == SEQ_CODE as ::core::ffi::c_int as ::core::ffi::c_uint + || *in_pos < in_size) + { + let mut current_block_42: u64; + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + if lzma_lzma_lclppb_decode( + &raw mut (*coder).options, + *in_0.offset(*in_pos as isize), + ) { + return LZMA_FORMAT_ERROR; + } + (*coder).sequence = SEQ_DICTIONARY_SIZE; + *in_pos = (*in_pos).wrapping_add(1); + current_block_42 = 11048769245176032998; + } + 1 => { + (*coder).options.dict_size = ((*coder).options.dict_size as size_t + | (*in_0.offset(*in_pos as isize) as size_t) + << (*coder).pos.wrapping_mul(8 as size_t)) as uint32_t; + (*coder).pos = (*coder).pos.wrapping_add(1); + if (*coder).pos == 4 as size_t { + if (*coder).picky as ::core::ffi::c_int != 0 + && (*coder).options.dict_size != UINT32_MAX as uint32_t + { + let mut d: uint32_t = (*coder) + .options + .dict_size + .wrapping_sub(1 as uint32_t); + d |= d >> 2 as ::core::ffi::c_int; + d |= d >> 3 as ::core::ffi::c_int; + d |= d >> 4 as ::core::ffi::c_int; + d |= d >> 8 as ::core::ffi::c_int; + d |= d >> 16 as ::core::ffi::c_int; + d = d.wrapping_add(1); + if d != (*coder).options.dict_size { + return LZMA_FORMAT_ERROR; + } + } + (*coder).pos = 0 as size_t; + (*coder).sequence = SEQ_UNCOMPRESSED_SIZE; + } + *in_pos = (*in_pos).wrapping_add(1); + current_block_42 = 11048769245176032998; + } + 2 => { + (*coder).uncompressed_size + |= (*in_0.offset(*in_pos as isize) as lzma_vli) + << (*coder).pos.wrapping_mul(8 as size_t); + *in_pos = (*in_pos).wrapping_add(1); + (*coder).pos = (*coder).pos.wrapping_add(1); + if (*coder).pos < 8 as size_t { + current_block_42 = 11048769245176032998; + } else { + if (*coder).picky as ::core::ffi::c_int != 0 + && (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli + && (*coder).uncompressed_size + >= (1 as lzma_vli) << 38 as ::core::ffi::c_int + { + return LZMA_FORMAT_ERROR; + } + (*coder).options.ext_flags = LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t; + (*coder).options.ext_size_low = (*coder).uncompressed_size + as uint32_t; + (*coder).options.ext_size_high = ((*coder).uncompressed_size + >> 32 as ::core::ffi::c_int) as uint32_t; + (*coder).memusage = lzma_lzma_decoder_memusage_nocheck( + &raw mut (*coder).options as *const ::core::ffi::c_void, + ) + .wrapping_add(LZMA_MEMUSAGE_BASE as uint64_t); + (*coder).pos = 0 as size_t; + (*coder).sequence = SEQ_CODER_INIT; + current_block_42 = 14763689060501151050; + } + } + 3 => { + current_block_42 = 14763689060501151050; + } + 4 => { + return (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ); + } + _ => return LZMA_PROG_ERROR, + } + match current_block_42 { + 14763689060501151050 => { + if (*coder).memusage > (*coder).memlimit { + return LZMA_MEMLIMIT_ERROR; + } + let mut filters: [lzma_filter_info; 2] = [ + lzma_filter_info_s { + id: LZMA_FILTER_LZMA1EXT as lzma_vli, + init: Some( + lzma_lzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + options: &raw mut (*coder).options as *mut ::core::ffi::c_void, + }, + lzma_filter_info_s { + id: 0, + init: None, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + ]; + let ret_: lzma_ret = lzma_next_filter_init( + &raw mut (*coder).next, + allocator, + &raw mut filters as *mut lzma_filter_info, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + (*coder).sequence = SEQ_CODE; + } + _ => {} + } + } + return LZMA_OK; +} +unsafe extern "C" fn alone_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn alone_decoder_memconfig( + mut coder_ptr: *mut ::core::ffi::c_void, + mut memusage: *mut uint64_t, + mut old_memlimit: *mut uint64_t, + mut new_memlimit: uint64_t, +) -> lzma_ret { + let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; + *memusage = (*coder).memusage; + *old_memlimit = (*coder).memlimit; + if new_memlimit != 0 as uint64_t { + if new_memlimit < (*coder).memusage { + return LZMA_MEMLIMIT_ERROR; + } + (*coder).memlimit = new_memlimit; + } + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_alone_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut memlimit: uint64_t, + mut picky: bool, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + bool, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_alone_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + bool, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + bool, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_alone_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + bool, + ) -> lzma_ret, + ), + ); + let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_alone_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + alone_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + alone_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).memconfig = Some( + alone_decoder_memconfig + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + (*coder).sequence = SEQ_PROPERTIES; + (*coder).picky = picky; + (*coder).pos = 0 as size_t; + (*coder).options.dict_size = 0 as uint32_t; + (*coder).options.preset_dict = ::core::ptr::null::(); + (*coder).options.preset_dict_size = 0 as uint32_t; + (*coder).uncompressed_size = 0 as lzma_vli; + (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).memusage = LZMA_MEMUSAGE_BASE as uint64_t; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_alone_decoder( + mut strm: *mut lzma_stream, + mut memlimit: uint64_t, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_alone_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + memlimit, + 0 as ::core::ffi::c_int != 0, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs new file mode 100644 index 00000000..4de5826f --- /dev/null +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -0,0 +1,517 @@ +extern "C" { + fn memset( + __b: *mut ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __len: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_end(strm: *mut lzma_stream); + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_lzma_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma_lclppb_encode( + options: *const lzma_options_lzma, + byte: *mut uint8_t, + ) -> bool; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_alone_coder { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed_0, + pub header_pos: size_t, + pub header: [uint8_t; 13], +} +pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub const SEQ_CODE: C2RustUnnamed_0 = 1; +pub const SEQ_HEADER: C2RustUnnamed_0 = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { + *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; + *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) + as uint8_t; +} +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 + as ::core::ffi::c_ulonglong; +pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; +pub const ALONE_HEADER_SIZE: ::core::ffi::c_int = 1 as ::core::ffi::c_int + + 4 as ::core::ffi::c_int + 8 as ::core::ffi::c_int; +unsafe extern "C" fn alone_encode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; + while *out_pos < out_size { + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + lzma_bufcpy( + &raw mut (*coder).header as *mut uint8_t, + &raw mut (*coder).header_pos, + ALONE_HEADER_SIZE as size_t, + out, + out_pos, + out_size, + ); + if (*coder).header_pos < ALONE_HEADER_SIZE as size_t { + return LZMA_OK; + } + (*coder).sequence = SEQ_CODE; + } + 1 => { + return (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ); + } + _ => return LZMA_PROG_ERROR, + } + } + return LZMA_OK; +} +unsafe extern "C" fn alone_encoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn alone_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut options: *const lzma_options_lzma, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + alone_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + alone_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + ), + ); + let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_alone_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + alone_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + alone_encoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + (*coder).sequence = SEQ_HEADER; + (*coder).header_pos = 0 as size_t; + if lzma_lzma_lclppb_encode(options, &raw mut (*coder).header as *mut uint8_t) { + return LZMA_OPTIONS_ERROR; + } + if (*options).dict_size < LZMA_DICT_SIZE_MIN as uint32_t { + return LZMA_OPTIONS_ERROR; + } + let mut d: uint32_t = (*options).dict_size.wrapping_sub(1 as uint32_t); + d |= d >> 2 as ::core::ffi::c_int; + d |= d >> 3 as ::core::ffi::c_int; + d |= d >> 4 as ::core::ffi::c_int; + d |= d >> 8 as ::core::ffi::c_int; + d |= d >> 16 as ::core::ffi::c_int; + if d != UINT32_MAX as uint32_t { + d = d.wrapping_add(1); + } + write32le( + (&raw mut (*coder).header as *mut uint8_t) + .offset(1 as ::core::ffi::c_int as isize), + d, + ); + memset( + (&raw mut (*coder).header as *mut uint8_t) + .offset(1 as ::core::ffi::c_int as isize) + .offset(4 as ::core::ffi::c_int as isize) as *mut ::core::ffi::c_void, + 0xff as ::core::ffi::c_int, + 8 as size_t, + ); + let filters: [lzma_filter_info; 2] = [ + lzma_filter_info_s { + id: LZMA_FILTER_LZMA1 as lzma_vli, + init: Some( + lzma_lzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + options: options as *mut ::core::ffi::c_void, + }, + lzma_filter_info_s { + id: 0, + init: None, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + ]; + return lzma_next_filter_init( + &raw mut (*coder).next, + allocator, + &raw const filters as *const lzma_filter_info, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_alone_encoder( + mut strm: *mut lzma_stream, + mut options: *const lzma_options_lzma, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = alone_encoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + options, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs new file mode 100644 index 00000000..d729d076 --- /dev/null +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -0,0 +1,519 @@ +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_stream_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + memlimit: uint64_t, + flags: uint32_t, + ) -> lzma_ret; + fn lzma_alone_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + memlimit: uint64_t, + picky: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub const SEQ_FINISH: C2RustUnnamed_0 = 2; +pub const SEQ_CODE: C2RustUnnamed_0 = 1; +pub const SEQ_INIT: C2RustUnnamed_0 = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_auto_coder { + pub next: lzma_next_coder, + pub memlimit: uint64_t, + pub flags: uint32_t, + pub sequence: C2RustUnnamed_0, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_TELL_NO_CHECK: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; +pub const LZMA_TELL_UNSUPPORTED_CHECK: ::core::ffi::c_uint = 0x2 as ::core::ffi::c_uint; +pub const LZMA_TELL_ANY_CHECK: ::core::ffi::c_uint = 0x4 as ::core::ffi::c_uint; +pub const LZMA_IGNORE_CHECK: ::core::ffi::c_uint = 0x10 as ::core::ffi::c_uint; +pub const LZMA_CONCATENATED: ::core::ffi::c_uint = 0x8 as ::core::ffi::c_uint; +pub const LZMA_FAIL_FAST: ::core::ffi::c_uint = 0x20 as ::core::ffi::c_uint; +pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) + << 15 as ::core::ffi::c_int; +pub const LZMA_SUPPORTED_FLAGS: ::core::ffi::c_uint = LZMA_TELL_NO_CHECK + | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK | LZMA_IGNORE_CHECK + | LZMA_CONCATENATED | LZMA_FAIL_FAST; +unsafe extern "C" fn auto_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; + let mut current_block_28: u64; + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + if *in_pos >= in_size { + return LZMA_OK; + } + (*coder).sequence = SEQ_CODE; + if *in_0.offset(*in_pos as isize) as ::core::ffi::c_int + == 0xfd as ::core::ffi::c_int + { + let ret_: lzma_ret = lzma_stream_decoder_init( + &raw mut (*coder).next, + allocator, + (*coder).memlimit, + (*coder).flags, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + } else { + let ret__0: lzma_ret = lzma_alone_decoder_init( + &raw mut (*coder).next, + allocator, + (*coder).memlimit, + 1 as ::core::ffi::c_int != 0, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__0; + } + if (*coder).flags & LZMA_TELL_NO_CHECK as uint32_t != 0 { + return LZMA_NO_CHECK; + } + if (*coder).flags & LZMA_TELL_ANY_CHECK as uint32_t != 0 { + return LZMA_GET_CHECK; + } + } + current_block_28 = 13935781298497728377; + } + 1 => { + current_block_28 = 13935781298497728377; + } + 2 => { + current_block_28 = 4647193646042868866; + } + _ => return LZMA_PROG_ERROR, + } + match current_block_28 { + 13935781298497728377 => { + let ret: lzma_ret = (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + || (*coder).flags & LZMA_CONCATENATED as uint32_t == 0 as uint32_t + { + return ret; + } + (*coder).sequence = SEQ_FINISH; + } + _ => {} + } + if *in_pos < in_size { + return LZMA_DATA_ERROR; + } + return (if action as ::core::ffi::c_uint + == LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + { + LZMA_STREAM_END as ::core::ffi::c_int + } else { + LZMA_OK as ::core::ffi::c_int + }) as lzma_ret; +} +unsafe extern "C" fn auto_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn auto_decoder_get_check( + mut coder_ptr: *const ::core::ffi::c_void, +) -> lzma_check { + let mut coder: *const lzma_auto_coder = coder_ptr as *const lzma_auto_coder; + return (if (*coder).next.get_check.is_none() { + LZMA_CHECK_NONE as ::core::ffi::c_int as ::core::ffi::c_uint + } else { + (*coder).next.get_check.expect("non-null function pointer")((*coder).next.coder) + as ::core::ffi::c_uint + }) as lzma_check; +} +unsafe extern "C" fn auto_decoder_memconfig( + mut coder_ptr: *mut ::core::ffi::c_void, + mut memusage: *mut uint64_t, + mut old_memlimit: *mut uint64_t, + mut new_memlimit: uint64_t, +) -> lzma_ret { + let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; + let mut ret: lzma_ret = LZMA_OK; + if (*coder).next.memconfig.is_some() { + ret = (*coder) + .next + .memconfig + .expect( + "non-null function pointer", + )((*coder).next.coder, memusage, old_memlimit, new_memlimit); + } else { + *memusage = LZMA_MEMUSAGE_BASE as uint64_t; + *old_memlimit = (*coder).memlimit; + ret = LZMA_OK; + if new_memlimit != 0 as uint64_t && new_memlimit < *memusage { + ret = LZMA_MEMLIMIT_ERROR; + } + } + if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + && new_memlimit != 0 as uint64_t + { + (*coder).memlimit = new_memlimit; + } + return ret; +} +unsafe extern "C" fn auto_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut memlimit: uint64_t, + mut flags: uint32_t, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + auto_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + auto_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + ), + ); + if flags & !(LZMA_SUPPORTED_FLAGS as uint32_t) != 0 { + return LZMA_OPTIONS_ERROR; + } + let mut coder: *mut lzma_auto_coder = (*next).coder as *mut lzma_auto_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_auto_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + auto_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + auto_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).get_check = Some( + auto_decoder_get_check + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + ) as Option lzma_check>; + (*next).memconfig = Some( + auto_decoder_memconfig + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).flags = flags; + (*coder).sequence = SEQ_INIT; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_auto_decoder( + mut strm: *mut lzma_stream, + mut memlimit: uint64_t, + mut flags: uint32_t, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = auto_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + memlimit, + flags, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs new file mode 100644 index 00000000..b9dc6136 --- /dev/null +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -0,0 +1,246 @@ +extern "C" { + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_block_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +#[no_mangle] +pub unsafe extern "C" fn lzma_block_buffer_decode( + mut block: *mut lzma_block, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + if in_pos.is_null() || in_0.is_null() && *in_pos != in_size || *in_pos > in_size + || out_pos.is_null() || out.is_null() && *out_pos != out_size + || *out_pos > out_size + { + return LZMA_PROG_ERROR; + } + let mut block_decoder: lzma_next_coder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + let mut ret: lzma_ret = lzma_block_decoder_init( + &raw mut block_decoder, + allocator, + block, + ); + if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + ret = block_decoder + .code + .expect( + "non-null function pointer", + )( + block_decoder.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + LZMA_FINISH, + ); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_OK; + } else { + if ret as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + if *in_pos == in_size { + ret = LZMA_DATA_ERROR; + } else { + ret = LZMA_BUF_ERROR; + } + } + *in_pos = in_start; + *out_pos = out_start; + } + } + lzma_next_end(&raw mut block_decoder, allocator); + return ret; +} diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs new file mode 100644 index 00000000..35e53aee --- /dev/null +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -0,0 +1,629 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; + fn lzma_check_size(check: lzma_check) -> uint32_t; + fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; + fn lzma_block_header_encode(block: *const lzma_block, out: *mut uint8_t) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_raw_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + ) -> lzma_ret; + fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); + fn lzma_check_update( + check: *mut lzma_check_state, + type_0: lzma_check, + buf: *const uint8_t, + size: size_t, + ); + fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub u8_0: [uint8_t; 64], + pub u32_0: [uint32_t; 16], + pub u64_0: [uint64_t; 8], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_check_state { + pub buffer: C2RustUnnamed, + pub state: C2RustUnnamed_0, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub crc32: uint32_t, + pub crc64: uint64_t, + pub sha256: lzma_sha256_state, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_sha256_state { + pub state: [uint32_t; 8], + pub size: uint64_t, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_VLI_BYTES_MAX: ::core::ffi::c_int = 9 as ::core::ffi::c_int; +pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +pub const LZMA_CHECK_SIZE_MAX: ::core::ffi::c_int = 64 as ::core::ffi::c_int; +pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: ::core::ffi::c_int = 1024 as ::core::ffi::c_int; +pub const COMPRESSED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX + .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as ::core::ffi::c_ulonglong) + .wrapping_sub(LZMA_CHECK_SIZE_MAX as ::core::ffi::c_ulonglong) + & !(3 as ::core::ffi::c_ulonglong); +pub const LZMA2_CHUNK_MAX: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 16 as ::core::ffi::c_int; +pub const LZMA2_HEADER_UNCOMPRESSED: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +pub const HEADERS_BOUND: ::core::ffi::c_int = 1 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int + 2 as ::core::ffi::c_int * LZMA_VLI_BYTES_MAX + + 3 as ::core::ffi::c_int + 4 as ::core::ffi::c_int + LZMA_CHECK_SIZE_MAX + + 3 as ::core::ffi::c_int & !(3 as ::core::ffi::c_int); +unsafe extern "C" fn lzma2_bound(mut uncompressed_size: uint64_t) -> uint64_t { + if uncompressed_size > COMPRESSED_SIZE_MAX as uint64_t { + return 0 as uint64_t; + } + let overhead: uint64_t = uncompressed_size + .wrapping_add(LZMA2_CHUNK_MAX as uint64_t) + .wrapping_sub(1 as uint64_t) + .wrapping_div(LZMA2_CHUNK_MAX as uint64_t) + .wrapping_mul(LZMA2_HEADER_UNCOMPRESSED as uint64_t) + .wrapping_add(1 as uint64_t); + if (COMPRESSED_SIZE_MAX as uint64_t).wrapping_sub(overhead) < uncompressed_size { + return 0 as uint64_t; + } + return uncompressed_size.wrapping_add(overhead); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_buffer_bound64( + mut uncompressed_size: uint64_t, +) -> uint64_t { + let mut lzma2_size: uint64_t = lzma2_bound(uncompressed_size); + if lzma2_size == 0 as uint64_t { + return 0 as uint64_t; + } + lzma2_size = lzma2_size.wrapping_add(3 as uint64_t) & !(3 as uint64_t); + return (HEADERS_BOUND as uint64_t).wrapping_add(lzma2_size); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_buffer_bound( + mut uncompressed_size: size_t, +) -> size_t { + let mut ret: uint64_t = lzma_block_buffer_bound64(uncompressed_size as uint64_t); + return ret as size_t; +} +unsafe extern "C" fn block_encode_uncompressed( + mut block: *mut lzma_block, + mut in_0: *const uint8_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + let mut lzma2: lzma_options_lzma = lzma_options_lzma { + dict_size: LZMA_DICT_SIZE_MIN as uint32_t, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + lc: 0, + lp: 0, + pb: 0, + mode: 0 as lzma_mode, + nice_len: 0, + mf: 0 as lzma_match_finder, + depth: 0, + ext_flags: 0, + ext_size_low: 0, + ext_size_high: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; + let mut filters: [lzma_filter; 2] = [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 2]; + filters[0 as ::core::ffi::c_int as usize].id = LZMA_FILTER_LZMA2 as lzma_vli; + filters[0 as ::core::ffi::c_int as usize].options = &raw mut lzma2 + as *mut ::core::ffi::c_void; + filters[1 as ::core::ffi::c_int as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + let mut filters_orig: *mut lzma_filter = (*block).filters; + (*block).filters = &raw mut filters as *mut lzma_filter; + if lzma_block_header_size(block) as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*block).filters = filters_orig; + return LZMA_PROG_ERROR; + } + if (out_size.wrapping_sub(*out_pos) as lzma_vli) + < ((*block).header_size as lzma_vli).wrapping_add((*block).compressed_size) + { + (*block).filters = filters_orig; + return LZMA_BUF_ERROR; + } + if lzma_block_header_encode(block, out.offset(*out_pos as isize)) + as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*block).filters = filters_orig; + return LZMA_PROG_ERROR; + } + (*block).filters = filters_orig; + *out_pos = (*out_pos).wrapping_add((*block).header_size as size_t); + let mut in_pos: size_t = 0 as size_t; + let mut control: uint8_t = 0x1 as uint8_t; + while in_pos < in_size { + let fresh1 = *out_pos; + *out_pos = (*out_pos).wrapping_add(1); + *out.offset(fresh1 as isize) = control; + control = 0x2 as uint8_t; + let copy_size: size_t = if in_size.wrapping_sub(in_pos) + < ((1 as ::core::ffi::c_uint) << 16 as ::core::ffi::c_int) as size_t + { + in_size.wrapping_sub(in_pos) + } else { + ((1 as ::core::ffi::c_uint) << 16 as ::core::ffi::c_int) as size_t + }; + let fresh2 = *out_pos; + *out_pos = (*out_pos).wrapping_add(1); + *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1 as size_t) + >> 8 as ::core::ffi::c_int) as uint8_t; + let fresh3 = *out_pos; + *out_pos = (*out_pos).wrapping_add(1); + *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1 as size_t) + & 0xff as size_t) as uint8_t; + memcpy( + out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, + in_0.offset(in_pos as isize) as *const ::core::ffi::c_void, + copy_size, + ); + in_pos = in_pos.wrapping_add(copy_size); + *out_pos = (*out_pos).wrapping_add(copy_size); + } + let fresh4 = *out_pos; + *out_pos = (*out_pos).wrapping_add(1); + *out.offset(fresh4 as isize) = 0 as uint8_t; + return LZMA_OK; +} +unsafe extern "C" fn block_encode_normal( + mut block: *mut lzma_block, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + let ret_: lzma_ret = lzma_block_header_size(block) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + if out_size.wrapping_sub(*out_pos) <= (*block).header_size as size_t { + return LZMA_BUF_ERROR; + } + let out_start: size_t = *out_pos; + *out_pos = (*out_pos).wrapping_add((*block).header_size as size_t); + if out_size.wrapping_sub(*out_pos) as lzma_vli > (*block).compressed_size { + out_size = (*out_pos as lzma_vli).wrapping_add((*block).compressed_size) + as size_t; + } + let mut raw_encoder: lzma_next_coder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + let mut ret: lzma_ret = lzma_raw_encoder_init( + &raw mut raw_encoder, + allocator, + (*block).filters, + ); + if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + let mut in_pos: size_t = 0 as size_t; + ret = raw_encoder + .code + .expect( + "non-null function pointer", + )( + raw_encoder.coder, + allocator, + in_0, + &raw mut in_pos, + in_size, + out, + out_pos, + out_size, + LZMA_FINISH, + ); + } + lzma_next_end(&raw mut raw_encoder, allocator); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*block).compressed_size = (*out_pos) + .wrapping_sub(out_start.wrapping_add((*block).header_size as size_t)) + as lzma_vli; + ret = lzma_block_header_encode(block, out.offset(out_start as isize)); + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_PROG_ERROR; + } + } else if ret as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_BUF_ERROR; + } + if ret as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + *out_pos = out_start; + } + return ret; +} +unsafe extern "C" fn block_buffer_encode( + mut block: *mut lzma_block, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut try_to_compress: bool, +) -> lzma_ret { + if block.is_null() || in_0.is_null() && in_size != 0 as size_t || out.is_null() + || out_pos.is_null() || *out_pos > out_size + { + return LZMA_PROG_ERROR; + } + if (*block).version > 1 as uint32_t { + return LZMA_OPTIONS_ERROR; + } + if (*block).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + || try_to_compress as ::core::ffi::c_int != 0 && (*block).filters.is_null() + { + return LZMA_PROG_ERROR; + } + if lzma_check_is_supported((*block).check) == 0 { + return LZMA_UNSUPPORTED_CHECK; + } + out_size = out_size.wrapping_sub(out_size.wrapping_sub(*out_pos) & 3 as size_t); + let check_size: size_t = lzma_check_size((*block).check) as size_t; + if out_size.wrapping_sub(*out_pos) <= check_size { + return LZMA_BUF_ERROR; + } + out_size = out_size.wrapping_sub(check_size); + (*block).uncompressed_size = in_size as lzma_vli; + (*block).compressed_size = lzma2_bound(in_size as uint64_t) as lzma_vli; + if (*block).compressed_size == 0 as lzma_vli { + return LZMA_DATA_ERROR; + } + let mut ret: lzma_ret = LZMA_BUF_ERROR; + if try_to_compress { + ret = block_encode_normal( + block, + allocator, + in_0, + in_size, + out, + out_pos, + out_size, + ); + } + if ret as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + if ret as ::core::ffi::c_uint + != LZMA_BUF_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + let ret_: lzma_ret = block_encode_uncompressed( + block, + in_0, + in_size, + out, + out_pos, + out_size, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + } + let mut i: size_t = (*block).compressed_size as size_t; + while i & 3 as size_t != 0 { + let fresh0 = *out_pos; + *out_pos = (*out_pos).wrapping_add(1); + *out.offset(fresh0 as isize) = 0 as uint8_t; + i = i.wrapping_add(1); + } + if check_size > 0 as size_t { + let mut check: lzma_check_state = lzma_check_state { + buffer: C2RustUnnamed { u8_0: [0; 64] }, + state: C2RustUnnamed_0 { crc32: 0 }, + }; + lzma_check_init(&raw mut check, (*block).check); + lzma_check_update(&raw mut check, (*block).check, in_0, in_size); + lzma_check_finish(&raw mut check, (*block).check); + memcpy( + &raw mut (*block).raw_check as *mut uint8_t as *mut ::core::ffi::c_void, + &raw mut check.buffer.u8_0 as *mut uint8_t as *const ::core::ffi::c_void, + check_size, + ); + memcpy( + out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, + &raw mut check.buffer.u8_0 as *mut uint8_t as *const ::core::ffi::c_void, + check_size, + ); + *out_pos = (*out_pos).wrapping_add(check_size); + } + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_buffer_encode( + mut block: *mut lzma_block, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + return block_buffer_encode( + block, + allocator, + in_0, + in_size, + out, + out_pos, + out_size, + true_0 != 0, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_uncomp_encode( + mut block: *mut lzma_block, + mut in_0: *const uint8_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + return block_buffer_encode( + block, + ::core::ptr::null::(), + in_0, + in_size, + out, + out_pos, + out_size, + false_0 != 0, + ); +} diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs new file mode 100644 index 00000000..3aca231d --- /dev/null +++ b/liblzma-rs/src/common/block_decoder.rs @@ -0,0 +1,641 @@ +extern "C" { + fn memcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: size_t, + ) -> ::core::ffi::c_int; + fn lzma_end(strm: *mut lzma_stream); + fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; + fn lzma_check_size(check: lzma_check) -> uint32_t; + fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_raw_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_filter, + ) -> lzma_ret; + fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); + fn lzma_check_update( + check: *mut lzma_check_state, + type_0: lzma_check, + buf: *const uint8_t, + size: size_t, + ); + fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block_coder { + pub sequence: C2RustUnnamed_2, + pub next: lzma_next_coder, + pub block: *mut lzma_block, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub compressed_limit: lzma_vli, + pub uncompressed_limit: lzma_vli, + pub check_pos: size_t, + pub check: lzma_check_state, + pub ignore_check: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_check_state { + pub buffer: C2RustUnnamed_1, + pub state: C2RustUnnamed_0, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub crc32: uint32_t, + pub crc64: uint64_t, + pub sha256: lzma_sha256_state, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_sha256_state { + pub state: [uint32_t; 8], + pub size: uint64_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_1 { + pub u8_0: [uint8_t; 64], + pub u32_0: [uint32_t; 16], + pub u64_0: [uint64_t; 8], +} +pub type C2RustUnnamed_2 = ::core::ffi::c_uint; +pub const SEQ_CHECK: C2RustUnnamed_2 = 2; +pub const SEQ_PADDING: C2RustUnnamed_2 = 1; +pub const SEQ_CODE: C2RustUnnamed_2 = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +#[inline] +unsafe extern "C" fn is_size_valid(mut size: lzma_vli, mut reference: lzma_vli) -> bool { + return reference == LZMA_VLI_UNKNOWN as lzma_vli || reference == size; +} +unsafe extern "C" fn block_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; + 's_177: { + let mut current_block_40: u64; + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + let in_stop: size_t = (*in_pos) + .wrapping_add( + (if (in_size.wrapping_sub(*in_pos) as lzma_vli) + < (*coder) + .compressed_limit + .wrapping_sub((*coder).compressed_size) + { + in_size.wrapping_sub(*in_pos) as lzma_vli + } else { + (*coder) + .compressed_limit + .wrapping_sub((*coder).compressed_size) + }) as size_t, + ); + let out_stop: size_t = (*out_pos) + .wrapping_add( + (if (out_size.wrapping_sub(*out_pos) as lzma_vli) + < (*coder) + .uncompressed_limit + .wrapping_sub((*coder).uncompressed_size) + { + out_size.wrapping_sub(*out_pos) as lzma_vli + } else { + (*coder) + .uncompressed_limit + .wrapping_sub((*coder).uncompressed_size) + }) as size_t, + ); + let ret: lzma_ret = (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_stop, + out, + out_pos, + out_stop, + action, + ) as lzma_ret; + let in_used: size_t = (*in_pos).wrapping_sub(in_start); + let out_used: size_t = (*out_pos).wrapping_sub(out_start); + (*coder).compressed_size = (*coder) + .compressed_size + .wrapping_add(in_used as lzma_vli); + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_add(out_used as lzma_vli); + if ret as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + let comp_done: bool = (*coder).compressed_size + == (*(*coder).block).compressed_size; + let uncomp_done: bool = (*coder).uncompressed_size + == (*(*coder).block).uncompressed_size; + if comp_done as ::core::ffi::c_int != 0 + && uncomp_done as ::core::ffi::c_int != 0 + { + return LZMA_DATA_ERROR; + } + if comp_done as ::core::ffi::c_int != 0 && *out_pos < out_size { + return LZMA_DATA_ERROR; + } + if uncomp_done as ::core::ffi::c_int != 0 && *in_pos < in_size { + return LZMA_DATA_ERROR; + } + } + if !(*coder).ignore_check && out_used > 0 as size_t { + lzma_check_update( + &raw mut (*coder).check, + (*(*coder).block).check, + out.offset(out_start as isize), + out_used, + ); + } + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + if !is_size_valid( + (*coder).compressed_size, + (*(*coder).block).compressed_size, + ) + || !is_size_valid( + (*coder).uncompressed_size, + (*(*coder).block).uncompressed_size, + ) + { + return LZMA_DATA_ERROR; + } + (*(*coder).block).compressed_size = (*coder).compressed_size; + (*(*coder).block).uncompressed_size = (*coder).uncompressed_size; + (*coder).sequence = SEQ_PADDING; + current_block_40 = 17473121293339793080; + } + 1 => { + current_block_40 = 17473121293339793080; + } + 2 => { + current_block_40 = 9393557385011460022; + } + _ => { + break 's_177; + } + } + match current_block_40 { + 17473121293339793080 => { + while (*coder).compressed_size & 3 as lzma_vli != 0 { + if *in_pos >= in_size { + return LZMA_OK; + } + (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); + let fresh0 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + if *in_0.offset(fresh0 as isize) as ::core::ffi::c_int + != 0 as ::core::ffi::c_int + { + return LZMA_DATA_ERROR; + } + } + if (*(*coder).block).check as ::core::ffi::c_uint + == LZMA_CHECK_NONE as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_STREAM_END; + } + if !(*coder).ignore_check { + lzma_check_finish(&raw mut (*coder).check, (*(*coder).block).check); + } + (*coder).sequence = SEQ_CHECK; + } + _ => {} + } + let check_size: size_t = lzma_check_size((*(*coder).block).check) as size_t; + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*(*coder).block).raw_check as *mut uint8_t, + &raw mut (*coder).check_pos, + check_size, + ); + if (*coder).check_pos < check_size { + return LZMA_OK; + } + if !(*coder).ignore_check + && lzma_check_is_supported((*(*coder).block).check) as ::core::ffi::c_int + != 0 + && memcmp( + &raw mut (*(*coder).block).raw_check as *mut uint8_t + as *const ::core::ffi::c_void, + &raw mut (*coder).check.buffer.u8_0 as *mut uint8_t + as *const ::core::ffi::c_void, + check_size, + ) != 0 as ::core::ffi::c_int + { + return LZMA_DATA_ERROR; + } + return LZMA_STREAM_END; + } + return LZMA_PROG_ERROR; +} +unsafe extern "C" fn block_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut block: *mut lzma_block, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_block_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_block_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + ), + ); + if lzma_block_unpadded_size(block) == 0 as lzma_vli + || !((*block).uncompressed_size <= LZMA_VLI_MAX as lzma_vli + || (*block).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli) + { + return LZMA_PROG_ERROR; + } + let mut coder: *mut lzma_block_coder = (*next).coder as *mut lzma_block_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_block_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + block_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + block_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + (*coder).sequence = SEQ_CODE; + (*coder).block = block; + (*coder).compressed_size = 0 as lzma_vli; + (*coder).uncompressed_size = 0 as lzma_vli; + (*coder).compressed_limit = if (*block).compressed_size + == LZMA_VLI_UNKNOWN as lzma_vli + { + (LZMA_VLI_MAX as lzma_vli & !(3 as lzma_vli)) + .wrapping_sub((*block).header_size as lzma_vli) + .wrapping_sub(lzma_check_size((*block).check) as lzma_vli) + } else { + (*block).compressed_size + }; + (*coder).uncompressed_limit = if (*block).uncompressed_size + == LZMA_VLI_UNKNOWN as lzma_vli + { + LZMA_VLI_MAX as lzma_vli + } else { + (*block).uncompressed_size + }; + (*coder).check_pos = 0 as size_t; + lzma_check_init(&raw mut (*coder).check, (*block).check); + (*coder).ignore_check = if (*block).version >= 1 as uint32_t { + (*block).ignore_check as ::core::ffi::c_int + } else { + false_0 + } != 0; + return lzma_raw_decoder_init(&raw mut (*coder).next, allocator, (*block).filters); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_decoder( + mut strm: *mut lzma_stream, + mut block: *mut lzma_block, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_block_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + block, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs new file mode 100644 index 00000000..02d50241 --- /dev/null +++ b/liblzma-rs/src/common/block_encoder.rs @@ -0,0 +1,603 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_end(strm: *mut lzma_stream); + fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; + fn lzma_check_size(check: lzma_check) -> uint32_t; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_filter_update( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + reversed_filters: *const lzma_filter, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_raw_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + ) -> lzma_ret; + fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); + fn lzma_check_update( + check: *mut lzma_check_state, + type_0: lzma_check, + buf: *const uint8_t, + size: size_t, + ); + fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block_coder { + pub next: lzma_next_coder, + pub block: *mut lzma_block, + pub sequence: C2RustUnnamed_2, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub pos: size_t, + pub check: lzma_check_state, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_check_state { + pub buffer: C2RustUnnamed_1, + pub state: C2RustUnnamed_0, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub crc32: uint32_t, + pub crc64: uint64_t, + pub sha256: lzma_sha256_state, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_sha256_state { + pub state: [uint32_t; 8], + pub size: uint64_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_1 { + pub u8_0: [uint8_t; 64], + pub u32_0: [uint32_t; 16], + pub u64_0: [uint64_t; 8], +} +pub type C2RustUnnamed_2 = ::core::ffi::c_uint; +pub const SEQ_CHECK: C2RustUnnamed_2 = 2; +pub const SEQ_PADDING: C2RustUnnamed_2 = 1; +pub const SEQ_CODE: C2RustUnnamed_2 = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +pub const LZMA_CHECK_SIZE_MAX: ::core::ffi::c_int = 64 as ::core::ffi::c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: ::core::ffi::c_int = 1024 as ::core::ffi::c_int; +pub const COMPRESSED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX + .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as ::core::ffi::c_ulonglong) + .wrapping_sub(LZMA_CHECK_SIZE_MAX as ::core::ffi::c_ulonglong) + & !(3 as ::core::ffi::c_ulonglong); +unsafe extern "C" fn block_encode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; + if (LZMA_VLI_MAX as lzma_vli).wrapping_sub((*coder).uncompressed_size) + < in_size.wrapping_sub(*in_pos) as lzma_vli + { + return LZMA_DATA_ERROR; + } + 's_142: { + let mut current_block_34: u64; + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + let ret: lzma_ret = (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + let in_used: size_t = (*in_pos).wrapping_sub(in_start); + let out_used: size_t = (*out_pos).wrapping_sub(out_start); + if (COMPRESSED_SIZE_MAX as lzma_vli) + .wrapping_sub((*coder).compressed_size) < out_used as lzma_vli + { + return LZMA_DATA_ERROR; + } + (*coder).compressed_size = (*coder) + .compressed_size + .wrapping_add(out_used as lzma_vli); + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_add(in_used as lzma_vli); + if in_used > 0 as size_t { + lzma_check_update( + &raw mut (*coder).check, + (*(*coder).block).check, + in_0.offset(in_start as isize), + in_used, + ); + } + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + || action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + (*(*coder).block).compressed_size = (*coder).compressed_size; + (*(*coder).block).uncompressed_size = (*coder).uncompressed_size; + (*coder).sequence = SEQ_PADDING; + current_block_34 = 6470892831169497455; + } + 1 => { + current_block_34 = 6470892831169497455; + } + 2 => { + current_block_34 = 47327340716975230; + } + _ => { + break 's_142; + } + } + match current_block_34 { + 6470892831169497455 => { + while (*coder).compressed_size & 3 as lzma_vli != 0 { + if *out_pos >= out_size { + return LZMA_OK; + } + *out.offset(*out_pos as isize) = 0 as uint8_t; + *out_pos = (*out_pos).wrapping_add(1); + (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); + } + if (*(*coder).block).check as ::core::ffi::c_uint + == LZMA_CHECK_NONE as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_STREAM_END; + } + lzma_check_finish(&raw mut (*coder).check, (*(*coder).block).check); + (*coder).sequence = SEQ_CHECK; + } + _ => {} + } + let check_size: size_t = lzma_check_size((*(*coder).block).check) as size_t; + lzma_bufcpy( + &raw mut (*coder).check.buffer.u8_0 as *mut uint8_t, + &raw mut (*coder).pos, + check_size, + out, + out_pos, + out_size, + ); + if (*coder).pos < check_size { + return LZMA_OK; + } + memcpy( + &raw mut (*(*coder).block).raw_check as *mut uint8_t + as *mut ::core::ffi::c_void, + &raw mut (*coder).check.buffer.u8_0 as *mut uint8_t + as *const ::core::ffi::c_void, + check_size, + ); + return LZMA_STREAM_END; + } + return LZMA_PROG_ERROR; +} +unsafe extern "C" fn block_encoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn block_encoder_update( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter, + mut reversed_filters: *const lzma_filter, +) -> lzma_ret { + let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; + if (*coder).sequence as ::core::ffi::c_uint + != SEQ_CODE as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + return lzma_next_filter_update(&raw mut (*coder).next, allocator, reversed_filters); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut block: *mut lzma_block, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_block_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_block_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + ), + ); + if block.is_null() { + return LZMA_PROG_ERROR; + } + if (*block).version > 1 as uint32_t { + return LZMA_OPTIONS_ERROR; + } + if (*block).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint { + return LZMA_PROG_ERROR; + } + if lzma_check_is_supported((*block).check) == 0 { + return LZMA_UNSUPPORTED_CHECK; + } + let mut coder: *mut lzma_block_coder = (*next).coder as *mut lzma_block_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_block_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + block_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + block_encoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).update = Some( + block_encoder_update + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + (*coder).sequence = SEQ_CODE; + (*coder).block = block; + (*coder).compressed_size = 0 as lzma_vli; + (*coder).uncompressed_size = 0 as lzma_vli; + (*coder).pos = 0 as size_t; + lzma_check_init(&raw mut (*coder).check, (*block).check); + return lzma_raw_encoder_init(&raw mut (*coder).next, allocator, (*block).filters); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_encoder( + mut strm: *mut lzma_stream, + mut block: *mut lzma_block, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_block_encoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + block, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal) + .supported_actions[LZMA_SYNC_FLUSH as ::core::ffi::c_int as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs new file mode 100644 index 00000000..974608f1 --- /dev/null +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -0,0 +1,244 @@ +extern "C" { + fn lzma_vli_decode( + vli: *mut lzma_vli, + vli_pos: *mut size_t, + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); + fn lzma_filter_flags_decode( + filter: *mut lzma_filter, + allocator: *const lzma_allocator, + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { + let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; + num + |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + num + |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 16 as ::core::ffi::c_int; + num + |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) + << 24 as ::core::ffi::c_int; + return num; +} +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +pub const LZMA_FILTERS_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_block_header_decode( + mut block: *mut lzma_block, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, +) -> lzma_ret { + if block.is_null() || (*block).filters.is_null() || in_0.is_null() { + return LZMA_PROG_ERROR; + } + let mut i: size_t = 0 as size_t; + while i <= LZMA_FILTERS_MAX as size_t { + (*(*block).filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN as lzma_vli; + let ref mut fresh0 = (*(*block).filters.offset(i as isize)).options; + *fresh0 = NULL; + i = i.wrapping_add(1); + } + if (*block).version > 1 as uint32_t { + (*block).version = 1 as uint32_t; + } + (*block).ignore_check = false_0 as lzma_bool; + if (*in_0.offset(0 as ::core::ffi::c_int as isize) as uint32_t) + .wrapping_add(1 as uint32_t) + .wrapping_mul(4 as uint32_t) != (*block).header_size + || (*block).check as ::core::ffi::c_uint + > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + let in_size: size_t = (*block).header_size.wrapping_sub(4 as uint32_t) as size_t; + if lzma_crc32(in_0, in_size, 0 as uint32_t) + != read32le(in_0.offset(in_size as isize)) + { + return LZMA_DATA_ERROR; + } + if *in_0.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + & 0x3c as ::core::ffi::c_int != 0 + { + return LZMA_OPTIONS_ERROR; + } + let mut in_pos: size_t = 2 as size_t; + if *in_0.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + & 0x40 as ::core::ffi::c_int != 0 + { + let ret_: lzma_ret = lzma_vli_decode( + &raw mut (*block).compressed_size, + ::core::ptr::null_mut::(), + in_0, + &raw mut in_pos, + in_size, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + if lzma_block_unpadded_size(block) == 0 as lzma_vli { + return LZMA_DATA_ERROR; + } + } else { + (*block).compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; + } + if *in_0.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + & 0x80 as ::core::ffi::c_int != 0 + { + let ret__0: lzma_ret = lzma_vli_decode( + &raw mut (*block).uncompressed_size, + ::core::ptr::null_mut::(), + in_0, + &raw mut in_pos, + in_size, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__0; + } + } else { + (*block).uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; + } + let filter_count: size_t = (*in_0.offset(1 as ::core::ffi::c_int as isize) + as ::core::ffi::c_uint & 3 as ::core::ffi::c_uint) + .wrapping_add(1 as ::core::ffi::c_uint) as size_t; + let mut i_0: size_t = 0 as size_t; + while i_0 < filter_count { + let ret: lzma_ret = lzma_filter_flags_decode( + (*block).filters.offset(i_0 as isize) as *mut lzma_filter, + allocator, + in_0, + &raw mut in_pos, + in_size, + ) as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_filters_free((*block).filters, allocator); + return ret; + } + i_0 = i_0.wrapping_add(1); + } + while in_pos < in_size { + let fresh1 = in_pos; + in_pos = in_pos.wrapping_add(1); + if *in_0.offset(fresh1 as isize) as ::core::ffi::c_int != 0 as ::core::ffi::c_int + { + lzma_filters_free((*block).filters, allocator); + return LZMA_OPTIONS_ERROR; + } + } + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs new file mode 100644 index 00000000..10952de2 --- /dev/null +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -0,0 +1,260 @@ +extern "C" { + fn memset( + __b: *mut ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __len: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_vli_encode( + vli: lzma_vli, + vli_pos: *mut size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; + fn lzma_vli_size(vli: lzma_vli) -> uint32_t; + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_filter_flags_size( + size: *mut uint32_t, + filter: *const lzma_filter, + ) -> lzma_ret; + fn lzma_filter_flags_encode( + filter: *const lzma_filter, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; + fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +#[inline] +unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { + *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; + *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) + as uint8_t; +} +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTERS_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_block_header_size(mut block: *mut lzma_block) -> lzma_ret { + if (*block).version > 1 as uint32_t { + return LZMA_OPTIONS_ERROR; + } + let mut size: uint32_t = (1 as ::core::ffi::c_int + 1 as ::core::ffi::c_int + + 4 as ::core::ffi::c_int) as uint32_t; + if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + let add: uint32_t = lzma_vli_size((*block).compressed_size) as uint32_t; + if add == 0 as uint32_t || (*block).compressed_size == 0 as lzma_vli { + return LZMA_PROG_ERROR; + } + size = size.wrapping_add(add); + } + if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + let add_0: uint32_t = lzma_vli_size((*block).uncompressed_size) as uint32_t; + if add_0 == 0 as uint32_t { + return LZMA_PROG_ERROR; + } + size = size.wrapping_add(add_0); + } + if (*block).filters.is_null() + || (*(*block).filters.offset(0 as ::core::ffi::c_int as isize)).id + == LZMA_VLI_UNKNOWN as lzma_vli + { + return LZMA_PROG_ERROR; + } + let mut i: size_t = 0 as size_t; + while (*(*block).filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + if i == LZMA_FILTERS_MAX as size_t { + return LZMA_PROG_ERROR; + } + let mut add_1: uint32_t = 0; + let ret_: lzma_ret = lzma_filter_flags_size( + &raw mut add_1, + (*block).filters.offset(i as isize), + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + size = size.wrapping_add(add_1); + i = i.wrapping_add(1); + } + (*block).header_size = size.wrapping_add(3 as uint32_t) & !(3 as uint32_t); + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_header_encode( + mut block: *const lzma_block, + mut out: *mut uint8_t, +) -> lzma_ret { + if lzma_block_unpadded_size(block) == 0 as lzma_vli + || !((*block).uncompressed_size <= LZMA_VLI_MAX as lzma_vli + || (*block).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli) + { + return LZMA_PROG_ERROR; + } + let out_size: size_t = (*block).header_size.wrapping_sub(4 as uint32_t) as size_t; + *out.offset(0 as ::core::ffi::c_int as isize) = out_size.wrapping_div(4 as size_t) + as uint8_t; + *out.offset(1 as ::core::ffi::c_int as isize) = 0 as uint8_t; + let mut out_pos: size_t = 2 as size_t; + if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + let ret_: lzma_ret = lzma_vli_encode( + (*block).compressed_size, + ::core::ptr::null_mut::(), + out, + &raw mut out_pos, + out_size, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ref mut fresh0 = *out.offset(1 as ::core::ffi::c_int as isize); + *fresh0 = (*fresh0 as ::core::ffi::c_int | 0x40 as ::core::ffi::c_int) + as uint8_t; + } + if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + let ret__0: lzma_ret = lzma_vli_encode( + (*block).uncompressed_size, + ::core::ptr::null_mut::(), + out, + &raw mut out_pos, + out_size, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__0; + } + let ref mut fresh1 = *out.offset(1 as ::core::ffi::c_int as isize); + *fresh1 = (*fresh1 as ::core::ffi::c_int | 0x80 as ::core::ffi::c_int) + as uint8_t; + } + if (*block).filters.is_null() + || (*(*block).filters.offset(0 as ::core::ffi::c_int as isize)).id + == LZMA_VLI_UNKNOWN as lzma_vli + { + return LZMA_PROG_ERROR; + } + let mut filter_count: size_t = 0 as size_t; + loop { + if filter_count == LZMA_FILTERS_MAX as size_t { + return LZMA_PROG_ERROR; + } + let ret__1: lzma_ret = lzma_filter_flags_encode( + (*block).filters.offset(filter_count as isize), + out, + &raw mut out_pos, + out_size, + ) as lzma_ret; + if ret__1 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__1; + } + filter_count = filter_count.wrapping_add(1); + if !((*(*block).filters.offset(filter_count as isize)).id + != LZMA_VLI_UNKNOWN as lzma_vli) + { + break; + } + } + let ref mut fresh2 = *out.offset(1 as ::core::ffi::c_int as isize); + *fresh2 = (*fresh2 as size_t | filter_count.wrapping_sub(1 as size_t)) as uint8_t; + memset( + out.offset(out_pos as isize) as *mut ::core::ffi::c_void, + 0 as ::core::ffi::c_int, + out_size.wrapping_sub(out_pos), + ); + write32le(out.offset(out_size as isize), lzma_crc32(out, out_size, 0 as uint32_t)); + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs new file mode 100644 index 00000000..5de1afe7 --- /dev/null +++ b/liblzma-rs/src/common/block_util.rs @@ -0,0 +1,157 @@ +extern "C" { + fn lzma_check_size(check: lzma_check) -> uint32_t; +} +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MIN: ::core::ffi::c_int = 8 as ::core::ffi::c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: ::core::ffi::c_int = 1024 as ::core::ffi::c_int; +pub const UNPADDED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX + & !(3 as ::core::ffi::c_ulonglong); +#[inline] +unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { + return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_compressed_size( + mut block: *mut lzma_block, + mut unpadded_size: lzma_vli, +) -> lzma_ret { + if lzma_block_unpadded_size(block) == 0 as lzma_vli { + return LZMA_PROG_ERROR; + } + let container_size: uint32_t = (*block) + .header_size + .wrapping_add(lzma_check_size((*block).check) as uint32_t); + if unpadded_size <= container_size as lzma_vli { + return LZMA_DATA_ERROR; + } + let compressed_size: lzma_vli = unpadded_size + .wrapping_sub(container_size as lzma_vli); + if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli + && (*block).compressed_size != compressed_size + { + return LZMA_DATA_ERROR; + } + (*block).compressed_size = compressed_size; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_unpadded_size( + mut block: *const lzma_block, +) -> lzma_vli { + if block.is_null() || (*block).version > 1 as uint32_t + || (*block).header_size < LZMA_BLOCK_HEADER_SIZE_MIN as uint32_t + || (*block).header_size > LZMA_BLOCK_HEADER_SIZE_MAX as uint32_t + || (*block).header_size & 3 as uint32_t != 0 + || !((*block).compressed_size <= LZMA_VLI_MAX as lzma_vli + || (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli) + || (*block).compressed_size == 0 as lzma_vli + || (*block).check as ::core::ffi::c_uint + > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + { + return 0 as lzma_vli; + } + if (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli { + return LZMA_VLI_UNKNOWN as lzma_vli; + } + let unpadded_size: lzma_vli = (*block) + .compressed_size + .wrapping_add((*block).header_size as lzma_vli) + .wrapping_add(lzma_check_size((*block).check) as lzma_vli); + if unpadded_size > UNPADDED_SIZE_MAX as lzma_vli { + return 0 as lzma_vli; + } + return unpadded_size; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_block_total_size( + mut block: *const lzma_block, +) -> lzma_vli { + let mut unpadded_size: lzma_vli = lzma_block_unpadded_size(block); + if unpadded_size != LZMA_VLI_UNKNOWN as lzma_vli { + unpadded_size = vli_ceil4(unpadded_size); + } + return unpadded_size; +} diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs new file mode 100644 index 00000000..4c27d9b0 --- /dev/null +++ b/liblzma-rs/src/common/common.rs @@ -0,0 +1,690 @@ +extern "C" { + fn malloc(__size: size_t) -> *mut ::core::ffi::c_void; + fn calloc(__count: size_t, __size: size_t) -> *mut ::core::ffi::c_void; + fn free(_: *mut ::core::ffi::c_void); + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn memset( + __b: *mut ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __len: size_t, + ) -> *mut ::core::ffi::c_void; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VERSION_MAJOR: ::core::ffi::c_int = 5 as ::core::ffi::c_int; +pub const LZMA_VERSION_MINOR: ::core::ffi::c_int = 8 as ::core::ffi::c_int; +pub const LZMA_VERSION_PATCH: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const LZMA_VERSION_STABILITY: ::core::ffi::c_int = LZMA_VERSION_STABILITY_STABLE; +pub const LZMA_VERSION_STABILITY_STABLE: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const LZMA_VERSION: ::core::ffi::c_uint = (LZMA_VERSION_MAJOR as ::core::ffi::c_uint) + .wrapping_mul(10000000 as ::core::ffi::c_uint) + .wrapping_add( + (LZMA_VERSION_MINOR as ::core::ffi::c_uint) + .wrapping_mul(10000 as ::core::ffi::c_uint), + ) + .wrapping_add( + (LZMA_VERSION_PATCH as ::core::ffi::c_uint) + .wrapping_mul(10 as ::core::ffi::c_uint), + ) + .wrapping_add(LZMA_VERSION_STABILITY as ::core::ffi::c_uint); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_TIMED_OUT: ::core::ffi::c_uint = 101 as ::core::ffi::c_uint; +#[no_mangle] +pub unsafe extern "C" fn lzma_version_number() -> uint32_t { + return LZMA_VERSION as uint32_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_version_string() -> *const ::core::ffi::c_char { + return b"5.8.2\0" as *const u8 as *const ::core::ffi::c_char; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_alloc( + mut size: size_t, + mut allocator: *const lzma_allocator, +) -> *mut ::core::ffi::c_void { + if size == 0 as size_t { + size = 1 as size_t; + } + let mut ptr: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, + >(); + if !allocator.is_null() && (*allocator).alloc.is_some() { + ptr = (*allocator) + .alloc + .expect("non-null function pointer")((*allocator).opaque, 1 as size_t, size); + } else { + ptr = malloc(size); + } + return ptr; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_alloc_zero( + mut size: size_t, + mut allocator: *const lzma_allocator, +) -> *mut ::core::ffi::c_void { + if size == 0 as size_t { + size = 1 as size_t; + } + let mut ptr: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, + >(); + if !allocator.is_null() && (*allocator).alloc.is_some() { + ptr = (*allocator) + .alloc + .expect("non-null function pointer")((*allocator).opaque, 1 as size_t, size); + if !ptr.is_null() { + memset(ptr, 0 as ::core::ffi::c_int, size); + } + } else { + ptr = calloc(1 as size_t, size); + } + return ptr; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_free( + mut ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + if !allocator.is_null() && (*allocator).free.is_some() { + (*allocator).free.expect("non-null function pointer")((*allocator).opaque, ptr); + } else { + free(ptr); + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_bufcpy( + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> size_t { + let in_avail: size_t = in_size.wrapping_sub(*in_pos); + let out_avail: size_t = out_size.wrapping_sub(*out_pos); + let copy_size: size_t = if in_avail < out_avail { in_avail } else { out_avail }; + if copy_size > 0 as size_t { + memcpy( + out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, + in_0.offset(*in_pos as isize) as *const ::core::ffi::c_void, + copy_size, + ); + } + *in_pos = (*in_pos).wrapping_add(copy_size); + *out_pos = (*out_pos).wrapping_add(copy_size); + return copy_size; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_next_filter_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + if ::core::mem::transmute::< + lzma_init_function, + uintptr_t, + >((*filters.offset(0 as ::core::ffi::c_int as isize)).init) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + lzma_init_function, + uintptr_t, + >((*filters.offset(0 as ::core::ffi::c_int as isize)).init); + (*next).id = (*filters.offset(0 as ::core::ffi::c_int as isize)).id; + return (if (*filters.offset(0 as ::core::ffi::c_int as isize)).init.is_none() { + LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + } else { + (*filters.offset(0 as ::core::ffi::c_int as isize)) + .init + .expect("non-null function pointer")(next, allocator, filters) + as ::core::ffi::c_uint + }) as lzma_ret; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_next_filter_update( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut reversed_filters: *const lzma_filter, +) -> lzma_ret { + if (*reversed_filters.offset(0 as ::core::ffi::c_int as isize)).id != (*next).id { + return LZMA_PROG_ERROR; + } + if (*reversed_filters.offset(0 as ::core::ffi::c_int as isize)).id + == LZMA_VLI_UNKNOWN as lzma_vli + { + return LZMA_OK; + } + return (*next) + .update + .expect( + "non-null function pointer", + )( + (*next).coder, + allocator, + ::core::ptr::null::(), + reversed_filters, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_next_end( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, +) { + if (*next).init != ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t { + if (*next).end.is_some() { + (*next).end.expect("non-null function pointer")((*next).coder, allocator); + } else { + lzma_free((*next).coder, allocator); + } + *next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_strm_init(mut strm: *mut lzma_stream) -> lzma_ret { + if strm.is_null() { + return LZMA_PROG_ERROR; + } + if (*strm).internal.is_null() { + (*strm).internal = lzma_alloc( + ::core::mem::size_of::() as size_t, + (*strm).allocator, + ) as *mut lzma_internal; + if (*strm).internal.is_null() { + return LZMA_MEM_ERROR; + } + (*(*strm).internal).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + memset( + &raw mut (*(*strm).internal).supported_actions as *mut bool + as *mut ::core::ffi::c_void, + 0 as ::core::ffi::c_int, + ::core::mem::size_of::<[bool; 5]>() as size_t, + ); + (*(*strm).internal).sequence = ISEQ_RUN; + (*(*strm).internal).allow_buf_error = false_0 != 0; + (*strm).total_in = 0 as uint64_t; + (*strm).total_out = 0 as uint64_t; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_code( + mut strm: *mut lzma_stream, + mut action: lzma_action, +) -> lzma_ret { + if (*strm).next_in.is_null() && (*strm).avail_in != 0 as size_t + || (*strm).next_out.is_null() && (*strm).avail_out != 0 as size_t + || (*strm).internal.is_null() || (*(*strm).internal).next.code.is_none() + || action as ::core::ffi::c_uint + > LZMA_FULL_BARRIER as ::core::ffi::c_int as ::core::ffi::c_uint + || !(*(*strm).internal).supported_actions[action as usize] + { + return LZMA_PROG_ERROR; + } + if !(*strm).reserved_ptr1.is_null() || !(*strm).reserved_ptr2.is_null() + || !(*strm).reserved_ptr3.is_null() || !(*strm).reserved_ptr4.is_null() + || (*strm).reserved_int2 != 0 as uint64_t || (*strm).reserved_int3 != 0 as size_t + || (*strm).reserved_int4 != 0 as size_t + || (*strm).reserved_enum1 as ::core::ffi::c_uint + != LZMA_RESERVED_ENUM as ::core::ffi::c_int as ::core::ffi::c_uint + || (*strm).reserved_enum2 as ::core::ffi::c_uint + != LZMA_RESERVED_ENUM as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_OPTIONS_ERROR; + } + match (*(*strm).internal).sequence as ::core::ffi::c_uint { + 0 => { + match action as ::core::ffi::c_uint { + 1 => { + (*(*strm).internal).sequence = ISEQ_SYNC_FLUSH; + } + 2 => { + (*(*strm).internal).sequence = ISEQ_FULL_FLUSH; + } + 3 => { + (*(*strm).internal).sequence = ISEQ_FINISH; + } + 4 => { + (*(*strm).internal).sequence = ISEQ_FULL_BARRIER; + } + 0 | _ => {} + } + } + 1 => { + if action as ::core::ffi::c_uint + != LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + || (*(*strm).internal).avail_in != (*strm).avail_in + { + return LZMA_PROG_ERROR; + } + } + 2 => { + if action as ::core::ffi::c_uint + != LZMA_FULL_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + || (*(*strm).internal).avail_in != (*strm).avail_in + { + return LZMA_PROG_ERROR; + } + } + 3 => { + if action as ::core::ffi::c_uint + != LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + || (*(*strm).internal).avail_in != (*strm).avail_in + { + return LZMA_PROG_ERROR; + } + } + 4 => { + if action as ::core::ffi::c_uint + != LZMA_FULL_BARRIER as ::core::ffi::c_int as ::core::ffi::c_uint + || (*(*strm).internal).avail_in != (*strm).avail_in + { + return LZMA_PROG_ERROR; + } + } + 5 => return LZMA_STREAM_END, + 6 | _ => return LZMA_PROG_ERROR, + } + let mut in_pos: size_t = 0 as size_t; + let mut out_pos: size_t = 0 as size_t; + let mut ret: lzma_ret = (*(*strm).internal) + .next + .code + .expect( + "non-null function pointer", + )( + (*(*strm).internal).next.coder, + (*strm).allocator, + (*strm).next_in, + &raw mut in_pos, + (*strm).avail_in, + (*strm).next_out, + &raw mut out_pos, + (*strm).avail_out, + action, + ); + if in_pos > 0 as size_t { + (*strm).next_in = (*strm).next_in.offset(in_pos as isize); + (*strm).avail_in = (*strm).avail_in.wrapping_sub(in_pos); + (*strm).total_in = (*strm).total_in.wrapping_add(in_pos as uint64_t); + } + if out_pos > 0 as size_t { + (*strm).next_out = (*strm).next_out.offset(out_pos as isize); + (*strm).avail_out = (*strm).avail_out.wrapping_sub(out_pos); + (*strm).total_out = (*strm).total_out.wrapping_add(out_pos as uint64_t); + } + (*(*strm).internal).avail_in = (*strm).avail_in; + let mut current_block_49: u64; + match ret as ::core::ffi::c_uint { + 0 => { + if out_pos == 0 as size_t && in_pos == 0 as size_t { + if (*(*strm).internal).allow_buf_error { + ret = LZMA_BUF_ERROR; + } else { + (*(*strm).internal).allow_buf_error = true_0 != 0; + } + } else { + (*(*strm).internal).allow_buf_error = false_0 != 0; + } + current_block_49 = 12556861819962772176; + } + 101 => { + (*(*strm).internal).allow_buf_error = false_0 != 0; + ret = LZMA_OK; + current_block_49 = 12556861819962772176; + } + 12 => { + (*(*strm).internal).allow_buf_error = false_0 != 0; + if (*(*strm).internal).sequence as ::core::ffi::c_uint + == ISEQ_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*(*strm).internal).sequence = ISEQ_RUN; + } + current_block_49 = 12556861819962772176; + } + 1 => { + if (*(*strm).internal).sequence as ::core::ffi::c_uint + == ISEQ_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + || (*(*strm).internal).sequence as ::core::ffi::c_uint + == ISEQ_FULL_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + || (*(*strm).internal).sequence as ::core::ffi::c_uint + == ISEQ_FULL_BARRIER as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*(*strm).internal).sequence = ISEQ_RUN; + } else { + (*(*strm).internal).sequence = ISEQ_END; + } + current_block_49 = 16143107162343188004; + } + 2 | 3 | 4 | 6 => { + current_block_49 = 16143107162343188004; + } + _ => { + (*(*strm).internal).sequence = ISEQ_ERROR; + current_block_49 = 12556861819962772176; + } + } + match current_block_49 { + 16143107162343188004 => { + (*(*strm).internal).allow_buf_error = false_0 != 0; + } + _ => {} + } + return ret; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_end(mut strm: *mut lzma_stream) { + if !strm.is_null() && !(*strm).internal.is_null() { + lzma_next_end(&raw mut (*(*strm).internal).next, (*strm).allocator); + lzma_free((*strm).internal as *mut ::core::ffi::c_void, (*strm).allocator); + (*strm).internal = ::core::ptr::null_mut::(); + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_get_progress( + mut strm: *mut lzma_stream, + mut progress_in: *mut uint64_t, + mut progress_out: *mut uint64_t, +) { + if (*(*strm).internal).next.get_progress.is_some() { + (*(*strm).internal) + .next + .get_progress + .expect( + "non-null function pointer", + )((*(*strm).internal).next.coder, progress_in, progress_out); + } else { + *progress_in = (*strm).total_in; + *progress_out = (*strm).total_out; + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_get_check(mut strm: *const lzma_stream) -> lzma_check { + if (*(*strm).internal).next.get_check.is_none() { + return LZMA_CHECK_NONE; + } + return (*(*strm).internal) + .next + .get_check + .expect("non-null function pointer")((*(*strm).internal).next.coder); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_memusage(mut strm: *const lzma_stream) -> uint64_t { + let mut memusage: uint64_t = 0; + let mut old_memlimit: uint64_t = 0; + if strm.is_null() || (*strm).internal.is_null() + || (*(*strm).internal).next.memconfig.is_none() + || (*(*strm).internal) + .next + .memconfig + .expect( + "non-null function pointer", + )( + (*(*strm).internal).next.coder, + &raw mut memusage, + &raw mut old_memlimit, + 0 as uint64_t, + ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return 0 as uint64_t; + } + return memusage; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_memlimit_get(mut strm: *const lzma_stream) -> uint64_t { + let mut old_memlimit: uint64_t = 0; + let mut memusage: uint64_t = 0; + if strm.is_null() || (*strm).internal.is_null() + || (*(*strm).internal).next.memconfig.is_none() + || (*(*strm).internal) + .next + .memconfig + .expect( + "non-null function pointer", + )( + (*(*strm).internal).next.coder, + &raw mut memusage, + &raw mut old_memlimit, + 0 as uint64_t, + ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return 0 as uint64_t; + } + return old_memlimit; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_memlimit_set( + mut strm: *mut lzma_stream, + mut new_memlimit: uint64_t, +) -> lzma_ret { + let mut old_memlimit: uint64_t = 0; + let mut memusage: uint64_t = 0; + if strm.is_null() || (*strm).internal.is_null() + || (*(*strm).internal).next.memconfig.is_none() + { + return LZMA_PROG_ERROR; + } + if new_memlimit == 0 as uint64_t { + new_memlimit = 1 as uint64_t; + } + return (*(*strm).internal) + .next + .memconfig + .expect( + "non-null function pointer", + )( + (*(*strm).internal).next.coder, + &raw mut memusage, + &raw mut old_memlimit, + new_memlimit, + ); +} diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs new file mode 100644 index 00000000..6af32897 --- /dev/null +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -0,0 +1,169 @@ +extern "C" { + fn lzma_stream_buffer_encode( + filters: *mut lzma_filter, + check: lzma_check, + allocator: *const lzma_allocator, + in_0: *const uint8_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: uint32_t) -> bool; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_easy { + pub filters: [lzma_filter; 5], + pub opt_lzma: lzma_options_lzma, +} +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_buffer_encode( + mut preset: uint32_t, + mut check: lzma_check, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + let mut opt_easy: lzma_options_easy = lzma_options_easy { + filters: [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5], + opt_lzma: lzma_options_lzma { + dict_size: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + lc: 0, + lp: 0, + pb: 0, + mode: 0 as lzma_mode, + nice_len: 0, + mf: 0 as lzma_match_finder, + depth: 0, + ext_flags: 0, + ext_size_low: 0, + ext_size_high: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + }; + if lzma_easy_preset(&raw mut opt_easy, preset) { + return LZMA_OPTIONS_ERROR; + } + return lzma_stream_buffer_encode( + &raw mut opt_easy.filters as *mut lzma_filter, + check, + allocator, + in_0, + in_size, + out, + out_pos, + out_size, + ); +} diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs new file mode 100644 index 00000000..d77825e0 --- /dev/null +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -0,0 +1,99 @@ +extern "C" { + fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> uint64_t; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: uint32_t) -> bool; +} +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_easy { + pub filters: [lzma_filter; 5], + pub opt_lzma: lzma_options_lzma, +} +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_decoder_memusage(mut preset: uint32_t) -> uint64_t { + let mut opt_easy: lzma_options_easy = lzma_options_easy { + filters: [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5], + opt_lzma: lzma_options_lzma { + dict_size: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + lc: 0, + lp: 0, + pb: 0, + mode: 0 as lzma_mode, + nice_len: 0, + mf: 0 as lzma_match_finder, + depth: 0, + ext_flags: 0, + ext_size_low: 0, + ext_size_high: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + }; + if lzma_easy_preset(&raw mut opt_easy, preset) { + return UINT32_MAX as uint64_t; + } + return lzma_raw_decoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter); +} diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs new file mode 100644 index 00000000..5e1a81d0 --- /dev/null +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -0,0 +1,260 @@ +extern "C" { + fn lzma_stream_encoder( + strm: *mut lzma_stream, + filters: *const lzma_filter, + check: lzma_check, + ) -> lzma_ret; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: uint32_t) -> bool; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_easy { + pub filters: [lzma_filter; 5], + pub opt_lzma: lzma_options_lzma, +} +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_encoder( + mut strm: *mut lzma_stream, + mut preset: uint32_t, + mut check: lzma_check, +) -> lzma_ret { + let mut opt_easy: lzma_options_easy = lzma_options_easy { + filters: [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5], + opt_lzma: lzma_options_lzma { + dict_size: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + lc: 0, + lp: 0, + pb: 0, + mode: 0 as lzma_mode, + nice_len: 0, + mf: 0 as lzma_match_finder, + depth: 0, + ext_flags: 0, + ext_size_low: 0, + ext_size_high: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + }; + if lzma_easy_preset(&raw mut opt_easy, preset) { + return LZMA_OPTIONS_ERROR; + } + return lzma_stream_encoder( + strm, + &raw mut opt_easy.filters as *mut lzma_filter, + check, + ); +} diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs new file mode 100644 index 00000000..a942c783 --- /dev/null +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -0,0 +1,99 @@ +extern "C" { + fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> uint64_t; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: uint32_t) -> bool; +} +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_easy { + pub filters: [lzma_filter; 5], + pub opt_lzma: lzma_options_lzma, +} +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_encoder_memusage(mut preset: uint32_t) -> uint64_t { + let mut opt_easy: lzma_options_easy = lzma_options_easy { + filters: [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5], + opt_lzma: lzma_options_lzma { + dict_size: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + lc: 0, + lp: 0, + pb: 0, + mode: 0 as lzma_mode, + nice_len: 0, + mf: 0 as lzma_match_finder, + depth: 0, + ext_flags: 0, + ext_size_low: 0, + ext_size_high: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + }; + if lzma_easy_preset(&raw mut opt_easy, preset) { + return UINT32_MAX as uint64_t; + } + return lzma_raw_encoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter); +} diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs new file mode 100644 index 00000000..eae4d0be --- /dev/null +++ b/liblzma-rs/src/common/easy_preset.rs @@ -0,0 +1,81 @@ +extern "C" { + fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: uint32_t) -> lzma_bool; +} +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_easy { + pub filters: [lzma_filter; 5], + pub opt_lzma: lzma_options_lzma, +} +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_preset( + mut opt_easy: *mut lzma_options_easy, + mut preset: uint32_t, +) -> bool { + if lzma_lzma_preset(&raw mut (*opt_easy).opt_lzma, preset) != 0 { + return true_0 != 0; + } + (*opt_easy).filters[0 as ::core::ffi::c_int as usize].id = LZMA_FILTER_LZMA2 + as lzma_vli; + (*opt_easy).filters[0 as ::core::ffi::c_int as usize].options = &raw mut (*opt_easy) + .opt_lzma as *mut ::core::ffi::c_void; + (*opt_easy).filters[1 as ::core::ffi::c_int as usize].id = LZMA_VLI_UNKNOWN + as lzma_vli; + return false_0 != 0; +} diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs new file mode 100644 index 00000000..5b8d14d9 --- /dev/null +++ b/liblzma-rs/src/common/file_info.rs @@ -0,0 +1,1064 @@ +#[repr(C)] +pub struct lzma_index_s { _opaque: [u8; 0] } +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_stream_header_decode( + options: *mut lzma_stream_flags, + in_0: *const uint8_t, + ) -> lzma_ret; + fn lzma_stream_footer_decode( + options: *mut lzma_stream_flags, + in_0: *const uint8_t, + ) -> lzma_ret; + fn lzma_stream_flags_compare( + a: *const lzma_stream_flags, + b: *const lzma_stream_flags, + ) -> lzma_ret; + fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> uint64_t; + fn lzma_index_memused(i: *const lzma_index) -> uint64_t; + fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); + fn lzma_index_stream_flags( + i: *mut lzma_index, + stream_flags: *const lzma_stream_flags, + ) -> lzma_ret; + fn lzma_index_stream_padding( + i: *mut lzma_index, + stream_padding: lzma_vli, + ) -> lzma_ret; + fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli; + fn lzma_index_cat( + dest: *mut lzma_index, + src: *mut lzma_index, + allocator: *const lzma_allocator, + ) -> lzma_ret; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_index_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + i: *mut *mut lzma_index, + memlimit: uint64_t, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +pub type lzma_index = lzma_index_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_file_info_coder { + pub sequence: C2RustUnnamed_0, + pub file_cur_pos: uint64_t, + pub file_target_pos: uint64_t, + pub file_size: uint64_t, + pub index_decoder: lzma_next_coder, + pub index_remaining: lzma_vli, + pub this_index: *mut lzma_index, + pub stream_padding: lzma_vli, + pub combined_index: *mut lzma_index, + pub dest_index: *mut *mut lzma_index, + pub external_seek_pos: *mut uint64_t, + pub memlimit: uint64_t, + pub first_header_flags: lzma_stream_flags, + pub header_flags: lzma_stream_flags, + pub footer_flags: lzma_stream_flags, + pub temp_pos: size_t, + pub temp_size: size_t, + pub temp: [uint8_t; 8192], +} +pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub const SEQ_HEADER_COMPARE: C2RustUnnamed_0 = 7; +pub const SEQ_HEADER_DECODE: C2RustUnnamed_0 = 6; +pub const SEQ_INDEX_DECODE: C2RustUnnamed_0 = 5; +pub const SEQ_INDEX_INIT: C2RustUnnamed_0 = 4; +pub const SEQ_FOOTER: C2RustUnnamed_0 = 3; +pub const SEQ_PADDING_DECODE: C2RustUnnamed_0 = 2; +pub const SEQ_PADDING_SEEK: C2RustUnnamed_0 = 1; +pub const SEQ_MAGIC_BYTES: C2RustUnnamed_0 = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +unsafe extern "C" fn fill_temp( + mut coder: *mut lzma_file_info_coder, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> bool { + (*coder).file_cur_pos = (*coder) + .file_cur_pos + .wrapping_add( + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).temp as *mut uint8_t, + &raw mut (*coder).temp_pos, + (*coder).temp_size, + ) as uint64_t, + ); + return (*coder).temp_pos < (*coder).temp_size; +} +unsafe extern "C" fn seek_to_pos( + mut coder: *mut lzma_file_info_coder, + mut target_pos: uint64_t, + mut in_start: size_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> bool { + let pos_min: uint64_t = (*coder) + .file_cur_pos + .wrapping_sub((*in_pos).wrapping_sub(in_start) as uint64_t); + let pos_max: uint64_t = (*coder) + .file_cur_pos + .wrapping_add(in_size.wrapping_sub(*in_pos) as uint64_t); + let mut external_seek_needed: bool = false; + if target_pos >= pos_min && target_pos <= pos_max { + *in_pos = (*in_pos) + .wrapping_add(target_pos.wrapping_sub((*coder).file_cur_pos) as size_t); + external_seek_needed = false_0 != 0; + } else { + *(*coder).external_seek_pos = target_pos; + external_seek_needed = true_0 != 0; + *in_pos = in_size; + } + (*coder).file_cur_pos = target_pos; + return external_seek_needed; +} +unsafe extern "C" fn reverse_seek( + mut coder: *mut lzma_file_info_coder, + mut in_start: size_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + if (*coder).file_target_pos + < (2 as ::core::ffi::c_int * LZMA_STREAM_HEADER_SIZE) as uint64_t + { + return LZMA_DATA_ERROR; + } + (*coder).temp_pos = 0 as size_t; + if (*coder).file_target_pos.wrapping_sub(LZMA_STREAM_HEADER_SIZE as uint64_t) + < ::core::mem::size_of::<[uint8_t; 8192]>() as uint64_t + { + (*coder).temp_size = (*coder) + .file_target_pos + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as uint64_t) as size_t; + } else { + (*coder).temp_size = ::core::mem::size_of::<[uint8_t; 8192]>() as usize + as size_t; + } + if seek_to_pos( + coder, + (*coder).file_target_pos.wrapping_sub((*coder).temp_size as uint64_t), + in_start, + in_pos, + in_size, + ) { + return LZMA_SEEK_NEEDED; + } + return LZMA_OK; +} +unsafe extern "C" fn get_padding_size( + mut buf: *const uint8_t, + mut buf_size: size_t, +) -> size_t { + let mut padding: size_t = 0 as size_t; + while buf_size > 0 as size_t + && { + buf_size = buf_size.wrapping_sub(1); + *buf.offset(buf_size as isize) as ::core::ffi::c_int + == 0 as ::core::ffi::c_int + } + { + padding = padding.wrapping_add(1); + } + return padding; +} +unsafe extern "C" fn hide_format_error(mut ret: lzma_ret) -> lzma_ret { + if ret as ::core::ffi::c_uint + == LZMA_FORMAT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_DATA_ERROR; + } + return ret; +} +unsafe extern "C" fn decode_index( + mut coder: *mut lzma_file_info_coder, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut update_file_cur_pos: bool, +) -> lzma_ret { + let in_start: size_t = *in_pos; + let ret: lzma_ret = (*coder) + .index_decoder + .code + .expect( + "non-null function pointer", + )( + (*coder).index_decoder.coder, + allocator, + in_0, + in_pos, + in_size, + ::core::ptr::null_mut::(), + ::core::ptr::null_mut::(), + 0 as size_t, + LZMA_RUN, + ) as lzma_ret; + (*coder).index_remaining = (*coder) + .index_remaining + .wrapping_sub((*in_pos).wrapping_sub(in_start) as lzma_vli); + if update_file_cur_pos { + (*coder).file_cur_pos = (*coder) + .file_cur_pos + .wrapping_add((*in_pos).wrapping_sub(in_start) as uint64_t); + } + return ret; +} +unsafe extern "C" fn file_info_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; + let in_start: size_t = *in_pos; + if (*coder).file_size.wrapping_sub((*coder).file_cur_pos) + < in_size.wrapping_sub(in_start) as uint64_t + { + in_size = in_start + .wrapping_add( + (*coder).file_size.wrapping_sub((*coder).file_cur_pos) as size_t, + ); + } + loop { + let mut current_block_142: u64; + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + if (*coder).file_size < LZMA_STREAM_HEADER_SIZE as uint64_t { + return LZMA_FORMAT_ERROR; + } + if fill_temp(coder, in_0, in_pos, in_size) { + return LZMA_OK; + } + let ret_: lzma_ret = lzma_stream_header_decode( + &raw mut (*coder).first_header_flags, + &raw mut (*coder).temp as *mut uint8_t, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + if (*coder).file_size > LZMA_VLI_MAX as uint64_t + || (*coder).file_size & 3 as uint64_t != 0 + { + return LZMA_DATA_ERROR; + } + (*coder).file_target_pos = (*coder).file_size; + current_block_142 = 10445208204442080639; + } + 1 => { + current_block_142 = 10445208204442080639; + } + 2 => { + current_block_142 = 13242334135786603907; + } + 3 => { + current_block_142 = 9626344630975045425; + } + 4 => { + current_block_142 = 9376024032952078885; + } + 5 => { + current_block_142 = 16203797167131938757; + } + 6 => { + current_block_142 = 1317013834825322123; + } + 7 => { + current_block_142 = 6010056518000876263; + } + _ => return LZMA_PROG_ERROR, + } + match current_block_142 { + 10445208204442080639 => { + (*coder).sequence = SEQ_PADDING_DECODE; + let ret__0: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size) + as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__0; + } + current_block_142 = 13242334135786603907; + } + _ => {} + } + match current_block_142 { + 13242334135786603907 => { + if fill_temp(coder, in_0, in_pos, in_size) { + return LZMA_OK; + } + let new_padding: size_t = get_padding_size( + &raw mut (*coder).temp as *mut uint8_t, + (*coder).temp_size, + ) as size_t; + (*coder).stream_padding = (*coder) + .stream_padding + .wrapping_add(new_padding as lzma_vli); + (*coder).file_target_pos = (*coder) + .file_target_pos + .wrapping_sub(new_padding as uint64_t); + if new_padding == (*coder).temp_size { + (*coder).sequence = SEQ_PADDING_SEEK; + current_block_142 = 13014351284863956202; + } else { + if (*coder).stream_padding & 3 as lzma_vli != 0 { + return LZMA_DATA_ERROR; + } + (*coder).sequence = SEQ_FOOTER; + (*coder).temp_size = (*coder).temp_size.wrapping_sub(new_padding); + (*coder).temp_pos = (*coder).temp_size; + if (*coder).temp_size < LZMA_STREAM_HEADER_SIZE as size_t { + let ret__1: lzma_ret = reverse_seek( + coder, + in_start, + in_pos, + in_size, + ) as lzma_ret; + if ret__1 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__1; + } + } + current_block_142 = 9626344630975045425; + } + } + _ => {} + } + match current_block_142 { + 9626344630975045425 => { + if fill_temp(coder, in_0, in_pos, in_size) { + return LZMA_OK; + } + (*coder).file_target_pos = (*coder) + .file_target_pos + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as uint64_t); + (*coder).temp_size = (*coder) + .temp_size + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); + let ret__2: lzma_ret = hide_format_error( + lzma_stream_footer_decode( + &raw mut (*coder).footer_flags, + (&raw mut (*coder).temp as *mut uint8_t) + .offset((*coder).temp_size as isize), + ), + ) as lzma_ret; + if ret__2 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__2; + } + if (*coder).file_target_pos + < (*coder) + .footer_flags + .backward_size + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) + { + return LZMA_DATA_ERROR; + } + (*coder).file_target_pos = (*coder) + .file_target_pos + .wrapping_sub((*coder).footer_flags.backward_size as uint64_t); + (*coder).sequence = SEQ_INDEX_INIT; + if (*coder).temp_size as lzma_vli >= (*coder).footer_flags.backward_size + { + (*coder).temp_pos = ((*coder).temp_size as lzma_vli) + .wrapping_sub((*coder).footer_flags.backward_size) as size_t; + } else { + (*coder).temp_pos = 0 as size_t; + (*coder).temp_size = 0 as size_t; + if seek_to_pos( + coder, + (*coder).file_target_pos, + in_start, + in_pos, + in_size, + ) { + return LZMA_SEEK_NEEDED; + } + } + current_block_142 = 9376024032952078885; + } + _ => {} + } + match current_block_142 { + 9376024032952078885 => { + let mut memused: uint64_t = 0 as uint64_t; + if !(*coder).combined_index.is_null() { + memused = lzma_index_memused((*coder).combined_index); + if memused > (*coder).memlimit { + return LZMA_PROG_ERROR; + } + } + let ret__3: lzma_ret = lzma_index_decoder_init( + &raw mut (*coder).index_decoder, + allocator, + &raw mut (*coder).this_index, + (*coder).memlimit.wrapping_sub(memused), + ) as lzma_ret; + if ret__3 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__3; + } + (*coder).index_remaining = (*coder).footer_flags.backward_size; + (*coder).sequence = SEQ_INDEX_DECODE; + current_block_142 = 16203797167131938757; + } + _ => {} + } + match current_block_142 { + 16203797167131938757 => { + let mut ret: lzma_ret = LZMA_OK; + if (*coder).temp_size != 0 as size_t { + ret = decode_index( + coder, + allocator, + &raw mut (*coder).temp as *mut uint8_t, + &raw mut (*coder).temp_pos, + (*coder).temp_size, + false_0 != 0, + ); + } else { + let mut in_stop: size_t = in_size; + if in_size.wrapping_sub(*in_pos) as lzma_vli + > (*coder).index_remaining + { + in_stop = (*in_pos) + .wrapping_add((*coder).index_remaining as size_t); + } + ret = decode_index( + coder, + allocator, + in_0, + in_pos, + in_stop, + true_0 != 0, + ); + } + match ret as ::core::ffi::c_uint { + 0 => { + if (*coder).index_remaining == 0 as lzma_vli { + return LZMA_DATA_ERROR; + } + return LZMA_OK; + } + 1 => { + if (*coder).index_remaining != 0 as lzma_vli { + return LZMA_DATA_ERROR; + } + } + _ => return ret, + } + let seek_amount: uint64_t = (lzma_index_total_size((*coder).this_index) + as uint64_t) + .wrapping_add(LZMA_STREAM_HEADER_SIZE as uint64_t); + if (*coder).file_target_pos < seek_amount { + return LZMA_DATA_ERROR; + } + (*coder).file_target_pos = (*coder) + .file_target_pos + .wrapping_sub(seek_amount); + if (*coder).file_target_pos == 0 as uint64_t { + (*coder).header_flags = (*coder).first_header_flags; + (*coder).sequence = SEQ_HEADER_COMPARE; + current_block_142 = 13014351284863956202; + } else { + (*coder).sequence = SEQ_HEADER_DECODE; + (*coder).file_target_pos = (*coder) + .file_target_pos + .wrapping_add(LZMA_STREAM_HEADER_SIZE as uint64_t); + if (*coder).temp_size != 0 as size_t + && ((*coder).temp_size as lzma_vli) + .wrapping_sub((*coder).footer_flags.backward_size) + >= seek_amount + { + (*coder).temp_pos = ((*coder).temp_size as lzma_vli) + .wrapping_sub((*coder).footer_flags.backward_size) + .wrapping_sub(seek_amount as lzma_vli) + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) as size_t; + (*coder).temp_size = (*coder).temp_pos; + } else { + let ret__4: lzma_ret = reverse_seek( + coder, + in_start, + in_pos, + in_size, + ) as lzma_ret; + if ret__4 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__4; + } + } + current_block_142 = 1317013834825322123; + } + } + _ => {} + } + match current_block_142 { + 1317013834825322123 => { + if fill_temp(coder, in_0, in_pos, in_size) { + return LZMA_OK; + } + (*coder).file_target_pos = (*coder) + .file_target_pos + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as uint64_t); + (*coder).temp_size = (*coder) + .temp_size + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); + (*coder).temp_pos = (*coder).temp_size; + let ret__5: lzma_ret = hide_format_error( + lzma_stream_header_decode( + &raw mut (*coder).header_flags, + (&raw mut (*coder).temp as *mut uint8_t) + .offset((*coder).temp_size as isize), + ), + ) as lzma_ret; + if ret__5 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__5; + } + (*coder).sequence = SEQ_HEADER_COMPARE; + current_block_142 = 6010056518000876263; + } + _ => {} + } + match current_block_142 { + 6010056518000876263 => { + let ret__6: lzma_ret = lzma_stream_flags_compare( + &raw mut (*coder).header_flags, + &raw mut (*coder).footer_flags, + ) as lzma_ret; + if ret__6 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__6; + } + if lzma_index_stream_flags( + (*coder).this_index, + &raw mut (*coder).footer_flags, + ) as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + if lzma_index_stream_padding( + (*coder).this_index, + (*coder).stream_padding, + ) as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + (*coder).stream_padding = 0 as lzma_vli; + if !(*coder).combined_index.is_null() { + let ret__7: lzma_ret = lzma_index_cat( + (*coder).this_index, + (*coder).combined_index, + allocator, + ) as lzma_ret; + if ret__7 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__7; + } + } + (*coder).combined_index = (*coder).this_index; + (*coder).this_index = ::core::ptr::null_mut::(); + if (*coder).file_target_pos == 0 as uint64_t { + *(*coder).dest_index = (*coder).combined_index; + (*coder).combined_index = ::core::ptr::null_mut::(); + *in_pos = in_size; + return LZMA_STREAM_END; + } + (*coder).sequence = (if (*coder).temp_size > 0 as size_t { + SEQ_PADDING_DECODE as ::core::ffi::c_int + } else { + SEQ_PADDING_SEEK as ::core::ffi::c_int + }) as C2RustUnnamed_0; + } + _ => {} + } + }; +} +unsafe extern "C" fn file_info_decoder_memconfig( + mut coder_ptr: *mut ::core::ffi::c_void, + mut memusage: *mut uint64_t, + mut old_memlimit: *mut uint64_t, + mut new_memlimit: uint64_t, +) -> lzma_ret { + let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; + let mut combined_index_memusage: uint64_t = 0 as uint64_t; + let mut this_index_memusage: uint64_t = 0 as uint64_t; + if !(*coder).combined_index.is_null() { + combined_index_memusage = lzma_index_memused((*coder).combined_index); + } + if !(*coder).this_index.is_null() { + this_index_memusage = lzma_index_memused((*coder).this_index); + } else if (*coder).sequence as ::core::ffi::c_uint + == SEQ_INDEX_DECODE as ::core::ffi::c_int as ::core::ffi::c_uint + { + let mut dummy: uint64_t = 0; + if (*coder) + .index_decoder + .memconfig + .expect( + "non-null function pointer", + )( + (*coder).index_decoder.coder, + &raw mut this_index_memusage, + &raw mut dummy, + 0 as uint64_t, + ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + } + *memusage = combined_index_memusage.wrapping_add(this_index_memusage); + if *memusage == 0 as uint64_t { + *memusage = lzma_index_memusage(1 as lzma_vli, 0 as lzma_vli); + } + *old_memlimit = (*coder).memlimit; + if new_memlimit != 0 as uint64_t { + if new_memlimit < *memusage { + return LZMA_MEMLIMIT_ERROR; + } + if (*coder).this_index.is_null() + && (*coder).sequence as ::core::ffi::c_uint + == SEQ_INDEX_DECODE as ::core::ffi::c_int as ::core::ffi::c_uint + { + let idec_new_memlimit: uint64_t = new_memlimit + .wrapping_sub(combined_index_memusage); + let mut dummy1: uint64_t = 0; + let mut dummy2: uint64_t = 0; + if (*coder) + .index_decoder + .memconfig + .expect( + "non-null function pointer", + )( + (*coder).index_decoder.coder, + &raw mut dummy1, + &raw mut dummy2, + idec_new_memlimit, + ) as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + } + (*coder).memlimit = new_memlimit; + } + return LZMA_OK; +} +unsafe extern "C" fn file_info_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; + lzma_next_end(&raw mut (*coder).index_decoder, allocator); + lzma_index_end((*coder).this_index, allocator); + lzma_index_end((*coder).combined_index, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn lzma_file_info_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut seek_pos: *mut uint64_t, + mut dest_index: *mut *mut lzma_index, + mut memlimit: uint64_t, + mut file_size: uint64_t, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut uint64_t, + *mut *mut lzma_index, + uint64_t, + uint64_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_file_info_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut uint64_t, + *mut *mut lzma_index, + uint64_t, + uint64_t, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut uint64_t, + *mut *mut lzma_index, + uint64_t, + uint64_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_file_info_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut uint64_t, + *mut *mut lzma_index, + uint64_t, + uint64_t, + ) -> lzma_ret, + ), + ); + if dest_index.is_null() { + return LZMA_PROG_ERROR; + } + let mut coder: *mut lzma_file_info_coder = (*next).coder + as *mut lzma_file_info_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_file_info_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + file_info_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + file_info_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).memconfig = Some( + file_info_decoder_memconfig + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >; + (*coder).index_decoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*coder).this_index = ::core::ptr::null_mut::(); + (*coder).combined_index = ::core::ptr::null_mut::(); + } + (*coder).sequence = SEQ_MAGIC_BYTES; + (*coder).file_cur_pos = 0 as uint64_t; + (*coder).file_target_pos = 0 as uint64_t; + (*coder).file_size = file_size; + lzma_index_end((*coder).this_index, allocator); + (*coder).this_index = ::core::ptr::null_mut::(); + lzma_index_end((*coder).combined_index, allocator); + (*coder).combined_index = ::core::ptr::null_mut::(); + (*coder).stream_padding = 0 as lzma_vli; + (*coder).dest_index = dest_index; + (*coder).external_seek_pos = seek_pos; + (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).temp_pos = 0 as size_t; + (*coder).temp_size = LZMA_STREAM_HEADER_SIZE as size_t; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_file_info_decoder( + mut strm: *mut lzma_stream, + mut dest_index: *mut *mut lzma_index, + mut memlimit: uint64_t, + mut file_size: uint64_t, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_file_info_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + &raw mut (*strm).seek_pos, + dest_index, + memlimit, + file_size, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs new file mode 100644 index 00000000..f35340b2 --- /dev/null +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -0,0 +1,229 @@ +extern "C" { + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_raw_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_filter, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_buffer_decode( + mut filters: *const lzma_filter, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + if in_0.is_null() || in_pos.is_null() || *in_pos > in_size || out.is_null() + || out_pos.is_null() || *out_pos > out_size + { + return LZMA_PROG_ERROR; + } + let mut next: lzma_next_coder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + let ret_: lzma_ret = lzma_raw_decoder_init(&raw mut next, allocator, filters) + as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + let mut ret: lzma_ret = next + .code + .expect( + "non-null function pointer", + )( + next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + LZMA_FINISH, + ); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_OK; + } else { + if ret as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + if *in_pos != in_size { + ret = LZMA_BUF_ERROR; + } else if *out_pos != out_size { + ret = LZMA_DATA_ERROR; + } else { + let mut tmp: [uint8_t; 1] = [0; 1]; + let mut tmp_pos: size_t = 0 as size_t; + next + .code + .expect( + "non-null function pointer", + )( + next.coder, + allocator, + in_0, + in_pos, + in_size, + &raw mut tmp as *mut uint8_t, + &raw mut tmp_pos, + 1 as size_t, + LZMA_FINISH, + ); + if tmp_pos == 1 as size_t { + ret = LZMA_BUF_ERROR; + } else { + ret = LZMA_DATA_ERROR; + } + } + } + *in_pos = in_start; + *out_pos = out_start; + } + lzma_next_end(&raw mut next, allocator); + return ret; +} diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs new file mode 100644 index 00000000..10bb4837 --- /dev/null +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -0,0 +1,200 @@ +extern "C" { + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_raw_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_buffer_encode( + mut filters: *const lzma_filter, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + if in_0.is_null() && in_size != 0 as size_t || out.is_null() || out_pos.is_null() + || *out_pos > out_size + { + return LZMA_PROG_ERROR; + } + let mut next: lzma_next_coder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + let ret_: lzma_ret = lzma_raw_encoder_init(&raw mut next, allocator, filters) + as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let out_start: size_t = *out_pos; + let mut in_pos: size_t = 0 as size_t; + let mut ret: lzma_ret = next + .code + .expect( + "non-null function pointer", + )( + next.coder, + allocator, + in_0, + &raw mut in_pos, + in_size, + out, + out_pos, + out_size, + LZMA_FINISH, + ); + lzma_next_end(&raw mut next, allocator); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_OK; + } else { + if ret as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_BUF_ERROR; + } + *out_pos = out_start; + } + return ret; +} diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs new file mode 100644 index 00000000..3ae950ff --- /dev/null +++ b/liblzma-rs/src/common/filter_common.rs @@ -0,0 +1,599 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed { + pub id: lzma_vli, + pub options_size: size_t, + pub non_last_ok: bool, + pub last_ok: bool, + pub changes_size: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_delta { + pub type_0: lzma_delta_type, + pub dist: uint32_t, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +pub type lzma_delta_type = ::core::ffi::c_uint; +pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_bcj { + pub start_offset: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_coder { + pub id: lzma_vli, + pub init: lzma_init_function, + pub memusage: Option uint64_t>, +} +pub type lzma_filter_find = Option< + unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTERS_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_FILTER_X86: ::core::ffi::c_ulonglong = 0x4 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_POWERPC: ::core::ffi::c_ulonglong = 0x5 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_IA64: ::core::ffi::c_ulonglong = 0x6 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARM: ::core::ffi::c_ulonglong = 0x7 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARMTHUMB: ::core::ffi::c_ulonglong = 0x8 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_SPARC: ::core::ffi::c_ulonglong = 0x9 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARM64: ::core::ffi::c_ulonglong = 0xa as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_RISCV: ::core::ffi::c_ulonglong = 0xb as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_DELTA: ::core::ffi::c_ulonglong = 0x3 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) + << 15 as ::core::ffi::c_int; +static mut features: [C2RustUnnamed; 13] = [ + C2RustUnnamed { + id: LZMA_FILTER_LZMA1 as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: false_0 != 0, + last_ok: true_0 != 0, + changes_size: true_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_LZMA1EXT as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: false_0 != 0, + last_ok: true_0 != 0, + changes_size: true_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_LZMA2 as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: false_0 != 0, + last_ok: true_0 != 0, + changes_size: true_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_X86 as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_POWERPC as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_IA64 as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_ARM as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_ARMTHUMB as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_ARM64 as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_SPARC as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_RISCV as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_FILTER_DELTA as lzma_vli, + options_size: ::core::mem::size_of::() as size_t, + non_last_ok: true_0 != 0, + last_ok: false_0 != 0, + changes_size: false_0 != 0, + }, + C2RustUnnamed { + id: LZMA_VLI_UNKNOWN as lzma_vli, + options_size: 0, + non_last_ok: false, + last_ok: false, + changes_size: false, + }, +]; +#[no_mangle] +pub unsafe extern "C" fn lzma_filters_copy( + mut src: *const lzma_filter, + mut real_dest: *mut lzma_filter, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + let mut current_block: u64; + if src.is_null() || real_dest.is_null() { + return LZMA_PROG_ERROR; + } + let mut dest: [lzma_filter; 5] = [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5]; + let mut ret: lzma_ret = LZMA_OK; + let mut i: size_t = 0; + i = 0 as size_t; + 's_15: loop { + if !((*src.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { + current_block = 7175849428784450219; + break; + } + if i == LZMA_FILTERS_MAX as size_t { + ret = LZMA_OPTIONS_ERROR; + current_block = 6392083060350426025; + break; + } else { + dest[i as usize].id = (*src.offset(i as isize)).id; + if (*src.offset(i as isize)).options.is_null() { + dest[i as usize].options = NULL; + } else { + let mut j: size_t = 0; + j = 0 as size_t; + while (*src.offset(i as isize)).id != features[j as usize].id { + if features[j as usize].id == LZMA_VLI_UNKNOWN as lzma_vli { + ret = LZMA_OPTIONS_ERROR; + current_block = 6392083060350426025; + break 's_15; + } else { + j = j.wrapping_add(1); + } + } + dest[i as usize].options = lzma_alloc( + features[j as usize].options_size, + allocator, + ); + if dest[i as usize].options.is_null() { + ret = LZMA_MEM_ERROR; + current_block = 6392083060350426025; + break; + } else { + memcpy( + dest[i as usize].options, + (*src.offset(i as isize)).options, + features[j as usize].options_size, + ); + } + } + i = i.wrapping_add(1); + } + } + match current_block { + 6392083060350426025 => { + while i > 0 as size_t { + i = i.wrapping_sub(1); + lzma_free(dest[i as usize].options, allocator); + } + return ret; + } + _ => { + dest[i as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + dest[i as usize].options = NULL; + memcpy( + real_dest as *mut ::core::ffi::c_void, + &raw mut dest as *mut lzma_filter as *const ::core::ffi::c_void, + i + .wrapping_add(1 as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + ); + return LZMA_OK; + } + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_filters_free( + mut filters: *mut lzma_filter, + mut allocator: *const lzma_allocator, +) { + if filters.is_null() { + return; + } + let mut i: size_t = 0 as size_t; + while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + if i == LZMA_FILTERS_MAX as size_t { + break; + } + lzma_free((*filters.offset(i as isize)).options, allocator); + let ref mut fresh0 = (*filters.offset(i as isize)).options; + *fresh0 = NULL; + (*filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN as lzma_vli; + i = i.wrapping_add(1); + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_validate_chain( + mut filters: *const lzma_filter, + mut count: *mut size_t, +) -> lzma_ret { + if filters.is_null() + || (*filters.offset(0 as ::core::ffi::c_int as isize)).id + == LZMA_VLI_UNKNOWN as lzma_vli + { + return LZMA_PROG_ERROR; + } + let mut changes_size_count: size_t = 0 as size_t; + let mut non_last_ok: bool = true_0 != 0; + let mut last_ok: bool = false_0 != 0; + let mut i: size_t = 0 as size_t; + loop { + let mut j: size_t = 0; + j = 0 as size_t; + while (*filters.offset(i as isize)).id != features[j as usize].id { + if features[j as usize].id == LZMA_VLI_UNKNOWN as lzma_vli { + return LZMA_OPTIONS_ERROR; + } + j = j.wrapping_add(1); + } + if !non_last_ok { + return LZMA_OPTIONS_ERROR; + } + non_last_ok = features[j as usize].non_last_ok; + last_ok = features[j as usize].last_ok; + changes_size_count = changes_size_count + .wrapping_add(features[j as usize].changes_size as size_t); + i = i.wrapping_add(1); + if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { + break; + } + } + if i > LZMA_FILTERS_MAX as size_t || !last_ok || changes_size_count > 3 as size_t { + return LZMA_OPTIONS_ERROR; + } + *count = i; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut options: *const lzma_filter, + mut coder_find: lzma_filter_find, + mut is_encoder: bool, +) -> lzma_ret { + let mut count: size_t = 0; + let ret_: lzma_ret = lzma_validate_chain(options, &raw mut count) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let mut filters: [lzma_filter_info; 5] = [lzma_filter_info_s { + id: 0, + init: None, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5]; + if is_encoder { + let mut i: size_t = 0 as size_t; + while i < count { + let j: size_t = count.wrapping_sub(i).wrapping_sub(1 as size_t); + let fc: *const lzma_filter_coder = coder_find + .expect("non-null function pointer")((*options.offset(i as isize)).id) + as *const lzma_filter_coder; + if fc.is_null() || (*fc).init.is_none() { + return LZMA_OPTIONS_ERROR; + } + filters[j as usize].id = (*options.offset(i as isize)).id; + filters[j as usize].init = (*fc).init; + filters[j as usize].options = (*options.offset(i as isize)).options; + i = i.wrapping_add(1); + } + } else { + let mut i_0: size_t = 0 as size_t; + while i_0 < count { + let fc_0: *const lzma_filter_coder = coder_find + .expect("non-null function pointer")((*options.offset(i_0 as isize)).id) + as *const lzma_filter_coder; + if fc_0.is_null() || (*fc_0).init.is_none() { + return LZMA_OPTIONS_ERROR; + } + filters[i_0 as usize].id = (*options.offset(i_0 as isize)).id; + filters[i_0 as usize].init = (*fc_0).init; + filters[i_0 as usize].options = (*options.offset(i_0 as isize)).options; + i_0 = i_0.wrapping_add(1); + } + } + filters[count as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + filters[count as usize].init = None; + let ret: lzma_ret = lzma_next_filter_init( + next, + allocator, + &raw mut filters as *mut lzma_filter_info, + ) as lzma_ret; + if ret as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_next_end(next, allocator); + } + return ret; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_coder_memusage( + mut coder_find: lzma_filter_find, + mut filters: *const lzma_filter, +) -> uint64_t { + let mut tmp: size_t = 0; + if lzma_validate_chain(filters, &raw mut tmp) as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return UINT64_MAX as uint64_t; + } + let mut total: uint64_t = 0 as uint64_t; + let mut i: size_t = 0 as size_t; + loop { + let fc: *const lzma_filter_coder = coder_find + .expect("non-null function pointer")((*filters.offset(i as isize)).id) + as *const lzma_filter_coder; + if fc.is_null() { + return UINT64_MAX as uint64_t; + } + if (*fc).memusage.is_none() { + total = total.wrapping_add(1024 as uint64_t); + } else { + let usage: uint64_t = (*fc) + .memusage + .expect( + "non-null function pointer", + )((*filters.offset(i as isize)).options) as uint64_t; + if usage == UINT64_MAX as uint64_t { + return UINT64_MAX as uint64_t; + } + total = total.wrapping_add(usage); + } + i = i.wrapping_add(1); + if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { + break; + } + } + return total.wrapping_add(LZMA_MEMUSAGE_BASE as uint64_t); +} diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs new file mode 100644 index 00000000..3baedef9 --- /dev/null +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -0,0 +1,688 @@ +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_raw_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + coder_find_0: lzma_filter_find, + is_encoder: bool, + ) -> lzma_ret; + fn lzma_raw_coder_memusage( + coder_find_0: lzma_filter_find, + filters: *const lzma_filter, + ) -> uint64_t; + fn lzma_lzma_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma_decoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_lzma_props_decode( + options: *mut *mut ::core::ffi::c_void, + allocator: *const lzma_allocator, + props: *const uint8_t, + props_size: size_t, + ) -> lzma_ret; + fn lzma_lzma2_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma2_decoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_lzma2_props_decode( + options: *mut *mut ::core::ffi::c_void, + allocator: *const lzma_allocator, + props: *const uint8_t, + props_size: size_t, + ) -> lzma_ret; + fn lzma_simple_x86_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_powerpc_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_ia64_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_arm_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_armthumb_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_arm64_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_sparc_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_riscv_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_props_decode( + options: *mut *mut ::core::ffi::c_void, + allocator: *const lzma_allocator, + props: *const uint8_t, + props_size: size_t, + ) -> lzma_ret; + fn lzma_delta_coder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_delta_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_delta_props_decode( + options: *mut *mut ::core::ffi::c_void, + allocator: *const lzma_allocator, + props: *const uint8_t, + props_size: size_t, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_decoder { + pub id: lzma_vli, + pub init: lzma_init_function, + pub memusage: Option uint64_t>, + pub props_decode: Option< + unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + >, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_coder { + pub id: lzma_vli, + pub init: lzma_init_function, + pub memusage: Option uint64_t>, +} +pub type lzma_filter_find = Option< + unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_FILTER_X86: ::core::ffi::c_ulonglong = 0x4 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_POWERPC: ::core::ffi::c_ulonglong = 0x5 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_IA64: ::core::ffi::c_ulonglong = 0x6 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARM: ::core::ffi::c_ulonglong = 0x7 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARMTHUMB: ::core::ffi::c_ulonglong = 0x8 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_SPARC: ::core::ffi::c_ulonglong = 0x9 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARM64: ::core::ffi::c_ulonglong = 0xa as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_RISCV: ::core::ffi::c_ulonglong = 0xb as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_DELTA: ::core::ffi::c_ulonglong = 0x3 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +static mut decoders: [lzma_filter_decoder; 12] = [ + lzma_filter_decoder { + id: LZMA_FILTER_LZMA1 as lzma_vli, + init: Some( + lzma_lzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: Some( + lzma_lzma_decoder_memusage + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + props_decode: Some( + lzma_lzma_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_LZMA1EXT as lzma_vli, + init: Some( + lzma_lzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: Some( + lzma_lzma_decoder_memusage + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + props_decode: Some( + lzma_lzma_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_LZMA2 as lzma_vli, + init: Some( + lzma_lzma2_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: Some( + lzma_lzma2_decoder_memusage + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + props_decode: Some( + lzma_lzma2_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_X86 as lzma_vli, + init: Some( + lzma_simple_x86_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + props_decode: Some( + lzma_simple_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_POWERPC as lzma_vli, + init: Some( + lzma_simple_powerpc_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + props_decode: Some( + lzma_simple_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_IA64 as lzma_vli, + init: Some( + lzma_simple_ia64_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + props_decode: Some( + lzma_simple_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_ARM as lzma_vli, + init: Some( + lzma_simple_arm_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + props_decode: Some( + lzma_simple_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_ARMTHUMB as lzma_vli, + init: Some( + lzma_simple_armthumb_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + props_decode: Some( + lzma_simple_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_ARM64 as lzma_vli, + init: Some( + lzma_simple_arm64_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + props_decode: Some( + lzma_simple_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_SPARC as lzma_vli, + init: Some( + lzma_simple_sparc_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + props_decode: Some( + lzma_simple_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_RISCV as lzma_vli, + init: Some( + lzma_simple_riscv_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + props_decode: Some( + lzma_simple_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, + lzma_filter_decoder { + id: LZMA_FILTER_DELTA as lzma_vli, + init: Some( + lzma_delta_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: Some( + lzma_delta_coder_memusage + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + props_decode: Some( + lzma_delta_props_decode + as unsafe extern "C" fn( + *mut *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + size_t, + ) -> lzma_ret, + ), + }, +]; +unsafe extern "C" fn decoder_find(mut id: lzma_vli) -> *const lzma_filter_decoder { + let mut i: size_t = 0 as size_t; + while i + < (::core::mem::size_of::<[lzma_filter_decoder; 12]>() as usize) + .wrapping_div(::core::mem::size_of::() as usize) + { + if decoders[i as usize].id == id { + return (&raw const decoders as *const lzma_filter_decoder) + .offset(i as isize); + } + i = i.wrapping_add(1); + } + return ::core::ptr::null::(); +} +unsafe extern "C" fn coder_find(mut id: lzma_vli) -> *const lzma_filter_coder { + return decoder_find(id) as *const lzma_filter_coder; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_decoder_is_supported( + mut id: lzma_vli, +) -> lzma_bool { + return (decoder_find(id) != NULL as *const lzma_filter_decoder) as ::core::ffi::c_int + as lzma_bool; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut options: *const lzma_filter, +) -> lzma_ret { + return lzma_raw_coder_init( + next, + allocator, + options, + Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), + false_0 != 0, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_decoder( + mut strm: *mut lzma_stream, + mut options: *const lzma_filter, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_raw_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + options, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_decoder_memusage( + mut filters: *const lzma_filter, +) -> uint64_t { + return lzma_raw_coder_memusage( + Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), + filters, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_properties_decode( + mut filter: *mut lzma_filter, + mut allocator: *const lzma_allocator, + mut props: *const uint8_t, + mut props_size: size_t, +) -> lzma_ret { + (*filter).options = NULL; + let fd: *const lzma_filter_decoder = decoder_find((*filter).id) + as *const lzma_filter_decoder; + if fd.is_null() { + return LZMA_OPTIONS_ERROR; + } + if (*fd).props_decode.is_none() { + return (if props_size == 0 as size_t { + LZMA_OK as ::core::ffi::c_int + } else { + LZMA_OPTIONS_ERROR as ::core::ffi::c_int + }) as lzma_ret; + } + return (*fd) + .props_decode + .expect( + "non-null function pointer", + )(&raw mut (*filter).options, allocator, props, props_size); +} diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs new file mode 100644 index 00000000..bee86fa8 --- /dev/null +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -0,0 +1,838 @@ +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_raw_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + coder_find_0: lzma_filter_find, + is_encoder: bool, + ) -> lzma_ret; + fn lzma_raw_coder_memusage( + coder_find_0: lzma_filter_find, + filters: *const lzma_filter, + ) -> uint64_t; + fn lzma_lzma_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma_encoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_lzma_props_encode( + options: *const ::core::ffi::c_void, + out: *mut uint8_t, + ) -> lzma_ret; + fn lzma_lzma2_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma2_encoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_lzma2_props_encode( + options: *const ::core::ffi::c_void, + out: *mut uint8_t, + ) -> lzma_ret; + fn lzma_lzma2_block_size(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_simple_x86_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_powerpc_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_ia64_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_arm_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_armthumb_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_arm64_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_sparc_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_riscv_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_simple_props_size( + size: *mut uint32_t, + options: *const ::core::ffi::c_void, + ) -> lzma_ret; + fn lzma_simple_props_encode( + options: *const ::core::ffi::c_void, + out: *mut uint8_t, + ) -> lzma_ret; + fn lzma_delta_coder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_delta_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_delta_props_encode( + options: *const ::core::ffi::c_void, + out: *mut uint8_t, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_encoder { + pub id: lzma_vli, + pub init: lzma_init_function, + pub memusage: Option uint64_t>, + pub block_size: Option uint64_t>, + pub props_size_get: Option< + unsafe extern "C" fn(*mut uint32_t, *const ::core::ffi::c_void) -> lzma_ret, + >, + pub props_size_fixed: uint32_t, + pub props_encode: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void, *mut uint8_t) -> lzma_ret, + >, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_coder { + pub id: lzma_vli, + pub init: lzma_init_function, + pub memusage: Option uint64_t>, +} +pub type lzma_filter_find = Option< + unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_X86: ::core::ffi::c_ulonglong = 0x4 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_POWERPC: ::core::ffi::c_ulonglong = 0x5 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_IA64: ::core::ffi::c_ulonglong = 0x6 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARM: ::core::ffi::c_ulonglong = 0x7 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARMTHUMB: ::core::ffi::c_ulonglong = 0x8 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_SPARC: ::core::ffi::c_ulonglong = 0x9 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARM64: ::core::ffi::c_ulonglong = 0xa as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_RISCV: ::core::ffi::c_ulonglong = 0xb as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_DELTA: ::core::ffi::c_ulonglong = 0x3 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +static mut encoders: [lzma_filter_encoder; 12] = [ + lzma_filter_encoder { + id: LZMA_FILTER_LZMA1 as lzma_vli, + init: Some( + lzma_lzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: Some( + lzma_lzma_encoder_memusage + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + block_size: None, + props_size_get: None, + props_size_fixed: 5 as uint32_t, + props_encode: Some( + lzma_lzma_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_LZMA1EXT as lzma_vli, + init: Some( + lzma_lzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: Some( + lzma_lzma_encoder_memusage + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + block_size: None, + props_size_get: None, + props_size_fixed: 5 as uint32_t, + props_encode: Some( + lzma_lzma_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_LZMA2 as lzma_vli, + init: Some( + lzma_lzma2_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: Some( + lzma_lzma2_encoder_memusage + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + block_size: Some( + lzma_lzma2_block_size + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + props_size_get: None, + props_size_fixed: 1 as uint32_t, + props_encode: Some( + lzma_lzma2_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_X86 as lzma_vli, + init: Some( + lzma_simple_x86_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + block_size: None, + props_size_get: Some( + lzma_simple_props_size + as unsafe extern "C" fn( + *mut uint32_t, + *const ::core::ffi::c_void, + ) -> lzma_ret, + ), + props_size_fixed: 0, + props_encode: Some( + lzma_simple_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_POWERPC as lzma_vli, + init: Some( + lzma_simple_powerpc_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + block_size: None, + props_size_get: Some( + lzma_simple_props_size + as unsafe extern "C" fn( + *mut uint32_t, + *const ::core::ffi::c_void, + ) -> lzma_ret, + ), + props_size_fixed: 0, + props_encode: Some( + lzma_simple_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_IA64 as lzma_vli, + init: Some( + lzma_simple_ia64_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + block_size: None, + props_size_get: Some( + lzma_simple_props_size + as unsafe extern "C" fn( + *mut uint32_t, + *const ::core::ffi::c_void, + ) -> lzma_ret, + ), + props_size_fixed: 0, + props_encode: Some( + lzma_simple_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_ARM as lzma_vli, + init: Some( + lzma_simple_arm_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + block_size: None, + props_size_get: Some( + lzma_simple_props_size + as unsafe extern "C" fn( + *mut uint32_t, + *const ::core::ffi::c_void, + ) -> lzma_ret, + ), + props_size_fixed: 0, + props_encode: Some( + lzma_simple_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_ARMTHUMB as lzma_vli, + init: Some( + lzma_simple_armthumb_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + block_size: None, + props_size_get: Some( + lzma_simple_props_size + as unsafe extern "C" fn( + *mut uint32_t, + *const ::core::ffi::c_void, + ) -> lzma_ret, + ), + props_size_fixed: 0, + props_encode: Some( + lzma_simple_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_ARM64 as lzma_vli, + init: Some( + lzma_simple_arm64_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + block_size: None, + props_size_get: Some( + lzma_simple_props_size + as unsafe extern "C" fn( + *mut uint32_t, + *const ::core::ffi::c_void, + ) -> lzma_ret, + ), + props_size_fixed: 0, + props_encode: Some( + lzma_simple_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_SPARC as lzma_vli, + init: Some( + lzma_simple_sparc_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + block_size: None, + props_size_get: Some( + lzma_simple_props_size + as unsafe extern "C" fn( + *mut uint32_t, + *const ::core::ffi::c_void, + ) -> lzma_ret, + ), + props_size_fixed: 0, + props_encode: Some( + lzma_simple_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_RISCV as lzma_vli, + init: Some( + lzma_simple_riscv_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: None, + block_size: None, + props_size_get: Some( + lzma_simple_props_size + as unsafe extern "C" fn( + *mut uint32_t, + *const ::core::ffi::c_void, + ) -> lzma_ret, + ), + props_size_fixed: 0, + props_encode: Some( + lzma_simple_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, + lzma_filter_encoder { + id: LZMA_FILTER_DELTA as lzma_vli, + init: Some( + lzma_delta_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + memusage: Some( + lzma_delta_coder_memusage + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, + ), + block_size: None, + props_size_get: None, + props_size_fixed: 1 as uint32_t, + props_encode: Some( + lzma_delta_props_encode + as unsafe extern "C" fn( + *const ::core::ffi::c_void, + *mut uint8_t, + ) -> lzma_ret, + ), + }, +]; +unsafe extern "C" fn encoder_find(mut id: lzma_vli) -> *const lzma_filter_encoder { + let mut i: size_t = 0 as size_t; + while i + < (::core::mem::size_of::<[lzma_filter_encoder; 12]>() as usize) + .wrapping_div(::core::mem::size_of::() as usize) + { + if encoders[i as usize].id == id { + return (&raw const encoders as *const lzma_filter_encoder) + .offset(i as isize); + } + i = i.wrapping_add(1); + } + return ::core::ptr::null::(); +} +unsafe extern "C" fn coder_find(mut id: lzma_vli) -> *const lzma_filter_coder { + return encoder_find(id) as *const lzma_filter_coder; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_encoder_is_supported( + mut id: lzma_vli, +) -> lzma_bool { + return (encoder_find(id) != NULL as *const lzma_filter_encoder) as ::core::ffi::c_int + as lzma_bool; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_filters_update( + mut strm: *mut lzma_stream, + mut filters: *const lzma_filter, +) -> lzma_ret { + if (*(*strm).internal).next.update.is_none() { + return LZMA_PROG_ERROR; + } + if lzma_raw_encoder_memusage(filters) == UINT64_MAX as uint64_t { + return LZMA_OPTIONS_ERROR; + } + let mut count: size_t = 1 as size_t; + while (*filters.offset(count as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + count = count.wrapping_add(1); + } + let mut reversed_filters: [lzma_filter; 5] = [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5]; + let mut i: size_t = 0 as size_t; + while i < count { + reversed_filters[count.wrapping_sub(i).wrapping_sub(1 as size_t) as usize] = *filters + .offset(i as isize); + i = i.wrapping_add(1); + } + reversed_filters[count as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + return (*(*strm).internal) + .next + .update + .expect( + "non-null function pointer", + )( + (*(*strm).internal).next.coder, + (*strm).allocator, + filters, + &raw mut reversed_filters as *mut lzma_filter, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter, +) -> lzma_ret { + return lzma_raw_coder_init( + next, + allocator, + filters, + Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), + true_0 != 0, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_encoder( + mut strm: *mut lzma_stream, + mut filters: *const lzma_filter, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_raw_coder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + filters, + Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), + 1 as ::core::ffi::c_int != 0, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal) + .supported_actions[LZMA_SYNC_FLUSH as ::core::ffi::c_int as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_encoder_memusage( + mut filters: *const lzma_filter, +) -> uint64_t { + return lzma_raw_coder_memusage( + Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), + filters, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mt_block_size( + mut filters: *const lzma_filter, +) -> uint64_t { + if filters.is_null() { + return UINT64_MAX as uint64_t; + } + let mut max: uint64_t = 0 as uint64_t; + let mut i: size_t = 0 as size_t; + while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + let fe: *const lzma_filter_encoder = encoder_find( + (*filters.offset(i as isize)).id, + ) as *const lzma_filter_encoder; + if fe.is_null() { + return UINT64_MAX as uint64_t; + } + if (*fe).block_size.is_some() { + let size: uint64_t = (*fe) + .block_size + .expect( + "non-null function pointer", + )((*filters.offset(i as isize)).options) as uint64_t; + if size > max { + max = size; + } + } + i = i.wrapping_add(1); + } + return if max == 0 as uint64_t { UINT64_MAX as uint64_t } else { max }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_properties_size( + mut size: *mut uint32_t, + mut filter: *const lzma_filter, +) -> lzma_ret { + let fe: *const lzma_filter_encoder = encoder_find((*filter).id) + as *const lzma_filter_encoder; + if fe.is_null() { + return (if (*filter).id <= LZMA_VLI_MAX as lzma_vli { + LZMA_OPTIONS_ERROR as ::core::ffi::c_int + } else { + LZMA_PROG_ERROR as ::core::ffi::c_int + }) as lzma_ret; + } + if (*fe).props_size_get.is_none() { + *size = (*fe).props_size_fixed; + return LZMA_OK; + } + return (*fe) + .props_size_get + .expect("non-null function pointer")(size, (*filter).options); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_properties_encode( + mut filter: *const lzma_filter, + mut props: *mut uint8_t, +) -> lzma_ret { + let fe: *const lzma_filter_encoder = encoder_find((*filter).id) + as *const lzma_filter_encoder; + if fe.is_null() { + return LZMA_PROG_ERROR; + } + if (*fe).props_encode.is_none() { + return LZMA_OK; + } + return (*fe) + .props_encode + .expect("non-null function pointer")((*filter).options, props); +} diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs new file mode 100644 index 00000000..1f979aee --- /dev/null +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -0,0 +1,118 @@ +extern "C" { + fn lzma_vli_decode( + vli: *mut lzma_vli, + vli_pos: *mut size_t, + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + fn lzma_properties_decode( + filter: *mut lzma_filter, + allocator: *const lzma_allocator, + props: *const uint8_t, + props_size: size_t, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const LZMA_FILTER_RESERVED_START: ::core::ffi::c_ulonglong = (1 + as ::core::ffi::c_ulonglong) << 62 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_flags_decode( + mut filter: *mut lzma_filter, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + (*filter).options = NULL; + let ret_: lzma_ret = lzma_vli_decode( + &raw mut (*filter).id, + ::core::ptr::null_mut::(), + in_0, + in_pos, + in_size, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { + return LZMA_DATA_ERROR; + } + let mut props_size: lzma_vli = 0; + let ret__0: lzma_ret = lzma_vli_decode( + &raw mut props_size, + ::core::ptr::null_mut::(), + in_0, + in_pos, + in_size, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__0; + } + if (in_size.wrapping_sub(*in_pos) as lzma_vli) < props_size { + return LZMA_DATA_ERROR; + } + let ret: lzma_ret = lzma_properties_decode( + filter, + allocator, + in_0.offset(*in_pos as isize), + props_size as size_t, + ) as lzma_ret; + *in_pos = (*in_pos as lzma_vli).wrapping_add(props_size) as size_t as size_t; + return ret; +} diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs new file mode 100644 index 00000000..fbcf7884 --- /dev/null +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -0,0 +1,125 @@ +extern "C" { + fn lzma_vli_encode( + vli: lzma_vli, + vli_pos: *mut size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; + fn lzma_vli_size(vli: lzma_vli) -> uint32_t; + fn lzma_properties_size(size: *mut uint32_t, filter: *const lzma_filter) -> lzma_ret; + fn lzma_properties_encode( + filter: *const lzma_filter, + props: *mut uint8_t, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub const LZMA_FILTER_RESERVED_START: ::core::ffi::c_ulonglong = (1 + as ::core::ffi::c_ulonglong) << 62 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_flags_size( + mut size: *mut uint32_t, + mut filter: *const lzma_filter, +) -> lzma_ret { + if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { + return LZMA_PROG_ERROR; + } + let ret_: lzma_ret = lzma_properties_size(size, filter) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + *size = (*size) + .wrapping_add( + lzma_vli_size((*filter).id).wrapping_add(lzma_vli_size(*size as lzma_vli)), + ); + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_flags_encode( + mut filter: *const lzma_filter, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { + return LZMA_PROG_ERROR; + } + let ret_: lzma_ret = lzma_vli_encode( + (*filter).id, + ::core::ptr::null_mut::(), + out, + out_pos, + out_size, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let mut props_size: uint32_t = 0; + let ret__0: lzma_ret = lzma_properties_size(&raw mut props_size, filter) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__0; + } + let ret__1: lzma_ret = lzma_vli_encode( + props_size as lzma_vli, + ::core::ptr::null_mut::(), + out, + out_pos, + out_size, + ) as lzma_ret; + if ret__1 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__1; + } + if out_size.wrapping_sub(*out_pos) < props_size as size_t { + return LZMA_PROG_ERROR; + } + let ret__2: lzma_ret = lzma_properties_encode(filter, out.offset(*out_pos as isize)) + as lzma_ret; + if ret__2 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__2; + } + *out_pos = (*out_pos).wrapping_add(props_size as size_t); + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/hardware_cputhreads.rs b/liblzma-rs/src/common/hardware_cputhreads.rs new file mode 100644 index 00000000..ec8be0ad --- /dev/null +++ b/liblzma-rs/src/common/hardware_cputhreads.rs @@ -0,0 +1,8 @@ +extern "C" { + fn tuklib_cpucores() -> uint32_t; +} +pub type uint32_t = u32; +#[no_mangle] +pub unsafe extern "C" fn lzma_cputhreads() -> uint32_t { + return tuklib_cpucores(); +} diff --git a/liblzma-rs/src/common/hardware_physmem.rs b/liblzma-rs/src/common/hardware_physmem.rs new file mode 100644 index 00000000..63664e95 --- /dev/null +++ b/liblzma-rs/src/common/hardware_physmem.rs @@ -0,0 +1,8 @@ +extern "C" { + fn tuklib_physmem() -> uint64_t; +} +pub type uint64_t = u64; +#[no_mangle] +pub unsafe extern "C" fn lzma_physmem() -> uint64_t { + return tuklib_physmem(); +} diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs new file mode 100644 index 00000000..518906e9 --- /dev/null +++ b/liblzma-rs/src/common/index.rs @@ -0,0 +1,1252 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_vli_size(vli: lzma_vli) -> uint32_t; + fn lzma_stream_flags_compare( + a: *const lzma_stream_flags, + b: *const lzma_stream_flags, + ) -> lzma_ret; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_s { + pub streams: index_tree, + pub uncompressed_size: lzma_vli, + pub total_size: lzma_vli, + pub record_count: lzma_vli, + pub index_list_size: lzma_vli, + pub prealloc: size_t, + pub checks: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct index_tree { + pub root: *mut index_tree_node, + pub leftmost: *mut index_tree_node, + pub rightmost: *mut index_tree_node, + pub count: uint32_t, +} +pub type index_tree_node = index_tree_node_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct index_tree_node_s { + pub uncompressed_base: lzma_vli, + pub compressed_base: lzma_vli, + pub parent: *mut index_tree_node, + pub left: *mut index_tree_node, + pub right: *mut index_tree_node, +} +pub type lzma_index = lzma_index_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_iter { + pub stream: C2RustUnnamed_1, + pub block: C2RustUnnamed_0, + pub internal: [C2RustUnnamed; 6], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub p: *const ::core::ffi::c_void, + pub s: size_t, + pub v: lzma_vli, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_0 { + pub number_in_file: lzma_vli, + pub compressed_file_offset: lzma_vli, + pub uncompressed_file_offset: lzma_vli, + pub number_in_stream: lzma_vli, + pub compressed_stream_offset: lzma_vli, + pub uncompressed_stream_offset: lzma_vli, + pub uncompressed_size: lzma_vli, + pub unpadded_size: lzma_vli, + pub total_size: lzma_vli, + pub reserved_vli1: lzma_vli, + pub reserved_vli2: lzma_vli, + pub reserved_vli3: lzma_vli, + pub reserved_vli4: lzma_vli, + pub reserved_ptr1: *const ::core::ffi::c_void, + pub reserved_ptr2: *const ::core::ffi::c_void, + pub reserved_ptr3: *const ::core::ffi::c_void, + pub reserved_ptr4: *const ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_1 { + pub flags: *const lzma_stream_flags, + pub reserved_ptr1: *const ::core::ffi::c_void, + pub reserved_ptr2: *const ::core::ffi::c_void, + pub reserved_ptr3: *const ::core::ffi::c_void, + pub number: lzma_vli, + pub block_count: lzma_vli, + pub compressed_offset: lzma_vli, + pub uncompressed_offset: lzma_vli, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub padding: lzma_vli, + pub reserved_vli1: lzma_vli, + pub reserved_vli2: lzma_vli, + pub reserved_vli3: lzma_vli, + pub reserved_vli4: lzma_vli, +} +pub type lzma_index_iter_mode = ::core::ffi::c_uint; +pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; +pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; +pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; +pub const LZMA_INDEX_ITER_ANY: lzma_index_iter_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct index_record { + pub uncompressed_sum: lzma_vli, + pub unpadded_sum: lzma_vli, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct index_group { + pub node: index_tree_node, + pub number_base: lzma_vli, + pub allocated: size_t, + pub last: size_t, + pub records: [index_record; 0], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct index_stream { + pub node: index_tree_node, + pub number: uint32_t, + pub block_number_base: lzma_vli, + pub groups: index_tree, + pub record_count: lzma_vli, + pub index_list_size: lzma_vli, + pub stream_flags: lzma_stream_flags, + pub stream_padding: lzma_vli, +} +pub const ITER_METHOD_NORMAL: C2RustUnnamed_3 = 0; +pub const ITER_METHOD: C2RustUnnamed_2 = 4; +pub const ITER_RECORD: C2RustUnnamed_2 = 3; +pub const ITER_GROUP: C2RustUnnamed_2 = 2; +pub const ITER_STREAM: C2RustUnnamed_2 = 1; +pub const ITER_INDEX: C2RustUnnamed_2 = 0; +pub const ITER_METHOD_LEFTMOST: C2RustUnnamed_3 = 2; +pub const ITER_METHOD_NEXT: C2RustUnnamed_3 = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct index_cat_info { + pub uncompressed_size: lzma_vli, + pub file_size: lzma_vli, + pub block_number_add: lzma_vli, + pub stream_number_add: uint32_t, + pub streams: *mut index_tree, +} +pub type C2RustUnnamed_2 = ::core::ffi::c_uint; +pub type C2RustUnnamed_3 = ::core::ffi::c_uint; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const UINTPTR_MAX: ::core::ffi::c_ulong = 18446744073709551615 + as ::core::ffi::c_ulong; +pub const SIZE_MAX: ::core::ffi::c_ulong = UINTPTR_MAX; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn bsr32(mut n: uint32_t) -> uint32_t { + return n.leading_zeros() as i32 as uint32_t ^ 31 as uint32_t; +} +#[inline] +unsafe extern "C" fn ctz32(mut n: uint32_t) -> uint32_t { + return n.trailing_zeros() as i32 as uint32_t; +} +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const LZMA_BACKWARD_SIZE_MAX: ::core::ffi::c_ulonglong = (1 + as ::core::ffi::c_ulonglong) << 34 as ::core::ffi::c_int; +pub const UNPADDED_SIZE_MIN: ::core::ffi::c_ulonglong = 5 as ::core::ffi::c_ulonglong; +pub const UNPADDED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX + & !(3 as ::core::ffi::c_ulonglong); +#[inline] +unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { + return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); +} +#[inline] +unsafe extern "C" fn index_size_unpadded( + mut count: lzma_vli, + mut index_list_size: lzma_vli, +) -> lzma_vli { + return ((1 as uint32_t).wrapping_add(lzma_vli_size(count)) as lzma_vli) + .wrapping_add(index_list_size) + .wrapping_add(4 as lzma_vli); +} +#[inline] +unsafe extern "C" fn index_size( + mut count: lzma_vli, + mut index_list_size: lzma_vli, +) -> lzma_vli { + return vli_ceil4(index_size_unpadded(count, index_list_size)); +} +pub const INDEX_GROUP_SIZE: ::core::ffi::c_int = 512 as ::core::ffi::c_int; +pub const PREALLOC_MAX: usize = (SIZE_MAX as usize) + .wrapping_sub(::core::mem::size_of::() as usize) + .wrapping_div(::core::mem::size_of::() as usize); +unsafe extern "C" fn index_tree_init(mut tree: *mut index_tree) { + (*tree).root = ::core::ptr::null_mut::(); + (*tree).leftmost = ::core::ptr::null_mut::(); + (*tree).rightmost = ::core::ptr::null_mut::(); + (*tree).count = 0 as uint32_t; +} +unsafe extern "C" fn index_tree_node_end( + mut node: *mut index_tree_node, + mut allocator: *const lzma_allocator, + mut free_func: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), + >, +) { + if !(*node).left.is_null() { + index_tree_node_end((*node).left, allocator, free_func); + } + if !(*node).right.is_null() { + index_tree_node_end((*node).right, allocator, free_func); + } + free_func + .expect( + "non-null function pointer", + )(node as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn index_tree_end( + mut tree: *mut index_tree, + mut allocator: *const lzma_allocator, + mut free_func: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), + >, +) { + if !(*tree).root.is_null() { + index_tree_node_end((*tree).root, allocator, free_func); + } +} +unsafe extern "C" fn index_tree_append( + mut tree: *mut index_tree, + mut node: *mut index_tree_node, +) { + (*node).parent = (*tree).rightmost; + (*node).left = ::core::ptr::null_mut::(); + (*node).right = ::core::ptr::null_mut::(); + (*tree).count = (*tree).count.wrapping_add(1); + if (*tree).root.is_null() { + (*tree).root = node; + (*tree).leftmost = node; + (*tree).rightmost = node; + return; + } + (*(*tree).rightmost).right = node; + (*tree).rightmost = node; + let mut up: uint32_t = (*tree).count ^ (1 as uint32_t) << bsr32((*tree).count); + if up != 0 as uint32_t { + up = ctz32((*tree).count).wrapping_add(2 as uint32_t); + loop { + node = (*node).parent; + up = up.wrapping_sub(1); + if !(up > 0 as uint32_t) { + break; + } + } + let mut pivot: *mut index_tree_node = (*node).right; + if (*node).parent.is_null() { + (*tree).root = pivot; + } else { + (*(*node).parent).right = pivot; + } + (*pivot).parent = (*node).parent; + (*node).right = (*pivot).left; + if !(*node).right.is_null() { + (*(*node).right).parent = node; + } + (*pivot).left = node; + (*node).parent = pivot; + } +} +unsafe extern "C" fn index_tree_next( + mut node: *const index_tree_node, +) -> *mut ::core::ffi::c_void { + if !(*node).right.is_null() { + node = (*node).right; + while !(*node).left.is_null() { + node = (*node).left; + } + return node as *mut ::core::ffi::c_void; + } + while !(*node).parent.is_null() + && (*(*node).parent).right == node as *mut index_tree_node + { + node = (*node).parent; + } + return (*node).parent as *mut ::core::ffi::c_void; +} +unsafe extern "C" fn index_tree_locate( + mut tree: *const index_tree, + mut target: lzma_vli, +) -> *mut ::core::ffi::c_void { + let mut result: *const index_tree_node = ::core::ptr::null::(); + let mut node: *const index_tree_node = (*tree).root; + while !node.is_null() { + if (*node).uncompressed_base > target { + node = (*node).left; + } else { + result = node; + node = (*node).right; + } + } + return result as *mut ::core::ffi::c_void; +} +unsafe extern "C" fn index_stream_init( + mut compressed_base: lzma_vli, + mut uncompressed_base: lzma_vli, + mut stream_number: uint32_t, + mut block_number_base: lzma_vli, + mut allocator: *const lzma_allocator, +) -> *mut index_stream { + let mut s: *mut index_stream = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut index_stream; + if s.is_null() { + return ::core::ptr::null_mut::(); + } + (*s).node.uncompressed_base = uncompressed_base; + (*s).node.compressed_base = compressed_base; + (*s).node.parent = ::core::ptr::null_mut::(); + (*s).node.left = ::core::ptr::null_mut::(); + (*s).node.right = ::core::ptr::null_mut::(); + (*s).number = stream_number; + (*s).block_number_base = block_number_base; + index_tree_init(&raw mut (*s).groups); + (*s).record_count = 0 as lzma_vli; + (*s).index_list_size = 0 as lzma_vli; + (*s).stream_flags.version = UINT32_MAX as uint32_t; + (*s).stream_padding = 0 as lzma_vli; + return s; +} +unsafe extern "C" fn index_stream_end( + mut node: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut s: *mut index_stream = node as *mut index_stream; + index_tree_end( + &raw mut (*s).groups, + allocator, + Some( + lzma_free + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ), + ); + lzma_free(s as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn index_init_plain( + mut allocator: *const lzma_allocator, +) -> *mut lzma_index { + let mut i: *mut lzma_index = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_index; + if !i.is_null() { + index_tree_init(&raw mut (*i).streams); + (*i).uncompressed_size = 0 as lzma_vli; + (*i).total_size = 0 as lzma_vli; + (*i).record_count = 0 as lzma_vli; + (*i).index_list_size = 0 as lzma_vli; + (*i).prealloc = INDEX_GROUP_SIZE as size_t; + (*i).checks = 0 as uint32_t; + } + return i; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_init( + mut allocator: *const lzma_allocator, +) -> *mut lzma_index { + let mut i: *mut lzma_index = index_init_plain(allocator); + if i.is_null() { + return ::core::ptr::null_mut::(); + } + let mut s: *mut index_stream = index_stream_init( + 0 as lzma_vli, + 0 as lzma_vli, + 1 as uint32_t, + 0 as lzma_vli, + allocator, + ); + if s.is_null() { + lzma_free(i as *mut ::core::ffi::c_void, allocator); + return ::core::ptr::null_mut::(); + } + index_tree_append(&raw mut (*i).streams, &raw mut (*s).node); + return i; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_end( + mut i: *mut lzma_index, + mut allocator: *const lzma_allocator, +) { + if !i.is_null() { + index_tree_end( + &raw mut (*i).streams, + allocator, + Some( + index_stream_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ), + ); + lzma_free(i as *mut ::core::ffi::c_void, allocator); + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_prealloc( + mut i: *mut lzma_index, + mut records: lzma_vli, +) { + if records > PREALLOC_MAX as lzma_vli { + records = PREALLOC_MAX as lzma_vli; + } + (*i).prealloc = records as size_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_memusage( + mut streams: lzma_vli, + mut blocks: lzma_vli, +) -> uint64_t { + let alloc_overhead: size_t = (4 as size_t) + .wrapping_mul(::core::mem::size_of::<*mut ::core::ffi::c_void>() as size_t); + let stream_base: size_t = (::core::mem::size_of::() as size_t) + .wrapping_add(::core::mem::size_of::() as size_t) + .wrapping_add((2 as size_t).wrapping_mul(alloc_overhead)); + let group_base: size_t = (::core::mem::size_of::() as size_t) + .wrapping_add( + (INDEX_GROUP_SIZE as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + ) + .wrapping_add(alloc_overhead); + let groups: lzma_vli = blocks + .wrapping_add(INDEX_GROUP_SIZE as lzma_vli) + .wrapping_sub(1 as lzma_vli) + .wrapping_div(INDEX_GROUP_SIZE as lzma_vli); + let streams_mem: uint64_t = (streams as uint64_t) + .wrapping_mul(stream_base as uint64_t); + let groups_mem: uint64_t = (groups as uint64_t).wrapping_mul(group_base as uint64_t); + let index_base: uint64_t = (::core::mem::size_of::() as usize) + .wrapping_add(alloc_overhead as usize) as uint64_t; + let limit: uint64_t = (UINT64_MAX as uint64_t).wrapping_sub(index_base); + if streams == 0 as lzma_vli || streams > UINT32_MAX as lzma_vli + || blocks > LZMA_VLI_MAX as lzma_vli + || streams > limit.wrapping_div(stream_base as uint64_t) + || groups > limit.wrapping_div(group_base as uint64_t) + || limit.wrapping_sub(streams_mem) < groups_mem + { + return UINT64_MAX as uint64_t; + } + return index_base.wrapping_add(streams_mem).wrapping_add(groups_mem); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_memused(mut i: *const lzma_index) -> uint64_t { + return lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_block_count(mut i: *const lzma_index) -> lzma_vli { + return (*i).record_count; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_stream_count(mut i: *const lzma_index) -> lzma_vli { + return (*i).streams.count as lzma_vli; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_size(mut i: *const lzma_index) -> lzma_vli { + return index_size((*i).record_count, (*i).index_list_size); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_total_size(mut i: *const lzma_index) -> lzma_vli { + return (*i).total_size; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_stream_size(mut i: *const lzma_index) -> lzma_vli { + return (LZMA_STREAM_HEADER_SIZE as lzma_vli) + .wrapping_add((*i).total_size) + .wrapping_add(index_size((*i).record_count, (*i).index_list_size)) + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli); +} +unsafe extern "C" fn index_file_size( + mut compressed_base: lzma_vli, + mut unpadded_sum: lzma_vli, + mut record_count: lzma_vli, + mut index_list_size: lzma_vli, + mut stream_padding: lzma_vli, +) -> lzma_vli { + let mut file_size: lzma_vli = compressed_base + .wrapping_add((2 as ::core::ffi::c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) + .wrapping_add(stream_padding) + .wrapping_add(vli_ceil4(unpadded_sum)); + if file_size > LZMA_VLI_MAX as lzma_vli { + return LZMA_VLI_UNKNOWN as lzma_vli; + } + file_size = file_size.wrapping_add(index_size(record_count, index_list_size)); + if file_size > LZMA_VLI_MAX as lzma_vli { + return LZMA_VLI_UNKNOWN as lzma_vli; + } + return file_size; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_file_size(mut i: *const lzma_index) -> lzma_vli { + let mut s: *const index_stream = (*i).streams.rightmost as *const index_stream; + let mut g: *const index_group = (*s).groups.rightmost as *const index_group; + return index_file_size( + (*s).node.compressed_base, + if g.is_null() { + 0 as lzma_vli + } else { + (*(&raw const (*g).records as *const index_record) + .offset((*g).last as isize)) + .unpadded_sum + }, + (*s).record_count, + (*s).index_list_size, + (*s).stream_padding, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_uncompressed_size( + mut i: *const lzma_index, +) -> lzma_vli { + return (*i).uncompressed_size; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_checks(mut i: *const lzma_index) -> uint32_t { + let mut checks: uint32_t = (*i).checks; + let mut s: *const index_stream = (*i).streams.rightmost as *const index_stream; + if (*s).stream_flags.version != UINT32_MAX as uint32_t { + checks = (checks as ::core::ffi::c_uint + | (1 as ::core::ffi::c_uint) + << (*s).stream_flags.check as ::core::ffi::c_uint) as uint32_t; + } + return checks; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_padding_size(mut i: *const lzma_index) -> uint32_t { + return ((4 as lzma_vli) + .wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) + & 3 as lzma_vli) as uint32_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_stream_flags( + mut i: *mut lzma_index, + mut stream_flags: *const lzma_stream_flags, +) -> lzma_ret { + if i.is_null() || stream_flags.is_null() { + return LZMA_PROG_ERROR; + } + let ret_: lzma_ret = lzma_stream_flags_compare(stream_flags, stream_flags) + as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let mut s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; + (*s).stream_flags = *stream_flags; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_stream_padding( + mut i: *mut lzma_index, + mut stream_padding: lzma_vli, +) -> lzma_ret { + if i.is_null() || stream_padding > LZMA_VLI_MAX as lzma_vli + || stream_padding & 3 as lzma_vli != 0 as lzma_vli + { + return LZMA_PROG_ERROR; + } + let mut s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; + let old_stream_padding: lzma_vli = (*s).stream_padding; + (*s).stream_padding = 0 as lzma_vli; + if lzma_index_file_size(i).wrapping_add(stream_padding) > LZMA_VLI_MAX as lzma_vli { + (*s).stream_padding = old_stream_padding; + return LZMA_DATA_ERROR; + } + (*s).stream_padding = stream_padding; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_append( + mut i: *mut lzma_index, + mut allocator: *const lzma_allocator, + mut unpadded_size: lzma_vli, + mut uncompressed_size: lzma_vli, +) -> lzma_ret { + if i.is_null() || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli + || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli + || uncompressed_size > LZMA_VLI_MAX as lzma_vli + { + return LZMA_PROG_ERROR; + } + let mut s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; + let mut g: *mut index_group = (*s).groups.rightmost as *mut index_group; + let compressed_base: lzma_vli = if g.is_null() { + 0 as lzma_vli + } else { + vli_ceil4( + (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)) + .unpadded_sum, + ) as lzma_vli + }; + let uncompressed_base: lzma_vli = if g.is_null() { + 0 as lzma_vli + } else { + (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)) + .uncompressed_sum + }; + let index_list_size_add: uint32_t = (lzma_vli_size(unpadded_size) as uint32_t) + .wrapping_add(lzma_vli_size(uncompressed_size) as uint32_t); + if uncompressed_base.wrapping_add(uncompressed_size) > LZMA_VLI_MAX as lzma_vli { + return LZMA_DATA_ERROR; + } + if compressed_base.wrapping_add(unpadded_size) > UNPADDED_SIZE_MAX as lzma_vli { + return LZMA_DATA_ERROR; + } + if index_file_size( + (*s).node.compressed_base, + compressed_base.wrapping_add(unpadded_size), + (*s).record_count.wrapping_add(1 as lzma_vli), + (*s).index_list_size.wrapping_add(index_list_size_add as lzma_vli), + (*s).stream_padding, + ) == LZMA_VLI_UNKNOWN as lzma_vli + { + return LZMA_DATA_ERROR; + } + if index_size( + (*i).record_count.wrapping_add(1 as lzma_vli), + (*i).index_list_size.wrapping_add(index_list_size_add as lzma_vli), + ) > LZMA_BACKWARD_SIZE_MAX as lzma_vli + { + return LZMA_DATA_ERROR; + } + if !g.is_null() && (*g).last.wrapping_add(1 as size_t) < (*g).allocated { + (*g).last = (*g).last.wrapping_add(1); + } else { + g = lzma_alloc( + (::core::mem::size_of::() as size_t) + .wrapping_add( + (*i) + .prealloc + .wrapping_mul(::core::mem::size_of::() as size_t), + ), + allocator, + ) as *mut index_group; + if g.is_null() { + return LZMA_MEM_ERROR; + } + (*g).last = 0 as size_t; + (*g).allocated = (*i).prealloc; + (*i).prealloc = INDEX_GROUP_SIZE as size_t; + (*g).node.uncompressed_base = uncompressed_base; + (*g).node.compressed_base = compressed_base; + (*g).number_base = (*s).record_count.wrapping_add(1 as lzma_vli); + index_tree_append(&raw mut (*s).groups, &raw mut (*g).node); + } + (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)) + .uncompressed_sum = uncompressed_base.wrapping_add(uncompressed_size); + (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)) + .unpadded_sum = compressed_base.wrapping_add(unpadded_size); + (*s).record_count = (*s).record_count.wrapping_add(1); + (*s).index_list_size = (*s) + .index_list_size + .wrapping_add(index_list_size_add as lzma_vli); + (*i).total_size = (*i).total_size.wrapping_add(vli_ceil4(unpadded_size)); + (*i).uncompressed_size = (*i).uncompressed_size.wrapping_add(uncompressed_size); + (*i).record_count = (*i).record_count.wrapping_add(1); + (*i).index_list_size = (*i) + .index_list_size + .wrapping_add(index_list_size_add as lzma_vli); + return LZMA_OK; +} +unsafe extern "C" fn index_cat_helper( + mut info: *const index_cat_info, + mut this: *mut index_stream, +) { + let mut left: *mut index_stream = (*this).node.left as *mut index_stream; + let mut right: *mut index_stream = (*this).node.right as *mut index_stream; + if !left.is_null() { + index_cat_helper(info, left); + } + (*this).node.uncompressed_base = (*this) + .node + .uncompressed_base + .wrapping_add((*info).uncompressed_size); + (*this).node.compressed_base = (*this) + .node + .compressed_base + .wrapping_add((*info).file_size); + (*this).number = (*this).number.wrapping_add((*info).stream_number_add); + (*this).block_number_base = (*this) + .block_number_base + .wrapping_add((*info).block_number_add); + index_tree_append((*info).streams, &raw mut (*this).node); + if !right.is_null() { + index_cat_helper(info, right); + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_cat( + mut dest: *mut lzma_index, + mut src: *mut lzma_index, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + if dest.is_null() || src.is_null() { + return LZMA_PROG_ERROR; + } + let dest_file_size: lzma_vli = lzma_index_file_size(dest) as lzma_vli; + if dest_file_size.wrapping_add(lzma_index_file_size(src)) > LZMA_VLI_MAX as lzma_vli + || (*dest).uncompressed_size.wrapping_add((*src).uncompressed_size) + > LZMA_VLI_MAX as lzma_vli + { + return LZMA_DATA_ERROR; + } + let dest_size: lzma_vli = index_size_unpadded( + (*dest).record_count, + (*dest).index_list_size, + ) as lzma_vli; + let src_size: lzma_vli = index_size_unpadded( + (*src).record_count, + (*src).index_list_size, + ) as lzma_vli; + if vli_ceil4(dest_size.wrapping_add(src_size)) > LZMA_BACKWARD_SIZE_MAX as lzma_vli { + return LZMA_DATA_ERROR; + } + let mut s: *mut index_stream = (*dest).streams.rightmost as *mut index_stream; + let mut g: *mut index_group = (*s).groups.rightmost as *mut index_group; + if !g.is_null() && (*g).last.wrapping_add(1 as size_t) < (*g).allocated { + let mut newg: *mut index_group = lzma_alloc( + (::core::mem::size_of::() as size_t) + .wrapping_add( + (*g) + .last + .wrapping_add(1 as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + ), + allocator, + ) as *mut index_group; + if newg.is_null() { + return LZMA_MEM_ERROR; + } + (*newg).node = (*g).node; + (*newg).allocated = (*g).last.wrapping_add(1 as size_t); + (*newg).last = (*g).last; + (*newg).number_base = (*g).number_base; + memcpy( + &raw mut (*newg).records as *mut index_record as *mut ::core::ffi::c_void, + &raw mut (*g).records as *mut index_record as *const ::core::ffi::c_void, + (*newg) + .allocated + .wrapping_mul(::core::mem::size_of::() as size_t), + ); + if !(*g).node.parent.is_null() { + (*(*g).node.parent).right = &raw mut (*newg).node; + } + if (*s).groups.leftmost == &raw mut (*g).node { + (*s).groups.leftmost = &raw mut (*newg).node; + (*s).groups.root = &raw mut (*newg).node; + } + (*s).groups.rightmost = &raw mut (*newg).node; + lzma_free(g as *mut ::core::ffi::c_void, allocator); + } + (*dest).checks = lzma_index_checks(dest); + let info: index_cat_info = index_cat_info { + uncompressed_size: (*dest).uncompressed_size, + file_size: dest_file_size, + block_number_add: (*dest).record_count, + stream_number_add: (*dest).streams.count, + streams: &raw mut (*dest).streams, + }; + index_cat_helper(&raw const info, (*src).streams.root as *mut index_stream); + (*dest).uncompressed_size = (*dest) + .uncompressed_size + .wrapping_add((*src).uncompressed_size); + (*dest).total_size = (*dest).total_size.wrapping_add((*src).total_size); + (*dest).record_count = (*dest).record_count.wrapping_add((*src).record_count); + (*dest).index_list_size = (*dest) + .index_list_size + .wrapping_add((*src).index_list_size); + (*dest).checks |= (*src).checks; + lzma_free(src as *mut ::core::ffi::c_void, allocator); + return LZMA_OK; +} +unsafe extern "C" fn index_dup_stream( + mut src: *const index_stream, + mut allocator: *const lzma_allocator, +) -> *mut index_stream { + if (*src).record_count > PREALLOC_MAX as lzma_vli { + return ::core::ptr::null_mut::(); + } + let mut dest: *mut index_stream = index_stream_init( + (*src).node.compressed_base, + (*src).node.uncompressed_base, + (*src).number, + (*src).block_number_base, + allocator, + ); + if dest.is_null() { + return ::core::ptr::null_mut::(); + } + (*dest).record_count = (*src).record_count; + (*dest).index_list_size = (*src).index_list_size; + (*dest).stream_flags = (*src).stream_flags; + (*dest).stream_padding = (*src).stream_padding; + if (*src).groups.leftmost.is_null() { + return dest; + } + let mut destg: *mut index_group = lzma_alloc( + (::core::mem::size_of::() as lzma_vli) + .wrapping_add( + (*src) + .record_count + .wrapping_mul(::core::mem::size_of::() as lzma_vli), + ) as size_t, + allocator, + ) as *mut index_group; + if destg.is_null() { + index_stream_end(dest as *mut ::core::ffi::c_void, allocator); + return ::core::ptr::null_mut::(); + } + (*destg).node.uncompressed_base = 0 as lzma_vli; + (*destg).node.compressed_base = 0 as lzma_vli; + (*destg).number_base = 1 as lzma_vli; + (*destg).allocated = (*src).record_count as size_t; + (*destg).last = (*src).record_count.wrapping_sub(1 as lzma_vli) as size_t; + let mut srcg: *const index_group = (*src).groups.leftmost as *const index_group; + let mut i: size_t = 0 as size_t; + loop { + memcpy( + (&raw mut (*destg).records as *mut index_record).offset(i as isize) + as *mut ::core::ffi::c_void, + &raw const (*srcg).records as *const index_record + as *const ::core::ffi::c_void, + (*srcg) + .last + .wrapping_add(1 as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + ); + i = i.wrapping_add((*srcg).last.wrapping_add(1 as size_t)); + srcg = index_tree_next(&raw const (*srcg).node) as *const index_group; + if srcg.is_null() { + break; + } + } + index_tree_append(&raw mut (*dest).groups, &raw mut (*destg).node); + return dest; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_dup( + mut src: *const lzma_index, + mut allocator: *const lzma_allocator, +) -> *mut lzma_index { + let mut dest: *mut lzma_index = index_init_plain(allocator); + if dest.is_null() { + return ::core::ptr::null_mut::(); + } + (*dest).uncompressed_size = (*src).uncompressed_size; + (*dest).total_size = (*src).total_size; + (*dest).record_count = (*src).record_count; + (*dest).index_list_size = (*src).index_list_size; + let mut srcstream: *const index_stream = (*src).streams.leftmost + as *const index_stream; + loop { + let mut deststream: *mut index_stream = index_dup_stream(srcstream, allocator); + if deststream.is_null() { + lzma_index_end(dest, allocator); + return ::core::ptr::null_mut::(); + } + index_tree_append(&raw mut (*dest).streams, &raw mut (*deststream).node); + srcstream = index_tree_next(&raw const (*srcstream).node) as *const index_stream; + if srcstream.is_null() { + break; + } + } + return dest; +} +unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { + let mut i: *const lzma_index = (*iter) + .internal[ITER_INDEX as ::core::ffi::c_int as usize] + .p as *const lzma_index; + let mut stream: *const index_stream = (*iter) + .internal[ITER_STREAM as ::core::ffi::c_int as usize] + .p as *const index_stream; + let mut group: *const index_group = (*iter) + .internal[ITER_GROUP as ::core::ffi::c_int as usize] + .p as *const index_group; + let record: size_t = (*iter).internal[ITER_RECORD as ::core::ffi::c_int as usize].s; + if group.is_null() { + (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_LEFTMOST + as ::core::ffi::c_int as size_t; + } else if (*i).streams.rightmost != &raw const (*stream).node as *mut index_tree_node + || (*stream).groups.rightmost != &raw const (*group).node as *mut index_tree_node + { + (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_NORMAL + as ::core::ffi::c_int as size_t; + } else if (*stream).groups.leftmost + != &raw const (*group).node as *mut index_tree_node + { + (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_NEXT + as ::core::ffi::c_int as size_t; + (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = (*group) + .node + .parent as *const ::core::ffi::c_void; + } else { + (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_LEFTMOST + as ::core::ffi::c_int as size_t; + (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = ::core::ptr::null::< + ::core::ffi::c_void, + >(); + } + (*iter).stream.number = (*stream).number as lzma_vli; + (*iter).stream.block_count = (*stream).record_count; + (*iter).stream.compressed_offset = (*stream).node.compressed_base; + (*iter).stream.uncompressed_offset = (*stream).node.uncompressed_base; + (*iter).stream.flags = if (*stream).stream_flags.version == UINT32_MAX as uint32_t { + ::core::ptr::null::() + } else { + &raw const (*stream).stream_flags + }; + (*iter).stream.padding = (*stream).stream_padding; + if (*stream).groups.rightmost.is_null() { + (*iter).stream.compressed_size = index_size(0 as lzma_vli, 0 as lzma_vli) + .wrapping_add( + (2 as ::core::ffi::c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli, + ); + (*iter).stream.uncompressed_size = 0 as lzma_vli; + } else { + let mut g: *const index_group = (*stream).groups.rightmost as *const index_group; + (*iter).stream.compressed_size = ((2 as ::core::ffi::c_int + * LZMA_STREAM_HEADER_SIZE) as lzma_vli) + .wrapping_add(index_size((*stream).record_count, (*stream).index_list_size)) + .wrapping_add( + vli_ceil4( + (*(&raw const (*g).records as *const index_record) + .offset((*g).last as isize)) + .unpadded_sum, + ), + ); + (*iter).stream.uncompressed_size = (*(&raw const (*g).records + as *const index_record) + .offset((*g).last as isize)) + .uncompressed_sum; + } + if !group.is_null() { + (*iter).block.number_in_stream = (*group) + .number_base + .wrapping_add(record as lzma_vli); + (*iter).block.number_in_file = (*iter) + .block + .number_in_stream + .wrapping_add((*stream).block_number_base); + (*iter).block.compressed_stream_offset = if record == 0 as size_t { + (*group).node.compressed_base + } else { + vli_ceil4( + (*(&raw const (*group).records as *const index_record) + .offset(record.wrapping_sub(1 as size_t) as isize)) + .unpadded_sum, + ) + }; + (*iter).block.uncompressed_stream_offset = if record == 0 as size_t { + (*group).node.uncompressed_base + } else { + (*(&raw const (*group).records as *const index_record) + .offset(record.wrapping_sub(1 as size_t) as isize)) + .uncompressed_sum + }; + (*iter).block.uncompressed_size = (*(&raw const (*group).records + as *const index_record) + .offset(record as isize)) + .uncompressed_sum + .wrapping_sub((*iter).block.uncompressed_stream_offset); + (*iter).block.unpadded_size = (*(&raw const (*group).records + as *const index_record) + .offset(record as isize)) + .unpadded_sum + .wrapping_sub((*iter).block.compressed_stream_offset); + (*iter).block.total_size = vli_ceil4((*iter).block.unpadded_size); + (*iter).block.compressed_stream_offset = (*iter) + .block + .compressed_stream_offset + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli); + (*iter).block.compressed_file_offset = (*iter) + .block + .compressed_stream_offset + .wrapping_add((*iter).stream.compressed_offset); + (*iter).block.uncompressed_file_offset = (*iter) + .block + .uncompressed_stream_offset + .wrapping_add((*iter).stream.uncompressed_offset); + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_iter_init( + mut iter: *mut lzma_index_iter, + mut i: *const lzma_index, +) { + (*iter).internal[ITER_INDEX as ::core::ffi::c_int as usize].p = i + as *const ::core::ffi::c_void; + lzma_index_iter_rewind(iter); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_iter_rewind(mut iter: *mut lzma_index_iter) { + (*iter).internal[ITER_STREAM as ::core::ffi::c_int as usize].p = ::core::ptr::null::< + ::core::ffi::c_void, + >(); + (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = ::core::ptr::null::< + ::core::ffi::c_void, + >(); + (*iter).internal[ITER_RECORD as ::core::ffi::c_int as usize].s = 0 as size_t; + (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_NORMAL + as ::core::ffi::c_int as size_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_iter_next( + mut iter: *mut lzma_index_iter, + mut mode: lzma_index_iter_mode, +) -> lzma_bool { + if mode as ::core::ffi::c_uint + > LZMA_INDEX_ITER_NONEMPTY_BLOCK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return true_0 as lzma_bool; + } + let mut i: *const lzma_index = (*iter) + .internal[ITER_INDEX as ::core::ffi::c_int as usize] + .p as *const lzma_index; + let mut stream: *const index_stream = (*iter) + .internal[ITER_STREAM as ::core::ffi::c_int as usize] + .p as *const index_stream; + let mut group: *const index_group = ::core::ptr::null::(); + let mut record: size_t = (*iter) + .internal[ITER_RECORD as ::core::ffi::c_int as usize] + .s; + if mode as ::core::ffi::c_uint + != LZMA_INDEX_ITER_STREAM as ::core::ffi::c_int as ::core::ffi::c_uint + { + match (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s { + 0 => { + group = (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p + as *const index_group; + } + 1 => { + group = index_tree_next( + (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p + as *const index_tree_node, + ) as *const index_group; + } + 2 => { + group = (*stream).groups.leftmost as *const index_group; + } + _ => {} + } + } + loop { + if stream.is_null() { + stream = (*i).streams.leftmost as *const index_stream; + if mode as ::core::ffi::c_uint + >= LZMA_INDEX_ITER_BLOCK as ::core::ffi::c_int as ::core::ffi::c_uint + { + while (*stream).groups.leftmost.is_null() { + stream = index_tree_next(&raw const (*stream).node) + as *const index_stream; + if stream.is_null() { + return true_0 as lzma_bool; + } + } + } + group = (*stream).groups.leftmost as *const index_group; + record = 0 as size_t; + } else if !group.is_null() && record < (*group).last { + record = record.wrapping_add(1); + } else { + record = 0 as size_t; + if !group.is_null() { + group = index_tree_next(&raw const (*group).node) as *const index_group; + } + if group.is_null() { + loop { + stream = index_tree_next(&raw const (*stream).node) + as *const index_stream; + if stream.is_null() { + return true_0 as lzma_bool; + } + if !(mode as ::core::ffi::c_uint + >= LZMA_INDEX_ITER_BLOCK as ::core::ffi::c_int + as ::core::ffi::c_uint + && (*stream).groups.leftmost.is_null()) + { + break; + } + } + group = (*stream).groups.leftmost as *const index_group; + } + } + if !(mode as ::core::ffi::c_uint + == LZMA_INDEX_ITER_NONEMPTY_BLOCK as ::core::ffi::c_int + as ::core::ffi::c_uint) + { + break; + } + if record == 0 as size_t { + if !((*group).node.uncompressed_base + == (*(&raw const (*group).records as *const index_record) + .offset(0 as ::core::ffi::c_int as isize)) + .uncompressed_sum) + { + break; + } + } else if !((*(&raw const (*group).records as *const index_record) + .offset(record.wrapping_sub(1 as size_t) as isize)) + .uncompressed_sum + == (*(&raw const (*group).records as *const index_record) + .offset(record as isize)) + .uncompressed_sum) + { + break; + } + } + (*iter).internal[ITER_STREAM as ::core::ffi::c_int as usize].p = stream + as *const ::core::ffi::c_void; + (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = group + as *const ::core::ffi::c_void; + (*iter).internal[ITER_RECORD as ::core::ffi::c_int as usize].s = record; + iter_set_info(iter); + return false_0 as lzma_bool; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_iter_locate( + mut iter: *mut lzma_index_iter, + mut target: lzma_vli, +) -> lzma_bool { + let mut i: *const lzma_index = (*iter) + .internal[ITER_INDEX as ::core::ffi::c_int as usize] + .p as *const lzma_index; + if (*i).uncompressed_size <= target { + return true_0 as lzma_bool; + } + let mut stream: *const index_stream = index_tree_locate( + &raw const (*i).streams, + target, + ) as *const index_stream; + target = target.wrapping_sub((*stream).node.uncompressed_base); + let mut group: *const index_group = index_tree_locate( + &raw const (*stream).groups, + target, + ) as *const index_group; + let mut left: size_t = 0 as size_t; + let mut right: size_t = (*group).last; + while left < right { + let pos: size_t = left + .wrapping_add(right.wrapping_sub(left).wrapping_div(2 as size_t)); + if (*(&raw const (*group).records as *const index_record).offset(pos as isize)) + .uncompressed_sum <= target + { + left = pos.wrapping_add(1 as size_t); + } else { + right = pos; + } + } + (*iter).internal[ITER_STREAM as ::core::ffi::c_int as usize].p = stream + as *const ::core::ffi::c_void; + (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = group + as *const ::core::ffi::c_void; + (*iter).internal[ITER_RECORD as ::core::ffi::c_int as usize].s = left; + iter_set_info(iter); + return false_0 as lzma_bool; +} diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs new file mode 100644 index 00000000..acae1705 --- /dev/null +++ b/liblzma-rs/src/common/index_decoder.rs @@ -0,0 +1,662 @@ +#[repr(C)] +pub struct lzma_index_s { _opaque: [u8; 0] } +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_vli_decode( + vli: *mut lzma_vli, + vli_pos: *mut size_t, + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> uint64_t; + fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; + fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); + fn lzma_index_append( + i: *mut lzma_index, + allocator: *const lzma_allocator, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, + ) -> lzma_ret; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_index_padding_size(i: *const lzma_index) -> uint32_t; + fn lzma_index_prealloc(i: *mut lzma_index, records: lzma_vli); +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub type lzma_index = lzma_index_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_coder { + pub sequence: C2RustUnnamed_0, + pub memlimit: uint64_t, + pub index: *mut lzma_index, + pub index_ptr: *mut *mut lzma_index, + pub count: lzma_vli, + pub unpadded_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub pos: size_t, + pub crc32: uint32_t, +} +pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub const SEQ_CRC32: C2RustUnnamed_0 = 7; +pub const SEQ_PADDING: C2RustUnnamed_0 = 6; +pub const SEQ_PADDING_INIT: C2RustUnnamed_0 = 5; +pub const SEQ_UNCOMPRESSED: C2RustUnnamed_0 = 4; +pub const SEQ_UNPADDED: C2RustUnnamed_0 = 3; +pub const SEQ_MEMUSAGE: C2RustUnnamed_0 = 2; +pub const SEQ_COUNT: C2RustUnnamed_0 = 1; +pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const UNPADDED_SIZE_MIN: ::core::ffi::c_ulonglong = 5 as ::core::ffi::c_ulonglong; +pub const UNPADDED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX + & !(3 as ::core::ffi::c_ulonglong); +pub const INDEX_INDICATOR: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn index_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut current_block: u64; + let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; + let in_start: size_t = *in_pos; + let mut ret: lzma_ret = LZMA_OK; + while *in_pos < in_size { + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + let fresh0 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + if *in_0.offset(fresh0 as isize) as ::core::ffi::c_int != INDEX_INDICATOR + { + return LZMA_DATA_ERROR; + } + (*coder).sequence = SEQ_COUNT; + continue; + } + 1 => { + ret = lzma_vli_decode( + &raw mut (*coder).count, + &raw mut (*coder).pos, + in_0, + in_pos, + in_size, + ); + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + break; + } + (*coder).pos = 0 as size_t; + (*coder).sequence = SEQ_MEMUSAGE; + current_block = 7642845755631126846; + } + 2 => { + current_block = 7642845755631126846; + } + 3 | 4 => { + let mut size: *mut lzma_vli = if (*coder).sequence as ::core::ffi::c_uint + == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint + { + &raw mut (*coder).unpadded_size + } else { + &raw mut (*coder).uncompressed_size + }; + ret = lzma_vli_decode( + size, + &raw mut (*coder).pos, + in_0, + in_pos, + in_size, + ); + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + break; + } + ret = LZMA_OK; + (*coder).pos = 0 as size_t; + if (*coder).sequence as ::core::ffi::c_uint + == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint + { + if (*coder).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli + || (*coder).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli + { + return LZMA_DATA_ERROR; + } + (*coder).sequence = SEQ_UNCOMPRESSED; + } else { + let ret_: lzma_ret = lzma_index_append( + (*coder).index, + allocator, + (*coder).unpadded_size, + (*coder).uncompressed_size, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + (*coder).count = (*coder).count.wrapping_sub(1); + (*coder).sequence = (if (*coder).count == 0 as lzma_vli { + SEQ_PADDING_INIT as ::core::ffi::c_int + } else { + SEQ_UNPADDED as ::core::ffi::c_int + }) as C2RustUnnamed_0; + } + continue; + } + 5 => { + (*coder).pos = lzma_index_padding_size((*coder).index) as size_t; + (*coder).sequence = SEQ_PADDING; + current_block = 8340016495055110192; + } + 6 => { + current_block = 8340016495055110192; + } + 7 => { + current_block = 9471676622948044094; + } + _ => return LZMA_PROG_ERROR, + } + match current_block { + 8340016495055110192 => { + if (*coder).pos > 0 as size_t { + (*coder).pos = (*coder).pos.wrapping_sub(1); + let fresh1 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + if *in_0.offset(fresh1 as isize) as ::core::ffi::c_int + != 0 as ::core::ffi::c_int + { + return LZMA_DATA_ERROR; + } + continue; + } else { + (*coder).crc32 = lzma_crc32( + in_0.offset(in_start as isize), + (*in_pos).wrapping_sub(in_start), + (*coder).crc32, + ); + (*coder).sequence = SEQ_CRC32; + } + } + 7642845755631126846 => { + if lzma_index_memusage(1 as lzma_vli, (*coder).count) > (*coder).memlimit + { + ret = LZMA_MEMLIMIT_ERROR; + break; + } else { + lzma_index_prealloc((*coder).index, (*coder).count); + ret = LZMA_OK; + (*coder).sequence = (if (*coder).count == 0 as lzma_vli { + SEQ_PADDING_INIT as ::core::ffi::c_int + } else { + SEQ_UNPADDED as ::core::ffi::c_int + }) as C2RustUnnamed_0; + continue; + } + } + _ => {} + } + loop { + if *in_pos == in_size { + return LZMA_OK; + } + let fresh2 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + if (*coder).crc32 >> (*coder).pos.wrapping_mul(8 as size_t) + & 0xff as uint32_t != *in_0.offset(fresh2 as isize) as uint32_t + { + return LZMA_DATA_ERROR; + } + (*coder).pos = (*coder).pos.wrapping_add(1); + if !((*coder).pos < 4 as size_t) { + break; + } + } + *(*coder).index_ptr = (*coder).index; + (*coder).index = ::core::ptr::null_mut::(); + return LZMA_STREAM_END; + } + let in_used: size_t = (*in_pos).wrapping_sub(in_start); + if in_used > 0 as size_t { + (*coder).crc32 = lzma_crc32( + in_0.offset(in_start as isize), + in_used, + (*coder).crc32, + ); + } + return ret; +} +unsafe extern "C" fn index_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; + lzma_index_end((*coder).index, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn index_decoder_memconfig( + mut coder_ptr: *mut ::core::ffi::c_void, + mut memusage: *mut uint64_t, + mut old_memlimit: *mut uint64_t, + mut new_memlimit: uint64_t, +) -> lzma_ret { + let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; + *memusage = lzma_index_memusage(1 as lzma_vli, (*coder).count); + *old_memlimit = (*coder).memlimit; + if new_memlimit != 0 as uint64_t { + if new_memlimit < *memusage { + return LZMA_MEMLIMIT_ERROR; + } + (*coder).memlimit = new_memlimit; + } + return LZMA_OK; +} +unsafe extern "C" fn index_decoder_reset( + mut coder: *mut lzma_index_coder, + mut allocator: *const lzma_allocator, + mut i: *mut *mut lzma_index, + mut memlimit: uint64_t, +) -> lzma_ret { + (*coder).index_ptr = i; + *i = ::core::ptr::null_mut::(); + (*coder).index = lzma_index_init(allocator); + if (*coder).index.is_null() { + return LZMA_MEM_ERROR; + } + (*coder).sequence = SEQ_INDICATOR; + (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).count = 0 as lzma_vli; + (*coder).pos = 0 as size_t; + (*coder).crc32 = 0 as uint32_t; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut i: *mut *mut lzma_index, + mut memlimit: uint64_t, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut *mut lzma_index, + uint64_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_index_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut *mut lzma_index, + uint64_t, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut *mut lzma_index, + uint64_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_index_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut *mut lzma_index, + uint64_t, + ) -> lzma_ret, + ), + ); + if i.is_null() { + return LZMA_PROG_ERROR; + } + let mut coder: *mut lzma_index_coder = (*next).coder as *mut lzma_index_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_index_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + index_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + index_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).memconfig = Some( + index_decoder_memconfig + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >; + (*coder).index = ::core::ptr::null_mut::(); + } else { + lzma_index_end((*coder).index, allocator); + } + return index_decoder_reset(coder, allocator, i, memlimit); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_decoder( + mut strm: *mut lzma_stream, + mut i: *mut *mut lzma_index, + mut memlimit: uint64_t, +) -> lzma_ret { + if !i.is_null() { + *i = ::core::ptr::null_mut::(); + } + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_index_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + i, + memlimit, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_buffer_decode( + mut i: *mut *mut lzma_index, + mut memlimit: *mut uint64_t, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + if !i.is_null() { + *i = ::core::ptr::null_mut::(); + } + if i.is_null() || memlimit.is_null() || in_0.is_null() || in_pos.is_null() + || *in_pos > in_size + { + return LZMA_PROG_ERROR; + } + let mut coder: lzma_index_coder = lzma_index_coder { + sequence: SEQ_INDICATOR, + memlimit: 0, + index: ::core::ptr::null_mut::(), + index_ptr: ::core::ptr::null_mut::<*mut lzma_index>(), + count: 0, + unpadded_size: 0, + uncompressed_size: 0, + pos: 0, + crc32: 0, + }; + let ret_: lzma_ret = index_decoder_reset(&raw mut coder, allocator, i, *memlimit) + as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let in_start: size_t = *in_pos; + let mut ret: lzma_ret = index_decode( + &raw mut coder as *mut ::core::ffi::c_void, + allocator, + in_0, + in_pos, + in_size, + ::core::ptr::null_mut::(), + ::core::ptr::null_mut::(), + 0 as size_t, + LZMA_RUN, + ); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_OK; + } else { + lzma_index_end(coder.index, allocator); + *in_pos = in_start; + if ret as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_DATA_ERROR; + } else if ret as ::core::ffi::c_uint + == LZMA_MEMLIMIT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + { + *memlimit = lzma_index_memusage(1 as lzma_vli, coder.count); + } + } + return ret; +} diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs new file mode 100644 index 00000000..d8774069 --- /dev/null +++ b/liblzma-rs/src/common/index_encoder.rs @@ -0,0 +1,637 @@ +#[repr(C)] +pub struct lzma_index_s { _opaque: [u8; 0] } +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_vli_encode( + vli: lzma_vli, + vli_pos: *mut size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli; + fn lzma_index_size(i: *const lzma_index) -> lzma_vli; + fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index); + fn lzma_index_iter_next( + iter: *mut lzma_index_iter, + mode: lzma_index_iter_mode, + ) -> lzma_bool; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_index_padding_size(i: *const lzma_index) -> uint32_t; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +pub type lzma_index = lzma_index_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_iter { + pub stream: C2RustUnnamed_2, + pub block: C2RustUnnamed_1, + pub internal: [C2RustUnnamed_0; 6], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub p: *const ::core::ffi::c_void, + pub s: size_t, + pub v: lzma_vli, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_1 { + pub number_in_file: lzma_vli, + pub compressed_file_offset: lzma_vli, + pub uncompressed_file_offset: lzma_vli, + pub number_in_stream: lzma_vli, + pub compressed_stream_offset: lzma_vli, + pub uncompressed_stream_offset: lzma_vli, + pub uncompressed_size: lzma_vli, + pub unpadded_size: lzma_vli, + pub total_size: lzma_vli, + pub reserved_vli1: lzma_vli, + pub reserved_vli2: lzma_vli, + pub reserved_vli3: lzma_vli, + pub reserved_vli4: lzma_vli, + pub reserved_ptr1: *const ::core::ffi::c_void, + pub reserved_ptr2: *const ::core::ffi::c_void, + pub reserved_ptr3: *const ::core::ffi::c_void, + pub reserved_ptr4: *const ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_2 { + pub flags: *const lzma_stream_flags, + pub reserved_ptr1: *const ::core::ffi::c_void, + pub reserved_ptr2: *const ::core::ffi::c_void, + pub reserved_ptr3: *const ::core::ffi::c_void, + pub number: lzma_vli, + pub block_count: lzma_vli, + pub compressed_offset: lzma_vli, + pub uncompressed_offset: lzma_vli, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub padding: lzma_vli, + pub reserved_vli1: lzma_vli, + pub reserved_vli2: lzma_vli, + pub reserved_vli3: lzma_vli, + pub reserved_vli4: lzma_vli, +} +pub type lzma_index_iter_mode = ::core::ffi::c_uint; +pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; +pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; +pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; +pub const LZMA_INDEX_ITER_ANY: lzma_index_iter_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_coder { + pub sequence: C2RustUnnamed_3, + pub index: *const lzma_index, + pub iter: lzma_index_iter, + pub pos: size_t, + pub crc32: uint32_t, +} +pub type C2RustUnnamed_3 = ::core::ffi::c_uint; +pub const SEQ_CRC32: C2RustUnnamed_3 = 6; +pub const SEQ_PADDING: C2RustUnnamed_3 = 5; +pub const SEQ_NEXT: C2RustUnnamed_3 = 4; +pub const SEQ_UNCOMPRESSED: C2RustUnnamed_3 = 3; +pub const SEQ_UNPADDED: C2RustUnnamed_3 = 2; +pub const SEQ_COUNT: C2RustUnnamed_3 = 1; +pub const SEQ_INDICATOR: C2RustUnnamed_3 = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const INDEX_INDICATOR: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn index_encode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut current_block: u64; + let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; + let out_start: size_t = *out_pos; + let mut ret: lzma_ret = LZMA_OK; + while *out_pos < out_size { + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + *out.offset(*out_pos as isize) = INDEX_INDICATOR as uint8_t; + *out_pos = (*out_pos).wrapping_add(1); + (*coder).sequence = SEQ_COUNT; + continue; + } + 1 => { + let count: lzma_vli = lzma_index_block_count((*coder).index) as lzma_vli; + ret = lzma_vli_encode( + count, + &raw mut (*coder).pos, + out, + out_pos, + out_size, + ); + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + break; + } + ret = LZMA_OK; + (*coder).pos = 0 as size_t; + (*coder).sequence = SEQ_NEXT; + continue; + } + 4 => { + if lzma_index_iter_next(&raw mut (*coder).iter, LZMA_INDEX_ITER_BLOCK) + != 0 + { + (*coder).pos = lzma_index_padding_size((*coder).index) as size_t; + (*coder).sequence = SEQ_PADDING; + continue; + } else { + (*coder).sequence = SEQ_UNPADDED; + } + current_block = 10048703153582371463; + } + 2 | 3 => { + current_block = 10048703153582371463; + } + 5 => { + if (*coder).pos > 0 as size_t { + (*coder).pos = (*coder).pos.wrapping_sub(1); + let fresh0 = *out_pos; + *out_pos = (*out_pos).wrapping_add(1); + *out.offset(fresh0 as isize) = 0 as uint8_t; + continue; + } else { + (*coder).crc32 = lzma_crc32( + out.offset(out_start as isize), + (*out_pos).wrapping_sub(out_start), + (*coder).crc32, + ); + (*coder).sequence = SEQ_CRC32; + } + current_block = 10175200006830010844; + } + 6 => { + current_block = 10175200006830010844; + } + _ => return LZMA_PROG_ERROR, + } + match current_block { + 10048703153582371463 => { + let size: lzma_vli = if (*coder).sequence as ::core::ffi::c_uint + == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*coder).iter.block.unpadded_size + } else { + (*coder).iter.block.uncompressed_size + }; + ret = lzma_vli_encode( + size, + &raw mut (*coder).pos, + out, + out_pos, + out_size, + ); + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + break; + } + ret = LZMA_OK; + (*coder).pos = 0 as size_t; + (*coder).sequence += 1; + } + _ => { + loop { + if *out_pos == out_size { + return LZMA_OK; + } + *out.offset(*out_pos as isize) = ((*coder).crc32 + >> (*coder).pos.wrapping_mul(8 as size_t) & 0xff as uint32_t) + as uint8_t; + *out_pos = (*out_pos).wrapping_add(1); + (*coder).pos = (*coder).pos.wrapping_add(1); + if !((*coder).pos < 4 as size_t) { + break; + } + } + return LZMA_STREAM_END; + } + } + } + let out_used: size_t = (*out_pos).wrapping_sub(out_start); + if out_used > 0 as size_t { + (*coder).crc32 = lzma_crc32( + out.offset(out_start as isize), + out_used, + (*coder).crc32, + ); + } + return ret; +} +unsafe extern "C" fn index_encoder_end( + mut coder: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + lzma_free(coder, allocator); +} +unsafe extern "C" fn index_encoder_reset( + mut coder: *mut lzma_index_coder, + mut i: *const lzma_index, +) { + lzma_index_iter_init(&raw mut (*coder).iter, i); + (*coder).sequence = SEQ_INDICATOR; + (*coder).index = i; + (*coder).pos = 0 as size_t; + (*coder).crc32 = 0 as uint32_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut i: *const lzma_index, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_index, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_index_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_index, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_index, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_index_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_index, + ) -> lzma_ret, + ), + ); + if i.is_null() { + return LZMA_PROG_ERROR; + } + if (*next).coder.is_null() { + (*next).coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ); + if (*next).coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).code = Some( + index_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + index_encoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + } + index_encoder_reset((*next).coder as *mut lzma_index_coder, i); + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_encoder( + mut strm: *mut lzma_stream, + mut i: *const lzma_index, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_index_encoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + i, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_buffer_encode( + mut i: *const lzma_index, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + if i.is_null() || out.is_null() || out_pos.is_null() || *out_pos > out_size { + return LZMA_PROG_ERROR; + } + if (out_size.wrapping_sub(*out_pos) as lzma_vli) < lzma_index_size(i) { + return LZMA_BUF_ERROR; + } + let mut coder: lzma_index_coder = lzma_index_coder { + sequence: SEQ_INDICATOR, + index: ::core::ptr::null::(), + iter: lzma_index_iter { + stream: C2RustUnnamed_2 { + flags: ::core::ptr::null::(), + reserved_ptr1: ::core::ptr::null::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null::<::core::ffi::c_void>(), + reserved_ptr3: ::core::ptr::null::<::core::ffi::c_void>(), + number: 0, + block_count: 0, + compressed_offset: 0, + uncompressed_offset: 0, + compressed_size: 0, + uncompressed_size: 0, + padding: 0, + reserved_vli1: 0, + reserved_vli2: 0, + reserved_vli3: 0, + reserved_vli4: 0, + }, + block: C2RustUnnamed_1 { + number_in_file: 0, + compressed_file_offset: 0, + uncompressed_file_offset: 0, + number_in_stream: 0, + compressed_stream_offset: 0, + uncompressed_stream_offset: 0, + uncompressed_size: 0, + unpadded_size: 0, + total_size: 0, + reserved_vli1: 0, + reserved_vli2: 0, + reserved_vli3: 0, + reserved_vli4: 0, + reserved_ptr1: ::core::ptr::null::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null::<::core::ffi::c_void>(), + reserved_ptr3: ::core::ptr::null::<::core::ffi::c_void>(), + reserved_ptr4: ::core::ptr::null::<::core::ffi::c_void>(), + }, + internal: [C2RustUnnamed_0 { + p: ::core::ptr::null::<::core::ffi::c_void>(), + }; 6], + }, + pos: 0, + crc32: 0, + }; + index_encoder_reset(&raw mut coder, i); + let out_start: size_t = *out_pos; + let mut ret: lzma_ret = index_encode( + &raw mut coder as *mut ::core::ffi::c_void, + ::core::ptr::null::(), + ::core::ptr::null::(), + ::core::ptr::null_mut::(), + 0 as size_t, + out, + out_pos, + out_size, + LZMA_RUN, + ); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_OK; + } else { + *out_pos = out_start; + ret = LZMA_PROG_ERROR; + } + return ret; +} diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs new file mode 100644 index 00000000..975894ab --- /dev/null +++ b/liblzma-rs/src/common/index_hash.rs @@ -0,0 +1,482 @@ +extern "C" { + fn memcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: size_t, + ) -> ::core::ffi::c_int; + fn lzma_vli_decode( + vli: *mut lzma_vli, + vli_pos: *mut size_t, + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + fn lzma_vli_size(vli: lzma_vli) -> uint32_t; + fn lzma_check_size(check: lzma_check) -> uint32_t; + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); + fn lzma_check_update( + check: *mut lzma_check_state, + type_0: lzma_check, + buf: *const uint8_t, + size: size_t, + ); + fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_hash_s { + pub sequence: C2RustUnnamed_1, + pub blocks: lzma_index_hash_info, + pub records: lzma_index_hash_info, + pub remaining: lzma_vli, + pub unpadded_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub pos: size_t, + pub crc32: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_hash_info { + pub blocks_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub count: lzma_vli, + pub index_list_size: lzma_vli, + pub check: lzma_check_state, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_check_state { + pub buffer: C2RustUnnamed_0, + pub state: C2RustUnnamed, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub crc32: uint32_t, + pub crc64: uint64_t, + pub sha256: lzma_sha256_state, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_sha256_state { + pub state: [uint32_t; 8], + pub size: uint64_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub u8_0: [uint8_t; 64], + pub u32_0: [uint32_t; 16], + pub u64_0: [uint64_t; 8], +} +pub type C2RustUnnamed_1 = ::core::ffi::c_uint; +pub const SEQ_CRC32: C2RustUnnamed_1 = 6; +pub const SEQ_PADDING: C2RustUnnamed_1 = 5; +pub const SEQ_PADDING_INIT: C2RustUnnamed_1 = 4; +pub const SEQ_UNCOMPRESSED: C2RustUnnamed_1 = 3; +pub const SEQ_UNPADDED: C2RustUnnamed_1 = 2; +pub const SEQ_COUNT: C2RustUnnamed_1 = 1; +pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; +pub type lzma_index_hash = lzma_index_hash_s; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const LZMA_BACKWARD_SIZE_MAX: ::core::ffi::c_ulonglong = (1 + as ::core::ffi::c_ulonglong) << 34 as ::core::ffi::c_int; +pub const UNPADDED_SIZE_MIN: ::core::ffi::c_ulonglong = 5 as ::core::ffi::c_ulonglong; +pub const UNPADDED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX + & !(3 as ::core::ffi::c_ulonglong); +pub const INDEX_INDICATOR: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { + return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); +} +#[inline] +unsafe extern "C" fn index_size_unpadded( + mut count: lzma_vli, + mut index_list_size: lzma_vli, +) -> lzma_vli { + return ((1 as uint32_t).wrapping_add(lzma_vli_size(count)) as lzma_vli) + .wrapping_add(index_list_size) + .wrapping_add(4 as lzma_vli); +} +#[inline] +unsafe extern "C" fn index_size( + mut count: lzma_vli, + mut index_list_size: lzma_vli, +) -> lzma_vli { + return vli_ceil4(index_size_unpadded(count, index_list_size)); +} +#[inline] +unsafe extern "C" fn index_stream_size( + mut blocks_size: lzma_vli, + mut count: lzma_vli, + mut index_list_size: lzma_vli, +) -> lzma_vli { + return (LZMA_STREAM_HEADER_SIZE as lzma_vli) + .wrapping_add(blocks_size) + .wrapping_add(index_size(count, index_list_size)) + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_init( + mut index_hash: *mut lzma_index_hash, + mut allocator: *const lzma_allocator, +) -> *mut lzma_index_hash { + if index_hash.is_null() { + index_hash = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_index_hash; + if index_hash.is_null() { + return ::core::ptr::null_mut::(); + } + } + (*index_hash).sequence = SEQ_BLOCK; + (*index_hash).blocks.blocks_size = 0 as lzma_vli; + (*index_hash).blocks.uncompressed_size = 0 as lzma_vli; + (*index_hash).blocks.count = 0 as lzma_vli; + (*index_hash).blocks.index_list_size = 0 as lzma_vli; + (*index_hash).records.blocks_size = 0 as lzma_vli; + (*index_hash).records.uncompressed_size = 0 as lzma_vli; + (*index_hash).records.count = 0 as lzma_vli; + (*index_hash).records.index_list_size = 0 as lzma_vli; + (*index_hash).unpadded_size = 0 as lzma_vli; + (*index_hash).uncompressed_size = 0 as lzma_vli; + (*index_hash).pos = 0 as size_t; + (*index_hash).crc32 = 0 as uint32_t; + lzma_check_init(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); + lzma_check_init(&raw mut (*index_hash).records.check, LZMA_CHECK_SHA256); + return index_hash; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_end( + mut index_hash: *mut lzma_index_hash, + mut allocator: *const lzma_allocator, +) { + lzma_free(index_hash as *mut ::core::ffi::c_void, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_size( + mut index_hash: *const lzma_index_hash, +) -> lzma_vli { + return index_size((*index_hash).blocks.count, (*index_hash).blocks.index_list_size); +} +unsafe extern "C" fn hash_append( + mut info: *mut lzma_index_hash_info, + mut unpadded_size: lzma_vli, + mut uncompressed_size: lzma_vli, +) { + (*info).blocks_size = (*info).blocks_size.wrapping_add(vli_ceil4(unpadded_size)); + (*info).uncompressed_size = (*info) + .uncompressed_size + .wrapping_add(uncompressed_size); + (*info).index_list_size = (*info) + .index_list_size + .wrapping_add( + lzma_vli_size(unpadded_size).wrapping_add(lzma_vli_size(uncompressed_size)) + as lzma_vli, + ); + (*info).count = (*info).count.wrapping_add(1); + let sizes: [lzma_vli; 2] = [unpadded_size, uncompressed_size]; + lzma_check_update( + &raw mut (*info).check, + LZMA_CHECK_SHA256, + &raw const sizes as *const lzma_vli as *const uint8_t, + ::core::mem::size_of::<[lzma_vli; 2]>() as size_t, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_append( + mut index_hash: *mut lzma_index_hash, + mut unpadded_size: lzma_vli, + mut uncompressed_size: lzma_vli, +) -> lzma_ret { + if index_hash.is_null() + || (*index_hash).sequence as ::core::ffi::c_uint + != SEQ_BLOCK as ::core::ffi::c_int as ::core::ffi::c_uint + || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli + || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli + || uncompressed_size > LZMA_VLI_MAX as lzma_vli + { + return LZMA_PROG_ERROR; + } + hash_append(&raw mut (*index_hash).blocks, unpadded_size, uncompressed_size); + if (*index_hash).blocks.blocks_size > LZMA_VLI_MAX as lzma_vli + || (*index_hash).blocks.uncompressed_size > LZMA_VLI_MAX as lzma_vli + || index_size((*index_hash).blocks.count, (*index_hash).blocks.index_list_size) + > LZMA_BACKWARD_SIZE_MAX as lzma_vli + || index_stream_size( + (*index_hash).blocks.blocks_size, + (*index_hash).blocks.count, + (*index_hash).blocks.index_list_size, + ) > LZMA_VLI_MAX as lzma_vli + { + return LZMA_DATA_ERROR; + } + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_decode( + mut index_hash: *mut lzma_index_hash, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + let mut current_block: u64; + if *in_pos >= in_size { + return LZMA_BUF_ERROR; + } + let in_start: size_t = *in_pos; + let mut ret: lzma_ret = LZMA_OK; + while *in_pos < in_size { + match (*index_hash).sequence as ::core::ffi::c_uint { + 0 => { + let fresh0 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + if *in_0.offset(fresh0 as isize) as ::core::ffi::c_int != INDEX_INDICATOR + { + return LZMA_DATA_ERROR; + } + (*index_hash).sequence = SEQ_COUNT; + continue; + } + 1 => { + ret = lzma_vli_decode( + &raw mut (*index_hash).remaining, + &raw mut (*index_hash).pos, + in_0, + in_pos, + in_size, + ); + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + break; + } + if (*index_hash).remaining != (*index_hash).blocks.count { + return LZMA_DATA_ERROR; + } + ret = LZMA_OK; + (*index_hash).pos = 0 as size_t; + (*index_hash).sequence = (if (*index_hash).remaining == 0 as lzma_vli { + SEQ_PADDING_INIT as ::core::ffi::c_int + } else { + SEQ_UNPADDED as ::core::ffi::c_int + }) as C2RustUnnamed_1; + continue; + } + 2 | 3 => { + let mut size: *mut lzma_vli = if (*index_hash).sequence + as ::core::ffi::c_uint + == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint + { + &raw mut (*index_hash).unpadded_size + } else { + &raw mut (*index_hash).uncompressed_size + }; + ret = lzma_vli_decode( + size, + &raw mut (*index_hash).pos, + in_0, + in_pos, + in_size, + ); + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + break; + } + ret = LZMA_OK; + (*index_hash).pos = 0 as size_t; + if (*index_hash).sequence as ::core::ffi::c_uint + == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint + { + if (*index_hash).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli + || (*index_hash).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli + { + return LZMA_DATA_ERROR; + } + (*index_hash).sequence = SEQ_UNCOMPRESSED; + } else { + hash_append( + &raw mut (*index_hash).records, + (*index_hash).unpadded_size, + (*index_hash).uncompressed_size, + ); + if (*index_hash).blocks.blocks_size + < (*index_hash).records.blocks_size + || (*index_hash).blocks.uncompressed_size + < (*index_hash).records.uncompressed_size + || (*index_hash).blocks.index_list_size + < (*index_hash).records.index_list_size + { + return LZMA_DATA_ERROR; + } + (*index_hash).remaining = (*index_hash).remaining.wrapping_sub(1); + (*index_hash).sequence = (if (*index_hash).remaining == 0 as lzma_vli + { + SEQ_PADDING_INIT as ::core::ffi::c_int + } else { + SEQ_UNPADDED as ::core::ffi::c_int + }) as C2RustUnnamed_1; + } + continue; + } + 4 => { + (*index_hash).pos = ((4 as lzma_vli) + .wrapping_sub( + index_size_unpadded( + (*index_hash).records.count, + (*index_hash).records.index_list_size, + ), + ) & 3 as lzma_vli) as size_t; + (*index_hash).sequence = SEQ_PADDING; + current_block = 12753679906265593574; + } + 5 => { + current_block = 12753679906265593574; + } + 6 => { + current_block = 88292361528268742; + } + _ => return LZMA_PROG_ERROR, + } + match current_block { + 12753679906265593574 => { + if (*index_hash).pos > 0 as size_t { + (*index_hash).pos = (*index_hash).pos.wrapping_sub(1); + let fresh1 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + if *in_0.offset(fresh1 as isize) as ::core::ffi::c_int + != 0 as ::core::ffi::c_int + { + return LZMA_DATA_ERROR; + } + continue; + } else { + if (*index_hash).blocks.blocks_size + != (*index_hash).records.blocks_size + || (*index_hash).blocks.uncompressed_size + != (*index_hash).records.uncompressed_size + || (*index_hash).blocks.index_list_size + != (*index_hash).records.index_list_size + { + return LZMA_DATA_ERROR; + } + lzma_check_finish( + &raw mut (*index_hash).blocks.check, + LZMA_CHECK_SHA256, + ); + lzma_check_finish( + &raw mut (*index_hash).records.check, + LZMA_CHECK_SHA256, + ); + if memcmp( + &raw mut (*index_hash).blocks.check.buffer.u8_0 as *mut uint8_t + as *const ::core::ffi::c_void, + &raw mut (*index_hash).records.check.buffer.u8_0 as *mut uint8_t + as *const ::core::ffi::c_void, + lzma_check_size(LZMA_CHECK_SHA256) as size_t, + ) != 0 as ::core::ffi::c_int + { + return LZMA_DATA_ERROR; + } + (*index_hash).crc32 = lzma_crc32( + in_0.offset(in_start as isize), + (*in_pos).wrapping_sub(in_start), + (*index_hash).crc32, + ); + (*index_hash).sequence = SEQ_CRC32; + } + } + _ => {} + } + loop { + if *in_pos == in_size { + return LZMA_OK; + } + let fresh2 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8 as size_t) + & 0xff as uint32_t != *in_0.offset(fresh2 as isize) as uint32_t + { + return LZMA_DATA_ERROR; + } + (*index_hash).pos = (*index_hash).pos.wrapping_add(1); + if !((*index_hash).pos < 4 as size_t) { + break; + } + } + return LZMA_STREAM_END; + } + let in_used: size_t = (*in_pos).wrapping_sub(in_start); + if in_used > 0 as size_t { + (*index_hash).crc32 = lzma_crc32( + in_0.offset(in_start as isize), + in_used, + (*index_hash).crc32, + ); + } + return ret; +} diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs new file mode 100644 index 00000000..2757dca8 --- /dev/null +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -0,0 +1,787 @@ +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_lzma_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma_decoder_memusage_nocheck( + options: *const ::core::ffi::c_void, + ) -> uint64_t; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lzip_coder { + pub sequence: C2RustUnnamed_0, + pub version: uint32_t, + pub crc32: uint32_t, + pub uncompressed_size: uint64_t, + pub member_size: uint64_t, + pub memlimit: uint64_t, + pub memusage: uint64_t, + pub tell_any_check: bool, + pub ignore_check: bool, + pub concatenated: bool, + pub first_member: bool, + pub pos: size_t, + pub buffer: [uint8_t; 20], + pub options: lzma_options_lzma, + pub lzma_decoder: lzma_next_coder, +} +pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub const SEQ_MEMBER_FOOTER: C2RustUnnamed_0 = 5; +pub const SEQ_LZMA_STREAM: C2RustUnnamed_0 = 4; +pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; +pub const SEQ_DICT_SIZE: C2RustUnnamed_0 = 2; +pub const SEQ_VERSION: C2RustUnnamed_0 = 1; +pub const SEQ_ID_STRING: C2RustUnnamed_0 = 0; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { + let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; + num + |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + num + |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 16 as ::core::ffi::c_int; + num + |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) + << 24 as ::core::ffi::c_int; + return num; +} +#[inline] +unsafe extern "C" fn read64le(mut buf: *const uint8_t) -> uint64_t { + let mut num: uint64_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint64_t; + num + |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint64_t) + << 8 as ::core::ffi::c_int; + num + |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint64_t) + << 16 as ::core::ffi::c_int; + num + |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint64_t) + << 24 as ::core::ffi::c_int; + num + |= (*buf.offset(4 as ::core::ffi::c_int as isize) as uint64_t) + << 32 as ::core::ffi::c_int; + num + |= (*buf.offset(5 as ::core::ffi::c_int as isize) as uint64_t) + << 40 as ::core::ffi::c_int; + num + |= (*buf.offset(6 as ::core::ffi::c_int as isize) as uint64_t) + << 48 as ::core::ffi::c_int; + num + |= (*buf.offset(7 as ::core::ffi::c_int as isize) as uint64_t) + << 56 as ::core::ffi::c_int; + return num; +} +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 + as ::core::ffi::c_ulonglong; +pub const LZMA_TELL_NO_CHECK: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; +pub const LZMA_TELL_UNSUPPORTED_CHECK: ::core::ffi::c_uint = 0x2 as ::core::ffi::c_uint; +pub const LZMA_TELL_ANY_CHECK: ::core::ffi::c_uint = 0x4 as ::core::ffi::c_uint; +pub const LZMA_IGNORE_CHECK: ::core::ffi::c_uint = 0x10 as ::core::ffi::c_uint; +pub const LZMA_CONCATENATED: ::core::ffi::c_uint = 0x8 as ::core::ffi::c_uint; +pub const LZMA_FAIL_FAST: ::core::ffi::c_uint = 0x20 as ::core::ffi::c_uint; +pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) + << 15 as ::core::ffi::c_int; +pub const LZMA_SUPPORTED_FLAGS: ::core::ffi::c_uint = LZMA_TELL_NO_CHECK + | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK | LZMA_IGNORE_CHECK + | LZMA_CONCATENATED | LZMA_FAIL_FAST; +pub const LZIP_V0_FOOTER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const LZIP_V1_FOOTER_SIZE: ::core::ffi::c_int = 20 as ::core::ffi::c_int; +pub const LZIP_LC: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +pub const LZIP_LP: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZIP_PB: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +unsafe extern "C" fn lzip_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; + loop { + let mut current_block_80: u64; + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + let lzip_id_string: [uint8_t; 4] = [ + 0x4c as ::core::ffi::c_int as uint8_t, + 0x5a as ::core::ffi::c_int as uint8_t, + 0x49 as ::core::ffi::c_int as uint8_t, + 0x50 as ::core::ffi::c_int as uint8_t, + ]; + while (*coder).pos < ::core::mem::size_of::<[uint8_t; 4]>() as usize { + if *in_pos >= in_size { + return (if !(*coder).first_member + && action as ::core::ffi::c_uint + == LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + { + LZMA_STREAM_END as ::core::ffi::c_int + } else { + LZMA_OK as ::core::ffi::c_int + }) as lzma_ret; + } + if *in_0.offset(*in_pos as isize) as ::core::ffi::c_int + != lzip_id_string[(*coder).pos as usize] as ::core::ffi::c_int + { + return (if !(*coder).first_member { + LZMA_STREAM_END as ::core::ffi::c_int + } else { + LZMA_FORMAT_ERROR as ::core::ffi::c_int + }) as lzma_ret; + } + *in_pos = (*in_pos).wrapping_add(1); + (*coder).pos = (*coder).pos.wrapping_add(1); + } + (*coder).pos = 0 as size_t; + (*coder).crc32 = 0 as uint32_t; + (*coder).uncompressed_size = 0 as uint64_t; + (*coder).member_size = ::core::mem::size_of::<[uint8_t; 4]>() + as uint64_t; + (*coder).sequence = SEQ_VERSION; + current_block_80 = 11220331375136032509; + } + 1 => { + current_block_80 = 11220331375136032509; + } + 2 => { + current_block_80 = 2770508642018830579; + } + 3 => { + current_block_80 = 15476230294461844687; + } + 4 => { + current_block_80 = 13394712405657322686; + } + 5 => { + current_block_80 = 13619784596304402172; + } + _ => return LZMA_PROG_ERROR, + } + match current_block_80 { + 11220331375136032509 => { + if *in_pos >= in_size { + return LZMA_OK; + } + let fresh0 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + (*coder).version = *in_0.offset(fresh0 as isize) as uint32_t; + if (*coder).version > 1 as uint32_t { + return LZMA_OPTIONS_ERROR; + } + (*coder).member_size = (*coder).member_size.wrapping_add(1); + (*coder).sequence = SEQ_DICT_SIZE; + if (*coder).tell_any_check { + return LZMA_GET_CHECK; + } + current_block_80 = 2770508642018830579; + } + _ => {} + } + match current_block_80 { + 2770508642018830579 => { + if *in_pos >= in_size { + return LZMA_OK; + } + let fresh1 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + let ds: uint32_t = *in_0.offset(fresh1 as isize) as uint32_t; + (*coder).member_size = (*coder).member_size.wrapping_add(1); + let b2log: uint32_t = ds & 0x1f as uint32_t; + let fracnum: uint32_t = ds >> 5 as ::core::ffi::c_int; + if b2log < 12 as uint32_t || b2log > 29 as uint32_t + || b2log == 12 as uint32_t && fracnum > 0 as uint32_t + { + return LZMA_DATA_ERROR; + } + (*coder).options.dict_size = ((1 as uint32_t) << b2log) + .wrapping_sub(fracnum << b2log.wrapping_sub(4 as uint32_t)); + (*coder).options.preset_dict = ::core::ptr::null::(); + (*coder).options.lc = LZIP_LC as uint32_t; + (*coder).options.lp = LZIP_LP as uint32_t; + (*coder).options.pb = LZIP_PB as uint32_t; + (*coder).memusage = lzma_lzma_decoder_memusage_nocheck( + &raw mut (*coder).options as *const ::core::ffi::c_void, + ) + .wrapping_add(LZMA_MEMUSAGE_BASE as uint64_t); + (*coder).sequence = SEQ_CODER_INIT; + current_block_80 = 15476230294461844687; + } + _ => {} + } + match current_block_80 { + 15476230294461844687 => { + if (*coder).memusage > (*coder).memlimit { + return LZMA_MEMLIMIT_ERROR; + } + let filters: [lzma_filter_info; 2] = [ + lzma_filter_info_s { + id: LZMA_FILTER_LZMA1 as lzma_vli, + init: Some( + lzma_lzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + options: &raw mut (*coder).options as *mut ::core::ffi::c_void, + }, + lzma_filter_info_s { + id: 0, + init: None, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + ]; + let ret_: lzma_ret = lzma_next_filter_init( + &raw mut (*coder).lzma_decoder, + allocator, + &raw const filters as *const lzma_filter_info, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + (*coder).crc32 = 0 as uint32_t; + (*coder).sequence = SEQ_LZMA_STREAM; + current_block_80 = 13394712405657322686; + } + _ => {} + } + match current_block_80 { + 13394712405657322686 => { + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + let ret: lzma_ret = (*coder) + .lzma_decoder + .code + .expect( + "non-null function pointer", + )( + (*coder).lzma_decoder.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + let out_used: size_t = (*out_pos).wrapping_sub(out_start); + (*coder).member_size = (*coder) + .member_size + .wrapping_add((*in_pos).wrapping_sub(in_start) as uint64_t); + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_add(out_used as uint64_t); + if !(*coder).ignore_check && out_used > 0 as size_t { + (*coder).crc32 = lzma_crc32( + out.offset(out_start as isize), + out_used, + (*coder).crc32, + ); + } + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + (*coder).sequence = SEQ_MEMBER_FOOTER; + } + _ => {} + } + let footer_size: size_t = (if (*coder).version == 0 as uint32_t { + LZIP_V0_FOOTER_SIZE + } else { + LZIP_V1_FOOTER_SIZE + }) as size_t; + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).pos, + footer_size, + ); + if (*coder).pos < footer_size { + return LZMA_OK; + } + (*coder).pos = 0 as size_t; + (*coder).member_size = (*coder) + .member_size + .wrapping_add(footer_size as uint64_t); + if !(*coder).ignore_check + && (*coder).crc32 + != read32le( + (&raw mut (*coder).buffer as *mut uint8_t) + .offset(0 as ::core::ffi::c_int as isize) as *mut uint8_t, + ) + { + return LZMA_DATA_ERROR; + } + if (*coder).uncompressed_size + != read64le( + (&raw mut (*coder).buffer as *mut uint8_t) + .offset(4 as ::core::ffi::c_int as isize) as *mut uint8_t, + ) + { + return LZMA_DATA_ERROR; + } + if (*coder).version > 0 as uint32_t { + if (*coder).member_size + != read64le( + (&raw mut (*coder).buffer as *mut uint8_t) + .offset(12 as ::core::ffi::c_int as isize) as *mut uint8_t, + ) + { + return LZMA_DATA_ERROR; + } + } + if !(*coder).concatenated { + return LZMA_STREAM_END; + } + (*coder).first_member = false_0 != 0; + (*coder).sequence = SEQ_ID_STRING; + }; +} +unsafe extern "C" fn lzip_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; + lzma_next_end(&raw mut (*coder).lzma_decoder, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn lzip_decoder_get_check( + mut coder_ptr: *const ::core::ffi::c_void, +) -> lzma_check { + return LZMA_CHECK_CRC32; +} +unsafe extern "C" fn lzip_decoder_memconfig( + mut coder_ptr: *mut ::core::ffi::c_void, + mut memusage: *mut uint64_t, + mut old_memlimit: *mut uint64_t, + mut new_memlimit: uint64_t, +) -> lzma_ret { + let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; + *memusage = (*coder).memusage; + *old_memlimit = (*coder).memlimit; + if new_memlimit != 0 as uint64_t { + if new_memlimit < (*coder).memusage { + return LZMA_MEMLIMIT_ERROR; + } + (*coder).memlimit = new_memlimit; + } + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzip_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut memlimit: uint64_t, + mut flags: uint32_t, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_lzip_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_lzip_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + ), + ); + if flags & !(LZMA_SUPPORTED_FLAGS as uint32_t) != 0 { + return LZMA_OPTIONS_ERROR; + } + let mut coder: *mut lzma_lzip_coder = (*next).coder as *mut lzma_lzip_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_lzip_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + lzip_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + lzip_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).get_check = Some( + lzip_decoder_get_check + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + ) as Option lzma_check>; + (*next).memconfig = Some( + lzip_decoder_memconfig + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >; + (*coder).lzma_decoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + (*coder).sequence = SEQ_ID_STRING; + (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).memusage = LZMA_MEMUSAGE_BASE as uint64_t; + (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as uint32_t != 0 as uint32_t; + (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as uint32_t != 0 as uint32_t; + (*coder).concatenated = flags & LZMA_CONCATENATED as uint32_t != 0 as uint32_t; + (*coder).first_member = true_0 != 0; + (*coder).pos = 0 as size_t; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzip_decoder( + mut strm: *mut lzma_stream, + mut memlimit: uint64_t, + mut flags: uint32_t, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_lzip_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + memlimit, + flags, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs new file mode 100644 index 00000000..7172b5f2 --- /dev/null +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -0,0 +1,574 @@ +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_lzma_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: uint8_t) -> bool; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_microlzma_coder { + pub lzma: lzma_next_coder, + pub comp_size: uint64_t, + pub uncomp_size: lzma_vli, + pub dict_size: uint32_t, + pub uncomp_size_is_exact: bool, + pub props_decoded: bool, +} +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 + as ::core::ffi::c_ulonglong; +unsafe extern "C" fn microlzma_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + if in_size.wrapping_sub(*in_pos) as uint64_t > (*coder).comp_size { + in_size = (*in_pos).wrapping_add((*coder).comp_size as size_t); + } + if !(*coder).uncomp_size_is_exact + && out_size.wrapping_sub(*out_pos) as lzma_vli > (*coder).uncomp_size + { + out_size = (*out_pos).wrapping_add((*coder).uncomp_size as size_t); + } + if !(*coder).props_decoded { + if *in_pos >= in_size { + return LZMA_OK; + } + let mut options: lzma_options_lzma = lzma_options_lzma { + dict_size: (*coder).dict_size, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0 as uint32_t, + lc: 0, + lp: 0, + pb: 0, + mode: 0 as lzma_mode, + nice_len: 0, + mf: 0 as lzma_match_finder, + depth: 0, + ext_flags: 0 as uint32_t, + ext_size_low: UINT32_MAX as uint32_t, + ext_size_high: UINT32_MAX as uint32_t, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; + if (*coder).uncomp_size_is_exact { + options.ext_size_low = (*coder).uncomp_size as uint32_t; + options.ext_size_high = ((*coder).uncomp_size >> 32 as ::core::ffi::c_int) + as uint32_t; + } + if lzma_lzma_lclppb_decode( + &raw mut options, + !(*in_0.offset(*in_pos as isize) as ::core::ffi::c_int) as uint8_t, + ) { + return LZMA_OPTIONS_ERROR; + } + *in_pos = (*in_pos).wrapping_add(1); + let mut filters: [lzma_filter_info; 2] = [ + lzma_filter_info_s { + id: LZMA_FILTER_LZMA1EXT as lzma_vli, + init: Some( + lzma_lzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + options: &raw mut options as *mut ::core::ffi::c_void, + }, + lzma_filter_info_s { + id: 0, + init: None, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + ]; + let ret_: lzma_ret = lzma_next_filter_init( + &raw mut (*coder).lzma, + allocator, + &raw mut filters as *mut lzma_filter_info, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let dummy_in: uint8_t = 0 as uint8_t; + let mut dummy_in_pos: size_t = 0 as size_t; + if (*coder) + .lzma + .code + .expect( + "non-null function pointer", + )( + (*coder).lzma.coder, + allocator, + &raw const dummy_in, + &raw mut dummy_in_pos, + 1 as size_t, + out, + out_pos, + out_size, + LZMA_RUN, + ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + (*coder).props_decoded = true_0 != 0; + } + let mut ret: lzma_ret = (*coder) + .lzma + .code + .expect( + "non-null function pointer", + )( + (*coder).lzma.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ); + (*coder).comp_size = (*coder) + .comp_size + .wrapping_sub((*in_pos).wrapping_sub(in_start) as uint64_t); + if (*coder).uncomp_size_is_exact { + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + && (*coder).comp_size != 0 as uint64_t + { + ret = LZMA_DATA_ERROR; + } + } else { + (*coder).uncomp_size = (*coder) + .uncomp_size + .wrapping_sub((*out_pos).wrapping_sub(out_start) as lzma_vli); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_DATA_ERROR; + } else if (*coder).uncomp_size == 0 as lzma_vli { + ret = LZMA_STREAM_END; + } + } + return ret; +} +unsafe extern "C" fn microlzma_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; + lzma_next_end(&raw mut (*coder).lzma, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn microlzma_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut comp_size: uint64_t, + mut uncomp_size: uint64_t, + mut uncomp_size_is_exact: bool, + mut dict_size: uint32_t, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint64_t, + bool, + uint32_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + microlzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint64_t, + bool, + uint32_t, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint64_t, + bool, + uint32_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + microlzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint64_t, + bool, + uint32_t, + ) -> lzma_ret, + ), + ); + let mut coder: *mut lzma_microlzma_coder = (*next).coder + as *mut lzma_microlzma_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_microlzma_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + microlzma_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + microlzma_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*coder).lzma = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + if uncomp_size > LZMA_VLI_MAX as uint64_t { + return LZMA_OPTIONS_ERROR; + } + (*coder).comp_size = comp_size; + (*coder).uncomp_size = uncomp_size as lzma_vli; + (*coder).uncomp_size_is_exact = uncomp_size_is_exact; + (*coder).dict_size = dict_size; + (*coder).props_decoded = false_0 != 0; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_microlzma_decoder( + mut strm: *mut lzma_stream, + mut comp_size: uint64_t, + mut uncomp_size: uint64_t, + mut uncomp_size_is_exact: lzma_bool, + mut dict_size: uint32_t, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = microlzma_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + comp_size, + uncomp_size, + uncomp_size_is_exact != 0, + dict_size, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs new file mode 100644 index 00000000..802b0aa2 --- /dev/null +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -0,0 +1,465 @@ +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_lzma_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_lzma_lclppb_encode( + options: *const lzma_options_lzma, + byte: *mut uint8_t, + ) -> bool; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_microlzma_coder { + pub lzma: lzma_next_coder, + pub props: uint8_t, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 + as ::core::ffi::c_ulonglong; +unsafe extern "C" fn microlzma_encode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; + let out_start: size_t = *out_pos; + let in_start: size_t = *in_pos; + let mut uncomp_size: uint64_t = 0; + if (*coder) + .lzma + .set_out_limit + .expect( + "non-null function pointer", + )( + (*coder).lzma.coder, + &raw mut uncomp_size, + out_size.wrapping_sub(*out_pos) as uint64_t, + ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + let ret: lzma_ret = (*coder) + .lzma + .code + .expect( + "non-null function pointer", + )( + (*coder).lzma.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + if ret as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + return ret; + } + *out.offset(out_start as isize) = !((*coder).props as ::core::ffi::c_int) as uint8_t; + *in_pos = in_start.wrapping_add(uncomp_size as size_t); + return ret; +} +unsafe extern "C" fn microlzma_encoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; + lzma_next_end(&raw mut (*coder).lzma, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn microlzma_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut options: *const lzma_options_lzma, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + microlzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + microlzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + ), + ); + let mut coder: *mut lzma_microlzma_coder = (*next).coder + as *mut lzma_microlzma_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_microlzma_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + microlzma_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + microlzma_encoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*coder).lzma = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + if lzma_lzma_lclppb_encode(options, &raw mut (*coder).props) { + return LZMA_OPTIONS_ERROR; + } + let filters: [lzma_filter_info; 2] = [ + lzma_filter_info_s { + id: LZMA_FILTER_LZMA1 as lzma_vli, + init: Some( + lzma_lzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, + ), + options: options as *mut ::core::ffi::c_void, + }, + lzma_filter_info_s { + id: 0, + init: None, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }, + ]; + return lzma_next_filter_init( + &raw mut (*coder).lzma, + allocator, + &raw const filters as *const lzma_filter_info, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_microlzma_encoder( + mut strm: *mut lzma_stream, + mut options: *const lzma_options_lzma, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = microlzma_encoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + options, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/mod.rs b/liblzma-rs/src/common/mod.rs new file mode 100644 index 00000000..537545fc --- /dev/null +++ b/liblzma-rs/src/common/mod.rs @@ -0,0 +1,45 @@ +pub mod alone_decoder; +pub mod alone_encoder; +pub mod auto_decoder; +pub mod block_buffer_decoder; +pub mod block_buffer_encoder; +pub mod block_decoder; +pub mod block_encoder; +pub mod block_header_decoder; +pub mod block_header_encoder; +pub mod block_util; +pub mod common; +pub mod easy_buffer_encoder; +pub mod easy_decoder_memusage; +pub mod easy_encoder; +pub mod easy_encoder_memusage; +pub mod easy_preset; +pub mod file_info; +pub mod filter_buffer_decoder; +pub mod filter_buffer_encoder; +pub mod filter_common; +pub mod filter_decoder; +pub mod filter_encoder; +pub mod filter_flags_decoder; +pub mod filter_flags_encoder; +pub mod hardware_cputhreads; +pub mod hardware_physmem; +pub mod index; +pub mod index_decoder; +pub mod index_encoder; +pub mod index_hash; +pub mod lzip_decoder; +pub mod microlzma_decoder; +pub mod microlzma_encoder; +pub mod outqueue; +pub mod stream_buffer_decoder; +pub mod stream_buffer_encoder; +pub mod stream_decoder; +pub mod stream_encoder; +pub mod stream_flags_common; +pub mod stream_flags_decoder; +pub mod stream_flags_encoder; +pub mod string_conversion; +pub mod vli_decoder; +pub mod vli_encoder; +pub mod vli_size; diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs new file mode 100644 index 00000000..f1e81152 --- /dev/null +++ b/liblzma-rs/src/common/outqueue.rs @@ -0,0 +1,317 @@ +extern "C" { + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_outbuf_s { + pub next: *mut lzma_outbuf, + pub worker: *mut ::core::ffi::c_void, + pub allocated: size_t, + pub pos: size_t, + pub decoder_in_pos: size_t, + pub finished: bool, + pub finish_ret: lzma_ret, + pub unpadded_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub buf: [uint8_t; 0], +} +pub type lzma_outbuf = lzma_outbuf_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_outq { + pub head: *mut lzma_outbuf, + pub tail: *mut lzma_outbuf, + pub read_pos: size_t, + pub cache: *mut lzma_outbuf, + pub mem_allocated: uint64_t, + pub mem_in_use: uint64_t, + pub bufs_in_use: uint32_t, + pub bufs_allocated: uint32_t, + pub bufs_limit: uint32_t, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const UINTPTR_MAX: ::core::ffi::c_ulong = 18446744073709551615 + as ::core::ffi::c_ulong; +pub const SIZE_MAX: ::core::ffi::c_ulong = UINTPTR_MAX; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_THREADS_MAX: ::core::ffi::c_int = 16384 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn lzma_outq_outbuf_memusage(mut buf_size: size_t) -> uint64_t { + return (::core::mem::size_of::() as usize) + .wrapping_add(buf_size as usize) as uint64_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_memusage( + mut buf_size_max: uint64_t, + mut threads: uint32_t, +) -> uint64_t { + let limit: uint64_t = (UINT64_MAX as uint64_t) + .wrapping_div( + (2 as ::core::ffi::c_int * 16384 as ::core::ffi::c_int) as uint64_t, + ) + .wrapping_div(2 as uint64_t); + if threads > LZMA_THREADS_MAX as uint32_t || buf_size_max > limit { + return UINT64_MAX as uint64_t; + } + return ((2 as uint32_t).wrapping_mul(threads) as uint64_t) + .wrapping_mul(lzma_outq_outbuf_memusage(buf_size_max as size_t)); +} +unsafe extern "C" fn move_head_to_cache( + mut outq: *mut lzma_outq, + mut allocator: *const lzma_allocator, +) { + let mut buf: *mut lzma_outbuf = (*outq).head; + (*outq).head = (*buf).next; + if (*outq).head.is_null() { + (*outq).tail = ::core::ptr::null_mut::(); + } + if !(*outq).cache.is_null() && (*(*outq).cache).allocated != (*buf).allocated { + lzma_outq_clear_cache(outq, allocator); + } + (*buf).next = (*outq).cache; + (*outq).cache = buf; + (*outq).bufs_in_use = (*outq).bufs_in_use.wrapping_sub(1); + (*outq).mem_in_use = (*outq) + .mem_in_use + .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); +} +unsafe extern "C" fn free_one_cached_buffer( + mut outq: *mut lzma_outq, + mut allocator: *const lzma_allocator, +) { + let mut buf: *mut lzma_outbuf = (*outq).cache; + (*outq).cache = (*buf).next; + (*outq).bufs_allocated = (*outq).bufs_allocated.wrapping_sub(1); + (*outq).mem_allocated = (*outq) + .mem_allocated + .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); + lzma_free(buf as *mut ::core::ffi::c_void, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_clear_cache( + mut outq: *mut lzma_outq, + mut allocator: *const lzma_allocator, +) { + while !(*outq).cache.is_null() { + free_one_cached_buffer(outq, allocator); + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_clear_cache2( + mut outq: *mut lzma_outq, + mut allocator: *const lzma_allocator, + mut keep_size: size_t, +) { + if (*outq).cache.is_null() { + return; + } + while !(*(*outq).cache).next.is_null() { + free_one_cached_buffer(outq, allocator); + } + if (*(*outq).cache).allocated != keep_size { + free_one_cached_buffer(outq, allocator); + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_init( + mut outq: *mut lzma_outq, + mut allocator: *const lzma_allocator, + mut threads: uint32_t, +) -> lzma_ret { + if threads > LZMA_THREADS_MAX as uint32_t { + return LZMA_OPTIONS_ERROR; + } + let bufs_limit: uint32_t = (2 as uint32_t).wrapping_mul(threads); + while !(*outq).head.is_null() { + move_head_to_cache(outq, allocator); + } + while bufs_limit < (*outq).bufs_allocated { + free_one_cached_buffer(outq, allocator); + } + (*outq).bufs_limit = bufs_limit; + (*outq).read_pos = 0 as size_t; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_end( + mut outq: *mut lzma_outq, + mut allocator: *const lzma_allocator, +) { + while !(*outq).head.is_null() { + move_head_to_cache(outq, allocator); + } + lzma_outq_clear_cache(outq, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_prealloc_buf( + mut outq: *mut lzma_outq, + mut allocator: *const lzma_allocator, + mut size: size_t, +) -> lzma_ret { + if !(*outq).cache.is_null() && (*(*outq).cache).allocated == size { + return LZMA_OK; + } + if size + > (SIZE_MAX as usize) + .wrapping_sub(::core::mem::size_of::() as usize) + { + return LZMA_MEM_ERROR; + } + let alloc_size: size_t = lzma_outq_outbuf_memusage(size) as size_t; + lzma_outq_clear_cache(outq, allocator); + (*outq).cache = lzma_alloc(alloc_size, allocator) as *mut lzma_outbuf; + if (*outq).cache.is_null() { + return LZMA_MEM_ERROR; + } + (*(*outq).cache).next = ::core::ptr::null_mut::(); + (*(*outq).cache).allocated = size; + (*outq).bufs_allocated = (*outq).bufs_allocated.wrapping_add(1); + (*outq).mem_allocated = (*outq).mem_allocated.wrapping_add(alloc_size as uint64_t); + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_get_buf( + mut outq: *mut lzma_outq, + mut worker: *mut ::core::ffi::c_void, +) -> *mut lzma_outbuf { + let mut buf: *mut lzma_outbuf = (*outq).cache; + (*outq).cache = (*buf).next; + (*buf).next = ::core::ptr::null_mut::(); + if !(*outq).tail.is_null() { + (*(*outq).tail).next = buf; + } else { + (*outq).head = buf; + } + (*outq).tail = buf; + (*buf).worker = worker; + (*buf).finished = false_0 != 0; + (*buf).finish_ret = LZMA_STREAM_END; + (*buf).pos = 0 as size_t; + (*buf).decoder_in_pos = 0 as size_t; + (*buf).unpadded_size = 0 as lzma_vli; + (*buf).uncompressed_size = 0 as lzma_vli; + (*outq).bufs_in_use = (*outq).bufs_in_use.wrapping_add(1); + (*outq).mem_in_use = (*outq) + .mem_in_use + .wrapping_add(lzma_outq_outbuf_memusage((*buf).allocated)); + return buf; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_is_readable(mut outq: *const lzma_outq) -> bool { + if (*outq).head.is_null() { + return false_0 != 0; + } + return (*outq).read_pos < (*(*outq).head).pos + || (*(*outq).head).finished as ::core::ffi::c_int != 0; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_read( + mut outq: *mut lzma_outq, + mut allocator: *const lzma_allocator, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut unpadded_size: *mut lzma_vli, + mut uncompressed_size: *mut lzma_vli, +) -> lzma_ret { + if (*outq).bufs_in_use == 0 as uint32_t { + return LZMA_OK; + } + let mut buf: *mut lzma_outbuf = (*outq).head; + lzma_bufcpy( + &raw mut (*buf).buf as *mut uint8_t, + &raw mut (*outq).read_pos, + (*buf).pos, + out, + out_pos, + out_size, + ); + if !(*buf).finished || (*outq).read_pos < (*buf).pos { + return LZMA_OK; + } + if !unpadded_size.is_null() { + *unpadded_size = (*buf).unpadded_size; + } + if !uncompressed_size.is_null() { + *uncompressed_size = (*buf).uncompressed_size; + } + let finish_ret: lzma_ret = (*buf).finish_ret; + move_head_to_cache(outq, allocator); + (*outq).read_pos = 0 as size_t; + return finish_ret; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_outq_enable_partial_output( + mut outq: *mut lzma_outq, + mut enable_partial_output: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void) -> (), + >, +) { + if !(*outq).head.is_null() && !(*(*outq).head).finished + && !(*(*outq).head).worker.is_null() + { + enable_partial_output + .expect("non-null function pointer")((*(*outq).head).worker); + (*(*outq).head).worker = NULL; + } +} diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs new file mode 100644 index 00000000..12e303e0 --- /dev/null +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -0,0 +1,225 @@ +extern "C" { + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_stream_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + memlimit: uint64_t, + flags: uint32_t, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_TELL_ANY_CHECK: ::core::ffi::c_uint = 0x4 as ::core::ffi::c_uint; +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_buffer_decode( + mut memlimit: *mut uint64_t, + mut flags: uint32_t, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + if in_pos.is_null() || in_0.is_null() && *in_pos != in_size || *in_pos > in_size + || out_pos.is_null() || out.is_null() && *out_pos != out_size + || *out_pos > out_size + { + return LZMA_PROG_ERROR; + } + if flags & LZMA_TELL_ANY_CHECK as uint32_t != 0 { + return LZMA_PROG_ERROR; + } + let mut stream_decoder: lzma_next_coder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + let mut ret: lzma_ret = lzma_stream_decoder_init( + &raw mut stream_decoder, + allocator, + *memlimit, + flags, + ); + if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + ret = stream_decoder + .code + .expect( + "non-null function pointer", + )( + stream_decoder.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + LZMA_FINISH, + ); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_OK; + } else { + *in_pos = in_start; + *out_pos = out_start; + if ret as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + if *in_pos == in_size { + ret = LZMA_DATA_ERROR; + } else { + ret = LZMA_BUF_ERROR; + } + } else if ret as ::core::ffi::c_uint + == LZMA_MEMLIMIT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + { + let mut memusage: uint64_t = 0; + stream_decoder + .memconfig + .expect( + "non-null function pointer", + )(stream_decoder.coder, memlimit, &raw mut memusage, 0 as uint64_t); + } + } + } + lzma_next_end(&raw mut stream_decoder, allocator); + return ret; +} diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs new file mode 100644 index 00000000..742e79fb --- /dev/null +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -0,0 +1,321 @@ +#[repr(C)] +pub struct lzma_index_s { _opaque: [u8; 0] } +extern "C" { + fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; + fn lzma_stream_header_encode( + options: *const lzma_stream_flags, + out: *mut uint8_t, + ) -> lzma_ret; + fn lzma_stream_footer_encode( + options: *const lzma_stream_flags, + out: *mut uint8_t, + ) -> lzma_ret; + fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; + fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t; + fn lzma_block_buffer_encode( + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const uint8_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; + fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; + fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); + fn lzma_index_append( + i: *mut lzma_index, + allocator: *const lzma_allocator, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, + ) -> lzma_ret; + fn lzma_index_size(i: *const lzma_index) -> lzma_vli; + fn lzma_index_buffer_encode( + i: *const lzma_index, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +pub type lzma_index = lzma_index_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const LZMA_VLI_BYTES_MAX: ::core::ffi::c_int = 9 as ::core::ffi::c_int; +pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const INDEX_BOUND: ::core::ffi::c_int = 1 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int + 2 as ::core::ffi::c_int * LZMA_VLI_BYTES_MAX + + 4 as ::core::ffi::c_int + 3 as ::core::ffi::c_int & !(3 as ::core::ffi::c_int); +pub const HEADERS_BOUND: ::core::ffi::c_int = 2 as ::core::ffi::c_int + * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_buffer_bound( + mut uncompressed_size: size_t, +) -> size_t { + let block_bound: size_t = lzma_block_buffer_bound(uncompressed_size) as size_t; + if block_bound == 0 as size_t { + return 0 as size_t; + } + if (if (18446744073709551615 as ::core::ffi::c_ulonglong) + < (18446744073709551615 as ::core::ffi::c_ulonglong) + .wrapping_div(2 as ::core::ffi::c_ulonglong) + { + 18446744073709551615 as ::core::ffi::c_ulonglong + } else { + (18446744073709551615 as ::core::ffi::c_ulonglong) + .wrapping_div(2 as ::core::ffi::c_ulonglong) + }) + .wrapping_sub(block_bound as ::core::ffi::c_ulonglong) + < HEADERS_BOUND as ::core::ffi::c_ulonglong + { + return 0 as size_t; + } + return block_bound.wrapping_add(HEADERS_BOUND as size_t); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_buffer_encode( + mut filters: *mut lzma_filter, + mut check: lzma_check, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos_ptr: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + if filters.is_null() + || check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + || in_0.is_null() && in_size != 0 as size_t || out.is_null() + || out_pos_ptr.is_null() || *out_pos_ptr > out_size + { + return LZMA_PROG_ERROR; + } + if lzma_check_is_supported(check) == 0 { + return LZMA_UNSUPPORTED_CHECK; + } + let mut out_pos: size_t = *out_pos_ptr; + if out_size.wrapping_sub(out_pos) + <= (2 as ::core::ffi::c_int * LZMA_STREAM_HEADER_SIZE) as size_t + { + return LZMA_BUF_ERROR; + } + out_size = out_size.wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); + let mut stream_flags: lzma_stream_flags = lzma_stream_flags { + version: 0 as uint32_t, + backward_size: 0, + check: check, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_bool1: 0, + reserved_bool2: 0, + reserved_bool3: 0, + reserved_bool4: 0, + reserved_bool5: 0, + reserved_bool6: 0, + reserved_bool7: 0, + reserved_bool8: 0, + reserved_int1: 0, + reserved_int2: 0, + }; + if lzma_stream_header_encode(&raw mut stream_flags, out.offset(out_pos as isize)) + as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); + let mut block: lzma_block = lzma_block { + version: 0 as uint32_t, + header_size: 0, + check: check, + compressed_size: 0, + uncompressed_size: 0, + filters: filters, + raw_check: [0; 64], + reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr3: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_int1: 0, + reserved_int2: 0, + reserved_int3: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + ignore_check: 0, + reserved_bool2: 0, + reserved_bool3: 0, + reserved_bool4: 0, + reserved_bool5: 0, + reserved_bool6: 0, + reserved_bool7: 0, + reserved_bool8: 0, + }; + if in_size > 0 as size_t { + let ret_: lzma_ret = lzma_block_buffer_encode( + &raw mut block, + allocator, + in_0, + in_size, + out, + &raw mut out_pos, + out_size, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + } + let mut i: *mut lzma_index = lzma_index_init(allocator); + if i.is_null() { + return LZMA_MEM_ERROR; + } + let mut ret: lzma_ret = LZMA_OK; + if in_size > 0 as size_t { + ret = lzma_index_append( + i, + allocator, + lzma_block_unpadded_size(&raw mut block), + block.uncompressed_size, + ); + } + if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = lzma_index_buffer_encode(i, out, &raw mut out_pos, out_size); + stream_flags.backward_size = lzma_index_size(i); + } + lzma_index_end(i, allocator); + if ret as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + if lzma_stream_footer_encode(&raw mut stream_flags, out.offset(out_pos as isize)) + as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); + *out_pos_ptr = out_pos; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs new file mode 100644 index 00000000..3f625e4b --- /dev/null +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -0,0 +1,871 @@ +#[repr(C)] +pub struct lzma_index_hash_s { _opaque: [u8; 0] } +extern "C" { + fn lzma_end(strm: *mut lzma_stream); + fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; + fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); + fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> uint64_t; + fn lzma_stream_header_decode( + options: *mut lzma_stream_flags, + in_0: *const uint8_t, + ) -> lzma_ret; + fn lzma_stream_footer_decode( + options: *mut lzma_stream_flags, + in_0: *const uint8_t, + ) -> lzma_ret; + fn lzma_stream_flags_compare( + a: *const lzma_stream_flags, + b: *const lzma_stream_flags, + ) -> lzma_ret; + fn lzma_block_header_decode( + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const uint8_t, + ) -> lzma_ret; + fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; + fn lzma_index_hash_init( + index_hash: *mut lzma_index_hash, + allocator: *const lzma_allocator, + ) -> *mut lzma_index_hash; + fn lzma_index_hash_end( + index_hash: *mut lzma_index_hash, + allocator: *const lzma_allocator, + ); + fn lzma_index_hash_append( + index_hash: *mut lzma_index_hash, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, + ) -> lzma_ret; + fn lzma_index_hash_decode( + index_hash: *mut lzma_index_hash, + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_block_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_coder { + pub sequence: C2RustUnnamed_0, + pub block_decoder: lzma_next_coder, + pub block_options: lzma_block, + pub stream_flags: lzma_stream_flags, + pub index_hash: *mut lzma_index_hash, + pub memlimit: uint64_t, + pub memusage: uint64_t, + pub tell_no_check: bool, + pub tell_unsupported_check: bool, + pub tell_any_check: bool, + pub ignore_check: bool, + pub concatenated: bool, + pub first_stream: bool, + pub pos: size_t, + pub buffer: [uint8_t; 1024], +} +pub type lzma_index_hash = lzma_index_hash_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 6; +pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; +pub const SEQ_INDEX: C2RustUnnamed_0 = 4; +pub const SEQ_BLOCK_RUN: C2RustUnnamed_0 = 3; +pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; +pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; +pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_TELL_NO_CHECK: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; +pub const LZMA_TELL_UNSUPPORTED_CHECK: ::core::ffi::c_uint = 0x2 as ::core::ffi::c_uint; +pub const LZMA_TELL_ANY_CHECK: ::core::ffi::c_uint = 0x4 as ::core::ffi::c_uint; +pub const LZMA_IGNORE_CHECK: ::core::ffi::c_uint = 0x10 as ::core::ffi::c_uint; +pub const LZMA_CONCATENATED: ::core::ffi::c_uint = 0x8 as ::core::ffi::c_uint; +pub const LZMA_FAIL_FAST: ::core::ffi::c_uint = 0x20 as ::core::ffi::c_uint; +pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) + << 15 as ::core::ffi::c_int; +pub const LZMA_SUPPORTED_FLAGS: ::core::ffi::c_uint = LZMA_TELL_NO_CHECK + | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK | LZMA_IGNORE_CHECK + | LZMA_CONCATENATED | LZMA_FAIL_FAST; +pub const INDEX_INDICATOR: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn stream_decoder_reset( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + (*coder).index_hash = lzma_index_hash_init((*coder).index_hash, allocator); + if (*coder).index_hash.is_null() { + return LZMA_MEM_ERROR; + } + (*coder).sequence = SEQ_STREAM_HEADER; + (*coder).pos = 0 as size_t; + return LZMA_OK; +} +unsafe extern "C" fn stream_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + loop { + let mut current_block_100: u64; + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).pos, + LZMA_STREAM_HEADER_SIZE as size_t, + ); + if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { + return LZMA_OK; + } + (*coder).pos = 0 as size_t; + let ret: lzma_ret = lzma_stream_header_decode( + &raw mut (*coder).stream_flags, + &raw mut (*coder).buffer as *mut uint8_t, + ) as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return (if ret as ::core::ffi::c_uint + == LZMA_FORMAT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + && !(*coder).first_stream + { + LZMA_DATA_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + } else { + ret as ::core::ffi::c_uint + }) as lzma_ret; + } + (*coder).first_stream = false_0 != 0; + (*coder).block_options.check = (*coder).stream_flags.check; + (*coder).sequence = SEQ_BLOCK_HEADER; + if (*coder).tell_no_check as ::core::ffi::c_int != 0 + && (*coder).stream_flags.check as ::core::ffi::c_uint + == LZMA_CHECK_NONE as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_NO_CHECK; + } + if (*coder).tell_unsupported_check as ::core::ffi::c_int != 0 + && lzma_check_is_supported((*coder).stream_flags.check) == 0 + { + return LZMA_UNSUPPORTED_CHECK; + } + if (*coder).tell_any_check { + return LZMA_GET_CHECK; + } + current_block_100 = 4166486009154926805; + } + 1 => { + current_block_100 = 4166486009154926805; + } + 2 => { + current_block_100 = 3500765272169221397; + } + 3 => { + current_block_100 = 721385680381463314; + } + 4 => { + if *in_pos >= in_size { + return LZMA_OK; + } + let ret_2: lzma_ret = lzma_index_hash_decode( + (*coder).index_hash, + in_0, + in_pos, + in_size, + ) as lzma_ret; + if ret_2 as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_2; + } + (*coder).sequence = SEQ_STREAM_FOOTER; + current_block_100 = 17861496924281778896; + } + 5 => { + current_block_100 = 17861496924281778896; + } + 6 => { + current_block_100 = 15462640364611497761; + } + _ => return LZMA_PROG_ERROR, + } + match current_block_100 { + 4166486009154926805 => { + if *in_pos >= in_size { + return LZMA_OK; + } + if (*coder).pos == 0 as size_t { + if *in_0.offset(*in_pos as isize) as ::core::ffi::c_int + == INDEX_INDICATOR + { + (*coder).sequence = SEQ_INDEX; + current_block_100 = 16789764818708874114; + } else { + (*coder).block_options.header_size = (*in_0 + .offset(*in_pos as isize) as uint32_t) + .wrapping_add(1 as uint32_t) + .wrapping_mul(4 as uint32_t); + current_block_100 = 13242334135786603907; + } + } else { + current_block_100 = 13242334135786603907; + } + match current_block_100 { + 16789764818708874114 => {} + _ => { + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).pos, + (*coder).block_options.header_size as size_t, + ); + if (*coder).pos < (*coder).block_options.header_size as size_t { + return LZMA_OK; + } + (*coder).pos = 0 as size_t; + (*coder).sequence = SEQ_BLOCK_INIT; + current_block_100 = 3500765272169221397; + } + } + } + 17861496924281778896 => { + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).pos, + LZMA_STREAM_HEADER_SIZE as size_t, + ); + if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { + return LZMA_OK; + } + (*coder).pos = 0 as size_t; + let mut footer_flags: lzma_stream_flags = lzma_stream_flags { + version: 0, + backward_size: 0, + check: LZMA_CHECK_NONE, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_bool1: 0, + reserved_bool2: 0, + reserved_bool3: 0, + reserved_bool4: 0, + reserved_bool5: 0, + reserved_bool6: 0, + reserved_bool7: 0, + reserved_bool8: 0, + reserved_int1: 0, + reserved_int2: 0, + }; + let ret_3: lzma_ret = lzma_stream_footer_decode( + &raw mut footer_flags, + &raw mut (*coder).buffer as *mut uint8_t, + ) as lzma_ret; + if ret_3 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return (if ret_3 as ::core::ffi::c_uint + == LZMA_FORMAT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + { + LZMA_DATA_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + } else { + ret_3 as ::core::ffi::c_uint + }) as lzma_ret; + } + if lzma_index_hash_size((*coder).index_hash) + != footer_flags.backward_size + { + return LZMA_DATA_ERROR; + } + let ret__1: lzma_ret = lzma_stream_flags_compare( + &raw mut (*coder).stream_flags, + &raw mut footer_flags, + ) as lzma_ret; + if ret__1 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__1; + } + if !(*coder).concatenated { + return LZMA_STREAM_END; + } + (*coder).sequence = SEQ_STREAM_PADDING; + current_block_100 = 15462640364611497761; + } + _ => {} + } + match current_block_100 { + 15462640364611497761 => { + loop { + if *in_pos >= in_size { + if action as ::core::ffi::c_uint + != LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_OK; + } + return (if (*coder).pos == 0 as size_t { + LZMA_STREAM_END as ::core::ffi::c_int + } else { + LZMA_DATA_ERROR as ::core::ffi::c_int + }) as lzma_ret; + } + if *in_0.offset(*in_pos as isize) as ::core::ffi::c_int + != 0 as ::core::ffi::c_int + { + break; + } + *in_pos = (*in_pos).wrapping_add(1); + (*coder).pos = (*coder).pos.wrapping_add(1 as size_t) & 3 as size_t; + } + if (*coder).pos != 0 as size_t { + *in_pos = (*in_pos).wrapping_add(1); + return LZMA_DATA_ERROR; + } + let ret__2: lzma_ret = stream_decoder_reset(coder, allocator) + as lzma_ret; + if ret__2 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__2; + } + current_block_100 = 16789764818708874114; + } + 3500765272169221397 => { + (*coder).block_options.version = 1 as uint32_t; + let mut filters: [lzma_filter; 5] = [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5]; + (*coder).block_options.filters = &raw mut filters as *mut lzma_filter; + let ret_: lzma_ret = lzma_block_header_decode( + &raw mut (*coder).block_options, + allocator, + &raw mut (*coder).buffer as *mut uint8_t, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + (*coder).block_options.ignore_check = (*coder).ignore_check as lzma_bool; + let memusage: uint64_t = lzma_raw_decoder_memusage( + &raw mut filters as *mut lzma_filter, + ) as uint64_t; + let mut ret_0: lzma_ret = LZMA_OK; + if memusage == UINT64_MAX as uint64_t { + ret_0 = LZMA_OPTIONS_ERROR; + } else { + (*coder).memusage = memusage; + if memusage > (*coder).memlimit { + ret_0 = LZMA_MEMLIMIT_ERROR; + } else { + ret_0 = lzma_block_decoder_init( + &raw mut (*coder).block_decoder, + allocator, + &raw mut (*coder).block_options, + ); + } + } + lzma_filters_free(&raw mut filters as *mut lzma_filter, allocator); + (*coder).block_options.filters = ::core::ptr::null_mut::(); + if ret_0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_0; + } + (*coder).sequence = SEQ_BLOCK_RUN; + current_block_100 = 721385680381463314; + } + _ => {} + } + match current_block_100 { + 721385680381463314 => { + let ret_1: lzma_ret = (*coder) + .block_decoder + .code + .expect( + "non-null function pointer", + )( + (*coder).block_decoder.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + if ret_1 as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_1; + } + let ret__0: lzma_ret = lzma_index_hash_append( + (*coder).index_hash, + lzma_block_unpadded_size(&raw mut (*coder).block_options), + (*coder).block_options.uncompressed_size, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__0; + } + (*coder).sequence = SEQ_BLOCK_HEADER; + } + _ => {} + } + }; +} +unsafe extern "C" fn stream_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + lzma_next_end(&raw mut (*coder).block_decoder, allocator); + lzma_index_hash_end((*coder).index_hash, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn stream_decoder_get_check( + mut coder_ptr: *const ::core::ffi::c_void, +) -> lzma_check { + let mut coder: *const lzma_stream_coder = coder_ptr as *const lzma_stream_coder; + return (*coder).stream_flags.check; +} +unsafe extern "C" fn stream_decoder_memconfig( + mut coder_ptr: *mut ::core::ffi::c_void, + mut memusage: *mut uint64_t, + mut old_memlimit: *mut uint64_t, + mut new_memlimit: uint64_t, +) -> lzma_ret { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + *memusage = (*coder).memusage; + *old_memlimit = (*coder).memlimit; + if new_memlimit != 0 as uint64_t { + if new_memlimit < (*coder).memusage { + return LZMA_MEMLIMIT_ERROR; + } + (*coder).memlimit = new_memlimit; + } + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut memlimit: uint64_t, + mut flags: uint32_t, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_stream_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + lzma_stream_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + uint64_t, + uint32_t, + ) -> lzma_ret, + ), + ); + if flags & !(LZMA_SUPPORTED_FLAGS as uint32_t) != 0 { + return LZMA_OPTIONS_ERROR; + } + let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_stream_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + stream_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + stream_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).get_check = Some( + stream_decoder_get_check + as unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + ) as Option lzma_check>; + (*next).memconfig = Some( + stream_decoder_memconfig + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >; + (*coder).block_decoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*coder).index_hash = ::core::ptr::null_mut::(); + } + (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).memusage = LZMA_MEMUSAGE_BASE as uint64_t; + (*coder).tell_no_check = flags & LZMA_TELL_NO_CHECK as uint32_t != 0 as uint32_t; + (*coder).tell_unsupported_check = flags & LZMA_TELL_UNSUPPORTED_CHECK as uint32_t + != 0 as uint32_t; + (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as uint32_t != 0 as uint32_t; + (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as uint32_t != 0 as uint32_t; + (*coder).concatenated = flags & LZMA_CONCATENATED as uint32_t != 0 as uint32_t; + (*coder).first_stream = true_0 != 0; + return stream_decoder_reset(coder, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_decoder( + mut strm: *mut lzma_stream, + mut memlimit: uint64_t, + mut flags: uint32_t, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = lzma_stream_decoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + memlimit, + flags, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs new file mode 100644 index 00000000..f7365996 --- /dev/null +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -0,0 +1,813 @@ +#[repr(C)] +pub struct lzma_index_s { _opaque: [u8; 0] } +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_end(strm: *mut lzma_stream); + fn lzma_filters_copy( + src: *const lzma_filter, + dest: *mut lzma_filter, + allocator: *const lzma_allocator, + ) -> lzma_ret; + fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); + fn lzma_stream_header_encode( + options: *const lzma_stream_flags, + out: *mut uint8_t, + ) -> lzma_ret; + fn lzma_stream_footer_encode( + options: *const lzma_stream_flags, + out: *mut uint8_t, + ) -> lzma_ret; + fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; + fn lzma_block_header_encode(block: *const lzma_block, out: *mut uint8_t) -> lzma_ret; + fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; + fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; + fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); + fn lzma_index_append( + i: *mut lzma_index, + allocator: *const lzma_allocator, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, + ) -> lzma_ret; + fn lzma_index_size(i: *const lzma_index) -> lzma_vli; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_block_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, + ) -> lzma_ret; + fn lzma_index_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + i: *const lzma_index, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const uint8_t, + pub avail_in: size_t, + pub total_in: uint64_t, + pub next_out: *mut uint8_t, + pub avail_out: size_t, + pub total_out: uint64_t, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_ptr4: *mut ::core::ffi::c_void, + pub seek_pos: uint64_t, + pub reserved_int2: uint64_t, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_coder { + pub sequence: C2RustUnnamed_0, + pub block_encoder_is_initialized: bool, + pub block_encoder: lzma_next_coder, + pub block_options: lzma_block, + pub filters: [lzma_filter; 5], + pub index_encoder: lzma_next_coder, + pub index: *mut lzma_index, + pub buffer_pos: size_t, + pub buffer_size: size_t, + pub buffer: [uint8_t; 1024], +} +pub type lzma_index = lzma_index_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: uint32_t, + pub header_size: uint32_t, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [uint8_t; 64], + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr3: *mut ::core::ffi::c_void, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; +pub const SEQ_INDEX_ENCODE: C2RustUnnamed_0 = 4; +pub const SEQ_BLOCK_ENCODE: C2RustUnnamed_0 = 3; +pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 2; +pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 1; +pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +unsafe extern "C" fn block_encoder_init( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + (*coder).block_options.compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).block_options.uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; + let ret_: lzma_ret = lzma_block_header_size(&raw mut (*coder).block_options) + as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + return lzma_block_encoder_init( + &raw mut (*coder).block_encoder, + allocator, + &raw mut (*coder).block_options, + ); +} +unsafe extern "C" fn stream_encode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + while *out_pos < out_size { + match (*coder).sequence as ::core::ffi::c_uint { + 0 | 2 | 5 => { + lzma_bufcpy( + &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer_pos, + (*coder).buffer_size, + out, + out_pos, + out_size, + ); + if (*coder).buffer_pos < (*coder).buffer_size { + return LZMA_OK; + } + if (*coder).sequence as ::core::ffi::c_uint + == SEQ_STREAM_FOOTER as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_STREAM_END; + } + (*coder).buffer_pos = 0 as size_t; + (*coder).sequence += 1; + } + 1 => { + if *in_pos == in_size { + if action as ::core::ffi::c_uint + != LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + { + return (if action as ::core::ffi::c_uint + == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint + { + LZMA_OK as ::core::ffi::c_int + } else { + LZMA_STREAM_END as ::core::ffi::c_int + }) as lzma_ret; + } + let ret_: lzma_ret = lzma_index_encoder_init( + &raw mut (*coder).index_encoder, + allocator, + (*coder).index, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + (*coder).sequence = SEQ_INDEX_ENCODE; + } else { + if !(*coder).block_encoder_is_initialized { + let ret__0: lzma_ret = block_encoder_init(coder, allocator) + as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__0; + } + } + (*coder).block_encoder_is_initialized = false_0 != 0; + if lzma_block_header_encode( + &raw mut (*coder).block_options, + &raw mut (*coder).buffer as *mut uint8_t, + ) as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + (*coder).buffer_size = (*coder).block_options.header_size as size_t; + (*coder).sequence = SEQ_BLOCK_HEADER; + } + } + 3 => { + static mut convert: [lzma_action; 5] = [ + LZMA_RUN, + LZMA_SYNC_FLUSH, + LZMA_FINISH, + LZMA_FINISH, + LZMA_FINISH, + ]; + let ret: lzma_ret = (*coder) + .block_encoder + .code + .expect( + "non-null function pointer", + )( + (*coder).block_encoder.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + convert[action as usize], + ) as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + || action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + let unpadded_size: lzma_vli = lzma_block_unpadded_size( + &raw mut (*coder).block_options, + ) as lzma_vli; + let ret__1: lzma_ret = lzma_index_append( + (*coder).index, + allocator, + unpadded_size, + (*coder).block_options.uncompressed_size, + ) as lzma_ret; + if ret__1 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret__1; + } + (*coder).sequence = SEQ_BLOCK_INIT; + } + 4 => { + let ret_0: lzma_ret = (*coder) + .index_encoder + .code + .expect( + "non-null function pointer", + )( + (*coder).index_encoder.coder, + allocator, + ::core::ptr::null::(), + ::core::ptr::null_mut::(), + 0 as size_t, + out, + out_pos, + out_size, + LZMA_RUN, + ) as lzma_ret; + if ret_0 as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_0; + } + let stream_flags: lzma_stream_flags = lzma_stream_flags { + version: 0 as uint32_t, + backward_size: lzma_index_size((*coder).index), + check: (*coder).block_options.check, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_bool1: 0, + reserved_bool2: 0, + reserved_bool3: 0, + reserved_bool4: 0, + reserved_bool5: 0, + reserved_bool6: 0, + reserved_bool7: 0, + reserved_bool8: 0, + reserved_int1: 0, + reserved_int2: 0, + }; + if lzma_stream_footer_encode( + &raw const stream_flags, + &raw mut (*coder).buffer as *mut uint8_t, + ) as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + (*coder).buffer_size = LZMA_STREAM_HEADER_SIZE as size_t; + (*coder).sequence = SEQ_STREAM_FOOTER; + } + _ => return LZMA_PROG_ERROR, + } + } + return LZMA_OK; +} +unsafe extern "C" fn stream_encoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + lzma_next_end(&raw mut (*coder).block_encoder, allocator); + lzma_next_end(&raw mut (*coder).index_encoder, allocator); + lzma_index_end((*coder).index, allocator); + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn stream_encoder_update( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter, + mut reversed_filters: *const lzma_filter, +) -> lzma_ret { + let mut current_block: u64; + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let mut ret: lzma_ret = LZMA_OK; + let mut temp: [lzma_filter; 5] = [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5]; + let ret_: lzma_ret = lzma_filters_copy( + filters, + &raw mut temp as *mut lzma_filter, + allocator, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + if (*coder).sequence as ::core::ffi::c_uint + <= SEQ_BLOCK_INIT as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*coder).block_encoder_is_initialized = false_0 != 0; + (*coder).block_options.filters = &raw mut temp as *mut lzma_filter; + ret = block_encoder_init(coder, allocator); + (*coder).block_options.filters = &raw mut (*coder).filters as *mut lzma_filter; + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + current_block = 9913398440939854562; + } else { + (*coder).block_encoder_is_initialized = true_0 != 0; + current_block = 8236137900636309791; + } + } else if (*coder).sequence as ::core::ffi::c_uint + <= SEQ_BLOCK_ENCODE as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = (*coder) + .block_encoder + .update + .expect( + "non-null function pointer", + )((*coder).block_encoder.coder, allocator, filters, reversed_filters); + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + current_block = 9913398440939854562; + } else { + current_block = 8236137900636309791; + } + } else { + ret = LZMA_PROG_ERROR; + current_block = 9913398440939854562; + } + match current_block { + 9913398440939854562 => { + lzma_filters_free(&raw mut temp as *mut lzma_filter, allocator); + return ret; + } + _ => { + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + memcpy( + &raw mut (*coder).filters as *mut lzma_filter + as *mut ::core::ffi::c_void, + &raw mut temp as *mut lzma_filter as *const ::core::ffi::c_void, + ::core::mem::size_of::<[lzma_filter; 5]>() as size_t, + ); + return LZMA_OK; + } + }; +} +unsafe extern "C" fn stream_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter, + mut check: lzma_check, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter, + lzma_check, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + stream_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter, + lzma_check, + ) -> lzma_ret, + ), + ) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter, + lzma_check, + ) -> lzma_ret, + >, + uintptr_t, + >( + Some( + stream_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter, + lzma_check, + ) -> lzma_ret, + ), + ); + if filters.is_null() { + return LZMA_PROG_ERROR; + } + let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_stream_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + stream_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + stream_encoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).update = Some( + stream_encoder_update + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >; + (*coder).filters[0 as ::core::ffi::c_int as usize].id = LZMA_VLI_UNKNOWN + as lzma_vli; + (*coder).block_encoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*coder).index_encoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*coder).index = ::core::ptr::null_mut::(); + } + (*coder).sequence = SEQ_STREAM_HEADER; + (*coder).block_options.version = 0 as uint32_t; + (*coder).block_options.check = check; + lzma_index_end((*coder).index, allocator); + (*coder).index = lzma_index_init(allocator); + if (*coder).index.is_null() { + return LZMA_MEM_ERROR; + } + let mut stream_flags: lzma_stream_flags = lzma_stream_flags { + version: 0 as uint32_t, + backward_size: 0, + check: check, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_bool1: 0, + reserved_bool2: 0, + reserved_bool3: 0, + reserved_bool4: 0, + reserved_bool5: 0, + reserved_bool6: 0, + reserved_bool7: 0, + reserved_bool8: 0, + reserved_int1: 0, + reserved_int2: 0, + }; + let ret_: lzma_ret = lzma_stream_header_encode( + &raw mut stream_flags, + &raw mut (*coder).buffer as *mut uint8_t, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + (*coder).buffer_pos = 0 as size_t; + (*coder).buffer_size = LZMA_STREAM_HEADER_SIZE as size_t; + return stream_encoder_update( + coder as *mut ::core::ffi::c_void, + allocator, + filters, + ::core::ptr::null::(), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_encoder( + mut strm: *mut lzma_stream, + mut filters: *const lzma_filter, + mut check: lzma_check, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let ret__0: lzma_ret = stream_encoder_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + filters, + check, + ) as lzma_ret; + if ret__0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal) + .supported_actions[LZMA_SYNC_FLUSH as ::core::ffi::c_int as usize] = true_0 != 0; + (*(*strm).internal) + .supported_actions[LZMA_FULL_FLUSH as ::core::ffi::c_int as usize] = true_0 != 0; + (*(*strm).internal) + .supported_actions[LZMA_FULL_BARRIER as ::core::ffi::c_int as usize] = true_0 + != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 + != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs new file mode 100644 index 00000000..b1c7589d --- /dev/null +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -0,0 +1,112 @@ +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +pub const LZMA_BACKWARD_SIZE_MIN: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_BACKWARD_SIZE_MAX: ::core::ffi::c_ulonglong = (1 + as ::core::ffi::c_ulonglong) << 34 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn is_backward_size_valid( + mut options: *const lzma_stream_flags, +) -> bool { + return (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli + && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli + && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli; +} +#[no_mangle] +pub static mut lzma_header_magic: [uint8_t; 6] = [ + 0xfd as ::core::ffi::c_int as uint8_t, + 0x37 as ::core::ffi::c_int as uint8_t, + 0x7a as ::core::ffi::c_int as uint8_t, + 0x58 as ::core::ffi::c_int as uint8_t, + 0x5a as ::core::ffi::c_int as uint8_t, + 0 as ::core::ffi::c_int as uint8_t, +]; +#[no_mangle] +pub static mut lzma_footer_magic: [uint8_t; 2] = [ + 0x59 as ::core::ffi::c_int as uint8_t, + 0x5a as ::core::ffi::c_int as uint8_t, +]; +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_flags_compare( + mut a: *const lzma_stream_flags, + mut b: *const lzma_stream_flags, +) -> lzma_ret { + if (*a).version != 0 as uint32_t || (*b).version != 0 as uint32_t { + return LZMA_OPTIONS_ERROR; + } + if (*a).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + || (*b).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + if (*a).check as ::core::ffi::c_uint != (*b).check as ::core::ffi::c_uint { + return LZMA_DATA_ERROR; + } + if (*a).backward_size != LZMA_VLI_UNKNOWN as lzma_vli + && (*b).backward_size != LZMA_VLI_UNKNOWN as lzma_vli + { + if !is_backward_size_valid(a) || !is_backward_size_valid(b) { + return LZMA_PROG_ERROR; + } + if (*a).backward_size != (*b).backward_size { + return LZMA_DATA_ERROR; + } + } + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs new file mode 100644 index 00000000..85985da0 --- /dev/null +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -0,0 +1,185 @@ +extern "C" { + fn memcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: size_t, + ) -> ::core::ffi::c_int; + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + static lzma_header_magic: [uint8_t; 6]; + static lzma_footer_magic: [uint8_t; 2]; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { + let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; + num + |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + num + |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 16 as ::core::ffi::c_int; + num + |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) + << 24 as ::core::ffi::c_int; + return num; +} +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_STREAM_FLAGS_SIZE: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +unsafe extern "C" fn stream_flags_decode( + mut options: *mut lzma_stream_flags, + mut in_0: *const uint8_t, +) -> bool { + if *in_0.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != 0 as ::core::ffi::c_int + || *in_0.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + & 0xf0 as ::core::ffi::c_int != 0 + { + return true_0 != 0; + } + (*options).version = 0 as uint32_t; + (*options).check = (*in_0.offset(1 as ::core::ffi::c_int as isize) + as ::core::ffi::c_int & 0xf as ::core::ffi::c_int) as lzma_check; + return false_0 != 0; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_header_decode( + mut options: *mut lzma_stream_flags, + mut in_0: *const uint8_t, +) -> lzma_ret { + if memcmp( + in_0 as *const ::core::ffi::c_void, + &raw const lzma_header_magic as *const uint8_t as *const ::core::ffi::c_void, + ::core::mem::size_of::<[uint8_t; 6]>() as size_t, + ) != 0 as ::core::ffi::c_int + { + return LZMA_FORMAT_ERROR; + } + let crc: uint32_t = lzma_crc32( + in_0.offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize), + LZMA_STREAM_FLAGS_SIZE as size_t, + 0 as uint32_t, + ) as uint32_t; + if crc + != read32le( + in_0 + .offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize) + .offset(LZMA_STREAM_FLAGS_SIZE as isize), + ) + { + return LZMA_DATA_ERROR; + } + if stream_flags_decode( + options, + in_0.offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize), + ) { + return LZMA_OPTIONS_ERROR; + } + (*options).backward_size = LZMA_VLI_UNKNOWN as lzma_vli; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_footer_decode( + mut options: *mut lzma_stream_flags, + mut in_0: *const uint8_t, +) -> lzma_ret { + if memcmp( + in_0 + .offset( + (::core::mem::size_of::() as usize).wrapping_mul(2 as usize) + as isize, + ) + .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *const ::core::ffi::c_void, + &raw const lzma_footer_magic as *const uint8_t as *const ::core::ffi::c_void, + ::core::mem::size_of::<[uint8_t; 2]>() as size_t, + ) != 0 as ::core::ffi::c_int + { + return LZMA_FORMAT_ERROR; + } + let crc: uint32_t = lzma_crc32( + in_0.offset(::core::mem::size_of::() as usize as isize), + (::core::mem::size_of::() as size_t) + .wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), + 0 as uint32_t, + ) as uint32_t; + if crc != read32le(in_0) { + return LZMA_DATA_ERROR; + } + if stream_flags_decode( + options, + in_0 + .offset( + (::core::mem::size_of::() as usize).wrapping_mul(2 as usize) + as isize, + ), + ) { + return LZMA_OPTIONS_ERROR; + } + (*options).backward_size = read32le( + in_0.offset(::core::mem::size_of::() as usize as isize), + ) as lzma_vli; + (*options).backward_size = (*options) + .backward_size + .wrapping_add(1 as lzma_vli) + .wrapping_mul(4 as lzma_vli); + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs new file mode 100644 index 00000000..fb098f6b --- /dev/null +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -0,0 +1,173 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + static lzma_header_magic: [uint8_t; 6]; + static lzma_footer_magic: [uint8_t; 2]; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: uint32_t, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, +} +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { + *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; + *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) + as uint8_t; +} +pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +pub const LZMA_BACKWARD_SIZE_MIN: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_BACKWARD_SIZE_MAX: ::core::ffi::c_ulonglong = (1 + as ::core::ffi::c_ulonglong) << 34 as ::core::ffi::c_int; +pub const LZMA_STREAM_FLAGS_SIZE: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn is_backward_size_valid( + mut options: *const lzma_stream_flags, +) -> bool { + return (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli + && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli + && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli; +} +unsafe extern "C" fn stream_flags_encode( + mut options: *const lzma_stream_flags, + mut out: *mut uint8_t, +) -> bool { + if (*options).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + { + return true_0 != 0; + } + *out.offset(0 as ::core::ffi::c_int as isize) = 0 as uint8_t; + *out.offset(1 as ::core::ffi::c_int as isize) = (*options).check as uint8_t; + return false_0 != 0; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_header_encode( + mut options: *const lzma_stream_flags, + mut out: *mut uint8_t, +) -> lzma_ret { + if (*options).version != 0 as uint32_t { + return LZMA_OPTIONS_ERROR; + } + memcpy( + out as *mut ::core::ffi::c_void, + &raw const lzma_header_magic as *const uint8_t as *const ::core::ffi::c_void, + ::core::mem::size_of::<[uint8_t; 6]>() as size_t, + ); + if stream_flags_encode( + options, + out.offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize), + ) { + return LZMA_PROG_ERROR; + } + let crc: uint32_t = lzma_crc32( + out.offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize), + LZMA_STREAM_FLAGS_SIZE as size_t, + 0 as uint32_t, + ) as uint32_t; + write32le( + out + .offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize) + .offset(LZMA_STREAM_FLAGS_SIZE as isize), + crc, + ); + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_footer_encode( + mut options: *const lzma_stream_flags, + mut out: *mut uint8_t, +) -> lzma_ret { + if (*options).version != 0 as uint32_t { + return LZMA_OPTIONS_ERROR; + } + if !is_backward_size_valid(options) { + return LZMA_PROG_ERROR; + } + write32le( + out.offset(4 as ::core::ffi::c_int as isize), + (*options).backward_size.wrapping_div(4 as lzma_vli).wrapping_sub(1 as lzma_vli) + as uint32_t, + ); + if stream_flags_encode( + options, + out.offset((2 as ::core::ffi::c_int * 4 as ::core::ffi::c_int) as isize), + ) { + return LZMA_PROG_ERROR; + } + let crc: uint32_t = lzma_crc32( + out.offset(4 as ::core::ffi::c_int as isize), + (4 as ::core::ffi::c_int + LZMA_STREAM_FLAGS_SIZE) as size_t, + 0 as uint32_t, + ) as uint32_t; + write32le(out, crc); + memcpy( + out + .offset((2 as ::core::ffi::c_int * 4 as ::core::ffi::c_int) as isize) + .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut ::core::ffi::c_void, + &raw const lzma_footer_magic as *const uint8_t as *const ::core::ffi::c_void, + ::core::mem::size_of::<[uint8_t; 2]>() as size_t, + ); + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs new file mode 100644 index 00000000..55d0b506 --- /dev/null +++ b/liblzma-rs/src/common/string_conversion.rs @@ -0,0 +1,1807 @@ +extern "C" { + fn memchr( + __s: *const ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn memcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: size_t, + ) -> ::core::ffi::c_int; + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn strlen(__s: *const ::core::ffi::c_char) -> size_t; + fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: uint32_t) -> lzma_bool; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc_zero( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_validate_chain(filters: *const lzma_filter, count: *mut size_t) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed { + pub name: [::core::ffi::c_char; 12], + pub opts_size: uint32_t, + pub id: lzma_vli, + pub parse: Option< + unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + >, + pub optmap: *const option_map, + pub strfy_encoder: uint8_t, + pub strfy_decoder: uint8_t, + pub allow_null: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct option_map { + pub name: [::core::ffi::c_char; 12], + pub type_0: uint8_t, + pub flags: uint8_t, + pub offset: uint16_t, + pub u: C2RustUnnamed_0, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub map: *const name_value_map, + pub range: C2RustUnnamed_1, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_1 { + pub min: uint32_t, + pub max: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct name_value_map { + pub name: [::core::ffi::c_char; 12], + pub value: uint32_t, +} +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub const OPTMAP_TYPE_LZMA_MATCH_FINDER: C2RustUnnamed_2 = 2; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +pub const OPTMAP_TYPE_LZMA_MODE: C2RustUnnamed_2 = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +pub const OPTMAP_TYPE_LZMA_PRESET: C2RustUnnamed_2 = 3; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_delta { + pub type_0: lzma_delta_type, + pub dist: uint32_t, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +pub type lzma_delta_type = ::core::ffi::c_uint; +pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_bcj { + pub start_offset: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_str { + pub buf: *mut ::core::ffi::c_char, + pub pos: size_t, +} +pub type C2RustUnnamed_2 = ::core::ffi::c_uint; +pub const OPTMAP_TYPE_UINT32: C2RustUnnamed_2 = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const INT_MAX: ::core::ffi::c_int = 2147483647 as ::core::ffi::c_int; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTERS_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_STR_ALL_FILTERS: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; +pub const LZMA_STR_NO_VALIDATION: ::core::ffi::c_uint = 0x2 as ::core::ffi::c_uint; +pub const LZMA_STR_ENCODER: ::core::ffi::c_uint = 0x10 as ::core::ffi::c_uint; +pub const LZMA_STR_DECODER: ::core::ffi::c_uint = 0x20 as ::core::ffi::c_uint; +pub const LZMA_STR_GETOPT_LONG: ::core::ffi::c_uint = 0x40 as ::core::ffi::c_uint; +pub const LZMA_STR_NO_SPACES: ::core::ffi::c_uint = 0x80 as ::core::ffi::c_uint; +pub const LZMA_FILTER_X86: ::core::ffi::c_ulonglong = 0x4 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_POWERPC: ::core::ffi::c_ulonglong = 0x5 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_IA64: ::core::ffi::c_ulonglong = 0x6 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARM: ::core::ffi::c_ulonglong = 0x7 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARMTHUMB: ::core::ffi::c_ulonglong = 0x8 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_SPARC: ::core::ffi::c_ulonglong = 0x9 as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_ARM64: ::core::ffi::c_ulonglong = 0xa as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_RISCV: ::core::ffi::c_ulonglong = 0xb as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_DELTA: ::core::ffi::c_ulonglong = 0x3 as ::core::ffi::c_ulonglong; +pub const LZMA_DELTA_DIST_MIN: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const LZMA_DELTA_DIST_MAX: ::core::ffi::c_int = 256 as ::core::ffi::c_int; +pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; +pub const LZMA_DICT_SIZE_DEFAULT: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 23 as ::core::ffi::c_int; +pub const LZMA_LCLP_MIN: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_LCLP_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_PB_MIN: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_PB_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_PRESET_DEFAULT: ::core::ffi::c_uint = 6 as ::core::ffi::c_uint; +pub const LZMA_PRESET_EXTREME: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 31 as ::core::ffi::c_int; +pub const LZMA_FILTER_RESERVED_START: ::core::ffi::c_ulonglong = (1 + as ::core::ffi::c_ulonglong) << 62 as ::core::ffi::c_int; +pub const STR_ALLOC_SIZE: ::core::ffi::c_int = 800 as ::core::ffi::c_int; +unsafe extern "C" fn str_init( + mut str: *mut lzma_str, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + (*str).buf = lzma_alloc(STR_ALLOC_SIZE as size_t, allocator) + as *mut ::core::ffi::c_char; + if (*str).buf.is_null() { + return LZMA_MEM_ERROR; + } + (*str).pos = 0 as size_t; + return LZMA_OK; +} +unsafe extern "C" fn str_free( + mut str: *mut lzma_str, + mut allocator: *const lzma_allocator, +) { + lzma_free((*str).buf as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn str_is_full(mut str: *const lzma_str) -> bool { + return (*str).pos == (STR_ALLOC_SIZE - 1 as ::core::ffi::c_int) as size_t; +} +unsafe extern "C" fn str_finish( + mut dest: *mut *mut ::core::ffi::c_char, + mut str: *mut lzma_str, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + if str_is_full(str) { + lzma_free((*str).buf as *mut ::core::ffi::c_void, allocator); + *dest = ::core::ptr::null_mut::<::core::ffi::c_char>(); + return LZMA_PROG_ERROR; + } + *(*str).buf.offset((*str).pos as isize) = '\0' as i32 as ::core::ffi::c_char; + *dest = (*str).buf; + return LZMA_OK; +} +unsafe extern "C" fn str_append_str( + mut str: *mut lzma_str, + mut s: *const ::core::ffi::c_char, +) { + let len: size_t = strlen(s) as size_t; + let limit: size_t = ((STR_ALLOC_SIZE - 1 as ::core::ffi::c_int) as size_t) + .wrapping_sub((*str).pos); + let copy_size: size_t = if len < limit { len } else { limit }; + memcpy( + (*str).buf.offset((*str).pos as isize) as *mut ::core::ffi::c_void, + s as *const ::core::ffi::c_void, + copy_size, + ); + (*str).pos = (*str).pos.wrapping_add(copy_size); +} +unsafe extern "C" fn str_append_u32( + mut str: *mut lzma_str, + mut v: uint32_t, + mut use_byte_suffix: bool, +) { + if v == 0 as uint32_t { + str_append_str(str, b"0\0" as *const u8 as *const ::core::ffi::c_char); + } else { + static mut suffixes: [[::core::ffi::c_char; 4]; 4] = unsafe { + [ + ::core::mem::transmute::< + [u8; 4], + [::core::ffi::c_char; 4], + >(*b"\0\0\0\0"), + ::core::mem::transmute::<[u8; 4], [::core::ffi::c_char; 4]>(*b"KiB\0"), + ::core::mem::transmute::<[u8; 4], [::core::ffi::c_char; 4]>(*b"MiB\0"), + ::core::mem::transmute::<[u8; 4], [::core::ffi::c_char; 4]>(*b"GiB\0"), + ] + }; + let mut suf: size_t = 0 as size_t; + if use_byte_suffix { + while v & 1023 as uint32_t == 0 as uint32_t + && suf + < (::core::mem::size_of::<[[::core::ffi::c_char; 4]; 4]>() as usize) + .wrapping_div( + ::core::mem::size_of::<[::core::ffi::c_char; 4]>() as usize, + ) + .wrapping_sub(1 as usize) + { + v >>= 10 as ::core::ffi::c_int; + suf = suf.wrapping_add(1); + } + } + let mut buf: [::core::ffi::c_char; 16] = ::core::mem::transmute::< + [u8; 16], + [::core::ffi::c_char; 16], + >(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); + let mut pos: size_t = (::core::mem::size_of::<[::core::ffi::c_char; 16]>() + as size_t) + .wrapping_sub(1 as size_t); + loop { + pos = pos.wrapping_sub(1); + buf[pos as usize] = ('0' as i32 as uint32_t) + .wrapping_add(v.wrapping_rem(10 as uint32_t)) as ::core::ffi::c_char; + v = v.wrapping_div(10 as uint32_t); + if !(v != 0 as uint32_t) { + break; + } + } + str_append_str( + str, + (&raw mut buf as *mut ::core::ffi::c_char).offset(pos as isize), + ); + str_append_str( + str, + &raw const *(&raw const suffixes as *const [::core::ffi::c_char; 4]) + .offset(suf as isize) as *const ::core::ffi::c_char, + ); + }; +} +pub const NAME_LEN_MAX: ::core::ffi::c_int = 11 as ::core::ffi::c_int; +pub const OPTMAP_USE_NAME_VALUE_MAP: ::core::ffi::c_int = 0x1 as ::core::ffi::c_int; +pub const OPTMAP_USE_BYTE_SUFFIX: ::core::ffi::c_int = 0x2 as ::core::ffi::c_int; +pub const OPTMAP_NO_STRFY_ZERO: ::core::ffi::c_int = 0x4 as ::core::ffi::c_int; +static mut bcj_optmap: [option_map; 1] = unsafe { + [ + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"start\0\0\0\0\0\0\0"), + type_0: 0, + flags: (OPTMAP_NO_STRFY_ZERO | OPTMAP_USE_BYTE_SUFFIX) as uint8_t, + offset: 0 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: 0 as uint32_t, + max: UINT32_MAX as uint32_t, + }, + }, + }, + ] +}; +unsafe extern "C" fn parse_bcj( + str: *mut *const ::core::ffi::c_char, + mut str_end: *const ::core::ffi::c_char, + mut filter_options: *mut ::core::ffi::c_void, +) -> *const ::core::ffi::c_char { + return parse_options( + str, + str_end, + filter_options, + &raw const bcj_optmap as *const option_map, + (::core::mem::size_of::<[option_map; 1]>() as size_t) + .wrapping_div(::core::mem::size_of::() as size_t), + ); +} +static mut delta_optmap: [option_map; 1] = unsafe { + [ + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"dist\0\0\0\0\0\0\0\0"), + type_0: 0, + flags: 0, + offset: 4 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: LZMA_DELTA_DIST_MIN as uint32_t, + max: LZMA_DELTA_DIST_MAX as uint32_t, + }, + }, + }, + ] +}; +unsafe extern "C" fn parse_delta( + str: *mut *const ::core::ffi::c_char, + mut str_end: *const ::core::ffi::c_char, + mut filter_options: *mut ::core::ffi::c_void, +) -> *const ::core::ffi::c_char { + let mut opts: *mut lzma_options_delta = filter_options as *mut lzma_options_delta; + (*opts).type_0 = LZMA_DELTA_TYPE_BYTE; + (*opts).dist = LZMA_DELTA_DIST_MIN as uint32_t; + return parse_options( + str, + str_end, + filter_options, + &raw const delta_optmap as *const option_map, + (::core::mem::size_of::<[option_map; 1]>() as size_t) + .wrapping_div(::core::mem::size_of::() as size_t), + ); +} +pub const LZMA12_PRESET_STR: [::core::ffi::c_char; 7] = unsafe { + ::core::mem::transmute::<[u8; 7], [::core::ffi::c_char; 7]>(*b"0-9[e]\0") +}; +unsafe extern "C" fn parse_lzma12_preset( + str: *mut *const ::core::ffi::c_char, + mut str_end: *const ::core::ffi::c_char, + mut preset: *mut uint32_t, +) -> *const ::core::ffi::c_char { + if !(**str as ::core::ffi::c_int >= '0' as i32 + && **str as ::core::ffi::c_int <= '9' as i32) + { + return b"Unsupported preset\0" as *const u8 as *const ::core::ffi::c_char; + } + *preset = (**str as ::core::ffi::c_int - '0' as i32) as uint32_t; + loop { + *str = (*str).offset(1); + if !(*str < str_end) { + break; + } + match **str as ::core::ffi::c_int { + 101 => { + *preset = (*preset as ::core::ffi::c_uint | LZMA_PRESET_EXTREME) + as uint32_t; + } + _ => { + return b"Unsupported flag in the preset\0" as *const u8 + as *const ::core::ffi::c_char; + } + } + } + return ::core::ptr::null::<::core::ffi::c_char>(); +} +unsafe extern "C" fn set_lzma12_preset( + str: *mut *const ::core::ffi::c_char, + mut str_end: *const ::core::ffi::c_char, + mut filter_options: *mut ::core::ffi::c_void, +) -> *const ::core::ffi::c_char { + let mut preset: uint32_t = 0; + let mut errmsg: *const ::core::ffi::c_char = parse_lzma12_preset( + str, + str_end, + &raw mut preset, + ); + if !errmsg.is_null() { + return errmsg; + } + let mut opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; + if lzma_lzma_preset(opts, preset) != 0 { + return b"Unsupported preset\0" as *const u8 as *const ::core::ffi::c_char; + } + return ::core::ptr::null::<::core::ffi::c_char>(); +} +static mut lzma12_mode_map: [name_value_map; 3] = unsafe { + [ + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"fast\0\0\0\0\0\0\0\0"), + value: LZMA_MODE_FAST as ::core::ffi::c_int as uint32_t, + }, + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"normal\0\0\0\0\0\0"), + value: LZMA_MODE_NORMAL as ::core::ffi::c_int as uint32_t, + }, + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), + value: 0 as uint32_t, + }, + ] +}; +static mut lzma12_mf_map: [name_value_map; 6] = unsafe { + [ + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"hc3\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_HC3 as ::core::ffi::c_int as uint32_t, + }, + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"hc4\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_HC4 as ::core::ffi::c_int as uint32_t, + }, + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"bt2\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_BT2 as ::core::ffi::c_int as uint32_t, + }, + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"bt3\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_BT3 as ::core::ffi::c_int as uint32_t, + }, + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"bt4\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_BT4 as ::core::ffi::c_int as uint32_t, + }, + name_value_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), + value: 0 as uint32_t, + }, + ] +}; +static mut lzma12_optmap: [option_map; 9] = [option_map { + name: [0; 12], + type_0: 0, + flags: 0, + offset: 0, + u: C2RustUnnamed_0 { + map: ::core::ptr::null::(), + }, +}; 9]; +unsafe extern "C" fn parse_lzma12( + str: *mut *const ::core::ffi::c_char, + mut str_end: *const ::core::ffi::c_char, + mut filter_options: *mut ::core::ffi::c_void, +) -> *const ::core::ffi::c_char { + let mut opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; + let preset_ret: bool = lzma_lzma_preset(opts, LZMA_PRESET_DEFAULT as uint32_t) != 0; + let mut errmsg: *const ::core::ffi::c_char = parse_options( + str, + str_end, + filter_options, + &raw const lzma12_optmap as *const option_map, + (::core::mem::size_of::<[option_map; 9]>() as size_t) + .wrapping_div(::core::mem::size_of::() as size_t), + ); + if !errmsg.is_null() { + return errmsg; + } + if (*opts).lc.wrapping_add((*opts).lp) > LZMA_LCLP_MAX as uint32_t { + return b"The sum of lc and lp must not exceed 4\0" as *const u8 + as *const ::core::ffi::c_char; + } + return ::core::ptr::null::<::core::ffi::c_char>(); +} +static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { + [ + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"lzma1\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_LZMA1 as lzma_vli, + parse: Some( + parse_lzma12 + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const lzma12_optmap as *const option_map, + strfy_encoder: 9 as uint8_t, + strfy_decoder: 5 as uint8_t, + allow_null: false_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"lzma2\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_LZMA2 as lzma_vli, + parse: Some( + parse_lzma12 + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const lzma12_optmap as *const option_map, + strfy_encoder: 9 as uint8_t, + strfy_decoder: 2 as uint8_t, + allow_null: false_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"x86\0\0\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_X86 as lzma_vli, + parse: Some( + parse_bcj + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const bcj_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: true_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"arm\0\0\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_ARM as lzma_vli, + parse: Some( + parse_bcj + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const bcj_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: true_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"armthumb\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_ARMTHUMB as lzma_vli, + parse: Some( + parse_bcj + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const bcj_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: true_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"arm64\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_ARM64 as lzma_vli, + parse: Some( + parse_bcj + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const bcj_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: true_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"riscv\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_RISCV as lzma_vli, + parse: Some( + parse_bcj + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const bcj_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: true_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"powerpc\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_POWERPC as lzma_vli, + parse: Some( + parse_bcj + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const bcj_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: true_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"ia64\0\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_IA64 as lzma_vli, + parse: Some( + parse_bcj + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const bcj_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: true_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"sparc\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_SPARC as lzma_vli, + parse: Some( + parse_bcj + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const bcj_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: true_0 != 0, + }, + C2RustUnnamed { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"delta\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as uint32_t, + id: LZMA_FILTER_DELTA as lzma_vli, + parse: Some( + parse_delta + as unsafe extern "C" fn( + *mut *const ::core::ffi::c_char, + *const ::core::ffi::c_char, + *mut ::core::ffi::c_void, + ) -> *const ::core::ffi::c_char, + ), + optmap: &raw const delta_optmap as *const option_map, + strfy_encoder: 1 as uint8_t, + strfy_decoder: 1 as uint8_t, + allow_null: false_0 != 0, + }, + ] +}; +unsafe extern "C" fn parse_options( + str: *mut *const ::core::ffi::c_char, + mut str_end: *const ::core::ffi::c_char, + mut filter_options: *mut ::core::ffi::c_void, + optmap: *const option_map, + optmap_size: size_t, +) -> *const ::core::ffi::c_char { + while *str < str_end && **str as ::core::ffi::c_int != '\0' as i32 { + if **str as ::core::ffi::c_int == ',' as i32 { + *str = (*str).offset(1); + } else { + let str_len: size_t = str_end.offset_from(*str) as ::core::ffi::c_long + as size_t; + let mut name_eq_value_end: *const ::core::ffi::c_char = memchr( + *str as *const ::core::ffi::c_void, + ',' as i32, + str_len, + ) as *const ::core::ffi::c_char; + if name_eq_value_end.is_null() { + name_eq_value_end = str_end; + } + let mut equals_sign: *const ::core::ffi::c_char = memchr( + *str as *const ::core::ffi::c_void, + '=' as i32, + name_eq_value_end.offset_from(*str) as ::core::ffi::c_long as size_t, + ) as *const ::core::ffi::c_char; + if equals_sign.is_null() || **str as ::core::ffi::c_int == '=' as i32 { + return b"Options must be 'name=value' pairs separated with commas\0" + as *const u8 as *const ::core::ffi::c_char; + } + let name_len: size_t = equals_sign.offset_from(*str) as ::core::ffi::c_long + as size_t; + if name_len > NAME_LEN_MAX as size_t { + return b"Unknown option name\0" as *const u8 + as *const ::core::ffi::c_char; + } + let mut i: size_t = 0 as size_t; + loop { + if i == optmap_size { + return b"Unknown option name\0" as *const u8 + as *const ::core::ffi::c_char; + } + if memcmp( + *str as *const ::core::ffi::c_void, + &raw const (*optmap.offset(i as isize)).name + as *const ::core::ffi::c_char as *const ::core::ffi::c_void, + name_len, + ) == 0 as ::core::ffi::c_int + && (*optmap.offset(i as isize)).name[name_len as usize] + as ::core::ffi::c_int == '\0' as i32 + { + break; + } + i = i.wrapping_add(1); + } + *str = equals_sign.offset(1 as ::core::ffi::c_int as isize); + let value_len: size_t = name_eq_value_end.offset_from(*str) + as ::core::ffi::c_long as size_t; + if value_len == 0 as size_t { + return b"Option value cannot be empty\0" as *const u8 + as *const ::core::ffi::c_char; + } + if (*optmap.offset(i as isize)).type_0 as ::core::ffi::c_int + == OPTMAP_TYPE_LZMA_PRESET as ::core::ffi::c_int + { + let mut errmsg: *const ::core::ffi::c_char = set_lzma12_preset( + str, + name_eq_value_end, + filter_options, + ); + if !errmsg.is_null() { + return errmsg; + } + } else { + let mut v: uint32_t = 0; + if (*optmap.offset(i as isize)).flags as ::core::ffi::c_int + & OPTMAP_USE_NAME_VALUE_MAP != 0 + { + if value_len > NAME_LEN_MAX as size_t { + return b"Invalid option value\0" as *const u8 + as *const ::core::ffi::c_char; + } + let mut map: *const name_value_map = (*optmap.offset(i as isize)) + .u + .map; + let mut j: size_t = 0 as size_t; + loop { + if (*map.offset(j as isize)) + .name[0 as ::core::ffi::c_int as usize] as ::core::ffi::c_int + == '\0' as i32 + { + return b"Invalid option value\0" as *const u8 + as *const ::core::ffi::c_char; + } + if memcmp( + *str as *const ::core::ffi::c_void, + &raw const (*map.offset(j as isize)).name + as *const ::core::ffi::c_char as *const ::core::ffi::c_void, + value_len, + ) == 0 as ::core::ffi::c_int + && (*map.offset(j as isize)).name[value_len as usize] + as ::core::ffi::c_int == '\0' as i32 + { + v = (*map.offset(j as isize)).value; + break; + } else { + j = j.wrapping_add(1); + } + } + } else if (**str as ::core::ffi::c_int) < '0' as i32 + || **str as ::core::ffi::c_int > '9' as i32 + { + return b"Value is not a non-negative decimal integer\0" as *const u8 + as *const ::core::ffi::c_char + } else { + let mut p: *const ::core::ffi::c_char = *str; + v = 0 as uint32_t; + loop { + if v > (UINT32_MAX as uint32_t).wrapping_div(10 as uint32_t) { + return b"Value out of range\0" as *const u8 + as *const ::core::ffi::c_char; + } + v = v.wrapping_mul(10 as uint32_t); + let add: uint32_t = (*p as ::core::ffi::c_int - '0' as i32) + as uint32_t; + if (UINT32_MAX as uint32_t).wrapping_sub(add) < v { + return b"Value out of range\0" as *const u8 + as *const ::core::ffi::c_char; + } + v = v.wrapping_add(add); + p = p.offset(1); + if !(p < name_eq_value_end + && *p as ::core::ffi::c_int >= '0' as i32 + && *p as ::core::ffi::c_int <= '9' as i32) + { + break; + } + } + if p < name_eq_value_end { + let mut multiplier_start: *const ::core::ffi::c_char = p; + if (*optmap.offset(i as isize)).flags as ::core::ffi::c_int + & OPTMAP_USE_BYTE_SUFFIX == 0 as ::core::ffi::c_int + { + *str = multiplier_start; + return b"This option does not support any multiplier suffixes\0" + as *const u8 as *const ::core::ffi::c_char; + } + let mut shift: uint32_t = 0; + match *p as ::core::ffi::c_int { + 107 | 75 => { + shift = 10 as uint32_t; + } + 109 | 77 => { + shift = 20 as uint32_t; + } + 103 | 71 => { + shift = 30 as uint32_t; + } + _ => { + *str = multiplier_start; + return b"Invalid multiplier suffix (KiB, MiB, or GiB)\0" + as *const u8 as *const ::core::ffi::c_char; + } + } + p = p.offset(1); + if p < name_eq_value_end + && *p as ::core::ffi::c_int == 'i' as i32 + { + p = p.offset(1); + } + if p < name_eq_value_end + && *p as ::core::ffi::c_int == 'B' as i32 + { + p = p.offset(1); + } + if p < name_eq_value_end { + *str = multiplier_start; + return b"Invalid multiplier suffix (KiB, MiB, or GiB)\0" + as *const u8 as *const ::core::ffi::c_char; + } + if v > UINT32_MAX as uint32_t >> shift { + return b"Value out of range\0" as *const u8 + as *const ::core::ffi::c_char; + } + v <<= shift; + } + if v < (*optmap.offset(i as isize)).u.range.min + || v > (*optmap.offset(i as isize)).u.range.max + { + return b"Value out of range\0" as *const u8 + as *const ::core::ffi::c_char; + } + } + let mut ptr: *mut ::core::ffi::c_void = (filter_options + as *mut ::core::ffi::c_char) + .offset( + (*optmap.offset(i as isize)).offset as ::core::ffi::c_int + as isize, + ) as *mut ::core::ffi::c_void; + match (*optmap.offset(i as isize)).type_0 as ::core::ffi::c_int { + 1 => { + *(ptr as *mut lzma_mode) = v as lzma_mode; + } + 2 => { + *(ptr as *mut lzma_match_finder) = v as lzma_match_finder; + } + _ => { + *(ptr as *mut uint32_t) = v; + } + } + *str = name_eq_value_end; + } + } + } + return ::core::ptr::null::<::core::ffi::c_char>(); +} +unsafe extern "C" fn parse_filter( + str: *mut *const ::core::ffi::c_char, + mut str_end: *const ::core::ffi::c_char, + mut filter: *mut lzma_filter, + mut allocator: *const lzma_allocator, + mut only_xz: bool, +) -> *const ::core::ffi::c_char { + let mut name_end: *const ::core::ffi::c_char = str_end; + let mut opts_start: *const ::core::ffi::c_char = str_end; + let mut p: *const ::core::ffi::c_char = *str; + while p < str_end { + if *p as ::core::ffi::c_int == ':' as i32 + || *p as ::core::ffi::c_int == '=' as i32 + { + name_end = p; + opts_start = p.offset(1 as ::core::ffi::c_int as isize); + break; + } else { + p = p.offset(1); + } + } + let name_len: size_t = name_end.offset_from(*str) as ::core::ffi::c_long as size_t; + if name_len > NAME_LEN_MAX as size_t { + return b"Unknown filter name\0" as *const u8 as *const ::core::ffi::c_char; + } + let mut i: size_t = 0 as size_t; + while i + < (::core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) + .wrapping_div(::core::mem::size_of::() as usize) + { + if memcmp( + *str as *const ::core::ffi::c_void, + &raw const (*(&raw const filter_name_map as *const C2RustUnnamed) + .offset(i as isize)) + .name as *const ::core::ffi::c_char as *const ::core::ffi::c_void, + name_len, + ) == 0 as ::core::ffi::c_int + && filter_name_map[i as usize].name[name_len as usize] as ::core::ffi::c_int + == '\0' as i32 + { + if only_xz as ::core::ffi::c_int != 0 + && filter_name_map[i as usize].id + >= LZMA_FILTER_RESERVED_START as lzma_vli + { + return b"This filter cannot be used in the .xz format\0" as *const u8 + as *const ::core::ffi::c_char; + } + let mut options: *mut ::core::ffi::c_void = lzma_alloc_zero( + filter_name_map[i as usize].opts_size as size_t, + allocator, + ); + if options.is_null() { + return b"Memory allocation failed\0" as *const u8 + as *const ::core::ffi::c_char; + } + *str = opts_start; + let mut errmsg: *const ::core::ffi::c_char = filter_name_map[i as usize] + .parse + .expect("non-null function pointer")(str, str_end, options); + if !errmsg.is_null() { + lzma_free(options, allocator); + return errmsg; + } + (*filter).id = filter_name_map[i as usize].id; + (*filter).options = options; + return ::core::ptr::null::<::core::ffi::c_char>(); + } + i = i.wrapping_add(1); + } + return b"Unknown filter name\0" as *const u8 as *const ::core::ffi::c_char; +} +unsafe extern "C" fn str_to_filters( + str: *mut *const ::core::ffi::c_char, + mut filters: *mut lzma_filter, + mut flags: uint32_t, + mut allocator: *const lzma_allocator, +) -> *const ::core::ffi::c_char { + let mut current_block: u64; + let mut errmsg: *const ::core::ffi::c_char = ::core::ptr::null::< + ::core::ffi::c_char, + >(); + while **str as ::core::ffi::c_int == ' ' as i32 { + *str = (*str).offset(1); + } + if **str as ::core::ffi::c_int == '\0' as i32 { + return b"Empty string is not allowed, try '6' if a default value is needed\0" + as *const u8 as *const ::core::ffi::c_char; + } + if **str as ::core::ffi::c_int >= '0' as i32 + && **str as ::core::ffi::c_int <= '9' as i32 + || **str as ::core::ffi::c_int == '-' as i32 + && (*(*str).offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + >= '0' as i32 + && *(*str).offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + <= '9' as i32) + { + if **str as ::core::ffi::c_int == '-' as i32 { + *str = (*str).offset(1); + } + let str_len: size_t = strlen(*str) as size_t; + let mut str_end: *const ::core::ffi::c_char = memchr( + *str as *const ::core::ffi::c_void, + ' ' as i32, + str_len, + ) as *const ::core::ffi::c_char; + if !str_end.is_null() { + let mut i: size_t = 1 as size_t; + while *str_end.offset(i as isize) as ::core::ffi::c_int != '\0' as i32 { + if *str_end.offset(i as isize) as ::core::ffi::c_int != ' ' as i32 { + return b"Unsupported preset\0" as *const u8 + as *const ::core::ffi::c_char; + } + i = i.wrapping_add(1); + } + } else { + str_end = (*str).offset(str_len as isize); + } + let mut preset: uint32_t = 0; + errmsg = parse_lzma12_preset(str, str_end, &raw mut preset); + if !errmsg.is_null() { + return errmsg; + } + let mut opts: *mut lzma_options_lzma = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_options_lzma; + if opts.is_null() { + return b"Memory allocation failed\0" as *const u8 + as *const ::core::ffi::c_char; + } + if lzma_lzma_preset(opts, preset) != 0 { + lzma_free(opts as *mut ::core::ffi::c_void, allocator); + return b"Unsupported preset\0" as *const u8 as *const ::core::ffi::c_char; + } + (*filters.offset(0 as ::core::ffi::c_int as isize)).id = LZMA_FILTER_LZMA2 + as lzma_vli; + let ref mut fresh0 = (*filters.offset(0 as ::core::ffi::c_int as isize)).options; + *fresh0 = opts as *mut ::core::ffi::c_void; + (*filters.offset(1 as ::core::ffi::c_int as isize)).id = LZMA_VLI_UNKNOWN + as lzma_vli; + let ref mut fresh1 = (*filters.offset(1 as ::core::ffi::c_int as isize)).options; + *fresh1 = NULL; + return ::core::ptr::null::<::core::ffi::c_char>(); + } + let only_xz: bool = flags & LZMA_STR_ALL_FILTERS as uint32_t == 0 as uint32_t; + let mut temp_filters: [lzma_filter; 5] = [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + }; 5]; + let mut i_0: size_t = 0 as size_t; + loop { + if i_0 == LZMA_FILTERS_MAX as size_t { + errmsg = b"The maximum number of filters is four\0" as *const u8 + as *const ::core::ffi::c_char; + current_block = 6100283484465977373; + break; + } else { + if *(*str).offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + == '-' as i32 + && *(*str).offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + == '-' as i32 + { + *str = (*str).offset(2 as ::core::ffi::c_int as isize); + } + let mut filter_end: *const ::core::ffi::c_char = *str; + while *filter_end.offset(0 as ::core::ffi::c_int as isize) + as ::core::ffi::c_int != '\0' as i32 + { + if *filter_end.offset(0 as ::core::ffi::c_int as isize) + as ::core::ffi::c_int == '-' as i32 + && *filter_end.offset(1 as ::core::ffi::c_int as isize) + as ::core::ffi::c_int == '-' as i32 + || *filter_end.offset(0 as ::core::ffi::c_int as isize) + as ::core::ffi::c_int == ' ' as i32 + { + break; + } + filter_end = filter_end.offset(1); + } + if filter_end == *str { + errmsg = b"Filter name is missing\0" as *const u8 + as *const ::core::ffi::c_char; + current_block = 6100283484465977373; + break; + } else { + errmsg = parse_filter( + str, + filter_end, + (&raw mut temp_filters as *mut lzma_filter).offset(i_0 as isize) + as *mut lzma_filter, + allocator, + only_xz, + ); + if !errmsg.is_null() { + current_block = 6100283484465977373; + break; + } + while **str as ::core::ffi::c_int == ' ' as i32 { + *str = (*str).offset(1); + } + i_0 = i_0.wrapping_add(1); + if !(**str as ::core::ffi::c_int != '\0' as i32) { + current_block = 15090052786889560393; + break; + } + } + } + } + match current_block { + 15090052786889560393 => { + temp_filters[i_0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + temp_filters[i_0 as usize].options = NULL; + if flags & LZMA_STR_NO_VALIDATION as uint32_t == 0 as uint32_t { + let mut dummy: size_t = 0; + let ret: lzma_ret = lzma_validate_chain( + &raw mut temp_filters as *mut lzma_filter, + &raw mut dummy, + ) as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + errmsg = b"Invalid filter chain ('lzma2' missing at the end?)\0" + as *const u8 as *const ::core::ffi::c_char; + current_block = 6100283484465977373; + } else { + current_block = 12381812505308290051; + } + } else { + current_block = 12381812505308290051; + } + match current_block { + 6100283484465977373 => {} + _ => { + memcpy( + filters as *mut ::core::ffi::c_void, + &raw mut temp_filters as *mut lzma_filter + as *const ::core::ffi::c_void, + i_0 + .wrapping_add(1 as size_t) + .wrapping_mul( + ::core::mem::size_of::() as size_t, + ), + ); + return ::core::ptr::null::<::core::ffi::c_char>(); + } + } + } + _ => {} + } + loop { + let fresh2 = i_0; + i_0 = i_0.wrapping_sub(1); + if !(fresh2 > 0 as size_t) { + break; + } + lzma_free(temp_filters[i_0 as usize].options, allocator); + } + return errmsg; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_str_to_filters( + mut str: *const ::core::ffi::c_char, + mut error_pos: *mut ::core::ffi::c_int, + mut filters: *mut lzma_filter, + mut flags: uint32_t, + mut allocator: *const lzma_allocator, +) -> *const ::core::ffi::c_char { + if !error_pos.is_null() { + *error_pos = 0 as ::core::ffi::c_int; + } + if str.is_null() || filters.is_null() { + return b"Unexpected NULL pointer argument(s) to lzma_str_to_filters()\0" + as *const u8 as *const ::core::ffi::c_char; + } + let supported_flags: uint32_t = LZMA_STR_ALL_FILTERS as uint32_t + | LZMA_STR_NO_VALIDATION as uint32_t; + if flags & !supported_flags != 0 { + return b"Unsupported flags to lzma_str_to_filters()\0" as *const u8 + as *const ::core::ffi::c_char; + } + let mut used: *const ::core::ffi::c_char = str; + let mut errmsg: *const ::core::ffi::c_char = str_to_filters( + &raw mut used, + filters, + flags, + allocator, + ); + if !error_pos.is_null() { + let n: size_t = used.offset_from(str) as ::core::ffi::c_long as size_t; + *error_pos = if n > INT_MAX as size_t { + INT_MAX + } else { + n as ::core::ffi::c_int + }; + } + return errmsg; +} +unsafe extern "C" fn strfy_filter( + mut dest: *mut lzma_str, + mut delimiter: *const ::core::ffi::c_char, + mut optmap: *const option_map, + mut optmap_count: size_t, + mut filter_options: *const ::core::ffi::c_void, +) { + let mut i: size_t = 0 as size_t; + while i < optmap_count { + if !((*optmap.offset(i as isize)).type_0 as ::core::ffi::c_int + == OPTMAP_TYPE_LZMA_PRESET as ::core::ffi::c_int) + { + let mut v: uint32_t = 0; + let mut ptr: *const ::core::ffi::c_void = (filter_options + as *const ::core::ffi::c_char) + .offset( + (*optmap.offset(i as isize)).offset as ::core::ffi::c_int as isize, + ) as *const ::core::ffi::c_void; + match (*optmap.offset(i as isize)).type_0 as ::core::ffi::c_int { + 1 => { + v = *(ptr as *const lzma_mode) as uint32_t; + } + 2 => { + v = *(ptr as *const lzma_match_finder) as uint32_t; + } + _ => { + v = *(ptr as *const uint32_t); + } + } + if !(v == 0 as uint32_t + && (*optmap.offset(i as isize)).flags as ::core::ffi::c_int + & OPTMAP_NO_STRFY_ZERO != 0) + { + str_append_str(dest, delimiter); + delimiter = b",\0" as *const u8 as *const ::core::ffi::c_char; + str_append_str( + dest, + &raw const (*optmap.offset(i as isize)).name + as *const ::core::ffi::c_char, + ); + str_append_str(dest, b"=\0" as *const u8 as *const ::core::ffi::c_char); + if (*optmap.offset(i as isize)).flags as ::core::ffi::c_int + & OPTMAP_USE_NAME_VALUE_MAP != 0 + { + let mut map: *const name_value_map = (*optmap.offset(i as isize)) + .u + .map; + let mut j: size_t = 0 as size_t; + loop { + if (*map.offset(j as isize)) + .name[0 as ::core::ffi::c_int as usize] as ::core::ffi::c_int + == '\0' as i32 + { + str_append_str( + dest, + b"UNKNOWN\0" as *const u8 as *const ::core::ffi::c_char, + ); + break; + } else if (*map.offset(j as isize)).value == v { + str_append_str( + dest, + &raw const (*map.offset(j as isize)).name + as *const ::core::ffi::c_char, + ); + break; + } else { + j = j.wrapping_add(1); + } + } + } else { + str_append_u32( + dest, + v, + (*optmap.offset(i as isize)).flags as ::core::ffi::c_int + & OPTMAP_USE_BYTE_SUFFIX != 0, + ); + } + } + } + i = i.wrapping_add(1); + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_str_from_filters( + mut output_str: *mut *mut ::core::ffi::c_char, + mut filters: *const lzma_filter, + mut flags: uint32_t, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + if output_str.is_null() { + return LZMA_PROG_ERROR; + } + *output_str = ::core::ptr::null_mut::<::core::ffi::c_char>(); + if filters.is_null() { + return LZMA_PROG_ERROR; + } + let supported_flags: uint32_t = LZMA_STR_ENCODER as uint32_t + | LZMA_STR_DECODER as uint32_t | LZMA_STR_GETOPT_LONG as uint32_t + | LZMA_STR_NO_SPACES as uint32_t; + if flags & !supported_flags != 0 { + return LZMA_OPTIONS_ERROR; + } + if (*filters.offset(0 as ::core::ffi::c_int as isize)).id + == LZMA_VLI_UNKNOWN as lzma_vli + { + return LZMA_OPTIONS_ERROR; + } + let mut dest: lzma_str = lzma_str { + buf: ::core::ptr::null_mut::<::core::ffi::c_char>(), + pos: 0, + }; + let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let show_opts: bool = flags + & (LZMA_STR_ENCODER as uint32_t | LZMA_STR_DECODER as uint32_t) != 0; + let mut opt_delim: *const ::core::ffi::c_char = if flags + & LZMA_STR_GETOPT_LONG as uint32_t != 0 + { + b"=\0" as *const u8 as *const ::core::ffi::c_char + } else { + b":\0" as *const u8 as *const ::core::ffi::c_char + }; + let mut i: size_t = 0 as size_t; + while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + if i == LZMA_FILTERS_MAX as size_t { + str_free(&raw mut dest, allocator); + return LZMA_OPTIONS_ERROR; + } + if i > 0 as size_t && flags & LZMA_STR_NO_SPACES as uint32_t == 0 { + str_append_str( + &raw mut dest, + b" \0" as *const u8 as *const ::core::ffi::c_char, + ); + } + if flags & LZMA_STR_GETOPT_LONG as uint32_t != 0 + || i > 0 as size_t && flags & LZMA_STR_NO_SPACES as uint32_t != 0 + { + str_append_str( + &raw mut dest, + b"--\0" as *const u8 as *const ::core::ffi::c_char, + ); + } + let mut j: size_t = 0 as size_t; + loop { + if j + == (::core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) + .wrapping_div(::core::mem::size_of::() as usize) + { + str_free(&raw mut dest, allocator); + return LZMA_OPTIONS_ERROR; + } + if filter_name_map[j as usize].id == (*filters.offset(i as isize)).id { + str_append_str( + &raw mut dest, + &raw const (*(&raw const filter_name_map as *const C2RustUnnamed) + .offset(j as isize)) + .name as *const ::core::ffi::c_char, + ); + if !show_opts { + break; + } + if (*filters.offset(i as isize)).options.is_null() { + if !filter_name_map[j as usize].allow_null { + str_free(&raw mut dest, allocator); + return LZMA_OPTIONS_ERROR; + } + break; + } else { + let optmap_count: size_t = (if flags & LZMA_STR_ENCODER as uint32_t + != 0 + { + filter_name_map[j as usize].strfy_encoder as ::core::ffi::c_int + } else { + filter_name_map[j as usize].strfy_decoder as ::core::ffi::c_int + }) as size_t; + strfy_filter( + &raw mut dest, + opt_delim, + filter_name_map[j as usize].optmap, + optmap_count, + (*filters.offset(i as isize)).options, + ); + break; + } + } else { + j = j.wrapping_add(1); + } + } + i = i.wrapping_add(1); + } + return str_finish(output_str, &raw mut dest, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_str_list_filters( + mut output_str: *mut *mut ::core::ffi::c_char, + mut filter_id: lzma_vli, + mut flags: uint32_t, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + if output_str.is_null() { + return LZMA_PROG_ERROR; + } + *output_str = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let supported_flags: uint32_t = LZMA_STR_ALL_FILTERS as uint32_t + | LZMA_STR_ENCODER as uint32_t | LZMA_STR_DECODER as uint32_t + | LZMA_STR_GETOPT_LONG as uint32_t; + if flags & !supported_flags != 0 { + return LZMA_OPTIONS_ERROR; + } + let mut dest: lzma_str = lzma_str { + buf: ::core::ptr::null_mut::<::core::ffi::c_char>(), + pos: 0, + }; + let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + let show_opts: bool = flags + & (LZMA_STR_ENCODER as uint32_t | LZMA_STR_DECODER as uint32_t) != 0; + let mut filter_delim: *const ::core::ffi::c_char = if show_opts as ::core::ffi::c_int + != 0 + { + b"\n\0" as *const u8 as *const ::core::ffi::c_char + } else { + b" \0" as *const u8 as *const ::core::ffi::c_char + }; + let mut opt_delim: *const ::core::ffi::c_char = if flags + & LZMA_STR_GETOPT_LONG as uint32_t != 0 + { + b"=\0" as *const u8 as *const ::core::ffi::c_char + } else { + b":\0" as *const u8 as *const ::core::ffi::c_char + }; + let mut first_filter_printed: bool = false_0 != 0; + let mut i: size_t = 0 as size_t; + while i + < (::core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) + .wrapping_div(::core::mem::size_of::() as usize) + { + if !(filter_id != LZMA_VLI_UNKNOWN as lzma_vli + && filter_id != filter_name_map[i as usize].id) + { + if !(filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START as lzma_vli + && flags & LZMA_STR_ALL_FILTERS as uint32_t == 0 as uint32_t + && filter_id == LZMA_VLI_UNKNOWN as lzma_vli) + { + if first_filter_printed { + str_append_str(&raw mut dest, filter_delim); + } + first_filter_printed = true_0 != 0; + if flags & LZMA_STR_GETOPT_LONG as uint32_t != 0 { + str_append_str( + &raw mut dest, + b"--\0" as *const u8 as *const ::core::ffi::c_char, + ); + } + str_append_str( + &raw mut dest, + &raw const (*(&raw const filter_name_map as *const C2RustUnnamed) + .offset(i as isize)) + .name as *const ::core::ffi::c_char, + ); + if show_opts { + let mut optmap: *const option_map = filter_name_map[i as usize] + .optmap; + let mut d: *const ::core::ffi::c_char = opt_delim; + let end: size_t = (if flags & LZMA_STR_ENCODER as uint32_t != 0 { + filter_name_map[i as usize].strfy_encoder as ::core::ffi::c_int + } else { + filter_name_map[i as usize].strfy_decoder as ::core::ffi::c_int + }) as size_t; + let mut j: size_t = 0 as size_t; + while j < end { + str_append_str(&raw mut dest, d); + d = b",\0" as *const u8 as *const ::core::ffi::c_char; + str_append_str( + &raw mut dest, + &raw const (*optmap.offset(j as isize)).name + as *const ::core::ffi::c_char, + ); + str_append_str( + &raw mut dest, + b"=<\0" as *const u8 as *const ::core::ffi::c_char, + ); + if (*optmap.offset(j as isize)).type_0 as ::core::ffi::c_int + == OPTMAP_TYPE_LZMA_PRESET as ::core::ffi::c_int + { + str_append_str(&raw mut dest, LZMA12_PRESET_STR.as_ptr()); + } else if (*optmap.offset(j as isize)).flags + as ::core::ffi::c_int & OPTMAP_USE_NAME_VALUE_MAP != 0 + { + let mut m: *const name_value_map = (*optmap + .offset(j as isize)) + .u + .map; + let mut k: size_t = 0 as size_t; + while (*m.offset(k as isize)) + .name[0 as ::core::ffi::c_int as usize] + as ::core::ffi::c_int != '\0' as i32 + { + if k > 0 as size_t { + str_append_str( + &raw mut dest, + b"|\0" as *const u8 as *const ::core::ffi::c_char, + ); + } + str_append_str( + &raw mut dest, + &raw const (*m.offset(k as isize)).name + as *const ::core::ffi::c_char, + ); + k = k.wrapping_add(1); + } + } else { + let use_byte_suffix: bool = (*optmap.offset(j as isize)) + .flags as ::core::ffi::c_int & OPTMAP_USE_BYTE_SUFFIX != 0; + str_append_u32( + &raw mut dest, + (*optmap.offset(j as isize)).u.range.min, + use_byte_suffix, + ); + str_append_str( + &raw mut dest, + b"-\0" as *const u8 as *const ::core::ffi::c_char, + ); + str_append_u32( + &raw mut dest, + (*optmap.offset(j as isize)).u.range.max, + use_byte_suffix, + ); + } + str_append_str( + &raw mut dest, + b">\0" as *const u8 as *const ::core::ffi::c_char, + ); + j = j.wrapping_add(1); + } + } + } + } + i = i.wrapping_add(1); + } + if !first_filter_printed { + str_free(&raw mut dest, allocator); + return LZMA_OPTIONS_ERROR; + } + return str_finish(output_str, &raw mut dest, allocator); +} +unsafe extern "C" fn run_static_initializers() { + lzma12_optmap = [ + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"preset\0\0\0\0\0\0"), + type_0: OPTMAP_TYPE_LZMA_PRESET as ::core::ffi::c_int as uint8_t, + flags: 0, + offset: 0, + u: C2RustUnnamed_0 { + map: ::core::ptr::null::(), + }, + }, + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"dict\0\0\0\0\0\0\0\0"), + type_0: 0, + flags: OPTMAP_USE_BYTE_SUFFIX as uint8_t, + offset: 0 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: LZMA_DICT_SIZE_MIN as uint32_t, + max: ((1 as uint32_t) << 30 as ::core::ffi::c_int) + .wrapping_add((1 as uint32_t) << 29 as ::core::ffi::c_int), + }, + }, + }, + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"lc\0\0\0\0\0\0\0\0\0\0"), + type_0: 0, + flags: 0, + offset: 20 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: LZMA_LCLP_MIN as uint32_t, + max: LZMA_LCLP_MAX as uint32_t, + }, + }, + }, + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"lp\0\0\0\0\0\0\0\0\0\0"), + type_0: 0, + flags: 0, + offset: 24 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: LZMA_LCLP_MIN as uint32_t, + max: LZMA_LCLP_MAX as uint32_t, + }, + }, + }, + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"pb\0\0\0\0\0\0\0\0\0\0"), + type_0: 0, + flags: 0, + offset: 28 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: LZMA_PB_MIN as uint32_t, + max: LZMA_PB_MAX as uint32_t, + }, + }, + }, + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"mode\0\0\0\0\0\0\0\0"), + type_0: OPTMAP_TYPE_LZMA_MODE as ::core::ffi::c_int as uint8_t, + flags: OPTMAP_USE_NAME_VALUE_MAP as uint8_t, + offset: 32 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + map: &raw const lzma12_mode_map as *const name_value_map, + }, + }, + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"nice\0\0\0\0\0\0\0\0"), + type_0: 0, + flags: 0, + offset: 36 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: 2 as uint32_t, + max: 273 as uint32_t, + }, + }, + }, + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"mf\0\0\0\0\0\0\0\0\0\0"), + type_0: OPTMAP_TYPE_LZMA_MATCH_FINDER as ::core::ffi::c_int as uint8_t, + flags: OPTMAP_USE_NAME_VALUE_MAP as uint8_t, + offset: 40 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + map: &raw const lzma12_mf_map as *const name_value_map, + }, + }, + option_map { + name: ::core::mem::transmute::< + [u8; 12], + [::core::ffi::c_char; 12], + >(*b"depth\0\0\0\0\0\0\0"), + type_0: 0, + flags: 0, + offset: 44 as ::core::ffi::c_ulong as uint16_t, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: 0 as uint32_t, + max: UINT32_MAX as uint32_t, + }, + }, + }, + ]; +} +#[used] +#[cfg_attr(target_os = "linux", link_section = ".init_array")] +#[cfg_attr(target_os = "windows", link_section = ".CRT$XIB")] +#[cfg_attr(target_os = "macos", link_section = "__DATA,__mod_init_func")] +static INIT_ARRAY: [unsafe extern "C" fn(); 1] = [run_static_initializers]; diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs new file mode 100644 index 00000000..0a85aecf --- /dev/null +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -0,0 +1,96 @@ +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_vli = uint64_t; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const LZMA_VLI_BYTES_MAX: ::core::ffi::c_int = 9 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_vli_decode( + mut vli: *mut lzma_vli, + mut vli_pos: *mut size_t, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + let mut vli_pos_internal: size_t = 0 as size_t; + if vli_pos.is_null() { + vli_pos = &raw mut vli_pos_internal; + *vli = 0 as lzma_vli; + if *in_pos >= in_size { + return LZMA_DATA_ERROR; + } + } else { + if *vli_pos == 0 as size_t { + *vli = 0 as lzma_vli; + } + if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t + || *vli >> (*vli_pos).wrapping_mul(7 as size_t) != 0 as lzma_vli + { + return LZMA_PROG_ERROR; + } + if *in_pos >= in_size { + return LZMA_BUF_ERROR; + } + } + loop { + let byte: uint8_t = *in_0.offset(*in_pos as isize); + *in_pos = (*in_pos).wrapping_add(1); + *vli = (*vli) + .wrapping_add( + ((byte as ::core::ffi::c_int & 0x7f as ::core::ffi::c_int) as lzma_vli) + << (*vli_pos).wrapping_mul(7 as size_t), + ); + *vli_pos = (*vli_pos).wrapping_add(1); + if byte as ::core::ffi::c_int & 0x80 as ::core::ffi::c_int + == 0 as ::core::ffi::c_int + { + if byte as ::core::ffi::c_int == 0 as ::core::ffi::c_int + && *vli_pos > 1 as size_t + { + return LZMA_DATA_ERROR; + } + return (if vli_pos == &raw mut vli_pos_internal { + LZMA_OK as ::core::ffi::c_int + } else { + LZMA_STREAM_END as ::core::ffi::c_int + }) as lzma_ret; + } + if *vli_pos == LZMA_VLI_BYTES_MAX as size_t { + return LZMA_DATA_ERROR; + } + if !(*in_pos < in_size) { + break; + } + } + return (if vli_pos == &raw mut vli_pos_internal { + LZMA_DATA_ERROR as ::core::ffi::c_int + } else { + LZMA_OK as ::core::ffi::c_int + }) as lzma_ret; +} diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs new file mode 100644 index 00000000..fc0b1861 --- /dev/null +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -0,0 +1,80 @@ +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_vli = uint64_t; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_BYTES_MAX: ::core::ffi::c_int = 9 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_vli_encode( + mut vli: lzma_vli, + mut vli_pos: *mut size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + let mut vli_pos_internal: size_t = 0 as size_t; + if vli_pos.is_null() { + vli_pos = &raw mut vli_pos_internal; + if *out_pos >= out_size { + return LZMA_PROG_ERROR; + } + } else if *out_pos >= out_size { + return LZMA_BUF_ERROR + } + if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || vli > LZMA_VLI_MAX as lzma_vli { + return LZMA_PROG_ERROR; + } + vli >>= (*vli_pos).wrapping_mul(7 as size_t); + while vli >= 0x80 as lzma_vli { + *vli_pos = (*vli_pos).wrapping_add(1); + *out.offset(*out_pos as isize) = (vli as uint8_t as ::core::ffi::c_int + | 0x80 as ::core::ffi::c_int) as uint8_t; + vli >>= 7 as ::core::ffi::c_int; + *out_pos = (*out_pos).wrapping_add(1); + if *out_pos == out_size { + return (if vli_pos == &raw mut vli_pos_internal { + LZMA_PROG_ERROR as ::core::ffi::c_int + } else { + LZMA_OK as ::core::ffi::c_int + }) as lzma_ret; + } + } + *out.offset(*out_pos as isize) = vli as uint8_t; + *out_pos = (*out_pos).wrapping_add(1); + *vli_pos = (*vli_pos).wrapping_add(1); + return (if vli_pos == &raw mut vli_pos_internal { + LZMA_OK as ::core::ffi::c_int + } else { + LZMA_STREAM_END as ::core::ffi::c_int + }) as lzma_ret; +} diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs new file mode 100644 index 00000000..34de1ab3 --- /dev/null +++ b/liblzma-rs/src/common/vli_size.rs @@ -0,0 +1,22 @@ +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_vli = uint64_t; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX + .wrapping_div(2 as ::core::ffi::c_ulonglong); +#[no_mangle] +pub unsafe extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> uint32_t { + if vli > LZMA_VLI_MAX as lzma_vli { + return 0 as uint32_t; + } + let mut i: uint32_t = 0 as uint32_t; + loop { + vli >>= 7 as ::core::ffi::c_int; + i = i.wrapping_add(1); + if !(vli != 0 as lzma_vli) { + break; + } + } + return i; +} diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs new file mode 100644 index 00000000..879cec5f --- /dev/null +++ b/liblzma-rs/src/delta/delta_common.rs @@ -0,0 +1,265 @@ +extern "C" { + fn memset( + __b: *mut ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __len: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_delta_type = ::core::ffi::c_uint; +pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_delta { + pub type_0: lzma_delta_type, + pub dist: uint32_t, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_delta_coder { + pub next: lzma_next_coder, + pub distance: size_t, + pub pos: uint8_t, + pub history: [uint8_t; 256], +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_DELTA_DIST_MIN: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const LZMA_DELTA_DIST_MAX: ::core::ffi::c_int = 256 as ::core::ffi::c_int; +unsafe extern "C" fn delta_coder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_delta_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + let mut coder: *mut lzma_delta_coder = (*next).coder as *mut lzma_delta_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_delta_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).end = Some( + delta_coder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + if lzma_delta_coder_memusage( + (*filters.offset(0 as ::core::ffi::c_int as isize)).options, + ) == UINT64_MAX as uint64_t + { + return LZMA_OPTIONS_ERROR; + } + let mut opt: *const lzma_options_delta = (*filters + .offset(0 as ::core::ffi::c_int as isize)) + .options as *const lzma_options_delta; + (*coder).distance = (*opt).dist as size_t; + (*coder).pos = 0 as uint8_t; + memset( + &raw mut (*coder).history as *mut uint8_t as *mut ::core::ffi::c_void, + 0 as ::core::ffi::c_int, + 256 as size_t, + ); + return lzma_next_filter_init( + &raw mut (*coder).next, + allocator, + filters.offset(1 as ::core::ffi::c_int as isize), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_delta_coder_memusage( + mut options: *const ::core::ffi::c_void, +) -> uint64_t { + let mut opt: *const lzma_options_delta = options as *const lzma_options_delta; + if opt.is_null() + || (*opt).type_0 as ::core::ffi::c_uint + != LZMA_DELTA_TYPE_BYTE as ::core::ffi::c_int as ::core::ffi::c_uint + || (*opt).dist < LZMA_DELTA_DIST_MIN as uint32_t + || (*opt).dist > LZMA_DELTA_DIST_MAX as uint32_t + { + return UINT64_MAX as uint64_t; + } + return ::core::mem::size_of::() as uint64_t; +} diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs new file mode 100644 index 00000000..4dda54d6 --- /dev/null +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -0,0 +1,274 @@ +extern "C" { + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_delta_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_delta_type = ::core::ffi::c_uint; +pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_delta { + pub type_0: lzma_delta_type, + pub dist: uint32_t, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_delta_coder { + pub next: lzma_next_coder, + pub distance: size_t, + pub pos: uint8_t, + pub history: [uint8_t; 256], +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +unsafe extern "C" fn decode_buffer( + mut coder: *mut lzma_delta_coder, + mut buffer: *mut uint8_t, + mut size: size_t, +) { + let distance: size_t = (*coder).distance; + let mut i: size_t = 0 as size_t; + while i < size { + let ref mut fresh0 = *buffer.offset(i as isize); + *fresh0 = (*fresh0 as ::core::ffi::c_int + + (*coder) + .history[(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) + as usize] as ::core::ffi::c_int) as uint8_t; + let fresh1 = (*coder).pos; + (*coder).pos = (*coder).pos.wrapping_sub(1); + (*coder) + .history[(fresh1 as ::core::ffi::c_int & 0xff as ::core::ffi::c_int) + as usize] = *buffer.offset(i as isize); + i = i.wrapping_add(1); + } +} +unsafe extern "C" fn delta_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; + let out_start: size_t = *out_pos; + let ret: lzma_ret = (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + let size: size_t = (*out_pos).wrapping_sub(out_start); + if size > 0 as size_t { + decode_buffer(coder, out.offset(out_start as isize), size); + } + return ret; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_delta_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + (*next).code = Some( + delta_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + return lzma_delta_coder_init(next, allocator, filters); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_delta_props_decode( + mut options: *mut *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut props: *const uint8_t, + mut props_size: size_t, +) -> lzma_ret { + if props_size != 1 as size_t { + return LZMA_OPTIONS_ERROR; + } + let mut opt: *mut lzma_options_delta = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_options_delta; + if opt.is_null() { + return LZMA_MEM_ERROR; + } + (*opt).type_0 = LZMA_DELTA_TYPE_BYTE; + (*opt).dist = (*props.offset(0 as ::core::ffi::c_int as isize) + as ::core::ffi::c_uint) + .wrapping_add(1 as ::core::ffi::c_uint) as uint32_t; + *options = opt as *mut ::core::ffi::c_void; + return LZMA_OK; +} diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs new file mode 100644 index 00000000..20a8c1e7 --- /dev/null +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -0,0 +1,346 @@ +extern "C" { + fn lzma_next_filter_update( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + reversed_filters: *const lzma_filter, + ) -> lzma_ret; + fn lzma_delta_coder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_delta_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_delta_type = ::core::ffi::c_uint; +pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_delta { + pub type_0: lzma_delta_type, + pub dist: uint32_t, + pub reserved_int1: uint32_t, + pub reserved_int2: uint32_t, + pub reserved_int3: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_delta_coder { + pub next: lzma_next_coder, + pub distance: size_t, + pub pos: uint8_t, + pub history: [uint8_t; 256], +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const LZMA_DELTA_DIST_MIN: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +unsafe extern "C" fn copy_and_encode( + mut coder: *mut lzma_delta_coder, + mut in_0: *const uint8_t, + mut out: *mut uint8_t, + mut size: size_t, +) { + let distance: size_t = (*coder).distance; + let mut i: size_t = 0 as size_t; + while i < size { + let tmp: uint8_t = (*coder) + .history[(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) + as usize]; + let fresh2 = (*coder).pos; + (*coder).pos = (*coder).pos.wrapping_sub(1); + (*coder) + .history[(fresh2 as ::core::ffi::c_int & 0xff as ::core::ffi::c_int) + as usize] = *in_0.offset(i as isize); + *out.offset(i as isize) = (*in_0.offset(i as isize) as ::core::ffi::c_int + - tmp as ::core::ffi::c_int) as uint8_t; + i = i.wrapping_add(1); + } +} +unsafe extern "C" fn encode_in_place( + mut coder: *mut lzma_delta_coder, + mut buffer: *mut uint8_t, + mut size: size_t, +) { + let distance: size_t = (*coder).distance; + let mut i: size_t = 0 as size_t; + while i < size { + let tmp: uint8_t = (*coder) + .history[(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) + as usize]; + let fresh0 = (*coder).pos; + (*coder).pos = (*coder).pos.wrapping_sub(1); + (*coder) + .history[(fresh0 as ::core::ffi::c_int & 0xff as ::core::ffi::c_int) + as usize] = *buffer.offset(i as isize); + let ref mut fresh1 = *buffer.offset(i as isize); + *fresh1 = (*fresh1 as ::core::ffi::c_int - tmp as ::core::ffi::c_int) as uint8_t; + i = i.wrapping_add(1); + } +} +unsafe extern "C" fn delta_encode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; + let mut ret: lzma_ret = LZMA_OK; + if (*coder).next.code.is_none() { + let in_avail: size_t = in_size.wrapping_sub(*in_pos); + let out_avail: size_t = out_size.wrapping_sub(*out_pos); + let size: size_t = if in_avail < out_avail { in_avail } else { out_avail }; + if size > 0 as size_t { + copy_and_encode( + coder, + in_0.offset(*in_pos as isize), + out.offset(*out_pos as isize), + size, + ); + } + *in_pos = (*in_pos).wrapping_add(size); + *out_pos = (*out_pos).wrapping_add(size); + ret = (if action as ::core::ffi::c_uint + != LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint + && *in_pos == in_size + { + LZMA_STREAM_END as ::core::ffi::c_int + } else { + LZMA_OK as ::core::ffi::c_int + }) as lzma_ret; + } else { + let out_start: size_t = *out_pos; + ret = (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ); + let size_0: size_t = (*out_pos).wrapping_sub(out_start); + if size_0 > 0 as size_t { + encode_in_place(coder, out.offset(out_start as isize), size_0); + } + } + return ret; +} +unsafe extern "C" fn delta_encoder_update( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut filters_null: *const lzma_filter, + mut reversed_filters: *const lzma_filter, +) -> lzma_ret { + let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; + return lzma_next_filter_update( + &raw mut (*coder).next, + allocator, + reversed_filters.offset(1 as ::core::ffi::c_int as isize), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_delta_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + (*next).code = Some( + delta_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).update = Some( + delta_encoder_update + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >; + return lzma_delta_coder_init(next, allocator, filters); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_delta_props_encode( + mut options: *const ::core::ffi::c_void, + mut out: *mut uint8_t, +) -> lzma_ret { + if lzma_delta_coder_memusage(options) == UINT64_MAX as uint64_t { + return LZMA_PROG_ERROR; + } + let mut opt: *const lzma_options_delta = options as *const lzma_options_delta; + *out.offset(0 as ::core::ffi::c_int as isize) = (*opt) + .dist + .wrapping_sub(LZMA_DELTA_DIST_MIN as uint32_t) as uint8_t; + return LZMA_OK; +} diff --git a/liblzma-rs/src/delta/mod.rs b/liblzma-rs/src/delta/mod.rs new file mode 100644 index 00000000..a584bd21 --- /dev/null +++ b/liblzma-rs/src/delta/mod.rs @@ -0,0 +1,3 @@ +pub mod delta_common; +pub mod delta_decoder; +pub mod delta_encoder; diff --git a/liblzma-rs/src/lib.rs b/liblzma-rs/src/lib.rs new file mode 100644 index 00000000..4aff872f --- /dev/null +++ b/liblzma-rs/src/lib.rs @@ -0,0 +1,22 @@ +#![allow( + clashing_extern_declarations, + dead_code, + non_camel_case_types, + non_snake_case, + non_upper_case_globals, + unused_assignments, + unused_mut, + unused_parens, + unused_variables, + unused_imports, + clippy::all, +)] + +pub mod check; +pub mod common; +pub mod delta; +pub mod lz; +pub mod lzma; +pub mod rangecoder; +pub mod simple; +pub mod tuklib; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs new file mode 100644 index 00000000..40230703 --- /dev/null +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -0,0 +1,552 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_dict { + pub buf: *mut uint8_t, + pub pos: size_t, + pub full: size_t, + pub limit: size_t, + pub size: size_t, + pub has_wrapped: bool, + pub need_reset: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_options { + pub dict_size: size_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: size_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_decoder { + pub coder: *mut ::core::ffi::c_void, + pub code: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_dict, + *const uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >, + pub reset: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const ::core::ffi::c_void) -> (), + >, + pub set_uncompressed: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), + >, + pub end: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_coder { + pub dict: lzma_dict, + pub lz: lzma_lz_decoder, + pub next: lzma_next_coder, + pub next_finished: bool, + pub this_finished: bool, + pub temp: C2RustUnnamed, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed { + pub pos: size_t, + pub size: size_t, + pub buffer: [uint8_t; 4096], +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const UINTPTR_MAX: ::core::ffi::c_ulong = 18446744073709551615 + as ::core::ffi::c_ulong; +pub const SIZE_MAX: ::core::ffi::c_ulong = UINTPTR_MAX; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_BUFFER_SIZE: ::core::ffi::c_int = 4096 as ::core::ffi::c_int; +pub const LZ_DICT_EXTRA: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZ_DICT_REPEAT_MAX: ::core::ffi::c_int = 288 as ::core::ffi::c_int; +pub const LZ_DICT_INIT_POS: ::core::ffi::c_int = 2 as ::core::ffi::c_int + * LZ_DICT_REPEAT_MAX; +pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { + coder: NULL, + code: None, + reset: None, + set_uncompressed: None, + end: None, +}; +unsafe extern "C" fn lz_decoder_reset(mut coder: *mut lzma_coder) { + (*coder).dict.pos = LZ_DICT_INIT_POS as size_t; + (*coder).dict.full = 0 as size_t; + *(*coder).dict.buf.offset((LZ_DICT_INIT_POS - 1 as ::core::ffi::c_int) as isize) = '\0' + as i32 as uint8_t; + (*coder).dict.has_wrapped = false_0 != 0; + (*coder).dict.need_reset = false_0 != 0; +} +unsafe extern "C" fn decode_buffer( + mut coder: *mut lzma_coder, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + loop { + if (*coder).dict.pos == (*coder).dict.size { + (*coder).dict.pos = LZ_DICT_REPEAT_MAX as size_t; + (*coder).dict.has_wrapped = true_0 != 0; + memcpy( + (*coder).dict.buf as *mut ::core::ffi::c_void, + (*coder) + .dict + .buf + .offset((*coder).dict.size as isize) + .offset(-(LZ_DICT_REPEAT_MAX as isize)) + as *const ::core::ffi::c_void, + LZ_DICT_REPEAT_MAX as size_t, + ); + } + let dict_start: size_t = (*coder).dict.pos; + (*coder).dict.limit = (*coder) + .dict + .pos + .wrapping_add( + (if out_size.wrapping_sub(*out_pos) + < (*coder).dict.size.wrapping_sub((*coder).dict.pos) + { + out_size.wrapping_sub(*out_pos) + } else { + (*coder).dict.size.wrapping_sub((*coder).dict.pos) + }), + ); + let ret: lzma_ret = (*coder) + .lz + .code + .expect( + "non-null function pointer", + )((*coder).lz.coder, &raw mut (*coder).dict, in_0, in_pos, in_size) + as lzma_ret; + let copy_size: size_t = (*coder).dict.pos.wrapping_sub(dict_start); + if copy_size > 0 as size_t { + memcpy( + out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, + (*coder).dict.buf.offset(dict_start as isize) + as *const ::core::ffi::c_void, + copy_size, + ); + } + *out_pos = (*out_pos).wrapping_add(copy_size); + if (*coder).dict.need_reset { + lz_decoder_reset(coder); + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + || *out_pos == out_size + { + return ret; + } + } else if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + || *out_pos == out_size || (*coder).dict.pos < (*coder).dict.size + { + return ret + } + }; +} +unsafe extern "C" fn lz_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + if (*coder).next.code.is_none() { + return decode_buffer(coder, in_0, in_pos, in_size, out, out_pos, out_size); + } + while *out_pos < out_size { + if !(*coder).next_finished && (*coder).temp.pos == (*coder).temp.size { + (*coder).temp.pos = 0 as size_t; + (*coder).temp.size = 0 as size_t; + let ret: lzma_ret = (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + &raw mut (*coder).temp.buffer as *mut uint8_t, + &raw mut (*coder).temp.size, + LZMA_BUFFER_SIZE as size_t, + action, + ) as lzma_ret; + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*coder).next_finished = true_0 != 0; + } else if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + || (*coder).temp.size == 0 as size_t + { + return ret + } + } + if (*coder).this_finished { + if (*coder).temp.size != 0 as size_t { + return LZMA_DATA_ERROR; + } + if (*coder).next_finished { + return LZMA_STREAM_END; + } + return LZMA_OK; + } + let ret_0: lzma_ret = decode_buffer( + coder, + &raw mut (*coder).temp.buffer as *mut uint8_t, + &raw mut (*coder).temp.pos, + (*coder).temp.size, + out, + out_pos, + out_size, + ) as lzma_ret; + if ret_0 as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*coder).this_finished = true_0 != 0; + } else if ret_0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_0 + } else if (*coder).next_finished as ::core::ffi::c_int != 0 + && *out_pos < out_size + { + return LZMA_DATA_ERROR + } + } + return LZMA_OK; +} +unsafe extern "C" fn lz_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free((*coder).dict.buf as *mut ::core::ffi::c_void, allocator); + if (*coder).lz.end.is_some() { + (*coder) + .lz + .end + .expect("non-null function pointer")((*coder).lz.coder, allocator); + } else { + lzma_free((*coder).lz.coder, allocator); + } + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lz_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut lz_init: Option< + unsafe extern "C" fn( + *mut lzma_lz_decoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + >, +) -> lzma_ret { + let mut coder: *mut lzma_coder = (*next).coder as *mut lzma_coder; + if coder.is_null() { + coder = lzma_alloc(::core::mem::size_of::() as size_t, allocator) + as *mut lzma_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + lz_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + lz_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*coder).dict.buf = ::core::ptr::null_mut::(); + (*coder).dict.size = 0 as size_t; + (*coder).lz = LZMA_LZ_DECODER_INIT; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + let mut lz_options: lzma_lz_options = lzma_lz_options { + dict_size: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + }; + let ret_: lzma_ret = lz_init + .expect( + "non-null function pointer", + )( + &raw mut (*coder).lz, + allocator, + (*filters.offset(0 as ::core::ffi::c_int as isize)).id, + (*filters.offset(0 as ::core::ffi::c_int as isize)).options, + &raw mut lz_options, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + if lz_options.dict_size < 4096 as size_t { + lz_options.dict_size = 4096 as size_t; + } + if lz_options.dict_size + > (SIZE_MAX as size_t) + .wrapping_sub(15 as size_t) + .wrapping_sub((2 as ::core::ffi::c_int * LZ_DICT_REPEAT_MAX) as size_t) + .wrapping_sub(LZ_DICT_EXTRA as size_t) + { + return LZMA_MEM_ERROR; + } + lz_options.dict_size = lz_options.dict_size.wrapping_add(15 as size_t) + & !(15 as ::core::ffi::c_int as size_t); + let alloc_size: size_t = lz_options + .dict_size + .wrapping_add((2 as ::core::ffi::c_int * LZ_DICT_REPEAT_MAX) as size_t); + if (*coder).dict.size != alloc_size { + lzma_free((*coder).dict.buf as *mut ::core::ffi::c_void, allocator); + (*coder).dict.buf = lzma_alloc( + alloc_size.wrapping_add(LZ_DICT_EXTRA as size_t), + allocator, + ) as *mut uint8_t; + if (*coder).dict.buf.is_null() { + return LZMA_MEM_ERROR; + } + (*coder).dict.size = alloc_size; + } + lz_decoder_reset((*next).coder as *mut lzma_coder); + if !lz_options.preset_dict.is_null() && lz_options.preset_dict_size > 0 as size_t { + let copy_size: size_t = if lz_options.preset_dict_size < lz_options.dict_size { + lz_options.preset_dict_size + } else { + lz_options.dict_size + }; + let offset: size_t = lz_options.preset_dict_size.wrapping_sub(copy_size); + memcpy( + (*coder).dict.buf.offset((*coder).dict.pos as isize) + as *mut ::core::ffi::c_void, + lz_options.preset_dict.offset(offset as isize) as *const ::core::ffi::c_void, + copy_size, + ); + (*coder).dict.pos = (*coder).dict.pos.wrapping_add(copy_size); + (*coder).dict.full = copy_size; + } + (*coder).next_finished = false_0 != 0; + (*coder).this_finished = false_0 != 0; + (*coder).temp.pos = 0 as size_t; + (*coder).temp.size = 0 as size_t; + return lzma_next_filter_init( + &raw mut (*coder).next, + allocator, + filters.offset(1 as ::core::ffi::c_int as isize), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lz_decoder_memusage( + mut dictionary_size: size_t, +) -> uint64_t { + return (::core::mem::size_of::() as uint64_t) + .wrapping_add(dictionary_size as uint64_t) + .wrapping_add((2 as ::core::ffi::c_int * LZ_DICT_REPEAT_MAX) as uint64_t) + .wrapping_add(LZ_DICT_EXTRA as uint64_t); +} diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs new file mode 100644 index 00000000..eecbaaf7 --- /dev/null +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -0,0 +1,921 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn memmove( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __len: size_t, + ) -> *mut ::core::ffi::c_void; + fn memset( + __b: *mut ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __len: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc_zero( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_filter_update( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + reversed_filters: *const lzma_filter, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_mf_hc3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; + fn lzma_mf_hc3_skip(dict: *mut lzma_mf, amount: uint32_t); + fn lzma_mf_hc4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; + fn lzma_mf_hc4_skip(dict: *mut lzma_mf, amount: uint32_t); + fn lzma_mf_bt2_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; + fn lzma_mf_bt2_skip(dict: *mut lzma_mf, amount: uint32_t); + fn lzma_mf_bt3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; + fn lzma_mf_bt3_skip(dict: *mut lzma_mf, amount: uint32_t); + fn lzma_mf_bt4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; + fn lzma_mf_bt4_skip(dict: *mut lzma_mf, amount: uint32_t); +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_match { + pub len: uint32_t, + pub dist: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mf_s { + pub buffer: *mut uint8_t, + pub size: uint32_t, + pub keep_size_before: uint32_t, + pub keep_size_after: uint32_t, + pub offset: uint32_t, + pub read_pos: uint32_t, + pub read_ahead: uint32_t, + pub read_limit: uint32_t, + pub write_pos: uint32_t, + pub pending: uint32_t, + pub find: Option uint32_t>, + pub skip: Option ()>, + pub hash: *mut uint32_t, + pub son: *mut uint32_t, + pub cyclic_pos: uint32_t, + pub cyclic_size: uint32_t, + pub hash_mask: uint32_t, + pub depth: uint32_t, + pub nice_len: uint32_t, + pub match_len_max: uint32_t, + pub action: lzma_action, + pub hash_count: uint32_t, + pub sons_count: uint32_t, +} +pub type lzma_mf = lzma_mf_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_options { + pub before_size: size_t, + pub dict_size: size_t, + pub after_size: size_t, + pub match_len_max: size_t, + pub nice_len: size_t, + pub match_finder: lzma_match_finder, + pub depth: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_encoder { + pub coder: *mut ::core::ffi::c_void, + pub code: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_mf, + *mut uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >, + pub end: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), + >, + pub options_update: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_filter) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_coder { + pub lz: lzma_lz_encoder, + pub mf: lzma_mf, + pub next: lzma_next_coder, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; +#[inline] +unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> uint32_t { + return match_finder as uint32_t & 0xf as uint32_t; +} +pub const HASH_2_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 10 as ::core::ffi::c_int; +pub const HASH_3_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 16 as ::core::ffi::c_int; +pub const LZMA_MEMCMPLEN_EXTRA: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn move_window(mut mf: *mut lzma_mf) { + let move_offset: uint32_t = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) + & !(15 as uint32_t); + let move_size: size_t = (*mf).write_pos.wrapping_sub(move_offset) as size_t; + memmove( + (*mf).buffer as *mut ::core::ffi::c_void, + (*mf).buffer.offset(move_offset as isize) as *const ::core::ffi::c_void, + move_size, + ); + (*mf).offset = (*mf).offset.wrapping_add(move_offset); + (*mf).read_pos = (*mf).read_pos.wrapping_sub(move_offset); + (*mf).read_limit = (*mf).read_limit.wrapping_sub(move_offset); + (*mf).write_pos = (*mf).write_pos.wrapping_sub(move_offset); +} +unsafe extern "C" fn fill_window( + mut coder: *mut lzma_coder, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + if (*coder).mf.read_pos >= (*coder).mf.size.wrapping_sub((*coder).mf.keep_size_after) + { + move_window(&raw mut (*coder).mf); + } + let mut write_pos: size_t = (*coder).mf.write_pos as size_t; + let mut ret: lzma_ret = LZMA_OK; + if (*coder).next.code.is_none() { + lzma_bufcpy( + in_0, + in_pos, + in_size, + (*coder).mf.buffer, + &raw mut write_pos, + (*coder).mf.size as size_t, + ); + ret = (if action as ::core::ffi::c_uint + != LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint + && *in_pos == in_size + { + LZMA_STREAM_END as ::core::ffi::c_int + } else { + LZMA_OK as ::core::ffi::c_int + }) as lzma_ret; + } else { + ret = (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + (*coder).mf.buffer, + &raw mut write_pos, + (*coder).mf.size as size_t, + action, + ); + } + (*coder).mf.write_pos = write_pos as uint32_t; + memset( + (*coder).mf.buffer.offset(write_pos as isize) as *mut ::core::ffi::c_void, + 0 as ::core::ffi::c_int, + 0 as size_t, + ); + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + ret = LZMA_OK; + (*coder).mf.action = action; + (*coder).mf.read_limit = (*coder).mf.write_pos; + } else if (*coder).mf.write_pos > (*coder).mf.keep_size_after { + (*coder).mf.read_limit = (*coder) + .mf + .write_pos + .wrapping_sub((*coder).mf.keep_size_after); + } + if (*coder).mf.pending > 0 as uint32_t + && (*coder).mf.read_pos < (*coder).mf.read_limit + { + let pending: uint32_t = (*coder).mf.pending; + (*coder).mf.pending = 0 as uint32_t; + (*coder).mf.read_pos = (*coder).mf.read_pos.wrapping_sub(pending); + (*coder) + .mf + .skip + .expect("non-null function pointer")(&raw mut (*coder).mf, pending); + } + return ret; +} +unsafe extern "C" fn lz_encode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + while *out_pos < out_size + && (*in_pos < in_size + || action as ::core::ffi::c_uint + != LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint) + { + if (*coder).mf.action as ::core::ffi::c_uint + == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint + && (*coder).mf.read_pos >= (*coder).mf.read_limit + { + let ret_: lzma_ret = fill_window( + coder, + allocator, + in_0, + in_pos, + in_size, + action, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + } + let ret: lzma_ret = (*coder) + .lz + .code + .expect( + "non-null function pointer", + )((*coder).lz.coder, &raw mut (*coder).mf, out, out_pos, out_size) + as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*coder).mf.action = LZMA_RUN; + return ret; + } + } + return LZMA_OK; +} +unsafe extern "C" fn lz_encoder_prepare( + mut mf: *mut lzma_mf, + mut allocator: *const lzma_allocator, + mut lz_options: *const lzma_lz_options, +) -> bool { + if !((*lz_options).dict_size >= LZMA_DICT_SIZE_MIN as size_t + && (*lz_options).dict_size + <= ((1 as ::core::ffi::c_uint) << 30 as ::core::ffi::c_int) + .wrapping_add((1 as ::core::ffi::c_uint) << 29 as ::core::ffi::c_int) + as size_t) || (*lz_options).nice_len > (*lz_options).match_len_max + { + return true_0 != 0; + } + (*mf).keep_size_before = (*lz_options) + .before_size + .wrapping_add((*lz_options).dict_size) as uint32_t; + (*mf).keep_size_after = (*lz_options) + .after_size + .wrapping_add((*lz_options).match_len_max) as uint32_t; + let mut reserve: uint32_t = (*lz_options).dict_size.wrapping_div(2 as size_t) + as uint32_t; + if reserve > (1 as uint32_t) << 30 as ::core::ffi::c_int { + reserve = reserve.wrapping_div(2 as uint32_t); + } + reserve = (reserve as size_t) + .wrapping_add( + (*lz_options) + .before_size + .wrapping_add((*lz_options).match_len_max) + .wrapping_add((*lz_options).after_size) + .wrapping_div(2 as size_t) + .wrapping_add( + ((1 as ::core::ffi::c_uint) << 19 as ::core::ffi::c_int) as size_t, + ), + ) as uint32_t as uint32_t; + let old_size: uint32_t = (*mf).size; + (*mf).size = (*mf) + .keep_size_before + .wrapping_add(reserve) + .wrapping_add((*mf).keep_size_after); + if !(*mf).buffer.is_null() && old_size != (*mf).size { + lzma_free((*mf).buffer as *mut ::core::ffi::c_void, allocator); + (*mf).buffer = ::core::ptr::null_mut::(); + } + (*mf).match_len_max = (*lz_options).match_len_max as uint32_t; + (*mf).nice_len = (*lz_options).nice_len as uint32_t; + (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1 as size_t) as uint32_t; + match (*lz_options).match_finder as ::core::ffi::c_uint { + 3 => { + (*mf).find = Some( + lzma_mf_hc3_find + as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, + ) as Option uint32_t>; + (*mf).skip = Some( + lzma_mf_hc3_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), + ) as Option ()>; + } + 4 => { + (*mf).find = Some( + lzma_mf_hc4_find + as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, + ) as Option uint32_t>; + (*mf).skip = Some( + lzma_mf_hc4_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), + ) as Option ()>; + } + 18 => { + (*mf).find = Some( + lzma_mf_bt2_find + as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, + ) as Option uint32_t>; + (*mf).skip = Some( + lzma_mf_bt2_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), + ) as Option ()>; + } + 19 => { + (*mf).find = Some( + lzma_mf_bt3_find + as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, + ) as Option uint32_t>; + (*mf).skip = Some( + lzma_mf_bt3_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), + ) as Option ()>; + } + 20 => { + (*mf).find = Some( + lzma_mf_bt4_find + as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, + ) as Option uint32_t>; + (*mf).skip = Some( + lzma_mf_bt4_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), + ) as Option ()>; + } + _ => return true_0 != 0, + } + let hash_bytes: uint32_t = mf_get_hash_bytes((*lz_options).match_finder) as uint32_t; + let is_bt: bool = (*lz_options).match_finder as ::core::ffi::c_uint + & 0x10 as ::core::ffi::c_uint != 0 as ::core::ffi::c_uint; + let mut hs: uint32_t = 0; + if hash_bytes == 2 as uint32_t { + hs = 0xffff as uint32_t; + } else { + hs = (*lz_options).dict_size.wrapping_sub(1 as size_t) as uint32_t; + hs |= hs >> 1 as ::core::ffi::c_int; + hs |= hs >> 2 as ::core::ffi::c_int; + hs |= hs >> 4 as ::core::ffi::c_int; + hs |= hs >> 8 as ::core::ffi::c_int; + hs >>= 1 as ::core::ffi::c_int; + hs |= 0xffff as uint32_t; + if hs > (1 as uint32_t) << 24 as ::core::ffi::c_int { + if hash_bytes == 3 as uint32_t { + hs = ((1 as ::core::ffi::c_uint) << 24 as ::core::ffi::c_int) + .wrapping_sub(1 as ::core::ffi::c_uint) as uint32_t; + } else { + hs >>= 1 as ::core::ffi::c_int; + } + } + } + (*mf).hash_mask = hs; + hs = hs.wrapping_add(1); + if hash_bytes > 2 as uint32_t { + hs = (hs as ::core::ffi::c_uint).wrapping_add(HASH_2_SIZE) as uint32_t + as uint32_t; + } + if hash_bytes > 3 as uint32_t { + hs = (hs as ::core::ffi::c_uint).wrapping_add(HASH_3_SIZE) as uint32_t + as uint32_t; + } + let old_hash_count: uint32_t = (*mf).hash_count; + let old_sons_count: uint32_t = (*mf).sons_count; + (*mf).hash_count = hs; + (*mf).sons_count = (*mf).cyclic_size; + if is_bt { + (*mf).sons_count = (*mf).sons_count.wrapping_mul(2 as uint32_t); + } + if old_hash_count != (*mf).hash_count || old_sons_count != (*mf).sons_count { + lzma_free((*mf).hash as *mut ::core::ffi::c_void, allocator); + (*mf).hash = ::core::ptr::null_mut::(); + lzma_free((*mf).son as *mut ::core::ffi::c_void, allocator); + (*mf).son = ::core::ptr::null_mut::(); + } + (*mf).depth = (*lz_options).depth; + if (*mf).depth == 0 as uint32_t { + if is_bt { + (*mf).depth = (16 as uint32_t) + .wrapping_add((*mf).nice_len.wrapping_div(2 as uint32_t)); + } else { + (*mf).depth = (4 as uint32_t) + .wrapping_add((*mf).nice_len.wrapping_div(4 as uint32_t)); + } + } + return false_0 != 0; +} +unsafe extern "C" fn lz_encoder_init( + mut mf: *mut lzma_mf, + mut allocator: *const lzma_allocator, + mut lz_options: *const lzma_lz_options, +) -> bool { + if (*mf).buffer.is_null() { + (*mf).buffer = lzma_alloc( + (*mf).size.wrapping_add(LZMA_MEMCMPLEN_EXTRA as uint32_t) as size_t, + allocator, + ) as *mut uint8_t; + if (*mf).buffer.is_null() { + return true_0 != 0; + } + memset( + (*mf).buffer.offset((*mf).size as isize) as *mut ::core::ffi::c_void, + 0 as ::core::ffi::c_int, + 0 as size_t, + ); + } + (*mf).offset = (*mf).cyclic_size; + (*mf).read_pos = 0 as uint32_t; + (*mf).read_ahead = 0 as uint32_t; + (*mf).read_limit = 0 as uint32_t; + (*mf).write_pos = 0 as uint32_t; + (*mf).pending = 0 as uint32_t; + if (*mf).hash.is_null() { + (*mf).hash = lzma_alloc_zero( + ((*mf).hash_count as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + allocator, + ) as *mut uint32_t; + (*mf).son = lzma_alloc( + ((*mf).sons_count as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + allocator, + ) as *mut uint32_t; + if (*mf).hash.is_null() || (*mf).son.is_null() { + lzma_free((*mf).hash as *mut ::core::ffi::c_void, allocator); + (*mf).hash = ::core::ptr::null_mut::(); + lzma_free((*mf).son as *mut ::core::ffi::c_void, allocator); + (*mf).son = ::core::ptr::null_mut::(); + return true_0 != 0; + } + } else { + memset( + (*mf).hash as *mut ::core::ffi::c_void, + 0 as ::core::ffi::c_int, + ((*mf).hash_count as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + ); + } + (*mf).cyclic_pos = 0 as uint32_t; + if !(*lz_options).preset_dict.is_null() + && (*lz_options).preset_dict_size > 0 as uint32_t + { + (*mf).write_pos = if (*lz_options).preset_dict_size < (*mf).size { + (*lz_options).preset_dict_size + } else { + (*mf).size + }; + memcpy( + (*mf).buffer as *mut ::core::ffi::c_void, + (*lz_options) + .preset_dict + .offset((*lz_options).preset_dict_size as isize) + .offset(-((*mf).write_pos as isize)) as *const ::core::ffi::c_void, + (*mf).write_pos as size_t, + ); + (*mf).action = LZMA_SYNC_FLUSH; + (*mf).skip.expect("non-null function pointer")(mf, (*mf).write_pos); + } + (*mf).action = LZMA_RUN; + return false_0 != 0; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lz_encoder_memusage( + mut lz_options: *const lzma_lz_options, +) -> uint64_t { + let mut mf: lzma_mf = lzma_mf_s { + buffer: ::core::ptr::null_mut::(), + size: 0, + keep_size_before: 0, + keep_size_after: 0, + offset: 0, + read_pos: 0, + read_ahead: 0, + read_limit: 0, + write_pos: 0, + pending: 0, + find: None, + skip: None, + hash: ::core::ptr::null_mut::(), + son: ::core::ptr::null_mut::(), + cyclic_pos: 0, + cyclic_size: 0, + hash_mask: 0, + depth: 0, + nice_len: 0, + match_len_max: 0, + action: LZMA_RUN, + hash_count: 0 as uint32_t, + sons_count: 0 as uint32_t, + }; + if lz_encoder_prepare( + &raw mut mf, + ::core::ptr::null::(), + lz_options, + ) { + return UINT64_MAX as uint64_t; + } + return (mf.hash_count as uint64_t) + .wrapping_add(mf.sons_count as uint64_t) + .wrapping_mul(::core::mem::size_of::() as uint64_t) + .wrapping_add(mf.size as uint64_t) + .wrapping_add(::core::mem::size_of::() as uint64_t); +} +unsafe extern "C" fn lz_encoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free((*coder).mf.son as *mut ::core::ffi::c_void, allocator); + lzma_free((*coder).mf.hash as *mut ::core::ffi::c_void, allocator); + lzma_free((*coder).mf.buffer as *mut ::core::ffi::c_void, allocator); + if (*coder).lz.end.is_some() { + (*coder) + .lz + .end + .expect("non-null function pointer")((*coder).lz.coder, allocator); + } else { + lzma_free((*coder).lz.coder, allocator); + } + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn lz_encoder_update( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut filters_null: *const lzma_filter, + mut reversed_filters: *const lzma_filter, +) -> lzma_ret { + let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + if (*coder).lz.options_update.is_none() { + return LZMA_PROG_ERROR; + } + let ret_: lzma_ret = (*coder) + .lz + .options_update + .expect("non-null function pointer")((*coder).lz.coder, reversed_filters) + as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + return lzma_next_filter_update( + &raw mut (*coder).next, + allocator, + reversed_filters.offset(1 as ::core::ffi::c_int as isize), + ); +} +unsafe extern "C" fn lz_encoder_set_out_limit( + mut coder_ptr: *mut ::core::ffi::c_void, + mut uncomp_size: *mut uint64_t, + mut out_limit: uint64_t, +) -> lzma_ret { + let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + if (*coder).next.code.is_none() && (*coder).lz.set_out_limit.is_some() { + return (*coder) + .lz + .set_out_limit + .expect( + "non-null function pointer", + )((*coder).lz.coder, uncomp_size, out_limit); + } + return LZMA_OPTIONS_ERROR; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lz_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut lz_init: Option< + unsafe extern "C" fn( + *mut lzma_lz_encoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + >, +) -> lzma_ret { + let mut coder: *mut lzma_coder = (*next).coder as *mut lzma_coder; + if coder.is_null() { + coder = lzma_alloc(::core::mem::size_of::() as size_t, allocator) + as *mut lzma_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + lz_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + lz_encoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).update = Some( + lz_encoder_update + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >; + (*next).set_out_limit = Some( + lz_encoder_set_out_limit + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >; + (*coder).lz.coder = NULL; + (*coder).lz.code = None; + (*coder).lz.end = None; + (*coder).lz.options_update = None; + (*coder).lz.set_out_limit = None; + (*coder).mf.buffer = ::core::ptr::null_mut::(); + (*coder).mf.size = 0 as uint32_t; + (*coder).mf.hash = ::core::ptr::null_mut::(); + (*coder).mf.son = ::core::ptr::null_mut::(); + (*coder).mf.hash_count = 0 as uint32_t; + (*coder).mf.sons_count = 0 as uint32_t; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + } + let mut lz_options: lzma_lz_options = lzma_lz_options { + before_size: 0, + dict_size: 0, + after_size: 0, + match_len_max: 0, + nice_len: 0, + match_finder: 0 as lzma_match_finder, + depth: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + }; + let ret_: lzma_ret = lz_init + .expect( + "non-null function pointer", + )( + &raw mut (*coder).lz, + allocator, + (*filters.offset(0 as ::core::ffi::c_int as isize)).id, + (*filters.offset(0 as ::core::ffi::c_int as isize)).options, + &raw mut lz_options, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + if lz_encoder_prepare(&raw mut (*coder).mf, allocator, &raw mut lz_options) { + return LZMA_OPTIONS_ERROR; + } + if lz_encoder_init(&raw mut (*coder).mf, allocator, &raw mut lz_options) { + return LZMA_MEM_ERROR; + } + return lzma_next_filter_init( + &raw mut (*coder).next, + allocator, + filters.offset(1 as ::core::ffi::c_int as isize), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_is_supported(mut mf: lzma_match_finder) -> lzma_bool { + match mf as ::core::ffi::c_uint { + 3 => return true_0 as lzma_bool, + 4 => return true_0 as lzma_bool, + 18 => return true_0 as lzma_bool, + 19 => return true_0 as lzma_bool, + 20 => return true_0 as lzma_bool, + _ => return false_0 as lzma_bool, + }; +} diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs new file mode 100644 index 00000000..df1f12bc --- /dev/null +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -0,0 +1,1001 @@ +extern "C" { + static lzma_crc32_table: [[uint32_t; 256]; 8]; +} +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_match { + pub len: uint32_t, + pub dist: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mf_s { + pub buffer: *mut uint8_t, + pub size: uint32_t, + pub keep_size_before: uint32_t, + pub keep_size_after: uint32_t, + pub offset: uint32_t, + pub read_pos: uint32_t, + pub read_ahead: uint32_t, + pub read_limit: uint32_t, + pub write_pos: uint32_t, + pub pending: uint32_t, + pub find: Option uint32_t>, + pub skip: Option ()>, + pub hash: *mut uint32_t, + pub son: *mut uint32_t, + pub cyclic_pos: uint32_t, + pub cyclic_size: uint32_t, + pub hash_mask: uint32_t, + pub depth: uint32_t, + pub nice_len: uint32_t, + pub match_len_max: uint32_t, + pub action: lzma_action, + pub hash_count: uint32_t, + pub sons_count: uint32_t, +} +pub type lzma_mf = lzma_mf_s; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const uint8_t { + return (*mf).buffer.offset((*mf).read_pos as isize); +} +#[inline] +unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> uint32_t { + return (*mf).write_pos.wrapping_sub((*mf).read_pos); +} +pub const HASH_2_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 10 as ::core::ffi::c_int; +pub const HASH_3_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 16 as ::core::ffi::c_int; +pub const HASH_2_MASK: ::core::ffi::c_uint = HASH_2_SIZE + .wrapping_sub(1 as ::core::ffi::c_uint); +pub const HASH_3_MASK: ::core::ffi::c_uint = HASH_3_SIZE + .wrapping_sub(1 as ::core::ffi::c_uint); +pub const FIX_3_HASH_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 10 as ::core::ffi::c_int; +pub const FIX_4_HASH_SIZE: ::core::ffi::c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); +#[inline(always)] +unsafe extern "C" fn lzma_memcmplen( + mut buf1: *const uint8_t, + mut buf2: *const uint8_t, + mut len: uint32_t, + mut limit: uint32_t, +) -> uint32_t { + while len < limit + && *buf1.offset(len as isize) as ::core::ffi::c_int + == *buf2.offset(len as isize) as ::core::ffi::c_int + { + len = len.wrapping_add(1); + } + return len; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_find( + mut mf: *mut lzma_mf, + mut count_ptr: *mut uint32_t, + mut matches: *mut lzma_match, +) -> uint32_t { + let count: uint32_t = (*mf).find.expect("non-null function pointer")(mf, matches) + as uint32_t; + let mut len_best: uint32_t = 0 as uint32_t; + if count > 0 as uint32_t { + len_best = (*matches.offset(count.wrapping_sub(1 as uint32_t) as isize)).len; + if len_best == (*mf).nice_len { + let mut limit: uint32_t = mf_avail(mf).wrapping_add(1 as uint32_t); + if limit > (*mf).match_len_max { + limit = (*mf).match_len_max; + } + let mut p1: *const uint8_t = mf_ptr(mf) + .offset(-(1 as ::core::ffi::c_int as isize)); + let mut p2: *const uint8_t = p1 + .offset( + -((*matches.offset(count.wrapping_sub(1 as uint32_t) as isize)).dist + as isize), + ) + .offset(-(1 as ::core::ffi::c_int as isize)); + len_best = lzma_memcmplen(p1, p2, len_best, limit); + } + } + *count_ptr = count; + (*mf).read_ahead = (*mf).read_ahead.wrapping_add(1); + return len_best; +} +pub const EMPTY_HASH_VALUE: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const MUST_NORMALIZE_POS: ::core::ffi::c_uint = UINT32_MAX; +unsafe extern "C" fn normalize(mut mf: *mut lzma_mf) { + let subvalue: uint32_t = (MUST_NORMALIZE_POS as uint32_t) + .wrapping_sub((*mf).cyclic_size); + let mut i: uint32_t = 0 as uint32_t; + while i < (*mf).hash_count { + if *(*mf).hash.offset(i as isize) <= subvalue { + *(*mf).hash.offset(i as isize) = EMPTY_HASH_VALUE as uint32_t; + } else { + let ref mut fresh0 = *(*mf).hash.offset(i as isize); + *fresh0 = (*fresh0).wrapping_sub(subvalue); + } + i = i.wrapping_add(1); + } + let mut i_0: uint32_t = 0 as uint32_t; + while i_0 < (*mf).sons_count { + if *(*mf).son.offset(i_0 as isize) <= subvalue { + *(*mf).son.offset(i_0 as isize) = EMPTY_HASH_VALUE as uint32_t; + } else { + let ref mut fresh1 = *(*mf).son.offset(i_0 as isize); + *fresh1 = (*fresh1).wrapping_sub(subvalue); + } + i_0 = i_0.wrapping_add(1); + } + (*mf).offset = (*mf).offset.wrapping_sub(subvalue); +} +unsafe extern "C" fn move_pos(mut mf: *mut lzma_mf) { + (*mf).cyclic_pos = (*mf).cyclic_pos.wrapping_add(1); + if (*mf).cyclic_pos == (*mf).cyclic_size { + (*mf).cyclic_pos = 0 as uint32_t; + } + (*mf).read_pos = (*mf).read_pos.wrapping_add(1); + if ((*mf).read_pos.wrapping_add((*mf).offset) == 4294967295 as uint32_t) + as ::core::ffi::c_int as ::core::ffi::c_long != 0 + { + normalize(mf); + } +} +unsafe extern "C" fn move_pending(mut mf: *mut lzma_mf) { + (*mf).read_pos = (*mf).read_pos.wrapping_add(1); + (*mf).pending = (*mf).pending.wrapping_add(1); +} +unsafe extern "C" fn hc_find_func( + len_limit: uint32_t, + pos: uint32_t, + cur: *const uint8_t, + mut cur_match: uint32_t, + mut depth: uint32_t, + son: *mut uint32_t, + cyclic_pos: uint32_t, + cyclic_size: uint32_t, + mut matches: *mut lzma_match, + mut len_best: uint32_t, +) -> *mut lzma_match { + *son.offset(cyclic_pos as isize) = cur_match; + loop { + let delta: uint32_t = pos.wrapping_sub(cur_match); + let fresh2 = depth; + depth = depth.wrapping_sub(1); + if fresh2 == 0 as uint32_t || delta >= cyclic_size { + return matches; + } + let pb: *const uint8_t = cur.offset(-(delta as isize)); + cur_match = *son + .offset( + cyclic_pos + .wrapping_sub(delta) + .wrapping_add( + (if delta > cyclic_pos { cyclic_size } else { 0 as uint32_t }), + ) as isize, + ); + if *pb.offset(len_best as isize) as ::core::ffi::c_int + == *cur.offset(len_best as isize) as ::core::ffi::c_int + && *pb.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + == *cur.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + { + let mut len: uint32_t = lzma_memcmplen(pb, cur, 1 as uint32_t, len_limit); + if len_best < len { + len_best = len; + (*matches).len = len; + (*matches).dist = delta.wrapping_sub(1 as uint32_t); + matches = matches.offset(1); + if len == len_limit { + return matches; + } + } + } + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_hc3_find( + mut mf: *mut lzma_mf, + mut matches: *mut lzma_match, +) -> uint32_t { + let mut len_limit: uint32_t = mf_avail(mf); + if (*mf).nice_len <= len_limit { + len_limit = (*mf).nice_len; + } else if len_limit < 3 as uint32_t + || 0 as ::core::ffi::c_int != 0 + && (*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + move_pending(mf); + return 0 as uint32_t; + } + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: uint32_t = 0 as uint32_t; + let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] + ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; + let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; + let hash_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int) & (*mf).hash_mask; + let delta2: uint32_t = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); + let cur_match: uint32_t = *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize) = pos; + let mut len_best: uint32_t = 2 as uint32_t; + if delta2 < (*mf).cyclic_size + && *cur.offset(-(delta2 as isize)) as ::core::ffi::c_int + == *cur as ::core::ffi::c_int + { + len_best = lzma_memcmplen( + cur.offset(-(delta2 as isize)), + cur, + len_best, + len_limit, + ); + (*matches.offset(0 as ::core::ffi::c_int as isize)).len = len_best; + (*matches.offset(0 as ::core::ffi::c_int as isize)).dist = delta2 + .wrapping_sub(1 as uint32_t); + matches_count = 1 as uint32_t; + if len_best == len_limit { + *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; + move_pos(mf); + return 1 as uint32_t; + } + } + matches_count = hc_find_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + len_best, + ) + .offset_from(matches) as ::core::ffi::c_long as uint32_t; + move_pos(mf); + return matches_count; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_hc3_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { + loop { + if mf_avail(mf) < 3 as uint32_t { + move_pending(mf); + } else { + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] + ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; + let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; + let hash_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int) & (*mf).hash_mask; + let cur_match: uint32_t = *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf) + .hash + .offset( + (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, + ) = pos; + *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; + move_pos(mf); + } + amount = amount.wrapping_sub(1); + if !(amount != 0 as uint32_t) { + break; + } + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_hc4_find( + mut mf: *mut lzma_mf, + mut matches: *mut lzma_match, +) -> uint32_t { + let mut len_limit: uint32_t = mf_avail(mf); + if (*mf).nice_len <= len_limit { + len_limit = (*mf).nice_len; + } else if len_limit < 4 as uint32_t + || 0 as ::core::ffi::c_int != 0 + && (*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + move_pending(mf); + return 0 as uint32_t; + } + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: uint32_t = 0 as uint32_t; + let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] + ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; + let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; + let hash_3_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int) & HASH_3_MASK as uint32_t; + let hash_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int + ^ lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(3 as ::core::ffi::c_int as isize) as usize] + << 5 as ::core::ffi::c_int) & (*mf).hash_mask; + let mut delta2: uint32_t = pos + .wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); + let delta3: uint32_t = pos + .wrapping_sub( + *(*mf) + .hash + .offset( + (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize, + ), + ); + let cur_match: uint32_t = *(*mf) + .hash + .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize) = pos; + *(*mf) + .hash + .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize) = pos; + let mut len_best: uint32_t = 1 as uint32_t; + if delta2 < (*mf).cyclic_size + && *cur.offset(-(delta2 as isize)) as ::core::ffi::c_int + == *cur as ::core::ffi::c_int + { + len_best = 2 as uint32_t; + (*matches.offset(0 as ::core::ffi::c_int as isize)).len = 2 as uint32_t; + (*matches.offset(0 as ::core::ffi::c_int as isize)).dist = delta2 + .wrapping_sub(1 as uint32_t); + matches_count = 1 as uint32_t; + } + if delta2 != delta3 && delta3 < (*mf).cyclic_size + && *cur.offset(-(delta3 as isize)) as ::core::ffi::c_int + == *cur as ::core::ffi::c_int + { + len_best = 3 as uint32_t; + let fresh3 = matches_count; + matches_count = matches_count.wrapping_add(1); + (*matches.offset(fresh3 as isize)).dist = delta3.wrapping_sub(1 as uint32_t); + delta2 = delta3; + } + if matches_count != 0 as uint32_t { + len_best = lzma_memcmplen( + cur.offset(-(delta2 as isize)), + cur, + len_best, + len_limit, + ); + (*matches.offset(matches_count.wrapping_sub(1 as uint32_t) as isize)).len = len_best; + if len_best == len_limit { + *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; + move_pos(mf); + return matches_count; + } + } + if len_best < 3 as uint32_t { + len_best = 3 as uint32_t; + } + matches_count = hc_find_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + len_best, + ) + .offset_from(matches) as ::core::ffi::c_long as uint32_t; + move_pos(mf); + return matches_count; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_hc4_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { + loop { + if mf_avail(mf) < 4 as uint32_t { + move_pending(mf); + } else { + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] + ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; + let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; + let hash_3_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int) & HASH_3_MASK as uint32_t; + let hash_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int + ^ lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(3 as ::core::ffi::c_int as isize) as usize] + << 5 as ::core::ffi::c_int) & (*mf).hash_mask; + let cur_match: uint32_t = *(*mf) + .hash + .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf) + .hash + .offset( + (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize, + ) = pos; + *(*mf) + .hash + .offset( + (FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, + ) = pos; + *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; + move_pos(mf); + } + amount = amount.wrapping_sub(1); + if !(amount != 0 as uint32_t) { + break; + } + }; +} +unsafe extern "C" fn bt_find_func( + len_limit: uint32_t, + pos: uint32_t, + cur: *const uint8_t, + mut cur_match: uint32_t, + mut depth: uint32_t, + son: *mut uint32_t, + cyclic_pos: uint32_t, + cyclic_size: uint32_t, + mut matches: *mut lzma_match, + mut len_best: uint32_t, +) -> *mut lzma_match { + let mut ptr0: *mut uint32_t = son + .offset((cyclic_pos << 1 as ::core::ffi::c_int) as isize) + .offset(1 as ::core::ffi::c_int as isize); + let mut ptr1: *mut uint32_t = son + .offset((cyclic_pos << 1 as ::core::ffi::c_int) as isize); + let mut len0: uint32_t = 0 as uint32_t; + let mut len1: uint32_t = 0 as uint32_t; + loop { + let delta: uint32_t = pos.wrapping_sub(cur_match); + let fresh4 = depth; + depth = depth.wrapping_sub(1); + if fresh4 == 0 as uint32_t || delta >= cyclic_size { + *ptr0 = EMPTY_HASH_VALUE as uint32_t; + *ptr1 = EMPTY_HASH_VALUE as uint32_t; + return matches; + } + let pair: *mut uint32_t = son + .offset( + (cyclic_pos + .wrapping_sub(delta) + .wrapping_add( + (if delta > cyclic_pos { cyclic_size } else { 0 as uint32_t }), + ) << 1 as ::core::ffi::c_int) as isize, + ); + let pb: *const uint8_t = cur.offset(-(delta as isize)); + let mut len: uint32_t = if len0 < len1 { len0 } else { len1 }; + if *pb.offset(len as isize) as ::core::ffi::c_int + == *cur.offset(len as isize) as ::core::ffi::c_int + { + len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as uint32_t), len_limit); + if len_best < len { + len_best = len; + (*matches).len = len; + (*matches).dist = delta.wrapping_sub(1 as uint32_t); + matches = matches.offset(1); + if len == len_limit { + *ptr1 = *pair.offset(0 as ::core::ffi::c_int as isize); + *ptr0 = *pair.offset(1 as ::core::ffi::c_int as isize); + return matches; + } + } + } + if (*pb.offset(len as isize) as ::core::ffi::c_int) + < *cur.offset(len as isize) as ::core::ffi::c_int + { + *ptr1 = cur_match; + ptr1 = pair.offset(1 as ::core::ffi::c_int as isize); + cur_match = *ptr1; + len1 = len; + } else { + *ptr0 = cur_match; + ptr0 = pair; + cur_match = *ptr0; + len0 = len; + } + }; +} +unsafe extern "C" fn bt_skip_func( + len_limit: uint32_t, + pos: uint32_t, + cur: *const uint8_t, + mut cur_match: uint32_t, + mut depth: uint32_t, + son: *mut uint32_t, + cyclic_pos: uint32_t, + cyclic_size: uint32_t, +) { + let mut ptr0: *mut uint32_t = son + .offset((cyclic_pos << 1 as ::core::ffi::c_int) as isize) + .offset(1 as ::core::ffi::c_int as isize); + let mut ptr1: *mut uint32_t = son + .offset((cyclic_pos << 1 as ::core::ffi::c_int) as isize); + let mut len0: uint32_t = 0 as uint32_t; + let mut len1: uint32_t = 0 as uint32_t; + loop { + let delta: uint32_t = pos.wrapping_sub(cur_match); + let fresh5 = depth; + depth = depth.wrapping_sub(1); + if fresh5 == 0 as uint32_t || delta >= cyclic_size { + *ptr0 = EMPTY_HASH_VALUE as uint32_t; + *ptr1 = EMPTY_HASH_VALUE as uint32_t; + return; + } + let mut pair: *mut uint32_t = son + .offset( + (cyclic_pos + .wrapping_sub(delta) + .wrapping_add( + (if delta > cyclic_pos { cyclic_size } else { 0 as uint32_t }), + ) << 1 as ::core::ffi::c_int) as isize, + ); + let mut pb: *const uint8_t = cur.offset(-(delta as isize)); + let mut len: uint32_t = if len0 < len1 { len0 } else { len1 }; + if *pb.offset(len as isize) as ::core::ffi::c_int + == *cur.offset(len as isize) as ::core::ffi::c_int + { + len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as uint32_t), len_limit); + if len == len_limit { + *ptr1 = *pair.offset(0 as ::core::ffi::c_int as isize); + *ptr0 = *pair.offset(1 as ::core::ffi::c_int as isize); + return; + } + } + if (*pb.offset(len as isize) as ::core::ffi::c_int) + < *cur.offset(len as isize) as ::core::ffi::c_int + { + *ptr1 = cur_match; + ptr1 = pair.offset(1 as ::core::ffi::c_int as isize); + cur_match = *ptr1; + len1 = len; + } else { + *ptr0 = cur_match; + ptr0 = pair; + cur_match = *ptr0; + len0 = len; + } + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_bt2_find( + mut mf: *mut lzma_mf, + mut matches: *mut lzma_match, +) -> uint32_t { + let mut len_limit: uint32_t = mf_avail(mf); + if (*mf).nice_len <= len_limit { + len_limit = (*mf).nice_len; + } else if len_limit < 2 as uint32_t + || 1 as ::core::ffi::c_int != 0 + && (*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + move_pending(mf); + return 0 as uint32_t; + } + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: uint32_t = 0 as uint32_t; + let hash_value: uint32_t = *cur.offset(0 as ::core::ffi::c_int as isize) as uint32_t + | (*cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + let cur_match: uint32_t = *(*mf).hash.offset(hash_value as isize); + *(*mf).hash.offset(hash_value as isize) = pos; + matches_count = bt_find_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + 1 as uint32_t, + ) + .offset_from(matches) as ::core::ffi::c_long as uint32_t; + move_pos(mf); + return matches_count; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { + let mut current_block_8: u64; + loop { + let mut len_limit: uint32_t = mf_avail(mf); + if (*mf).nice_len <= len_limit { + len_limit = (*mf).nice_len; + current_block_8 = 11875828834189669668; + } else if len_limit < 2 as uint32_t + || 1 as ::core::ffi::c_int != 0 + && (*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + move_pending(mf); + current_block_8 = 18088007599891946824; + } else { + current_block_8 = 11875828834189669668; + } + match current_block_8 { + 11875828834189669668 => { + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let hash_value: uint32_t = *cur.offset(0 as ::core::ffi::c_int as isize) + as uint32_t + | (*cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + let cur_match: uint32_t = *(*mf).hash.offset(hash_value as isize); + *(*mf).hash.offset(hash_value as isize) = pos; + bt_skip_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + ); + move_pos(mf); + } + _ => {} + } + amount = amount.wrapping_sub(1); + if !(amount != 0 as uint32_t) { + break; + } + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_bt3_find( + mut mf: *mut lzma_mf, + mut matches: *mut lzma_match, +) -> uint32_t { + let mut len_limit: uint32_t = mf_avail(mf); + if (*mf).nice_len <= len_limit { + len_limit = (*mf).nice_len; + } else if len_limit < 3 as uint32_t + || 1 as ::core::ffi::c_int != 0 + && (*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + move_pending(mf); + return 0 as uint32_t; + } + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: uint32_t = 0 as uint32_t; + let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] + ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; + let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; + let hash_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int) & (*mf).hash_mask; + let delta2: uint32_t = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); + let cur_match: uint32_t = *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize) = pos; + let mut len_best: uint32_t = 2 as uint32_t; + if delta2 < (*mf).cyclic_size + && *cur.offset(-(delta2 as isize)) as ::core::ffi::c_int + == *cur as ::core::ffi::c_int + { + len_best = lzma_memcmplen( + cur, + cur.offset(-(delta2 as isize)), + len_best, + len_limit, + ); + (*matches.offset(0 as ::core::ffi::c_int as isize)).len = len_best; + (*matches.offset(0 as ::core::ffi::c_int as isize)).dist = delta2 + .wrapping_sub(1 as uint32_t); + matches_count = 1 as uint32_t; + if len_best == len_limit { + bt_skip_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + ); + move_pos(mf); + return 1 as uint32_t; + } + } + matches_count = bt_find_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + len_best, + ) + .offset_from(matches) as ::core::ffi::c_long as uint32_t; + move_pos(mf); + return matches_count; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { + let mut current_block_9: u64; + loop { + let mut len_limit: uint32_t = mf_avail(mf); + if (*mf).nice_len <= len_limit { + len_limit = (*mf).nice_len; + current_block_9 = 11875828834189669668; + } else if len_limit < 3 as uint32_t + || 1 as ::core::ffi::c_int != 0 + && (*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + move_pending(mf); + current_block_9 = 18088007599891946824; + } else { + current_block_9 = 11875828834189669668; + } + match current_block_9 { + 11875828834189669668 => { + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] + ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; + let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; + let hash_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int) & (*mf).hash_mask; + let cur_match: uint32_t = *(*mf) + .hash + .offset( + (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, + ); + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf) + .hash + .offset( + (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, + ) = pos; + bt_skip_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + ); + move_pos(mf); + } + _ => {} + } + amount = amount.wrapping_sub(1); + if !(amount != 0 as uint32_t) { + break; + } + }; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_bt4_find( + mut mf: *mut lzma_mf, + mut matches: *mut lzma_match, +) -> uint32_t { + let mut len_limit: uint32_t = mf_avail(mf); + if (*mf).nice_len <= len_limit { + len_limit = (*mf).nice_len; + } else if len_limit < 4 as uint32_t + || 1 as ::core::ffi::c_int != 0 + && (*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + move_pending(mf); + return 0 as uint32_t; + } + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: uint32_t = 0 as uint32_t; + let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] + ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; + let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; + let hash_3_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int) & HASH_3_MASK as uint32_t; + let hash_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int + ^ lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(3 as ::core::ffi::c_int as isize) as usize] + << 5 as ::core::ffi::c_int) & (*mf).hash_mask; + let mut delta2: uint32_t = pos + .wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); + let delta3: uint32_t = pos + .wrapping_sub( + *(*mf) + .hash + .offset( + (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize, + ), + ); + let cur_match: uint32_t = *(*mf) + .hash + .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize) = pos; + *(*mf) + .hash + .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize) = pos; + let mut len_best: uint32_t = 1 as uint32_t; + if delta2 < (*mf).cyclic_size + && *cur.offset(-(delta2 as isize)) as ::core::ffi::c_int + == *cur as ::core::ffi::c_int + { + len_best = 2 as uint32_t; + (*matches.offset(0 as ::core::ffi::c_int as isize)).len = 2 as uint32_t; + (*matches.offset(0 as ::core::ffi::c_int as isize)).dist = delta2 + .wrapping_sub(1 as uint32_t); + matches_count = 1 as uint32_t; + } + if delta2 != delta3 && delta3 < (*mf).cyclic_size + && *cur.offset(-(delta3 as isize)) as ::core::ffi::c_int + == *cur as ::core::ffi::c_int + { + len_best = 3 as uint32_t; + let fresh6 = matches_count; + matches_count = matches_count.wrapping_add(1); + (*matches.offset(fresh6 as isize)).dist = delta3.wrapping_sub(1 as uint32_t); + delta2 = delta3; + } + if matches_count != 0 as uint32_t { + len_best = lzma_memcmplen( + cur, + cur.offset(-(delta2 as isize)), + len_best, + len_limit, + ); + (*matches.offset(matches_count.wrapping_sub(1 as uint32_t) as isize)).len = len_best; + if len_best == len_limit { + bt_skip_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + ); + move_pos(mf); + return matches_count; + } + } + if len_best < 3 as uint32_t { + len_best = 3 as uint32_t; + } + matches_count = bt_find_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + len_best, + ) + .offset_from(matches) as ::core::ffi::c_long as uint32_t; + move_pos(mf); + return matches_count; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { + let mut current_block_10: u64; + loop { + let mut len_limit: uint32_t = mf_avail(mf); + if (*mf).nice_len <= len_limit { + len_limit = (*mf).nice_len; + current_block_10 = 11875828834189669668; + } else if len_limit < 4 as uint32_t + || 1 as ::core::ffi::c_int != 0 + && (*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + move_pending(mf); + current_block_10 = 18088007599891946824; + } else { + current_block_10 = 11875828834189669668; + } + match current_block_10 { + 11875828834189669668 => { + let mut cur: *const uint8_t = mf_ptr(mf); + let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] + ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; + let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; + let hash_3_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int) & HASH_3_MASK as uint32_t; + let hash_value: uint32_t = (temp + ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int + ^ lzma_crc32_table[0 as ::core::ffi::c_int + as usize][*cur.offset(3 as ::core::ffi::c_int as isize) as usize] + << 5 as ::core::ffi::c_int) & (*mf).hash_mask; + let cur_match: uint32_t = *(*mf) + .hash + .offset( + (FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, + ); + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf) + .hash + .offset( + (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize, + ) = pos; + *(*mf) + .hash + .offset( + (FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, + ) = pos; + bt_skip_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + ); + move_pos(mf); + } + _ => {} + } + amount = amount.wrapping_sub(1); + if !(amount != 0 as uint32_t) { + break; + } + }; +} diff --git a/liblzma-rs/src/lz/mod.rs b/liblzma-rs/src/lz/mod.rs new file mode 100644 index 00000000..e835f7fc --- /dev/null +++ b/liblzma-rs/src/lz/mod.rs @@ -0,0 +1,3 @@ +pub mod lz_decoder; +pub mod lz_encoder; +pub mod lz_encoder_mf; diff --git a/liblzma-rs/src/lzma/fastpos_table.rs b/liblzma-rs/src/lzma/fastpos_table.rs new file mode 100644 index 00000000..c09ae003 --- /dev/null +++ b/liblzma-rs/src/lzma/fastpos_table.rs @@ -0,0 +1,8196 @@ +pub type uint8_t = u8; +#[no_mangle] +pub static mut lzma_fastpos: [uint8_t; 8192] = [ + 0 as ::core::ffi::c_int as uint8_t, + 1 as ::core::ffi::c_int as uint8_t, + 2 as ::core::ffi::c_int as uint8_t, + 3 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 5 as ::core::ffi::c_int as uint8_t, + 5 as ::core::ffi::c_int as uint8_t, + 6 as ::core::ffi::c_int as uint8_t, + 6 as ::core::ffi::c_int as uint8_t, + 6 as ::core::ffi::c_int as uint8_t, + 6 as ::core::ffi::c_int as uint8_t, + 7 as ::core::ffi::c_int as uint8_t, + 7 as ::core::ffi::c_int as uint8_t, + 7 as ::core::ffi::c_int as uint8_t, + 7 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, +]; diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs new file mode 100644 index 00000000..f80d22f0 --- /dev/null +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -0,0 +1,641 @@ +extern "C" { + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_lz_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + lz_init: Option< + unsafe extern "C" fn( + *mut lzma_lz_decoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + >, + ) -> lzma_ret; + fn lzma_lzma_decoder_memusage_nocheck( + options: *const ::core::ffi::c_void, + ) -> uint64_t; + fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: uint8_t) -> bool; + fn lzma_lzma_decoder_create( + lz: *mut lzma_lz_decoder, + allocator: *const lzma_allocator, + opt: *const lzma_options_lzma, + lz_options: *mut lzma_lz_options, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_options { + pub dict_size: size_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: size_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_decoder { + pub coder: *mut ::core::ffi::c_void, + pub code: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_dict, + *const uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >, + pub reset: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const ::core::ffi::c_void) -> (), + >, + pub set_uncompressed: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), + >, + pub end: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_dict { + pub buf: *mut uint8_t, + pub pos: size_t, + pub full: size_t, + pub limit: size_t, + pub size: size_t, + pub has_wrapped: bool, + pub need_reset: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lzma2_coder { + pub sequence: sequence, + pub next_sequence: sequence, + pub lzma: lzma_lz_decoder, + pub uncompressed_size: size_t, + pub compressed_size: size_t, + pub need_properties: bool, + pub need_dictionary_reset: bool, + pub options: lzma_options_lzma, +} +pub type sequence = ::core::ffi::c_uint; +pub const SEQ_COPY: sequence = 7; +pub const SEQ_LZMA: sequence = 6; +pub const SEQ_PROPERTIES: sequence = 5; +pub const SEQ_COMPRESSED_1: sequence = 4; +pub const SEQ_COMPRESSED_0: sequence = 3; +pub const SEQ_UNCOMPRESSED_2: sequence = 2; +pub const SEQ_UNCOMPRESSED_1: sequence = 1; +pub const SEQ_CONTROL: sequence = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZ_DICT_REPEAT_MAX: ::core::ffi::c_int = 288 as ::core::ffi::c_int; +pub const LZ_DICT_INIT_POS: ::core::ffi::c_int = 2 as ::core::ffi::c_int + * LZ_DICT_REPEAT_MAX; +pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { + coder: NULL, + code: None, + reset: None, + set_uncompressed: None, + end: None, +}; +#[inline] +unsafe extern "C" fn dict_write( + mut dict: *mut lzma_dict, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut left: *mut size_t, +) { + if in_size.wrapping_sub(*in_pos) > *left { + in_size = (*in_pos).wrapping_add(*left); + } + *left = (*left) + .wrapping_sub( + lzma_bufcpy( + in_0, + in_pos, + in_size, + (*dict).buf, + &raw mut (*dict).pos, + (*dict).limit, + ), + ); + if !(*dict).has_wrapped { + (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); + } +} +#[inline] +unsafe extern "C" fn dict_reset(mut dict: *mut lzma_dict) { + (*dict).need_reset = true_0 != 0; +} +unsafe extern "C" fn lzma2_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut dict: *mut lzma_dict, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; + while *in_pos < in_size + || (*coder).sequence as ::core::ffi::c_uint + == SEQ_LZMA as ::core::ffi::c_int as ::core::ffi::c_uint + { + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + let control: uint32_t = *in_0.offset(*in_pos as isize) as uint32_t; + *in_pos = (*in_pos).wrapping_add(1); + if control == 0 as uint32_t { + return LZMA_STREAM_END; + } + if control >= 0xe0 as uint32_t || control == 1 as uint32_t { + (*coder).need_properties = true_0 != 0; + (*coder).need_dictionary_reset = true_0 != 0; + } else if (*coder).need_dictionary_reset { + return LZMA_DATA_ERROR + } + if control >= 0x80 as uint32_t { + (*coder).uncompressed_size = ((control & 0x1f as uint32_t) + << 16 as ::core::ffi::c_int) as size_t; + (*coder).sequence = SEQ_UNCOMPRESSED_1; + if control >= 0xc0 as uint32_t { + (*coder).need_properties = false_0 != 0; + (*coder).next_sequence = SEQ_PROPERTIES; + } else if (*coder).need_properties { + return LZMA_DATA_ERROR + } else { + (*coder).next_sequence = SEQ_LZMA; + if control >= 0xa0 as uint32_t { + (*coder) + .lzma + .reset + .expect( + "non-null function pointer", + )( + (*coder).lzma.coder, + &raw mut (*coder).options as *const ::core::ffi::c_void, + ); + } + } + } else { + if control > 2 as uint32_t { + return LZMA_DATA_ERROR; + } + (*coder).sequence = SEQ_COMPRESSED_0; + (*coder).next_sequence = SEQ_COPY; + } + if (*coder).need_dictionary_reset { + (*coder).need_dictionary_reset = false_0 != 0; + dict_reset(dict); + return LZMA_OK; + } + } + 1 => { + let fresh0 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_add( + ((*in_0.offset(fresh0 as isize) as uint32_t) + << 8 as ::core::ffi::c_int) as size_t, + ); + (*coder).sequence = SEQ_UNCOMPRESSED_2; + } + 2 => { + let fresh1 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_add( + (*in_0.offset(fresh1 as isize) as ::core::ffi::c_uint) + .wrapping_add(1 as ::core::ffi::c_uint) as size_t, + ); + (*coder).sequence = SEQ_COMPRESSED_0; + (*coder) + .lzma + .set_uncompressed + .expect( + "non-null function pointer", + )( + (*coder).lzma.coder, + (*coder).uncompressed_size as lzma_vli, + false_0 != 0, + ); + } + 3 => { + let fresh2 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + (*coder).compressed_size = ((*in_0.offset(fresh2 as isize) as uint32_t) + << 8 as ::core::ffi::c_int) as size_t; + (*coder).sequence = SEQ_COMPRESSED_1; + } + 4 => { + let fresh3 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + (*coder).compressed_size = (*coder) + .compressed_size + .wrapping_add( + (*in_0.offset(fresh3 as isize) as ::core::ffi::c_uint) + .wrapping_add(1 as ::core::ffi::c_uint) as size_t, + ); + (*coder).sequence = (*coder).next_sequence as sequence; + } + 5 => { + let fresh4 = *in_pos; + *in_pos = (*in_pos).wrapping_add(1); + if lzma_lzma_lclppb_decode( + &raw mut (*coder).options, + *in_0.offset(fresh4 as isize), + ) { + return LZMA_DATA_ERROR; + } + (*coder) + .lzma + .reset + .expect( + "non-null function pointer", + )( + (*coder).lzma.coder, + &raw mut (*coder).options as *const ::core::ffi::c_void, + ); + (*coder).sequence = SEQ_LZMA; + } + 6 => { + let in_start: size_t = *in_pos; + let ret: lzma_ret = (*coder) + .lzma + .code + .expect( + "non-null function pointer", + )((*coder).lzma.coder, dict, in_0, in_pos, in_size) as lzma_ret; + let in_used: size_t = (*in_pos).wrapping_sub(in_start); + if in_used > (*coder).compressed_size { + return LZMA_DATA_ERROR; + } + (*coder).compressed_size = (*coder) + .compressed_size + .wrapping_sub(in_used); + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + if (*coder).compressed_size != 0 as size_t { + return LZMA_DATA_ERROR; + } + (*coder).sequence = SEQ_CONTROL; + } + 7 => { + dict_write( + dict, + in_0, + in_pos, + in_size, + &raw mut (*coder).compressed_size, + ); + if (*coder).compressed_size != 0 as size_t { + return LZMA_OK; + } + (*coder).sequence = SEQ_CONTROL; + } + _ => return LZMA_PROG_ERROR, + } + } + return LZMA_OK; +} +unsafe extern "C" fn lzma2_decoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; + lzma_free((*coder).lzma.coder, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn lzma2_decoder_init( + mut lz: *mut lzma_lz_decoder, + mut allocator: *const lzma_allocator, + mut id: lzma_vli, + mut opt: *const ::core::ffi::c_void, + mut lz_options: *mut lzma_lz_options, +) -> lzma_ret { + let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_lzma2_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*lz).coder = coder as *mut ::core::ffi::c_void; + (*lz).code = Some( + lzma2_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_dict, + *const uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_dict, + *const uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >; + (*lz).end = Some( + lzma2_decoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + >; + (*coder).lzma = LZMA_LZ_DECODER_INIT; + } + let mut options: *const lzma_options_lzma = opt as *const lzma_options_lzma; + (*coder).sequence = SEQ_CONTROL; + (*coder).need_properties = true_0 != 0; + (*coder).need_dictionary_reset = (*options).preset_dict.is_null() + || (*options).preset_dict_size == 0 as uint32_t; + return lzma_lzma_decoder_create( + &raw mut (*coder).lzma, + allocator, + options, + lz_options, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma2_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return lzma_lz_decoder_init( + next, + allocator, + filters, + Some( + lzma2_decoder_init + as unsafe extern "C" fn( + *mut lzma_lz_decoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + ), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma2_decoder_memusage( + mut options: *const ::core::ffi::c_void, +) -> uint64_t { + return (::core::mem::size_of::() as uint64_t) + .wrapping_add(lzma_lzma_decoder_memusage_nocheck(options)); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma2_props_decode( + mut options: *mut *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut props: *const uint8_t, + mut props_size: size_t, +) -> lzma_ret { + if props_size != 1 as size_t { + return LZMA_OPTIONS_ERROR; + } + if *props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + & 0xc0 as ::core::ffi::c_int != 0 + { + return LZMA_OPTIONS_ERROR; + } + if *props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + > 40 as ::core::ffi::c_int + { + return LZMA_OPTIONS_ERROR; + } + let mut opt: *mut lzma_options_lzma = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_options_lzma; + if opt.is_null() { + return LZMA_MEM_ERROR; + } + if *props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + == 40 as ::core::ffi::c_int + { + (*opt).dict_size = UINT32_MAX as uint32_t; + } else { + (*opt).dict_size = (2 as ::core::ffi::c_uint + | *props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_uint + & 1 as ::core::ffi::c_uint) as uint32_t; + (*opt).dict_size + <<= (*props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_uint) + .wrapping_div(2 as ::core::ffi::c_uint) + .wrapping_add(11 as ::core::ffi::c_uint); + } + (*opt).preset_dict = ::core::ptr::null::(); + (*opt).preset_dict_size = 0 as uint32_t; + *options = opt as *mut ::core::ffi::c_void; + return LZMA_OK; +} diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs new file mode 100644 index 00000000..e3aaf046 --- /dev/null +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -0,0 +1,846 @@ +#[repr(C)] +pub struct lzma_lzma1_encoder_s { _opaque: [u8; 0] } +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_lz_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + lz_init: Option< + unsafe extern "C" fn( + *mut lzma_lz_encoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + >, + ) -> lzma_ret; + fn lzma_lzma_encoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_lzma_lclppb_encode( + options: *const lzma_options_lzma, + byte: *mut uint8_t, + ) -> bool; + fn lzma_lzma_encoder_create( + coder_ptr: *mut *mut ::core::ffi::c_void, + allocator: *const lzma_allocator, + id: lzma_vli, + options: *const lzma_options_lzma, + lz_options: *mut lzma_lz_options, + ) -> lzma_ret; + fn lzma_lzma_encoder_reset( + coder: *mut lzma_lzma1_encoder, + options: *const lzma_options_lzma, + ) -> lzma_ret; + fn lzma_lzma_encode( + coder: *mut lzma_lzma1_encoder, + mf: *mut lzma_mf, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + read_limit: uint32_t, + ) -> lzma_ret; + static lzma_fastpos: [uint8_t; 8192]; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_match { + pub len: uint32_t, + pub dist: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mf_s { + pub buffer: *mut uint8_t, + pub size: uint32_t, + pub keep_size_before: uint32_t, + pub keep_size_after: uint32_t, + pub offset: uint32_t, + pub read_pos: uint32_t, + pub read_ahead: uint32_t, + pub read_limit: uint32_t, + pub write_pos: uint32_t, + pub pending: uint32_t, + pub find: Option uint32_t>, + pub skip: Option ()>, + pub hash: *mut uint32_t, + pub son: *mut uint32_t, + pub cyclic_pos: uint32_t, + pub cyclic_size: uint32_t, + pub hash_mask: uint32_t, + pub depth: uint32_t, + pub nice_len: uint32_t, + pub match_len_max: uint32_t, + pub action: lzma_action, + pub hash_count: uint32_t, + pub sons_count: uint32_t, +} +pub type lzma_mf = lzma_mf_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_options { + pub before_size: size_t, + pub dict_size: size_t, + pub after_size: size_t, + pub match_len_max: size_t, + pub nice_len: size_t, + pub match_finder: lzma_match_finder, + pub depth: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_encoder { + pub coder: *mut ::core::ffi::c_void, + pub code: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_mf, + *mut uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >, + pub end: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), + >, + pub options_update: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_filter) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lzma2_coder { + pub sequence: C2RustUnnamed, + pub lzma: *mut ::core::ffi::c_void, + pub opt_cur: lzma_options_lzma, + pub need_properties: bool, + pub need_state_reset: bool, + pub need_dictionary_reset: bool, + pub uncompressed_size: size_t, + pub compressed_size: size_t, + pub buf_pos: size_t, + pub buf: [uint8_t; 65542], +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const SEQ_UNCOMPRESSED_COPY: C2RustUnnamed = 4; +pub const SEQ_UNCOMPRESSED_HEADER: C2RustUnnamed = 3; +pub const SEQ_LZMA_COPY: C2RustUnnamed = 2; +pub const SEQ_LZMA_ENCODE: C2RustUnnamed = 1; +pub const SEQ_INIT: C2RustUnnamed = 0; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; +pub const LZMA_LCLP_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_PB_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn mf_unencoded(mut mf: *const lzma_mf) -> uint32_t { + return (*mf).write_pos.wrapping_sub((*mf).read_pos).wrapping_add((*mf).read_ahead); +} +#[inline] +unsafe extern "C" fn mf_read( + mut mf: *mut lzma_mf, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut left: *mut size_t, +) { + let out_avail: size_t = out_size.wrapping_sub(*out_pos); + let copy_size: size_t = if out_avail < *left { out_avail } else { *left }; + memcpy( + out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, + (*mf).buffer.offset((*mf).read_pos as isize).offset(-(*left as isize)) + as *const ::core::ffi::c_void, + copy_size, + ); + *out_pos = (*out_pos).wrapping_add(copy_size); + *left = (*left).wrapping_sub(copy_size); +} +pub const FASTPOS_BITS: ::core::ffi::c_int = 13 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn get_dist_slot(mut dist: uint32_t) -> uint32_t { + if dist + < (1 as uint32_t) + << FASTPOS_BITS + + (0 as ::core::ffi::c_int + + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + { + return lzma_fastpos[dist as usize] as uint32_t; + } + if dist + < (1 as uint32_t) + << FASTPOS_BITS + + (0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + { + return (lzma_fastpos[(dist + >> 0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); + } + return (lzma_fastpos[(dist + >> 0 as ::core::ffi::c_int + + 2 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (0 as ::core::ffi::c_int + + 2 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); +} +pub const LZMA2_CHUNK_MAX: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 16 as ::core::ffi::c_int; +pub const LZMA2_UNCOMPRESSED_MAX: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 21 as ::core::ffi::c_int; +pub const LZMA2_HEADER_MAX: ::core::ffi::c_int = 6 as ::core::ffi::c_int; +pub const LZMA2_HEADER_UNCOMPRESSED: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { + let mut pos: size_t = 0; + if (*coder).need_properties { + pos = 0 as size_t; + if (*coder).need_dictionary_reset { + (*coder).buf[pos as usize] = (0x80 as ::core::ffi::c_int + + ((3 as ::core::ffi::c_int) << 5 as ::core::ffi::c_int)) as uint8_t; + } else { + (*coder).buf[pos as usize] = (0x80 as ::core::ffi::c_int + + ((2 as ::core::ffi::c_int) << 5 as ::core::ffi::c_int)) as uint8_t; + } + } else { + pos = 1 as size_t; + if (*coder).need_state_reset { + (*coder).buf[pos as usize] = (0x80 as ::core::ffi::c_int + + ((1 as ::core::ffi::c_int) << 5 as ::core::ffi::c_int)) as uint8_t; + } else { + (*coder).buf[pos as usize] = 0x80 as uint8_t; + } + } + (*coder).buf_pos = pos; + let mut size: size_t = (*coder).uncompressed_size.wrapping_sub(1 as size_t); + let fresh1 = pos; + pos = pos.wrapping_add(1); + (*coder).buf[fresh1 as usize] = ((*coder).buf[fresh1 as usize] as size_t) + .wrapping_add(size >> 16 as ::core::ffi::c_int) as uint8_t as uint8_t; + let fresh2 = pos; + pos = pos.wrapping_add(1); + (*coder).buf[fresh2 as usize] = (size >> 8 as ::core::ffi::c_int & 0xff as size_t) + as uint8_t; + let fresh3 = pos; + pos = pos.wrapping_add(1); + (*coder).buf[fresh3 as usize] = (size & 0xff as size_t) as uint8_t; + size = (*coder).compressed_size.wrapping_sub(1 as size_t); + let fresh4 = pos; + pos = pos.wrapping_add(1); + (*coder).buf[fresh4 as usize] = (size >> 8 as ::core::ffi::c_int) as uint8_t; + let fresh5 = pos; + pos = pos.wrapping_add(1); + (*coder).buf[fresh5 as usize] = (size & 0xff as size_t) as uint8_t; + if (*coder).need_properties { + lzma_lzma_lclppb_encode( + &raw mut (*coder).opt_cur, + (&raw mut (*coder).buf as *mut uint8_t).offset(pos as isize), + ); + } + (*coder).need_properties = false_0 != 0; + (*coder).need_state_reset = false_0 != 0; + (*coder).need_dictionary_reset = false_0 != 0; + (*coder).compressed_size = (*coder) + .compressed_size + .wrapping_add(LZMA2_HEADER_MAX as size_t); +} +unsafe extern "C" fn lzma2_header_uncompressed(mut coder: *mut lzma_lzma2_coder) { + if (*coder).need_dictionary_reset { + (*coder).buf[0 as ::core::ffi::c_int as usize] = 1 as uint8_t; + } else { + (*coder).buf[0 as ::core::ffi::c_int as usize] = 2 as uint8_t; + } + (*coder).need_dictionary_reset = false_0 != 0; + (*coder).buf[1 as ::core::ffi::c_int as usize] = ((*coder) + .uncompressed_size + .wrapping_sub(1 as size_t) >> 8 as ::core::ffi::c_int) as uint8_t; + (*coder).buf[2 as ::core::ffi::c_int as usize] = ((*coder) + .uncompressed_size + .wrapping_sub(1 as size_t) & 0xff as size_t) as uint8_t; + (*coder).buf_pos = 0 as size_t; +} +unsafe extern "C" fn lzma2_encode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut mf: *mut lzma_mf, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; + while *out_pos < out_size { + let mut current_block_45: u64; + match (*coder).sequence as ::core::ffi::c_uint { + 0 => { + if mf_unencoded(mf) == 0 as uint32_t { + if (*mf).action as ::core::ffi::c_uint + == LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + { + let fresh0 = *out_pos; + *out_pos = (*out_pos).wrapping_add(1); + *out.offset(fresh0 as isize) = 0 as uint8_t; + } + return (if (*mf).action as ::core::ffi::c_uint + == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint + { + LZMA_OK as ::core::ffi::c_int + } else { + LZMA_STREAM_END as ::core::ffi::c_int + }) as lzma_ret; + } + if (*coder).need_state_reset { + let ret_: lzma_ret = lzma_lzma_encoder_reset( + (*coder).lzma as *mut lzma_lzma1_encoder, + &raw mut (*coder).opt_cur, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + } + (*coder).uncompressed_size = 0 as size_t; + (*coder).compressed_size = 0 as size_t; + (*coder).sequence = SEQ_LZMA_ENCODE; + current_block_45 = 2979737022853876585; + } + 1 => { + current_block_45 = 2979737022853876585; + } + 2 => { + current_block_45 = 13410404938545238636; + } + 3 => { + lzma_bufcpy( + &raw mut (*coder).buf as *mut uint8_t, + &raw mut (*coder).buf_pos, + LZMA2_HEADER_UNCOMPRESSED as size_t, + out, + out_pos, + out_size, + ); + if (*coder).buf_pos != LZMA2_HEADER_UNCOMPRESSED as size_t { + return LZMA_OK; + } + (*coder).sequence = SEQ_UNCOMPRESSED_COPY; + current_block_45 = 10903800704467975402; + } + 4 => { + current_block_45 = 10903800704467975402; + } + _ => { + current_block_45 = 11743904203796629665; + } + } + match current_block_45 { + 10903800704467975402 => { + mf_read(mf, out, out_pos, out_size, &raw mut (*coder).uncompressed_size); + if (*coder).uncompressed_size != 0 as size_t { + return LZMA_OK; + } + (*coder).sequence = SEQ_INIT; + current_block_45 = 11743904203796629665; + } + 2979737022853876585 => { + let left: uint32_t = (LZMA2_UNCOMPRESSED_MAX as size_t) + .wrapping_sub((*coder).uncompressed_size) as uint32_t; + let mut limit: uint32_t = 0; + if left < (*mf).match_len_max { + limit = 0 as uint32_t; + } else { + limit = (*mf) + .read_pos + .wrapping_sub((*mf).read_ahead) + .wrapping_add(left) + .wrapping_sub((*mf).match_len_max); + } + let read_start: uint32_t = (*mf).read_pos.wrapping_sub((*mf).read_ahead); + let ret: lzma_ret = lzma_lzma_encode( + (*coder).lzma as *mut lzma_lzma1_encoder, + mf, + (&raw mut (*coder).buf as *mut uint8_t) + .offset(LZMA2_HEADER_MAX as isize), + &raw mut (*coder).compressed_size, + LZMA2_CHUNK_MAX as size_t, + limit, + ) as lzma_ret; + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_add( + (*mf) + .read_pos + .wrapping_sub((*mf).read_ahead) + .wrapping_sub(read_start) as size_t, + ); + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_OK; + } + if (*coder).compressed_size >= (*coder).uncompressed_size { + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_add((*mf).read_ahead as size_t); + (*mf).read_ahead = 0 as uint32_t; + lzma2_header_uncompressed(coder); + (*coder).need_state_reset = true_0 != 0; + (*coder).sequence = SEQ_UNCOMPRESSED_HEADER; + current_block_45 = 11743904203796629665; + } else { + lzma2_header_lzma(coder); + (*coder).sequence = SEQ_LZMA_COPY; + current_block_45 = 13410404938545238636; + } + } + _ => {} + } + match current_block_45 { + 13410404938545238636 => { + lzma_bufcpy( + &raw mut (*coder).buf as *mut uint8_t, + &raw mut (*coder).buf_pos, + (*coder).compressed_size, + out, + out_pos, + out_size, + ); + if (*coder).buf_pos != (*coder).compressed_size { + return LZMA_OK; + } + (*coder).sequence = SEQ_INIT; + } + _ => {} + } + } + return LZMA_OK; +} +unsafe extern "C" fn lzma2_encoder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; + lzma_free((*coder).lzma, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn lzma2_encoder_options_update( + mut coder_ptr: *mut ::core::ffi::c_void, + mut filter: *const lzma_filter, +) -> lzma_ret { + let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; + if (*filter).options.is_null() + || (*coder).sequence as ::core::ffi::c_uint + != SEQ_INIT as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_PROG_ERROR; + } + let mut opt: *const lzma_options_lzma = (*filter).options + as *const lzma_options_lzma; + if (*coder).opt_cur.lc != (*opt).lc || (*coder).opt_cur.lp != (*opt).lp + || (*coder).opt_cur.pb != (*opt).pb + { + if (*opt).lc > LZMA_LCLP_MAX as uint32_t || (*opt).lp > LZMA_LCLP_MAX as uint32_t + || (*opt).lc.wrapping_add((*opt).lp) > LZMA_LCLP_MAX as uint32_t + || (*opt).pb > LZMA_PB_MAX as uint32_t + { + return LZMA_OPTIONS_ERROR; + } + (*coder).opt_cur.lc = (*opt).lc; + (*coder).opt_cur.lp = (*opt).lp; + (*coder).opt_cur.pb = (*opt).pb; + (*coder).need_properties = true_0 != 0; + (*coder).need_state_reset = true_0 != 0; + } + return LZMA_OK; +} +unsafe extern "C" fn lzma2_encoder_init( + mut lz: *mut lzma_lz_encoder, + mut allocator: *const lzma_allocator, + mut id: lzma_vli, + mut options: *const ::core::ffi::c_void, + mut lz_options: *mut lzma_lz_options, +) -> lzma_ret { + if options.is_null() { + return LZMA_PROG_ERROR; + } + let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_lzma2_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*lz).coder = coder as *mut ::core::ffi::c_void; + (*lz).code = Some( + lzma2_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_mf, + *mut uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_mf, + *mut uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >; + (*lz).end = Some( + lzma2_encoder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + >; + (*lz).options_update = Some( + lzma2_encoder_options_update + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_filter, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_filter, + ) -> lzma_ret, + >; + (*coder).lzma = NULL; + } + (*coder).opt_cur = *(options as *const lzma_options_lzma); + (*coder).sequence = SEQ_INIT; + (*coder).need_properties = true_0 != 0; + (*coder).need_state_reset = false_0 != 0; + (*coder).need_dictionary_reset = (*coder).opt_cur.preset_dict.is_null() + || (*coder).opt_cur.preset_dict_size == 0 as uint32_t; + let ret_: lzma_ret = lzma_lzma_encoder_create( + &raw mut (*coder).lzma, + allocator, + 0x21 as lzma_vli, + &raw mut (*coder).opt_cur, + lz_options, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + if (*lz_options).before_size.wrapping_add((*lz_options).dict_size) + < LZMA2_CHUNK_MAX as size_t + { + (*lz_options).before_size = (LZMA2_CHUNK_MAX as size_t) + .wrapping_sub((*lz_options).dict_size); + } + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma2_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return lzma_lz_encoder_init( + next, + allocator, + filters, + Some( + lzma2_encoder_init + as unsafe extern "C" fn( + *mut lzma_lz_encoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + ), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma2_encoder_memusage( + mut options: *const ::core::ffi::c_void, +) -> uint64_t { + let lzma_mem: uint64_t = lzma_lzma_encoder_memusage(options) as uint64_t; + if lzma_mem == UINT64_MAX as uint64_t { + return UINT64_MAX as uint64_t; + } + return (::core::mem::size_of::() as uint64_t) + .wrapping_add(lzma_mem); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma2_props_encode( + mut options: *const ::core::ffi::c_void, + mut out: *mut uint8_t, +) -> lzma_ret { + if options.is_null() { + return LZMA_PROG_ERROR; + } + let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; + let mut d: uint32_t = if (*opt).dict_size > 4096 as uint32_t { + (*opt).dict_size + } else { + 4096 as uint32_t + }; + d = d.wrapping_sub(1); + d |= d >> 2 as ::core::ffi::c_int; + d |= d >> 3 as ::core::ffi::c_int; + d |= d >> 4 as ::core::ffi::c_int; + d |= d >> 8 as ::core::ffi::c_int; + d |= d >> 16 as ::core::ffi::c_int; + if d == UINT32_MAX as uint32_t { + *out.offset(0 as ::core::ffi::c_int as isize) = 40 as uint8_t; + } else { + *out.offset(0 as ::core::ffi::c_int as isize) = get_dist_slot( + d.wrapping_add(1 as uint32_t), + ) + .wrapping_sub(24 as uint32_t) as uint8_t; + } + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma2_block_size( + mut options: *const ::core::ffi::c_void, +) -> uint64_t { + let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; + if !((*opt).dict_size >= LZMA_DICT_SIZE_MIN as uint32_t + && (*opt).dict_size + <= ((1 as uint32_t) << 30 as ::core::ffi::c_int) + .wrapping_add((1 as uint32_t) << 29 as ::core::ffi::c_int)) + { + return UINT64_MAX as uint64_t; + } + return if ((*opt).dict_size as uint64_t).wrapping_mul(3 as uint64_t) + > (1 as uint64_t) << 20 as ::core::ffi::c_int + { + ((*opt).dict_size as uint64_t).wrapping_mul(3 as uint64_t) + } else { + (1 as uint64_t) << 20 as ::core::ffi::c_int + }; +} diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs new file mode 100644 index 00000000..820f24da --- /dev/null +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -0,0 +1,4528 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_lz_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + lz_init: Option< + unsafe extern "C" fn( + *mut lzma_lz_decoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + >, + ) -> lzma_ret; + fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> uint64_t; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_dict { + pub buf: *mut uint8_t, + pub pos: size_t, + pub full: size_t, + pub limit: size_t, + pub size: size_t, + pub has_wrapped: bool, + pub need_reset: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_options { + pub dict_size: size_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: size_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_decoder { + pub coder: *mut ::core::ffi::c_void, + pub code: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_dict, + *const uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >, + pub reset: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const ::core::ffi::c_void) -> (), + >, + pub set_uncompressed: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), + >, + pub end: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), + >, +} +pub type probability = uint16_t; +pub type lzma_lzma_state = ::core::ffi::c_uint; +pub const STATE_NONLIT_REP: lzma_lzma_state = 11; +pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; +pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; +pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; +pub const STATE_LIT_MATCH: lzma_lzma_state = 7; +pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; +pub const STATE_REP_LIT: lzma_lzma_state = 5; +pub const STATE_MATCH_LIT: lzma_lzma_state = 4; +pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; +pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; +pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; +pub const STATE_LIT_LIT: lzma_lzma_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lzma1_decoder { + pub literal: [probability; 12288], + pub is_match: [[probability; 16]; 12], + pub is_rep: [probability; 12], + pub is_rep0: [probability; 12], + pub is_rep1: [probability; 12], + pub is_rep2: [probability; 12], + pub is_rep0_long: [[probability; 16]; 12], + pub dist_slot: [[probability; 64]; 4], + pub pos_special: [probability; 114], + pub pos_align: [probability; 16], + pub match_len_decoder: lzma_length_decoder, + pub rep_len_decoder: lzma_length_decoder, + pub rc: lzma_range_decoder, + pub state: lzma_lzma_state, + pub rep0: uint32_t, + pub rep1: uint32_t, + pub rep2: uint32_t, + pub rep3: uint32_t, + pub pos_mask: uint32_t, + pub literal_context_bits: uint32_t, + pub literal_mask: uint32_t, + pub uncompressed_size: lzma_vli, + pub allow_eopm: bool, + pub sequence: C2RustUnnamed, + pub probs: *mut probability, + pub symbol: uint32_t, + pub limit: uint32_t, + pub offset: uint32_t, + pub len: uint32_t, +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const SEQ_COPY: C2RustUnnamed = 22; +pub const SEQ_REP_LEN_BITTREE: C2RustUnnamed = 21; +pub const SEQ_REP_LEN_CHOICE2: C2RustUnnamed = 20; +pub const SEQ_REP_LEN_CHOICE: C2RustUnnamed = 19; +pub const SEQ_IS_REP2: C2RustUnnamed = 18; +pub const SEQ_IS_REP1: C2RustUnnamed = 17; +pub const SEQ_IS_REP0_LONG: C2RustUnnamed = 16; +pub const SEQ_SHORTREP: C2RustUnnamed = 15; +pub const SEQ_IS_REP0: C2RustUnnamed = 14; +pub const SEQ_EOPM: C2RustUnnamed = 13; +pub const SEQ_ALIGN: C2RustUnnamed = 12; +pub const SEQ_DIRECT: C2RustUnnamed = 11; +pub const SEQ_DIST_MODEL: C2RustUnnamed = 10; +pub const SEQ_DIST_SLOT: C2RustUnnamed = 9; +pub const SEQ_MATCH_LEN_BITTREE: C2RustUnnamed = 8; +pub const SEQ_MATCH_LEN_CHOICE2: C2RustUnnamed = 7; +pub const SEQ_MATCH_LEN_CHOICE: C2RustUnnamed = 6; +pub const SEQ_IS_REP: C2RustUnnamed = 5; +pub const SEQ_LITERAL_WRITE: C2RustUnnamed = 4; +pub const SEQ_LITERAL_MATCHED: C2RustUnnamed = 3; +pub const SEQ_LITERAL: C2RustUnnamed = 2; +pub const SEQ_IS_MATCH: C2RustUnnamed = 1; +pub const SEQ_NORMALIZE: C2RustUnnamed = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_range_decoder { + pub range: uint32_t, + pub code: uint32_t, + pub init_bytes_left: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_length_decoder { + pub choice: probability, + pub choice2: probability, + pub low: [[probability; 8]; 16], + pub mid: [[probability; 8]; 16], + pub high: [probability; 256], +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { + let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; + num + |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + num + |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 16 as ::core::ffi::c_int; + num + |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) + << 24 as ::core::ffi::c_int; + return num; +} +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 + as ::core::ffi::c_ulonglong; +pub const LZMA_LCLP_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_PB_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; +pub const LZ_DICT_REPEAT_MAX: ::core::ffi::c_int = 288 as ::core::ffi::c_int; +pub const LZ_DICT_INIT_POS: ::core::ffi::c_int = 2 as ::core::ffi::c_int + * LZ_DICT_REPEAT_MAX; +#[inline] +unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: uint32_t) -> uint8_t { + return *(*dict) + .buf + .offset( + (*dict) + .pos + .wrapping_sub(distance as size_t) + .wrapping_sub(1 as size_t) + .wrapping_add( + (if (distance as size_t) < (*dict).pos { + 0 as size_t + } else { + (*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t) + }), + ) as isize, + ); +} +#[inline] +unsafe extern "C" fn dict_get0(dict: *const lzma_dict) -> uint8_t { + return *(*dict).buf.offset((*dict).pos.wrapping_sub(1 as size_t) as isize); +} +#[inline] +unsafe extern "C" fn dict_is_distance_valid( + dict: *const lzma_dict, + distance: size_t, +) -> bool { + return (*dict).full > distance; +} +#[inline] +unsafe extern "C" fn dict_repeat( + mut dict: *mut lzma_dict, + mut distance: uint32_t, + mut len: *mut uint32_t, +) -> bool { + let dict_avail: size_t = (*dict).limit.wrapping_sub((*dict).pos); + let mut left: uint32_t = (if dict_avail < *len as size_t { + dict_avail + } else { + *len as size_t + }) as uint32_t; + *len = (*len).wrapping_sub(left); + let mut back: size_t = (*dict) + .pos + .wrapping_sub(distance as size_t) + .wrapping_sub(1 as size_t); + if distance as size_t >= (*dict).pos { + back = back + .wrapping_add((*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t)); + } + if distance < left { + loop { + let fresh0 = back; + back = back.wrapping_add(1); + let fresh1 = (*dict).pos; + (*dict).pos = (*dict).pos.wrapping_add(1); + *(*dict).buf.offset(fresh1 as isize) = *(*dict).buf.offset(fresh0 as isize); + left = left.wrapping_sub(1); + if !(left > 0 as uint32_t) { + break; + } + } + } else { + memcpy( + (*dict).buf.offset((*dict).pos as isize) as *mut ::core::ffi::c_void, + (*dict).buf.offset(back as isize) as *const ::core::ffi::c_void, + left as size_t, + ); + (*dict).pos = (*dict).pos.wrapping_add(left as size_t); + } + if !(*dict).has_wrapped { + (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); + } + return *len != 0 as uint32_t; +} +#[inline] +unsafe extern "C" fn dict_put(mut dict: *mut lzma_dict, mut byte: uint8_t) { + let fresh2 = (*dict).pos; + (*dict).pos = (*dict).pos.wrapping_add(1); + *(*dict).buf.offset(fresh2 as isize) = byte; + if !(*dict).has_wrapped { + (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); + } +} +#[inline] +unsafe extern "C" fn dict_put_safe(mut dict: *mut lzma_dict, mut byte: uint8_t) -> bool { + if ((*dict).pos == (*dict).limit) as ::core::ffi::c_int as ::core::ffi::c_long != 0 { + return true_0 != 0; + } + dict_put(dict, byte); + return false_0 != 0; +} +pub const RC_SHIFT_BITS: ::core::ffi::c_int = 8 as ::core::ffi::c_int; +pub const RC_TOP_BITS: ::core::ffi::c_int = 24 as ::core::ffi::c_int; +pub const RC_TOP_VALUE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) << RC_TOP_BITS; +pub const RC_BIT_MODEL_TOTAL_BITS: ::core::ffi::c_int = 11 as ::core::ffi::c_int; +pub const RC_BIT_MODEL_TOTAL: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_MOVE_BITS: ::core::ffi::c_int = 5 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> bool { + return (*options).lc <= LZMA_LCLP_MAX as uint32_t + && (*options).lp <= LZMA_LCLP_MAX as uint32_t + && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as uint32_t + && (*options).pb <= LZMA_PB_MAX as uint32_t; +} +pub const STATES: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const LIT_STATES: ::core::ffi::c_int = 7 as ::core::ffi::c_int; +pub const LITERAL_CODER_SIZE: ::core::ffi::c_uint = 0x300 as ::core::ffi::c_uint; +#[inline] +unsafe extern "C" fn literal_init( + mut probs: *mut probability, + mut lc: uint32_t, + mut lp: uint32_t, +) { + let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; + let mut i: size_t = 0 as size_t; + while i < coders { + *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + i = i.wrapping_add(1); + } +} +pub const MATCH_LEN_MIN: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const LEN_LOW_BITS: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +pub const LEN_LOW_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << LEN_LOW_BITS; +pub const LEN_MID_BITS: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +pub const LEN_MID_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << LEN_MID_BITS; +pub const LEN_HIGH_BITS: ::core::ffi::c_int = 8 as ::core::ffi::c_int; +pub const LEN_HIGH_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << LEN_HIGH_BITS; +pub const DIST_STATES: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const DIST_SLOT_BITS: ::core::ffi::c_int = 6 as ::core::ffi::c_int; +pub const DIST_SLOTS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) << DIST_SLOT_BITS; +pub const DIST_MODEL_START: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const DIST_MODEL_END: ::core::ffi::c_int = 14 as ::core::ffi::c_int; +pub const FULL_DISTANCES_BITS: ::core::ffi::c_int = DIST_MODEL_END + / 2 as ::core::ffi::c_int; +pub const FULL_DISTANCES: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const ALIGN_SIZE: ::core::ffi::c_int = (1 as ::core::ffi::c_int) << ALIGN_BITS; +#[inline] +unsafe extern "C" fn rc_read_init( + mut rc: *mut lzma_range_decoder, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + while (*rc).init_bytes_left > 0 as uint32_t { + if *in_pos == in_size { + return LZMA_OK; + } + if (*rc).init_bytes_left == 5 as uint32_t + && *in_0.offset(*in_pos as isize) as ::core::ffi::c_int + != 0 as ::core::ffi::c_int + { + return LZMA_DATA_ERROR; + } + (*rc).code = (*rc).code << 8 as ::core::ffi::c_int + | *in_0.offset(*in_pos as isize) as uint32_t; + *in_pos = (*in_pos).wrapping_add(1); + (*rc).init_bytes_left = (*rc).init_bytes_left.wrapping_sub(1); + } + return LZMA_STREAM_END; +} +unsafe extern "C" fn lzma_decode( + mut coder_ptr: *mut ::core::ffi::c_void, + mut dictptr: *mut lzma_dict, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + let mut current_block: u64; + let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; + let ret: lzma_ret = rc_read_init(&raw mut (*coder).rc, in_0, in_pos, in_size) + as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + let mut dict: lzma_dict = *dictptr; + let dict_start: size_t = dict.pos; + let mut rc: lzma_range_decoder = (*coder).rc; + let mut rc_in_ptr: *const uint8_t = in_0.offset(*in_pos as isize); + let mut rc_in_end: *const uint8_t = in_0.offset(in_size as isize); + let mut rc_in_fast_end: *const uint8_t = if rc_in_end.offset_from(rc_in_ptr) + as ::core::ffi::c_long <= 20 as ::core::ffi::c_long + { + rc_in_ptr + } else { + rc_in_end.offset(-(20 as ::core::ffi::c_int as isize)) + }; + let mut rc_bound: uint32_t = 0; + let mut state: uint32_t = (*coder).state as uint32_t; + let mut rep0: uint32_t = (*coder).rep0; + let mut rep1: uint32_t = (*coder).rep1; + let mut rep2: uint32_t = (*coder).rep2; + let mut rep3: uint32_t = (*coder).rep3; + let pos_mask: uint32_t = (*coder).pos_mask; + let mut probs: *mut probability = (*coder).probs; + let mut symbol: uint32_t = (*coder).symbol; + let mut limit: uint32_t = (*coder).limit; + let mut offset: uint32_t = (*coder).offset; + let mut len: uint32_t = (*coder).len; + let literal_mask: uint32_t = (*coder).literal_mask; + let literal_context_bits: uint32_t = (*coder).literal_context_bits; + let mut pos_state: uint32_t = (dict.pos & pos_mask as size_t) as uint32_t; + let mut ret_0: lzma_ret = LZMA_OK; + let mut eopm_is_valid: bool = (*coder).uncompressed_size + == LZMA_VLI_UNKNOWN as lzma_vli; + let mut might_finish_without_eopm: bool = false_0 != 0; + if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli + && (*coder).uncompressed_size <= dict.limit.wrapping_sub(dict.pos) as lzma_vli + { + dict.limit = dict.pos.wrapping_add((*coder).uncompressed_size as size_t); + might_finish_without_eopm = true_0 != 0; + } + match (*coder).sequence as ::core::ffi::c_uint { + 0 | 1 => { + current_block = 5979571030476392895; + } + 2 => { + current_block = 13844743919235296534; + } + 3 => { + current_block = 18125716024132132232; + } + 4 => { + current_block = 10535798129821001304; + } + 5 => { + current_block = 3469750012682708893; + } + 6 => { + current_block = 1138292997408115650; + } + 7 => { + current_block = 13912927785247575907; + } + 8 => { + current_block = 592696588731961849; + } + 9 => { + current_block = 4174862988780014241; + } + 10 => { + current_block = 617447976488552541; + } + 11 => { + current_block = 15418612220330286504; + } + 12 => { + current_block = 10510472849010538284; + } + 13 => { + current_block = 7073645523065812117; + } + 14 => { + current_block = 4420799852307653083; + } + 16 => { + current_block = 1698084742280242340; + } + 15 => { + current_block = 5341942013764523046; + } + 17 => { + current_block = 11808118301119257848; + } + 18 => { + current_block = 3996983927318648760; + } + 19 => { + current_block = 12043352250568755004; + } + 20 => { + current_block = 6834592846991627977; + } + 21 => { + current_block = 2467942631393454738; + } + 22 => { + current_block = 17340485688450593529; + } + _ => { + current_block = 4609795085482299213; + } + } + 'c_9380: loop { + match current_block { + 4609795085482299213 => { + (*dictptr).pos = dict.pos; + break; + } + 12043352250568755004 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_REP_LEN_CHOICE; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh142 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh142 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).rep_len_decoder.choice as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.choice as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + probs = &raw mut *(&raw mut (*coder).rep_len_decoder.low + as *mut [probability; 8]) + .offset(pos_state as isize) as *mut probability; + limit = LEN_LOW_SYMBOLS as uint32_t; + len = MATCH_LEN_MIN as uint32_t; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice + as ::core::ffi::c_int + - ((*coder).rep_len_decoder.choice as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + current_block = 6834592846991627977; + continue; + } + current_block = 16690975975023747857; + } + 3996983927318648760 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_IS_REP2; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh141 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh141 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep2[state as usize] as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep2[state as usize] as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + let distance_3: uint32_t = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance_3; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] + as ::core::ffi::c_int + - ((*coder).is_rep2[state as usize] as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + let distance_4: uint32_t = rep3; + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance_4; + } + current_block = 15498320742470848828; + } + 11808118301119257848 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_IS_REP1; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh140 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh140 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep1[state as usize] as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep1[state as usize] as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + let distance_2: uint32_t = rep1; + rep1 = rep0; + rep0 = distance_2; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] + as ::core::ffi::c_int + - ((*coder).is_rep1[state as usize] as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + current_block = 3996983927318648760; + continue; + } + current_block = 15498320742470848828; + } + 5341942013764523046 => { + if dict_put_safe(&raw mut dict, dict_get(&raw mut dict, rep0)) { + (*coder).sequence = SEQ_SHORTREP; + current_block = 4609795085482299213; + continue; + } else { + current_block = 4956146061682418353; + } + } + 1698084742280242340 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_IS_REP0_LONG; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh139 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh139 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).is_rep0_long[state as usize][pos_state as usize] + as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder) + .is_rep0_long[state as usize][pos_state as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep0_long[state as usize][pos_state as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + state = (if state < LIT_STATES as uint32_t { + STATE_LIT_SHORTREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as uint32_t; + current_block = 5341942013764523046; + continue; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder) + .is_rep0_long[state as usize][pos_state as usize] + as ::core::ffi::c_int + - ((*coder).is_rep0_long[state as usize][pos_state as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + } + current_block = 15498320742470848828; + } + 4420799852307653083 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_IS_REP0; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh138 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh138 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep0[state as usize] as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep0[state as usize] as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + current_block = 1698084742280242340; + continue; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] + as ::core::ffi::c_int + - ((*coder).is_rep0[state as usize] as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + current_block = 11808118301119257848; + continue; + } + } + 3469750012682708893 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_IS_REP; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh123 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh123 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep[state as usize] as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep[state as usize] as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + state = (if state < LIT_STATES as uint32_t { + STATE_LIT_MATCH as ::core::ffi::c_int + } else { + STATE_NONLIT_MATCH as ::core::ffi::c_int + }) as uint32_t; + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + current_block = 1138292997408115650; + continue; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] + as ::core::ffi::c_int + - ((*coder).is_rep[state as usize] as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + if !(!dict_is_distance_valid(&raw mut dict, 0 as size_t) + as ::core::ffi::c_int as ::core::ffi::c_long != 0) + { + current_block = 4420799852307653083; + continue; + } + ret_0 = LZMA_DATA_ERROR; + current_block = 4609795085482299213; + continue; + } + } + 7073645523065812117 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_EOPM; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh137 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh137 as uint32_t; + } + } + ret_0 = (if rc.code == 0 as uint32_t { + LZMA_STREAM_END as ::core::ffi::c_int + } else { + LZMA_DATA_ERROR as ::core::ffi::c_int + }) as lzma_ret; + current_block = 4609795085482299213; + continue; + } + 10510472849010538284 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_ALIGN; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh136 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh136 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).pos_align[offset.wrapping_add(symbol) as usize] + as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).pos_align[offset.wrapping_add(symbol) as usize] = ((*coder) + .pos_align[offset.wrapping_add(symbol) as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).pos_align[offset.wrapping_add(symbol) as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).pos_align[offset.wrapping_add(symbol) as usize] = ((*coder) + .pos_align[offset.wrapping_add(symbol) as usize] + as ::core::ffi::c_int + - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = symbol.wrapping_add(offset); + } + offset <<= 1 as ::core::ffi::c_int; + if offset < ALIGN_SIZE as uint32_t { + current_block = 10510472849010538284; + continue; + } + rep0 = rep0.wrapping_add(symbol); + if rep0 == UINT32_MAX as uint32_t { + current_block = 12043253436139097694; + } else { + current_block = 13383302701878543647; + } + } + 15418612220330286504 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_DIRECT; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh135 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh135 as uint32_t; + } + } + rc.range >>= 1 as ::core::ffi::c_int; + rc.code = rc.code.wrapping_sub(rc.range); + rc_bound = (0 as uint32_t) + .wrapping_sub(rc.code >> 31 as ::core::ffi::c_int); + rc.code = rc.code.wrapping_add(rc.range & rc_bound); + rep0 = (rep0 << 1 as ::core::ffi::c_int) + .wrapping_add(rc_bound.wrapping_add(1 as uint32_t)); + limit = limit.wrapping_sub(1); + if limit > 0 as uint32_t { + current_block = 15418612220330286504; + continue; + } + rep0 <<= ALIGN_BITS; + symbol = 0 as uint32_t; + offset = 1 as uint32_t; + current_block = 10510472849010538284; + continue; + } + 617447976488552541 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_DIST_MODEL; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh132 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh132 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh133 = *probs.offset(symbol as isize); + *fresh133 = (*fresh133 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh134 = *probs.offset(symbol as isize); + *fresh134 = (*fresh134 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + rep0 = (rep0 as ::core::ffi::c_uint) + .wrapping_add((1 as ::core::ffi::c_uint) << offset) as uint32_t + as uint32_t; + } + offset = offset.wrapping_add(1); + if offset < limit { + current_block = 617447976488552541; + continue; + } + current_block = 13383302701878543647; + } + 4174862988780014241 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_DIST_SLOT; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh129 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh129 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh130 = *probs.offset(symbol as isize); + *fresh130 = (*fresh130 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh131 = *probs.offset(symbol as isize); + *fresh131 = (*fresh131 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if symbol < DIST_SLOTS as uint32_t { + current_block = 4174862988780014241; + continue; + } + symbol = symbol.wrapping_sub(DIST_SLOTS as uint32_t); + if symbol < DIST_MODEL_START as uint32_t { + rep0 = symbol; + } else { + limit = (symbol >> 1 as ::core::ffi::c_int) + .wrapping_sub(1 as uint32_t); + rep0 = (2 as uint32_t).wrapping_add(symbol & 1 as uint32_t); + if symbol < DIST_MODEL_END as uint32_t { + rep0 <<= limit; + probs = (&raw mut (*coder).pos_special as *mut probability) + .offset(rep0 as isize) + .offset(-(symbol as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + symbol = 1 as uint32_t; + offset = 0 as uint32_t; + current_block = 617447976488552541; + continue; + } else { + limit = limit.wrapping_sub(ALIGN_BITS as uint32_t); + current_block = 15418612220330286504; + continue; + } + } + current_block = 13383302701878543647; + } + 592696588731961849 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_MATCH_LEN_BITTREE; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh126 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh126 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh127 = *probs.offset(symbol as isize); + *fresh127 = (*fresh127 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh128 = *probs.offset(symbol as isize); + *fresh128 = (*fresh128 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if symbol < limit { + current_block = 592696588731961849; + continue; + } + len = len.wrapping_add(symbol.wrapping_sub(limit)); + probs = &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) + .offset( + (if len < (DIST_STATES + MATCH_LEN_MIN) as uint32_t { + len.wrapping_sub(MATCH_LEN_MIN as uint32_t) + } else { + (DIST_STATES - 1 as ::core::ffi::c_int) as uint32_t + }) as isize, + ) as *mut probability; + symbol = 1 as uint32_t; + current_block = 4174862988780014241; + continue; + } + 13912927785247575907 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_MATCH_LEN_CHOICE2; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh125 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh125 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).match_len_decoder.choice2 as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.choice2 = ((*coder) + .match_len_decoder + .choice2 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.choice2 as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + probs = &raw mut *(&raw mut (*coder).match_len_decoder.mid + as *mut [probability; 8]) + .offset(pos_state as isize) as *mut probability; + limit = LEN_MID_SYMBOLS as uint32_t; + len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as uint32_t; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.choice2 = ((*coder) + .match_len_decoder + .choice2 as ::core::ffi::c_int + - ((*coder).match_len_decoder.choice2 as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + probs = &raw mut (*coder).match_len_decoder.high as *mut probability; + limit = LEN_HIGH_SYMBOLS as uint32_t; + len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) + as uint32_t; + } + current_block = 8485842003490715114; + } + 1138292997408115650 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_MATCH_LEN_CHOICE; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh124 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh124 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).match_len_decoder.choice as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.choice = ((*coder) + .match_len_decoder + .choice as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.choice as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + probs = &raw mut *(&raw mut (*coder).match_len_decoder.low + as *mut [probability; 8]) + .offset(pos_state as isize) as *mut probability; + limit = LEN_LOW_SYMBOLS as uint32_t; + len = MATCH_LEN_MIN as uint32_t; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.choice = ((*coder) + .match_len_decoder + .choice as ::core::ffi::c_int + - ((*coder).match_len_decoder.choice as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + current_block = 13912927785247575907; + continue; + } + current_block = 8485842003490715114; + } + 10535798129821001304 => { + if dict_put_safe(&raw mut dict, symbol as uint8_t) { + (*coder).sequence = SEQ_LITERAL_WRITE; + current_block = 4609795085482299213; + continue; + } else { + current_block = 4956146061682418353; + } + } + 18125716024132132232 => { + let match_bit: uint32_t = len & offset; + let subcoder_index: uint32_t = offset + .wrapping_add(match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_LITERAL_MATCHED; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh120 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh120 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(subcoder_index as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh121 = *probs.offset(subcoder_index as isize); + *fresh121 = (*fresh121 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + offset &= !match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh122 = *probs.offset(subcoder_index as isize); + *fresh122 = (*fresh122 as ::core::ffi::c_int + - (*probs.offset(subcoder_index as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + offset &= match_bit; + } + len <<= 1 as ::core::ffi::c_int; + if symbol + < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t + { + current_block = 18125716024132132232; + continue; + } else { + current_block = 10535798129821001304; + continue; + } + } + 5979571030476392895 => { + if (might_finish_without_eopm as ::core::ffi::c_int != 0 + && dict.pos == dict.limit) as ::core::ffi::c_int + as ::core::ffi::c_long != 0 + { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_NORMALIZE; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh115 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh115 as uint32_t; + } + } + if rc.code == 0 as uint32_t { + ret_0 = LZMA_STREAM_END; + current_block = 4609795085482299213; + continue; + } else if !(*coder).allow_eopm { + ret_0 = LZMA_DATA_ERROR; + current_block = 4609795085482299213; + continue; + } else { + eopm_is_valid = true_0 != 0; + } + } + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_IS_MATCH; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh116 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh116 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).is_match[state as usize][pos_state as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_match[state as usize][pos_state as usize] = ((*coder) + .is_match[state as usize][pos_state as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_match[state as usize][pos_state as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + probs = (&raw mut (*coder).literal as *mut probability) + .offset( + (3 as size_t) + .wrapping_mul( + ((dict.pos << 8 as ::core::ffi::c_int) + .wrapping_add(dict_get0(&raw mut dict) as size_t) + & literal_mask as size_t) << literal_context_bits, + ) as isize, + ); + symbol = 1 as uint32_t; + if state < LIT_STATES as uint32_t { + state = if state + <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as uint32_t + { + STATE_LIT_LIT as ::core::ffi::c_int as uint32_t + } else { + state.wrapping_sub(3 as uint32_t) + }; + current_block = 13844743919235296534; + continue; + } else { + state = if state + <= STATE_LIT_SHORTREP as ::core::ffi::c_int as uint32_t + { + state.wrapping_sub(3 as uint32_t) + } else { + state.wrapping_sub(6 as uint32_t) + }; + len = (dict_get(&raw mut dict, rep0) as uint32_t) + << 1 as ::core::ffi::c_int; + offset = 0x100 as uint32_t; + current_block = 18125716024132132232; + continue; + } + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_match[state as usize][pos_state as usize] = ((*coder) + .is_match[state as usize][pos_state as usize] + as ::core::ffi::c_int + - ((*coder).is_match[state as usize][pos_state as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + current_block = 3469750012682708893; + continue; + } + } + 13844743919235296534 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_LITERAL; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh117 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh117 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh118 = *probs.offset(symbol as isize); + *fresh118 = (*fresh118 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh119 = *probs.offset(symbol as isize); + *fresh119 = (*fresh119 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if symbol + < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t + { + current_block = 13844743919235296534; + continue; + } else { + current_block = 10535798129821001304; + continue; + } + } + 2467942631393454738 => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_REP_LEN_BITTREE; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh144 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh144 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh145 = *probs.offset(symbol as isize); + *fresh145 = (*fresh145 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh146 = *probs.offset(symbol as isize); + *fresh146 = (*fresh146 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if symbol < limit { + current_block = 2467942631393454738; + continue; + } + len = len.wrapping_add(symbol.wrapping_sub(limit)); + current_block = 17340485688450593529; + continue; + } + 17340485688450593529 => { + if dict_repeat(&raw mut dict, rep0, &raw mut len) as ::core::ffi::c_long + != 0 + { + (*coder).sequence = SEQ_COPY; + current_block = 4609795085482299213; + continue; + } else { + current_block = 4956146061682418353; + } + } + _ => { + if rc.range < RC_TOP_VALUE as uint32_t { + if rc_in_ptr == rc_in_end { + (*coder).sequence = SEQ_REP_LEN_CHOICE2; + current_block = 4609795085482299213; + continue; + } else { + rc.range <<= RC_SHIFT_BITS; + let fresh143 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh143 as uint32_t; + } + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).rep_len_decoder.choice2 as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.choice2 as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + probs = &raw mut *(&raw mut (*coder).rep_len_decoder.mid + as *mut [probability; 8]) + .offset(pos_state as isize) as *mut probability; + limit = LEN_MID_SYMBOLS as uint32_t; + len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as uint32_t; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 + as ::core::ffi::c_int + - ((*coder).rep_len_decoder.choice2 as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + probs = &raw mut (*coder).rep_len_decoder.high as *mut probability; + limit = LEN_HIGH_SYMBOLS as uint32_t; + len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) + as uint32_t; + } + current_block = 16690975975023747857; + } + } + match current_block { + 13383302701878543647 => { + if !(!dict_is_distance_valid(&raw mut dict, rep0 as size_t) + as ::core::ffi::c_int as ::core::ffi::c_long != 0) + { + current_block = 17340485688450593529; + continue; + } + ret_0 = LZMA_DATA_ERROR; + current_block = 4609795085482299213; + continue; + } + 4956146061682418353 => { + loop { + pos_state = (dict.pos & pos_mask as size_t) as uint32_t; + if (!(rc_in_ptr < rc_in_fast_end) || dict.pos == dict.limit) + as ::core::ffi::c_int as ::core::ffi::c_long != 0 + { + current_block = 5979571030476392895; + continue 'c_9380; + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh3 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh3 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).is_match[state as usize][pos_state as usize] + as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_match[state as usize][pos_state as usize] = ((*coder) + .is_match[state as usize][pos_state as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_match[state as usize][pos_state as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + probs = (&raw mut (*coder).literal as *mut probability) + .offset( + (3 as size_t) + .wrapping_mul( + ((dict.pos << 8 as ::core::ffi::c_int) + .wrapping_add(dict_get0(&raw mut dict) as size_t) + & literal_mask as size_t) << literal_context_bits, + ) as isize, + ); + if state < LIT_STATES as uint32_t { + state = if state + <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as uint32_t + { + STATE_LIT_LIT as ::core::ffi::c_int as uint32_t + } else { + state.wrapping_sub(3 as uint32_t) + }; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh4 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh4 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh5 = *probs.offset(symbol as isize); + *fresh5 = (*fresh5 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh6 = *probs.offset(symbol as isize); + *fresh6 = (*fresh6 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh7 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh7 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh8 = *probs.offset(symbol as isize); + *fresh8 = (*fresh8 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh9 = *probs.offset(symbol as isize); + *fresh9 = (*fresh9 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh10 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh10 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh11 = *probs.offset(symbol as isize); + *fresh11 = (*fresh11 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh12 = *probs.offset(symbol as isize); + *fresh12 = (*fresh12 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh13 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh13 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh14 = *probs.offset(symbol as isize); + *fresh14 = (*fresh14 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh15 = *probs.offset(symbol as isize); + *fresh15 = (*fresh15 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh16 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh16 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh17 = *probs.offset(symbol as isize); + *fresh17 = (*fresh17 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh18 = *probs.offset(symbol as isize); + *fresh18 = (*fresh18 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh19 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh19 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh20 = *probs.offset(symbol as isize); + *fresh20 = (*fresh20 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh21 = *probs.offset(symbol as isize); + *fresh21 = (*fresh21 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh22 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh22 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh23 = *probs.offset(symbol as isize); + *fresh23 = (*fresh23 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh24 = *probs.offset(symbol as isize); + *fresh24 = (*fresh24 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh25 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh25 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh26 = *probs.offset(symbol as isize); + *fresh26 = (*fresh26 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh27 = *probs.offset(symbol as isize); + *fresh27 = (*fresh27 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + symbol = symbol + .wrapping_add(0 as ::core::ffi::c_int as uint32_t); + } else { + state = if state + <= STATE_LIT_SHORTREP as ::core::ffi::c_int as uint32_t + { + state.wrapping_sub(3 as uint32_t) + } else { + state.wrapping_sub(6 as uint32_t) + }; + let mut t_match_byte: uint32_t = dict_get( + &raw mut dict, + rep0, + ) as uint32_t; + let mut t_match_bit: uint32_t = 0; + let mut t_subcoder_index: uint32_t = 0; + let mut t_offset: uint32_t = 0x100 as uint32_t; + symbol = 1 as uint32_t; + t_match_byte <<= 1 as ::core::ffi::c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset + .wrapping_add(t_match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh28 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh28 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + *probs.offset(t_subcoder_index as isize) as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh29 = *probs + .offset(t_subcoder_index as isize); + *fresh29 = (*fresh29 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh30 = *probs + .offset(t_subcoder_index as isize); + *fresh30 = (*fresh30 as ::core::ffi::c_int + - (*probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as ::core::ffi::c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset + .wrapping_add(t_match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh31 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh31 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + *probs.offset(t_subcoder_index as isize) as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh32 = *probs + .offset(t_subcoder_index as isize); + *fresh32 = (*fresh32 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh33 = *probs + .offset(t_subcoder_index as isize); + *fresh33 = (*fresh33 as ::core::ffi::c_int + - (*probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as ::core::ffi::c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset + .wrapping_add(t_match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh34 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh34 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + *probs.offset(t_subcoder_index as isize) as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh35 = *probs + .offset(t_subcoder_index as isize); + *fresh35 = (*fresh35 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh36 = *probs + .offset(t_subcoder_index as isize); + *fresh36 = (*fresh36 as ::core::ffi::c_int + - (*probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as ::core::ffi::c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset + .wrapping_add(t_match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh37 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh37 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + *probs.offset(t_subcoder_index as isize) as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh38 = *probs + .offset(t_subcoder_index as isize); + *fresh38 = (*fresh38 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh39 = *probs + .offset(t_subcoder_index as isize); + *fresh39 = (*fresh39 as ::core::ffi::c_int + - (*probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as ::core::ffi::c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset + .wrapping_add(t_match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh40 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh40 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + *probs.offset(t_subcoder_index as isize) as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh41 = *probs + .offset(t_subcoder_index as isize); + *fresh41 = (*fresh41 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh42 = *probs + .offset(t_subcoder_index as isize); + *fresh42 = (*fresh42 as ::core::ffi::c_int + - (*probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as ::core::ffi::c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset + .wrapping_add(t_match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh43 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh43 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + *probs.offset(t_subcoder_index as isize) as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh44 = *probs + .offset(t_subcoder_index as isize); + *fresh44 = (*fresh44 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh45 = *probs + .offset(t_subcoder_index as isize); + *fresh45 = (*fresh45 as ::core::ffi::c_int + - (*probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as ::core::ffi::c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset + .wrapping_add(t_match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh46 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh46 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + *probs.offset(t_subcoder_index as isize) as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh47 = *probs + .offset(t_subcoder_index as isize); + *fresh47 = (*fresh47 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh48 = *probs + .offset(t_subcoder_index as isize); + *fresh48 = (*fresh48 as ::core::ffi::c_int + - (*probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as ::core::ffi::c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset + .wrapping_add(t_match_bit) + .wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh49 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh49 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + *probs.offset(t_subcoder_index as isize) as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh50 = *probs + .offset(t_subcoder_index as isize); + *fresh50 = (*fresh50 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh51 = *probs + .offset(t_subcoder_index as isize); + *fresh51 = (*fresh51 as ::core::ffi::c_int + - (*probs.offset(t_subcoder_index as isize) + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + t_offset &= t_match_bit; + } + } + dict_put(&raw mut dict, symbol as uint8_t); + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_match[state as usize][pos_state as usize] = ((*coder) + .is_match[state as usize][pos_state as usize] + as ::core::ffi::c_int + - ((*coder).is_match[state as usize][pos_state as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh52 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh52 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep[state as usize] as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep[state as usize] = ((*coder) + .is_rep[state as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep[state as usize] as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + state = (if state < LIT_STATES as uint32_t { + STATE_LIT_MATCH as ::core::ffi::c_int + } else { + STATE_NONLIT_MATCH as ::core::ffi::c_int + }) as uint32_t; + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh53 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh53 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.choice as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.choice = ((*coder) + .match_len_decoder + .choice as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.choice as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh54 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh54 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh55 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh55 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh56 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh56 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .match_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + symbol = symbol + .wrapping_add( + (-((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + 2 as ::core::ffi::c_int) as uint32_t, + ); + len = symbol; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.choice = ((*coder) + .match_len_decoder + .choice as ::core::ffi::c_int + - ((*coder).match_len_decoder.choice as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh57 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh57 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.choice2 as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.choice2 = ((*coder) + .match_len_decoder + .choice2 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.choice2 as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh58 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh58 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh59 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh59 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh60 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh60 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .match_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + symbol = symbol + .wrapping_add( + (-((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + 2 as ::core::ffi::c_int + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int)) + as uint32_t, + ); + len = symbol; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.choice2 = ((*coder) + .match_len_decoder + .choice2 as ::core::ffi::c_int + - ((*coder).match_len_decoder.choice2 as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh61 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh61 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh62 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh62 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh63 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh63 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh64 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh64 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh65 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh65 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh66 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh66 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh67 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh67 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh68 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh68 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + symbol = symbol + .wrapping_add( + (-((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) + + 2 as ::core::ffi::c_int + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int)) + as uint32_t, + ); + len = symbol; + } + } + probs = &raw mut *(&raw mut (*coder).dist_slot + as *mut [probability; 64]) + .offset( + (if len < (DIST_STATES + MATCH_LEN_MIN) as uint32_t { + len.wrapping_sub(MATCH_LEN_MIN as uint32_t) + } else { + (DIST_STATES - 1 as ::core::ffi::c_int) as uint32_t + }) as isize, + ) as *mut probability; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh69 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh69 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh70 = *probs.offset(symbol as isize); + *fresh70 = (*fresh70 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh71 = *probs.offset(symbol as isize); + *fresh71 = (*fresh71 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh72 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh72 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh73 = *probs.offset(symbol as isize); + *fresh73 = (*fresh73 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh74 = *probs.offset(symbol as isize); + *fresh74 = (*fresh74 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh75 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh75 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh76 = *probs.offset(symbol as isize); + *fresh76 = (*fresh76 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh77 = *probs.offset(symbol as isize); + *fresh77 = (*fresh77 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh78 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh78 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh79 = *probs.offset(symbol as isize); + *fresh79 = (*fresh79 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh80 = *probs.offset(symbol as isize); + *fresh80 = (*fresh80 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh81 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh81 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh82 = *probs.offset(symbol as isize); + *fresh82 = (*fresh82 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh83 = *probs.offset(symbol as isize); + *fresh83 = (*fresh83 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh84 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh84 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh85 = *probs.offset(symbol as isize); + *fresh85 = (*fresh85 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh86 = *probs.offset(symbol as isize); + *fresh86 = (*fresh86 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + symbol = symbol + .wrapping_add( + -((1 as ::core::ffi::c_int) << 6 as ::core::ffi::c_int) + as uint32_t, + ); + if symbol < DIST_MODEL_START as uint32_t { + rep0 = symbol; + } else { + limit = (symbol >> 1 as ::core::ffi::c_int) + .wrapping_sub(1 as uint32_t); + rep0 = (2 as uint32_t).wrapping_add(symbol & 1 as uint32_t); + if symbol < DIST_MODEL_END as uint32_t { + rep0 <<= limit; + probs = (&raw mut (*coder).pos_special as *mut probability) + .offset(rep0 as isize) + .offset(-(symbol as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + symbol = 1 as uint32_t; + offset = 1 as uint32_t; + loop { + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh87 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh87 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh88 = *probs.offset(symbol as isize); + *fresh88 = (*fresh88 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + *probs.offset(symbol as isize) as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh89 = *probs.offset(symbol as isize); + *fresh89 = (*fresh89 as ::core::ffi::c_int + - (*probs.offset(symbol as isize) as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + rep0 = rep0.wrapping_add(offset); + } + offset <<= 1 as ::core::ffi::c_int; + limit = limit.wrapping_sub(1); + if !(limit > 0 as uint32_t) { + break; + } + } + } else { + limit = limit.wrapping_sub(ALIGN_BITS as uint32_t); + loop { + rep0 = (rep0 << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh90 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh90 as uint32_t; + } + rc.range >>= 1 as ::core::ffi::c_int; + rc.code = rc.code.wrapping_sub(rc.range); + rc_bound = (0 as uint32_t) + .wrapping_sub(rc.code >> 31 as ::core::ffi::c_int); + rep0 = rep0.wrapping_add(rc_bound); + rc.code = rc.code.wrapping_add(rc.range & rc_bound); + limit = limit.wrapping_sub(1); + if !(limit > 0 as uint32_t) { + break; + } + } + rep0 <<= ALIGN_BITS; + symbol = 0 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh91 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh91 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] + as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] = ((*coder) + .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] = ((*coder) + .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] + as ::core::ffi::c_int + - ((*coder) + .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = symbol.wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh92 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh92 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] + as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] = ((*coder) + .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] = ((*coder) + .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] + as ::core::ffi::c_int + - ((*coder) + .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = symbol.wrapping_add(2 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh93 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh93 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] + as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] = ((*coder) + .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] = ((*coder) + .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] + as ::core::ffi::c_int + - ((*coder) + .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = symbol.wrapping_add(4 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh94 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh94 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] + as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] = ((*coder) + .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] = ((*coder) + .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] + as ::core::ffi::c_int + - ((*coder) + .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = symbol.wrapping_add(8 as uint32_t); + } + rep0 = rep0.wrapping_add(symbol); + if rep0 == UINT32_MAX as uint32_t { + break; + } + } + } + if !dict_is_distance_valid(&raw mut dict, rep0 as size_t) + as ::core::ffi::c_int as ::core::ffi::c_long != 0 + { + ret_0 = LZMA_DATA_ERROR; + current_block = 4609795085482299213; + continue 'c_9380; + } + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep[state as usize] = ((*coder) + .is_rep[state as usize] as ::core::ffi::c_int + - ((*coder).is_rep[state as usize] as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + if !dict_is_distance_valid(&raw mut dict, 0 as size_t) + as ::core::ffi::c_int as ::core::ffi::c_long != 0 + { + ret_0 = LZMA_DATA_ERROR; + current_block = 4609795085482299213; + continue 'c_9380; + } else { + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh95 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh95 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep0[state as usize] as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep0[state as usize] = ((*coder) + .is_rep0[state as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep0[state as usize] as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh96 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh96 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).is_rep0_long[state as usize][pos_state as usize] + as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder) + .is_rep0_long[state as usize][pos_state as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep0_long[state as usize][pos_state as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + state = (if state < LIT_STATES as uint32_t { + STATE_LIT_SHORTREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as uint32_t; + dict_put(&raw mut dict, dict_get(&raw mut dict, rep0)); + continue; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder) + .is_rep0_long[state as usize][pos_state as usize] + as ::core::ffi::c_int + - ((*coder).is_rep0_long[state as usize][pos_state as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + } + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep0[state as usize] = ((*coder) + .is_rep0[state as usize] as ::core::ffi::c_int + - ((*coder).is_rep0[state as usize] as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh97 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh97 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep1[state as usize] as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep1[state as usize] = ((*coder) + .is_rep1[state as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep1[state as usize] as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + let distance: uint32_t = rep1; + rep1 = rep0; + rep0 = distance; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep1[state as usize] = ((*coder) + .is_rep1[state as usize] as ::core::ffi::c_int + - ((*coder).is_rep1[state as usize] as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh98 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh98 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep2[state as usize] as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep2[state as usize] = ((*coder) + .is_rep2[state as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).is_rep2[state as usize] as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + let distance_0: uint32_t = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance_0; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep2[state as usize] = ((*coder) + .is_rep2[state as usize] as ::core::ffi::c_int + - ((*coder).is_rep2[state as usize] as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + let distance_1: uint32_t = rep3; + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance_1; + } + } + } + state = (if state < LIT_STATES as uint32_t { + STATE_LIT_LONGREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as uint32_t; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh99 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh99 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).rep_len_decoder.choice as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.choice = ((*coder) + .rep_len_decoder + .choice as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.choice as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh100 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh100 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh101 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh101 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh102 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh102 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .rep_len_decoder + .low[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + symbol = symbol + .wrapping_add( + (-((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + 2 as ::core::ffi::c_int) as uint32_t, + ); + len = symbol; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.choice = ((*coder) + .rep_len_decoder + .choice as ::core::ffi::c_int + - ((*coder).rep_len_decoder.choice as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh103 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh103 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).rep_len_decoder.choice2 as uint32_t); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.choice2 = ((*coder) + .rep_len_decoder + .choice2 as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.choice2 as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh104 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh104 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh105 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh105 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh106 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh106 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] = ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int + - ((*coder) + .rep_len_decoder + .mid[pos_state as usize][symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + symbol = symbol + .wrapping_add( + (-((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + 2 as ::core::ffi::c_int + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int)) + as uint32_t, + ); + len = symbol; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.choice2 = ((*coder) + .rep_len_decoder + .choice2 as ::core::ffi::c_int + - ((*coder).rep_len_decoder.choice2 as ::core::ffi::c_int + >> RC_MOVE_BITS)) as probability; + symbol = 1 as uint32_t; + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh107 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh107 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh108 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh108 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh109 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh109 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh110 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh110 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh111 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh111 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh112 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh112 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh113 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh113 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + if rc.range < RC_TOP_VALUE as uint32_t { + rc.range <<= RC_SHIFT_BITS; + let fresh114 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh114 as uint32_t; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as ::core::ffi::c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] as ::core::ffi::c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + symbol = (symbol << 1 as ::core::ffi::c_int) + .wrapping_add(1 as uint32_t); + } + symbol = symbol + .wrapping_add( + (-((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) + + 2 as ::core::ffi::c_int + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int)) + as uint32_t, + ); + len = symbol; + } + } + } + } + if !(dict_repeat(&raw mut dict, rep0, &raw mut len) + as ::core::ffi::c_long != 0) + { + continue; + } + (*coder).sequence = SEQ_COPY; + current_block = 4609795085482299213; + continue 'c_9380; + } + } + } + 16690975975023747857 => { + symbol = 1 as uint32_t; + current_block = 2467942631393454738; + continue; + } + 15498320742470848828 => { + state = (if state < LIT_STATES as uint32_t { + STATE_LIT_LONGREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as uint32_t; + current_block = 12043352250568755004; + continue; + } + 8485842003490715114 => { + symbol = 1 as uint32_t; + current_block = 592696588731961849; + continue; + } + _ => {} + } + if eopm_is_valid { + current_block = 7073645523065812117; + continue; + } + ret_0 = LZMA_DATA_ERROR; + current_block = 4609795085482299213; + } + (*dictptr).full = dict.full; + (*coder).rc = rc; + *in_pos = rc_in_ptr.offset_from(in_0) as ::core::ffi::c_long as size_t; + (*coder).state = state as lzma_lzma_state; + (*coder).rep0 = rep0; + (*coder).rep1 = rep1; + (*coder).rep2 = rep2; + (*coder).rep3 = rep3; + (*coder).probs = probs; + (*coder).symbol = symbol; + (*coder).limit = limit; + (*coder).offset = offset; + (*coder).len = len; + if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_sub(dict.pos.wrapping_sub(dict_start) as lzma_vli); + if (*coder).uncompressed_size == 0 as lzma_vli + && ret_0 as ::core::ffi::c_uint + == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + && ((*coder).sequence as ::core::ffi::c_uint + == SEQ_LITERAL_WRITE as ::core::ffi::c_int as ::core::ffi::c_uint + || (*coder).sequence as ::core::ffi::c_uint + == SEQ_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint + || (*coder).sequence as ::core::ffi::c_uint + == SEQ_COPY as ::core::ffi::c_int as ::core::ffi::c_uint) + { + ret_0 = LZMA_DATA_ERROR; + } + } + if ret_0 as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*coder).rc.range = UINT32_MAX as uint32_t; + (*coder).rc.code = 0 as uint32_t; + (*coder).rc.init_bytes_left = 5 as uint32_t; + (*coder).sequence = SEQ_IS_MATCH; + } + return ret_0; +} +unsafe extern "C" fn lzma_decoder_uncompressed( + mut coder_ptr: *mut ::core::ffi::c_void, + mut uncompressed_size: lzma_vli, + mut allow_eopm: bool, +) { + let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; + (*coder).uncompressed_size = uncompressed_size; + (*coder).allow_eopm = allow_eopm; +} +unsafe extern "C" fn lzma_decoder_reset( + mut coder_ptr: *mut ::core::ffi::c_void, + mut opt: *const ::core::ffi::c_void, +) { + let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; + let mut options: *const lzma_options_lzma = opt as *const lzma_options_lzma; + (*coder).pos_mask = ((1 as ::core::ffi::c_uint) << (*options).pb) + .wrapping_sub(1 as ::core::ffi::c_uint) as uint32_t; + literal_init( + &raw mut (*coder).literal as *mut probability, + (*options).lc, + (*options).lp, + ); + (*coder).literal_context_bits = (*options).lc; + (*coder).literal_mask = ((0x100 as ::core::ffi::c_uint) << (*options).lp) + .wrapping_sub(0x100 as ::core::ffi::c_uint >> (*options).lc) as uint32_t; + (*coder).state = STATE_LIT_LIT; + (*coder).rep0 = 0 as uint32_t; + (*coder).rep1 = 0 as uint32_t; + (*coder).rep2 = 0 as uint32_t; + (*coder).rep3 = 0 as uint32_t; + (*coder).pos_mask = ((1 as ::core::ffi::c_uint) << (*options).pb) + .wrapping_sub(1 as ::core::ffi::c_uint) as uint32_t; + (*coder).rc.range = UINT32_MAX as uint32_t; + (*coder).rc.code = 0 as uint32_t; + (*coder).rc.init_bytes_left = 5 as uint32_t; + let mut i: uint32_t = 0 as uint32_t; + while i < STATES as uint32_t { + let mut j: uint32_t = 0 as uint32_t; + while j <= (*coder).pos_mask { + (*coder).is_match[i as usize][j as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + (*coder).is_rep0_long[i as usize][j as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + j = j.wrapping_add(1); + } + (*coder).is_rep[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).is_rep0[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).is_rep1[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).is_rep2[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + i = i.wrapping_add(1); + } + let mut i_0: uint32_t = 0 as uint32_t; + while i_0 < DIST_STATES as uint32_t { + let mut bt_i: uint32_t = 0 as uint32_t; + while bt_i < ((1 as ::core::ffi::c_int) << 6 as ::core::ffi::c_int) as uint32_t { + (*coder).dist_slot[i_0 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i = bt_i.wrapping_add(1); + } + i_0 = i_0.wrapping_add(1); + } + let mut i_1: uint32_t = 0 as uint32_t; + while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as uint32_t { + (*coder).pos_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + i_1 = i_1.wrapping_add(1); + } + let mut bt_i_0: uint32_t = 0 as uint32_t; + while bt_i_0 < ((1 as ::core::ffi::c_int) << 4 as ::core::ffi::c_int) as uint32_t { + (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_0 = bt_i_0.wrapping_add(1); + } + let num_pos_states: uint32_t = (1 as uint32_t) << (*options).pb; + (*coder).match_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).match_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).rep_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).rep_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + let mut pos_state: uint32_t = 0 as uint32_t; + while pos_state < num_pos_states { + let mut bt_i_1: uint32_t = 0 as uint32_t; + while bt_i_1 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t + { + (*coder).match_len_decoder.low[pos_state as usize][bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_1 = bt_i_1.wrapping_add(1); + } + let mut bt_i_2: uint32_t = 0 as uint32_t; + while bt_i_2 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t + { + (*coder).match_len_decoder.mid[pos_state as usize][bt_i_2 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_2 = bt_i_2.wrapping_add(1); + } + let mut bt_i_3: uint32_t = 0 as uint32_t; + while bt_i_3 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t + { + (*coder).rep_len_decoder.low[pos_state as usize][bt_i_3 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_3 = bt_i_3.wrapping_add(1); + } + let mut bt_i_4: uint32_t = 0 as uint32_t; + while bt_i_4 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t + { + (*coder).rep_len_decoder.mid[pos_state as usize][bt_i_4 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_4 = bt_i_4.wrapping_add(1); + } + pos_state = pos_state.wrapping_add(1); + } + let mut bt_i_5: uint32_t = 0 as uint32_t; + while bt_i_5 < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t { + (*coder).match_len_decoder.high[bt_i_5 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_5 = bt_i_5.wrapping_add(1); + } + let mut bt_i_6: uint32_t = 0 as uint32_t; + while bt_i_6 < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t { + (*coder).rep_len_decoder.high[bt_i_6 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_6 = bt_i_6.wrapping_add(1); + } + (*coder).sequence = SEQ_IS_MATCH; + (*coder).probs = ::core::ptr::null_mut::(); + (*coder).symbol = 0 as uint32_t; + (*coder).limit = 0 as uint32_t; + (*coder).offset = 0 as uint32_t; + (*coder).len = 0 as uint32_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_decoder_create( + mut lz: *mut lzma_lz_decoder, + mut allocator: *const lzma_allocator, + mut options: *const lzma_options_lzma, + mut lz_options: *mut lzma_lz_options, +) -> lzma_ret { + if (*lz).coder.is_null() { + (*lz).coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ); + if (*lz).coder.is_null() { + return LZMA_MEM_ERROR; + } + (*lz).code = Some( + lzma_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_dict, + *const uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_dict, + *const uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >; + (*lz).reset = Some( + lzma_decoder_reset + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const ::core::ffi::c_void, + ) -> (), + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const ::core::ffi::c_void, + ) -> (), + >; + (*lz).set_uncompressed = Some( + lzma_decoder_uncompressed + as unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), + ) + as Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), + >; + } + (*lz_options).dict_size = (*options).dict_size as size_t; + (*lz_options).preset_dict = (*options).preset_dict; + (*lz_options).preset_dict_size = (*options).preset_dict_size as size_t; + return LZMA_OK; +} +unsafe extern "C" fn lzma_decoder_init( + mut lz: *mut lzma_lz_decoder, + mut allocator: *const lzma_allocator, + mut id: lzma_vli, + mut options: *const ::core::ffi::c_void, + mut lz_options: *mut lzma_lz_options, +) -> lzma_ret { + if !is_lclppb_valid(options as *const lzma_options_lzma) { + return LZMA_PROG_ERROR; + } + let mut uncomp_size: lzma_vli = LZMA_VLI_UNKNOWN as lzma_vli; + let mut allow_eopm: bool = true_0 != 0; + if id == LZMA_FILTER_LZMA1EXT as lzma_vli { + let mut opt: *const lzma_options_lzma = options as *const lzma_options_lzma; + if (*opt).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t) != 0 { + return LZMA_OPTIONS_ERROR; + } + uncomp_size = ((*opt).ext_size_low as uint64_t) + .wrapping_add(((*opt).ext_size_high as uint64_t) << 32 as ::core::ffi::c_int) + as lzma_vli; + allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t + != 0 as uint32_t || uncomp_size == LZMA_VLI_UNKNOWN as lzma_vli; + } + let ret_: lzma_ret = lzma_lzma_decoder_create( + lz, + allocator, + options as *const lzma_options_lzma, + lz_options, + ) as lzma_ret; + if ret_ as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_; + } + lzma_decoder_reset((*lz).coder, options); + lzma_decoder_uncompressed((*lz).coder, uncomp_size, allow_eopm); + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return lzma_lz_decoder_init( + next, + allocator, + filters, + Some( + lzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_lz_decoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + ), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_lclppb_decode( + mut options: *mut lzma_options_lzma, + mut byte: uint8_t, +) -> bool { + if byte as ::core::ffi::c_int + > (4 as ::core::ffi::c_int * 5 as ::core::ffi::c_int + 4 as ::core::ffi::c_int) + * 9 as ::core::ffi::c_int + 8 as ::core::ffi::c_int + { + return true_0 != 0; + } + (*options).pb = (byte as ::core::ffi::c_int + / (9 as ::core::ffi::c_int * 5 as ::core::ffi::c_int)) as uint32_t; + byte = (byte as uint32_t) + .wrapping_sub( + (*options).pb.wrapping_mul(9 as uint32_t).wrapping_mul(5 as uint32_t), + ) as uint8_t as uint8_t; + (*options).lp = (byte as ::core::ffi::c_int / 9 as ::core::ffi::c_int) as uint32_t; + (*options).lc = (byte as uint32_t) + .wrapping_sub((*options).lp.wrapping_mul(9 as uint32_t)); + return (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX as uint32_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_decoder_memusage_nocheck( + mut options: *const ::core::ffi::c_void, +) -> uint64_t { + let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; + return (::core::mem::size_of::() as uint64_t) + .wrapping_add(lzma_lz_decoder_memusage((*opt).dict_size as size_t)); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_decoder_memusage( + mut options: *const ::core::ffi::c_void, +) -> uint64_t { + if !is_lclppb_valid(options as *const lzma_options_lzma) { + return UINT64_MAX as uint64_t; + } + return lzma_lzma_decoder_memusage_nocheck(options); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_props_decode( + mut options: *mut *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut props: *const uint8_t, + mut props_size: size_t, +) -> lzma_ret { + if props_size != 5 as size_t { + return LZMA_OPTIONS_ERROR; + } + let mut opt: *mut lzma_options_lzma = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_options_lzma; + if opt.is_null() { + return LZMA_MEM_ERROR; + } + if lzma_lzma_lclppb_decode(opt, *props.offset(0 as ::core::ffi::c_int as isize)) { + lzma_free(opt as *mut ::core::ffi::c_void, allocator); + return LZMA_OPTIONS_ERROR; + } else { + (*opt).dict_size = read32le(props.offset(1 as ::core::ffi::c_int as isize)); + (*opt).preset_dict = ::core::ptr::null::(); + (*opt).preset_dict_size = 0 as uint32_t; + *options = opt as *mut ::core::ffi::c_void; + return LZMA_OK; + }; +} diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs new file mode 100644 index 00000000..ddc80950 --- /dev/null +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -0,0 +1,1759 @@ +extern "C" { + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_lz_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + lz_init: Option< + unsafe extern "C" fn( + *mut lzma_lz_encoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + >, + ) -> lzma_ret; + fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> uint64_t; + static lzma_rc_prices: [uint8_t; 128]; + fn lzma_lzma_optimum_fast( + coder: *mut lzma_lzma1_encoder, + mf: *mut lzma_mf, + back_res: *mut uint32_t, + len_res: *mut uint32_t, + ); + fn lzma_lzma_optimum_normal( + coder: *mut lzma_lzma1_encoder, + mf: *mut lzma_mf, + back_res: *mut uint32_t, + len_res: *mut uint32_t, + position: uint32_t, + ); + static lzma_fastpos: [uint8_t; 8192]; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_match { + pub len: uint32_t, + pub dist: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mf_s { + pub buffer: *mut uint8_t, + pub size: uint32_t, + pub keep_size_before: uint32_t, + pub keep_size_after: uint32_t, + pub offset: uint32_t, + pub read_pos: uint32_t, + pub read_ahead: uint32_t, + pub read_limit: uint32_t, + pub write_pos: uint32_t, + pub pending: uint32_t, + pub find: Option uint32_t>, + pub skip: Option ()>, + pub hash: *mut uint32_t, + pub son: *mut uint32_t, + pub cyclic_pos: uint32_t, + pub cyclic_size: uint32_t, + pub hash_mask: uint32_t, + pub depth: uint32_t, + pub nice_len: uint32_t, + pub match_len_max: uint32_t, + pub action: lzma_action, + pub hash_count: uint32_t, + pub sons_count: uint32_t, +} +pub type lzma_mf = lzma_mf_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_options { + pub before_size: size_t, + pub dict_size: size_t, + pub after_size: size_t, + pub match_len_max: size_t, + pub nice_len: size_t, + pub match_finder: lzma_match_finder, + pub depth: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_encoder { + pub coder: *mut ::core::ffi::c_void, + pub code: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_mf, + *mut uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >, + pub end: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), + >, + pub options_update: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_filter) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +pub type probability = uint16_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_range_encoder { + pub low: uint64_t, + pub cache_size: uint64_t, + pub range: uint32_t, + pub cache: uint8_t, + pub out_total: uint64_t, + pub count: size_t, + pub pos: size_t, + pub symbols: [C2RustUnnamed; 53], + pub probs: [*mut probability; 53], +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const RC_FLUSH: C2RustUnnamed = 4; +pub const RC_DIRECT_1: C2RustUnnamed = 3; +pub const RC_DIRECT_0: C2RustUnnamed = 2; +pub const RC_BIT_1: C2RustUnnamed = 1; +pub const RC_BIT_0: C2RustUnnamed = 0; +pub type lzma_lzma_state = ::core::ffi::c_uint; +pub const STATE_NONLIT_REP: lzma_lzma_state = 11; +pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; +pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; +pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; +pub const STATE_LIT_MATCH: lzma_lzma_state = 7; +pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; +pub const STATE_REP_LIT: lzma_lzma_state = 5; +pub const STATE_MATCH_LIT: lzma_lzma_state = 4; +pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; +pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; +pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; +pub const STATE_LIT_LIT: lzma_lzma_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lzma1_encoder_s { + pub rc: lzma_range_encoder, + pub uncomp_size: uint64_t, + pub out_limit: uint64_t, + pub uncomp_size_ptr: *mut uint64_t, + pub state: lzma_lzma_state, + pub reps: [uint32_t; 4], + pub matches: [lzma_match; 274], + pub matches_count: uint32_t, + pub longest_match_length: uint32_t, + pub fast_mode: bool, + pub is_initialized: bool, + pub is_flushed: bool, + pub use_eopm: bool, + pub pos_mask: uint32_t, + pub literal_context_bits: uint32_t, + pub literal_mask: uint32_t, + pub literal: [probability; 12288], + pub is_match: [[probability; 16]; 12], + pub is_rep: [probability; 12], + pub is_rep0: [probability; 12], + pub is_rep1: [probability; 12], + pub is_rep2: [probability; 12], + pub is_rep0_long: [[probability; 16]; 12], + pub dist_slot: [[probability; 64]; 4], + pub dist_special: [probability; 114], + pub dist_align: [probability; 16], + pub match_len_encoder: lzma_length_encoder, + pub rep_len_encoder: lzma_length_encoder, + pub dist_slot_prices: [[uint32_t; 64]; 4], + pub dist_prices: [[uint32_t; 128]; 4], + pub dist_table_size: uint32_t, + pub match_price_count: uint32_t, + pub align_prices: [uint32_t; 16], + pub align_price_count: uint32_t, + pub opts_end_index: uint32_t, + pub opts_current_index: uint32_t, + pub opts: [lzma_optimal; 4096], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_optimal { + pub state: lzma_lzma_state, + pub prev_1_is_literal: bool, + pub prev_2: bool, + pub pos_prev_2: uint32_t, + pub back_prev_2: uint32_t, + pub price: uint32_t, + pub pos_prev: uint32_t, + pub back_prev: uint32_t, + pub backs: [uint32_t; 4], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_length_encoder { + pub choice: probability, + pub choice2: probability, + pub low: [[probability; 8]; 16], + pub mid: [[probability; 8]; 16], + pub high: [probability; 256], + pub prices: [[uint32_t; 272]; 16], + pub table_size: uint32_t, + pub counters: [uint32_t; 16], +} +pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { + *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; + *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) + as uint8_t; +} +pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 + as ::core::ffi::c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 + as ::core::ffi::c_ulonglong; +pub const LZMA_LCLP_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_PB_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; +pub const LZMA2_CHUNK_MAX: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 16 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> uint32_t { + return match_finder as uint32_t & 0xf as uint32_t; +} +#[inline] +unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { + if amount != 0 as uint32_t { + (*mf).skip.expect("non-null function pointer")(mf, amount); + (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); + } +} +pub const RC_SHIFT_BITS: ::core::ffi::c_int = 8 as ::core::ffi::c_int; +pub const RC_TOP_BITS: ::core::ffi::c_int = 24 as ::core::ffi::c_int; +pub const RC_TOP_VALUE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) << RC_TOP_BITS; +pub const RC_BIT_MODEL_TOTAL_BITS: ::core::ffi::c_int = 11 as ::core::ffi::c_int; +pub const RC_BIT_MODEL_TOTAL: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_MOVE_BITS: ::core::ffi::c_int = 5 as ::core::ffi::c_int; +pub const RC_MOVE_REDUCING_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn rc_bit_price(prob: probability, bit: uint32_t) -> uint32_t { + return lzma_rc_prices[((prob as uint32_t + ^ (0 as uint32_t).wrapping_sub(bit) + & (RC_BIT_MODEL_TOTAL as uint32_t).wrapping_sub(1 as uint32_t)) + >> RC_MOVE_REDUCING_BITS) as usize] as uint32_t; +} +#[inline] +unsafe extern "C" fn rc_bit_0_price(prob: probability) -> uint32_t { + return lzma_rc_prices[(prob as ::core::ffi::c_int >> RC_MOVE_REDUCING_BITS) as usize] + as uint32_t; +} +#[inline] +unsafe extern "C" fn rc_bit_1_price(prob: probability) -> uint32_t { + return lzma_rc_prices[((prob as ::core::ffi::c_uint + ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1 as ::core::ffi::c_uint)) + >> RC_MOVE_REDUCING_BITS) as usize] as uint32_t; +} +#[inline] +unsafe extern "C" fn rc_bittree_price( + probs: *const probability, + bit_levels: uint32_t, + mut symbol: uint32_t, +) -> uint32_t { + let mut price: uint32_t = 0 as uint32_t; + symbol = (symbol as ::core::ffi::c_uint) + .wrapping_add((1 as ::core::ffi::c_uint) << bit_levels) as uint32_t as uint32_t; + loop { + let bit: uint32_t = symbol & 1 as uint32_t; + symbol >>= 1 as ::core::ffi::c_int; + price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); + if !(symbol != 1 as uint32_t) { + break; + } + } + return price; +} +#[inline] +unsafe extern "C" fn rc_reset(mut rc: *mut lzma_range_encoder) { + (*rc).low = 0 as uint64_t; + (*rc).cache_size = 1 as uint64_t; + (*rc).range = UINT32_MAX as uint32_t; + (*rc).cache = 0 as uint8_t; + (*rc).out_total = 0 as uint64_t; + (*rc).count = 0 as size_t; + (*rc).pos = 0 as size_t; +} +#[inline] +unsafe extern "C" fn rc_forget(mut rc: *mut lzma_range_encoder) { + (*rc).count = 0 as size_t; +} +#[inline] +unsafe extern "C" fn rc_bit( + mut rc: *mut lzma_range_encoder, + mut prob: *mut probability, + mut bit: uint32_t, +) { + (*rc).symbols[(*rc).count as usize] = bit as C2RustUnnamed; + (*rc).probs[(*rc).count as usize] = prob; + (*rc).count = (*rc).count.wrapping_add(1); +} +#[inline] +unsafe extern "C" fn rc_bittree( + mut rc: *mut lzma_range_encoder, + mut probs: *mut probability, + mut bit_count: uint32_t, + mut symbol: uint32_t, +) { + let mut model_index: uint32_t = 1 as uint32_t; + loop { + bit_count = bit_count.wrapping_sub(1); + let bit: uint32_t = symbol >> bit_count & 1 as uint32_t; + rc_bit(rc, probs.offset(model_index as isize) as *mut probability, bit); + model_index = (model_index << 1 as ::core::ffi::c_int).wrapping_add(bit); + if !(bit_count != 0 as uint32_t) { + break; + } + }; +} +#[inline] +unsafe extern "C" fn rc_bittree_reverse( + mut rc: *mut lzma_range_encoder, + mut probs: *mut probability, + mut bit_count: uint32_t, + mut symbol: uint32_t, +) { + let mut model_index: uint32_t = 1 as uint32_t; + loop { + let bit: uint32_t = symbol & 1 as uint32_t; + symbol >>= 1 as ::core::ffi::c_int; + rc_bit(rc, probs.offset(model_index as isize) as *mut probability, bit); + model_index = (model_index << 1 as ::core::ffi::c_int).wrapping_add(bit); + bit_count = bit_count.wrapping_sub(1); + if !(bit_count != 0 as uint32_t) { + break; + } + }; +} +#[inline] +unsafe extern "C" fn rc_direct( + mut rc: *mut lzma_range_encoder, + mut value: uint32_t, + mut bit_count: uint32_t, +) { + loop { + bit_count = bit_count.wrapping_sub(1); + let fresh0 = (*rc).count; + (*rc).count = (*rc).count.wrapping_add(1); + (*rc).symbols[fresh0 as usize] = (RC_DIRECT_0 as ::core::ffi::c_int as uint32_t) + .wrapping_add(value >> bit_count & 1 as uint32_t) as C2RustUnnamed; + if !(bit_count != 0 as uint32_t) { + break; + } + }; +} +#[inline] +unsafe extern "C" fn rc_flush(mut rc: *mut lzma_range_encoder) { + let mut i: size_t = 0 as size_t; + while i < 5 as size_t { + let fresh1 = (*rc).count; + (*rc).count = (*rc).count.wrapping_add(1); + (*rc).symbols[fresh1 as usize] = RC_FLUSH; + i = i.wrapping_add(1); + } +} +#[inline] +unsafe extern "C" fn rc_shift_low( + mut rc: *mut lzma_range_encoder, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> bool { + if ((*rc).low as uint32_t) < 0xff000000 as ::core::ffi::c_uint as uint32_t + || ((*rc).low >> 32 as ::core::ffi::c_int) as uint32_t != 0 as uint32_t + { + loop { + if *out_pos == out_size { + return true_0 != 0; + } + *out.offset(*out_pos as isize) = ((*rc).cache as ::core::ffi::c_int + + ((*rc).low >> 32 as ::core::ffi::c_int) as uint8_t + as ::core::ffi::c_int) as uint8_t; + *out_pos = (*out_pos).wrapping_add(1); + (*rc).out_total = (*rc).out_total.wrapping_add(1); + (*rc).cache = 0xff as uint8_t; + (*rc).cache_size = (*rc).cache_size.wrapping_sub(1); + if !((*rc).cache_size != 0 as uint64_t) { + break; + } + } + (*rc).cache = ((*rc).low >> 24 as ::core::ffi::c_int & 0xff as uint64_t) + as uint8_t; + } + (*rc).cache_size = (*rc).cache_size.wrapping_add(1); + (*rc).low = ((*rc).low & 0xffffff as uint64_t) << RC_SHIFT_BITS; + return false_0 != 0; +} +#[inline] +unsafe extern "C" fn rc_shift_low_dummy( + mut low: *mut uint64_t, + mut cache_size: *mut uint64_t, + mut cache: *mut uint8_t, + mut out_pos: *mut uint64_t, + mut out_size: uint64_t, +) -> bool { + if (*low as uint32_t) < 0xff000000 as ::core::ffi::c_uint as uint32_t + || (*low >> 32 as ::core::ffi::c_int) as uint32_t != 0 as uint32_t + { + loop { + if *out_pos == out_size { + return true_0 != 0; + } + *out_pos = (*out_pos).wrapping_add(1); + *cache = 0xff as uint8_t; + *cache_size = (*cache_size).wrapping_sub(1); + if !(*cache_size != 0 as uint64_t) { + break; + } + } + *cache = (*low >> 24 as ::core::ffi::c_int & 0xff as uint64_t) as uint8_t; + } + *cache_size = (*cache_size).wrapping_add(1); + *low = (*low & 0xffffff as uint64_t) << RC_SHIFT_BITS; + return false_0 != 0; +} +#[inline] +unsafe extern "C" fn rc_encode( + mut rc: *mut lzma_range_encoder, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> bool { + while (*rc).pos < (*rc).count { + if (*rc).range < RC_TOP_VALUE as uint32_t { + if rc_shift_low(rc, out, out_pos, out_size) { + return true_0 != 0; + } + (*rc).range <<= RC_SHIFT_BITS; + } + match (*rc).symbols[(*rc).pos as usize] as ::core::ffi::c_uint { + 0 => { + let mut prob: probability = *(*rc).probs[(*rc).pos as usize]; + (*rc).range = ((*rc).range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(prob as uint32_t); + prob = (prob as ::core::ffi::c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(prob as ::core::ffi::c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + *(*rc).probs[(*rc).pos as usize] = prob; + } + 1 => { + let mut prob_0: probability = *(*rc).probs[(*rc).pos as usize]; + let bound: uint32_t = (prob_0 as uint32_t) + .wrapping_mul((*rc).range >> RC_BIT_MODEL_TOTAL_BITS); + (*rc).low = (*rc).low.wrapping_add(bound as uint64_t); + (*rc).range = (*rc).range.wrapping_sub(bound); + prob_0 = (prob_0 as ::core::ffi::c_int + - (prob_0 as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + *(*rc).probs[(*rc).pos as usize] = prob_0; + } + 2 => { + (*rc).range >>= 1 as ::core::ffi::c_int; + } + 3 => { + (*rc).range >>= 1 as ::core::ffi::c_int; + (*rc).low = (*rc).low.wrapping_add((*rc).range as uint64_t); + } + 4 => { + (*rc).range = UINT32_MAX as uint32_t; + loop { + if rc_shift_low(rc, out, out_pos, out_size) { + return true_0 != 0; + } + (*rc).pos = (*rc).pos.wrapping_add(1); + if !((*rc).pos < (*rc).count) { + break; + } + } + rc_reset(rc); + return false_0 != 0; + } + _ => {} + } + (*rc).pos = (*rc).pos.wrapping_add(1); + } + (*rc).count = 0 as size_t; + (*rc).pos = 0 as size_t; + return false_0 != 0; +} +#[inline] +unsafe extern "C" fn rc_encode_dummy( + mut rc: *const lzma_range_encoder, + mut out_limit: uint64_t, +) -> bool { + let mut low: uint64_t = (*rc).low; + let mut cache_size: uint64_t = (*rc).cache_size; + let mut range: uint32_t = (*rc).range; + let mut cache: uint8_t = (*rc).cache; + let mut out_pos: uint64_t = (*rc).out_total; + let mut pos: size_t = (*rc).pos; + loop { + if range < RC_TOP_VALUE as uint32_t { + if rc_shift_low_dummy( + &raw mut low, + &raw mut cache_size, + &raw mut cache, + &raw mut out_pos, + out_limit, + ) { + return true_0 != 0; + } + range <<= RC_SHIFT_BITS; + } + if pos == (*rc).count { + break; + } + match (*rc).symbols[pos as usize] as ::core::ffi::c_uint { + 0 => { + let mut prob: probability = *(*rc).probs[pos as usize]; + range = (range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(prob as uint32_t); + } + 1 => { + let mut prob_0: probability = *(*rc).probs[pos as usize]; + let bound: uint32_t = (prob_0 as uint32_t) + .wrapping_mul(range >> RC_BIT_MODEL_TOTAL_BITS); + low = low.wrapping_add(bound as uint64_t); + range = range.wrapping_sub(bound); + } + 2 => { + range >>= 1 as ::core::ffi::c_int; + } + 3 => { + range >>= 1 as ::core::ffi::c_int; + low = low.wrapping_add(range as uint64_t); + } + 4 | _ => {} + } + pos = pos.wrapping_add(1); + } + pos = 0 as size_t; + while pos < 5 as size_t { + if rc_shift_low_dummy( + &raw mut low, + &raw mut cache_size, + &raw mut cache, + &raw mut out_pos, + out_limit, + ) { + return true_0 != 0; + } + pos = pos.wrapping_add(1); + } + return false_0 != 0; +} +#[inline] +unsafe extern "C" fn rc_pending(mut rc: *const lzma_range_encoder) -> uint64_t { + return (*rc).cache_size.wrapping_add(5 as uint64_t).wrapping_sub(1 as uint64_t); +} +#[inline] +unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> bool { + return (*options).lc <= LZMA_LCLP_MAX as uint32_t + && (*options).lp <= LZMA_LCLP_MAX as uint32_t + && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as uint32_t + && (*options).pb <= LZMA_PB_MAX as uint32_t; +} +pub const STATES: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const LIT_STATES: ::core::ffi::c_int = 7 as ::core::ffi::c_int; +pub const LITERAL_CODER_SIZE: ::core::ffi::c_uint = 0x300 as ::core::ffi::c_uint; +#[inline] +unsafe extern "C" fn literal_init( + mut probs: *mut probability, + mut lc: uint32_t, + mut lp: uint32_t, +) { + let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; + let mut i: size_t = 0 as size_t; + while i < coders { + *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + i = i.wrapping_add(1); + } +} +pub const MATCH_LEN_MIN: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const LEN_LOW_BITS: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +pub const LEN_LOW_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << LEN_LOW_BITS; +pub const LEN_MID_BITS: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +pub const LEN_MID_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << LEN_MID_BITS; +pub const LEN_HIGH_BITS: ::core::ffi::c_int = 8 as ::core::ffi::c_int; +pub const LEN_HIGH_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << LEN_HIGH_BITS; +pub const LEN_SYMBOLS: ::core::ffi::c_int = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + + LEN_HIGH_SYMBOLS; +pub const MATCH_LEN_MAX: ::core::ffi::c_int = MATCH_LEN_MIN + LEN_SYMBOLS + - 1 as ::core::ffi::c_int; +pub const DIST_STATES: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const DIST_SLOT_BITS: ::core::ffi::c_int = 6 as ::core::ffi::c_int; +pub const DIST_MODEL_START: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const DIST_MODEL_END: ::core::ffi::c_int = 14 as ::core::ffi::c_int; +pub const FULL_DISTANCES_BITS: ::core::ffi::c_int = DIST_MODEL_END + / 2 as ::core::ffi::c_int; +pub const FULL_DISTANCES: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const ALIGN_SIZE: ::core::ffi::c_int = (1 as ::core::ffi::c_int) << ALIGN_BITS; +pub const ALIGN_MASK: ::core::ffi::c_int = ALIGN_SIZE - 1 as ::core::ffi::c_int; +pub const REPS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const OPTS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << 12 as ::core::ffi::c_int; +pub const FASTPOS_BITS: ::core::ffi::c_int = 13 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn get_dist_slot(mut dist: uint32_t) -> uint32_t { + if dist + < (1 as uint32_t) + << FASTPOS_BITS + + (0 as ::core::ffi::c_int + + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + { + return lzma_fastpos[dist as usize] as uint32_t; + } + if dist + < (1 as uint32_t) + << FASTPOS_BITS + + (0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + { + return (lzma_fastpos[(dist + >> 0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); + } + return (lzma_fastpos[(dist + >> 0 as ::core::ffi::c_int + + 2 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (0 as ::core::ffi::c_int + + 2 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); +} +#[inline] +unsafe extern "C" fn literal_matched( + mut rc: *mut lzma_range_encoder, + mut subcoder: *mut probability, + mut match_byte: uint32_t, + mut symbol: uint32_t, +) { + let mut offset: uint32_t = 0x100 as uint32_t; + symbol = (symbol as ::core::ffi::c_uint) + .wrapping_add((1 as ::core::ffi::c_uint) << 8 as ::core::ffi::c_int) as uint32_t + as uint32_t; + loop { + match_byte <<= 1 as ::core::ffi::c_int; + let match_bit: uint32_t = match_byte & offset; + let subcoder_index: uint32_t = offset + .wrapping_add(match_bit) + .wrapping_add(symbol >> 8 as ::core::ffi::c_int); + let bit: uint32_t = symbol >> 7 as ::core::ffi::c_int & 1 as uint32_t; + rc_bit(rc, subcoder.offset(subcoder_index as isize) as *mut probability, bit); + symbol <<= 1 as ::core::ffi::c_int; + offset &= !(match_byte ^ symbol); + if !(symbol < (1 as uint32_t) << 16 as ::core::ffi::c_int) { + break; + } + }; +} +#[inline] +unsafe extern "C" fn literal( + mut coder: *mut lzma_lzma1_encoder, + mut mf: *mut lzma_mf, + mut position: uint32_t, +) { + let cur_byte: uint8_t = *(*mf) + .buffer + .offset((*mf).read_pos.wrapping_sub((*mf).read_ahead) as isize); + let mut subcoder: *mut probability = (&raw mut (*coder).literal as *mut probability) + .offset( + (3 as uint32_t) + .wrapping_mul( + ((position << 8 as ::core::ffi::c_int) + .wrapping_add( + *(*mf) + .buffer + .offset( + (*mf) + .read_pos + .wrapping_sub((*mf).read_ahead) + .wrapping_sub(1 as uint32_t) as isize, + ) as uint32_t, + ) & (*coder).literal_mask) << (*coder).literal_context_bits, + ) as isize, + ); + if ((*coder).state as ::core::ffi::c_uint) < LIT_STATES as ::core::ffi::c_uint { + (*coder).state = (if (*coder).state as ::core::ffi::c_uint + <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + { + STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + } else { + ((*coder).state as ::core::ffi::c_uint) + .wrapping_sub(3 as ::core::ffi::c_uint) + }) as lzma_lzma_state; + rc_bittree(&raw mut (*coder).rc, subcoder, 8 as uint32_t, cur_byte as uint32_t); + } else { + (*coder).state = (if (*coder).state as ::core::ffi::c_uint + <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint + { + ((*coder).state as ::core::ffi::c_uint) + .wrapping_sub(3 as ::core::ffi::c_uint) + } else { + ((*coder).state as ::core::ffi::c_uint) + .wrapping_sub(6 as ::core::ffi::c_uint) + }) as lzma_lzma_state; + let match_byte: uint8_t = *(*mf) + .buffer + .offset( + (*mf) + .read_pos + .wrapping_sub((*coder).reps[0 as ::core::ffi::c_int as usize]) + .wrapping_sub(1 as uint32_t) + .wrapping_sub((*mf).read_ahead) as isize, + ); + literal_matched( + &raw mut (*coder).rc, + subcoder, + match_byte as uint32_t, + cur_byte as uint32_t, + ); + }; +} +unsafe extern "C" fn length_update_prices( + mut lc: *mut lzma_length_encoder, + pos_state: uint32_t, +) { + let table_size: uint32_t = (*lc).table_size; + (*lc).counters[pos_state as usize] = table_size; + let a0: uint32_t = rc_bit_0_price((*lc).choice) as uint32_t; + let a1: uint32_t = rc_bit_1_price((*lc).choice) as uint32_t; + let b0: uint32_t = a1.wrapping_add(rc_bit_0_price((*lc).choice2) as uint32_t); + let b1: uint32_t = a1.wrapping_add(rc_bit_1_price((*lc).choice2) as uint32_t); + let prices: *mut uint32_t = &raw mut *(&raw mut (*lc).prices as *mut [uint32_t; 272]) + .offset(pos_state as isize) as *mut uint32_t; + let mut i: uint32_t = 0; + i = 0 as uint32_t; + while i < table_size && i < LEN_LOW_SYMBOLS as uint32_t { + *prices.offset(i as isize) = a0 + .wrapping_add( + rc_bittree_price( + &raw mut *(&raw mut (*lc).low as *mut [probability; 8]) + .offset(pos_state as isize) as *mut probability, + LEN_LOW_BITS as uint32_t, + i, + ), + ); + i = i.wrapping_add(1); + } + while i < table_size && i < (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as uint32_t { + *prices.offset(i as isize) = b0 + .wrapping_add( + rc_bittree_price( + &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]) + .offset(pos_state as isize) as *mut probability, + LEN_MID_BITS as uint32_t, + i.wrapping_sub(LEN_LOW_SYMBOLS as uint32_t), + ), + ); + i = i.wrapping_add(1); + } + while i < table_size { + *prices.offset(i as isize) = b1 + .wrapping_add( + rc_bittree_price( + &raw mut (*lc).high as *mut probability, + LEN_HIGH_BITS as uint32_t, + i + .wrapping_sub(LEN_LOW_SYMBOLS as uint32_t) + .wrapping_sub(LEN_MID_SYMBOLS as uint32_t), + ), + ); + i = i.wrapping_add(1); + } +} +#[inline] +unsafe extern "C" fn length( + mut rc: *mut lzma_range_encoder, + mut lc: *mut lzma_length_encoder, + pos_state: uint32_t, + mut len: uint32_t, + fast_mode: bool, +) { + len = len.wrapping_sub(MATCH_LEN_MIN as uint32_t); + if len < LEN_LOW_SYMBOLS as uint32_t { + rc_bit(rc, &raw mut (*lc).choice, 0 as uint32_t); + rc_bittree( + rc, + &raw mut *(&raw mut (*lc).low as *mut [probability; 8]) + .offset(pos_state as isize) as *mut probability, + LEN_LOW_BITS as uint32_t, + len, + ); + } else { + rc_bit(rc, &raw mut (*lc).choice, 1 as uint32_t); + len = len.wrapping_sub(LEN_LOW_SYMBOLS as uint32_t); + if len < LEN_MID_SYMBOLS as uint32_t { + rc_bit(rc, &raw mut (*lc).choice2, 0 as uint32_t); + rc_bittree( + rc, + &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]) + .offset(pos_state as isize) as *mut probability, + LEN_MID_BITS as uint32_t, + len, + ); + } else { + rc_bit(rc, &raw mut (*lc).choice2, 1 as uint32_t); + len = len.wrapping_sub(LEN_MID_SYMBOLS as uint32_t); + rc_bittree( + rc, + &raw mut (*lc).high as *mut probability, + LEN_HIGH_BITS as uint32_t, + len, + ); + } + } + if !fast_mode { + (*lc).counters[pos_state as usize] = (*lc) + .counters[pos_state as usize] + .wrapping_sub(1); + if (*lc).counters[pos_state as usize] == 0 as uint32_t { + length_update_prices(lc, pos_state); + } + } +} +#[inline] +unsafe extern "C" fn match_0( + mut coder: *mut lzma_lzma1_encoder, + pos_state: uint32_t, + distance: uint32_t, + len: uint32_t, +) { + (*coder).state = (if ((*coder).state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_MATCH as ::core::ffi::c_int + } else { + STATE_NONLIT_MATCH as ::core::ffi::c_int + }) as lzma_lzma_state; + length( + &raw mut (*coder).rc, + &raw mut (*coder).match_len_encoder, + pos_state, + len, + (*coder).fast_mode, + ); + let dist_slot: uint32_t = get_dist_slot(distance) as uint32_t; + let dist_state: uint32_t = if len < (DIST_STATES + MATCH_LEN_MIN) as uint32_t { + len.wrapping_sub(MATCH_LEN_MIN as uint32_t) + } else { + (DIST_STATES - 1 as ::core::ffi::c_int) as uint32_t + }; + rc_bittree( + &raw mut (*coder).rc, + &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) + .offset(dist_state as isize) as *mut probability, + DIST_SLOT_BITS as uint32_t, + dist_slot, + ); + if dist_slot >= DIST_MODEL_START as uint32_t { + let footer_bits: uint32_t = (dist_slot >> 1 as ::core::ffi::c_int) + .wrapping_sub(1 as uint32_t); + let base: uint32_t = (2 as uint32_t | dist_slot & 1 as uint32_t) << footer_bits; + let dist_reduced: uint32_t = distance.wrapping_sub(base); + if dist_slot < DIST_MODEL_END as uint32_t { + rc_bittree_reverse( + &raw mut (*coder).rc, + (&raw mut (*coder).dist_special as *mut probability) + .offset(base as isize) + .offset(-(dist_slot as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)), + footer_bits, + dist_reduced, + ); + } else { + rc_direct( + &raw mut (*coder).rc, + dist_reduced >> ALIGN_BITS, + footer_bits.wrapping_sub(ALIGN_BITS as uint32_t), + ); + rc_bittree_reverse( + &raw mut (*coder).rc, + &raw mut (*coder).dist_align as *mut probability, + ALIGN_BITS as uint32_t, + dist_reduced & ALIGN_MASK as uint32_t, + ); + (*coder).align_price_count = (*coder).align_price_count.wrapping_add(1); + } + } + (*coder).reps[3 as ::core::ffi::c_int as usize] = (*coder) + .reps[2 as ::core::ffi::c_int as usize]; + (*coder).reps[2 as ::core::ffi::c_int as usize] = (*coder) + .reps[1 as ::core::ffi::c_int as usize]; + (*coder).reps[1 as ::core::ffi::c_int as usize] = (*coder) + .reps[0 as ::core::ffi::c_int as usize]; + (*coder).reps[0 as ::core::ffi::c_int as usize] = distance; + (*coder).match_price_count = (*coder).match_price_count.wrapping_add(1); +} +#[inline] +unsafe extern "C" fn rep_match( + mut coder: *mut lzma_lzma1_encoder, + pos_state: uint32_t, + rep: uint32_t, + len: uint32_t, +) { + if rep == 0 as uint32_t { + rc_bit( + &raw mut (*coder).rc, + (&raw mut (*coder).is_rep0 as *mut probability) + .offset((*coder).state as isize) as *mut probability, + 0 as uint32_t, + ); + rc_bit( + &raw mut (*coder).rc, + (&raw mut *(&raw mut (*coder).is_rep0_long as *mut [probability; 16]) + .offset((*coder).state as isize) as *mut probability) + .offset(pos_state as isize) as *mut probability, + (len != 1 as uint32_t) as ::core::ffi::c_int as uint32_t, + ); + } else { + let distance: uint32_t = (*coder).reps[rep as usize]; + rc_bit( + &raw mut (*coder).rc, + (&raw mut (*coder).is_rep0 as *mut probability) + .offset((*coder).state as isize) as *mut probability, + 1 as uint32_t, + ); + if rep == 1 as uint32_t { + rc_bit( + &raw mut (*coder).rc, + (&raw mut (*coder).is_rep1 as *mut probability) + .offset((*coder).state as isize) as *mut probability, + 0 as uint32_t, + ); + } else { + rc_bit( + &raw mut (*coder).rc, + (&raw mut (*coder).is_rep1 as *mut probability) + .offset((*coder).state as isize) as *mut probability, + 1 as uint32_t, + ); + rc_bit( + &raw mut (*coder).rc, + (&raw mut (*coder).is_rep2 as *mut probability) + .offset((*coder).state as isize) as *mut probability, + rep.wrapping_sub(2 as uint32_t), + ); + if rep == 3 as uint32_t { + (*coder).reps[3 as ::core::ffi::c_int as usize] = (*coder) + .reps[2 as ::core::ffi::c_int as usize]; + } + (*coder).reps[2 as ::core::ffi::c_int as usize] = (*coder) + .reps[1 as ::core::ffi::c_int as usize]; + } + (*coder).reps[1 as ::core::ffi::c_int as usize] = (*coder) + .reps[0 as ::core::ffi::c_int as usize]; + (*coder).reps[0 as ::core::ffi::c_int as usize] = distance; + } + if len == 1 as uint32_t { + (*coder).state = (if ((*coder).state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_SHORTREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as lzma_lzma_state; + } else { + length( + &raw mut (*coder).rc, + &raw mut (*coder).rep_len_encoder, + pos_state, + len, + (*coder).fast_mode, + ); + (*coder).state = (if ((*coder).state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_LONGREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as lzma_lzma_state; + }; +} +unsafe extern "C" fn encode_symbol( + mut coder: *mut lzma_lzma1_encoder, + mut mf: *mut lzma_mf, + mut back: uint32_t, + mut len: uint32_t, + mut position: uint32_t, +) { + let pos_state: uint32_t = position & (*coder).pos_mask; + if back == UINT32_MAX as uint32_t { + rc_bit( + &raw mut (*coder).rc, + (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) + .offset((*coder).state as isize) as *mut probability) + .offset(pos_state as isize) as *mut probability, + 0 as uint32_t, + ); + literal(coder, mf, position); + } else { + rc_bit( + &raw mut (*coder).rc, + (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) + .offset((*coder).state as isize) as *mut probability) + .offset(pos_state as isize) as *mut probability, + 1 as uint32_t, + ); + if back < REPS as uint32_t { + rc_bit( + &raw mut (*coder).rc, + (&raw mut (*coder).is_rep as *mut probability) + .offset((*coder).state as isize) as *mut probability, + 1 as uint32_t, + ); + rep_match(coder, pos_state, back, len); + } else { + rc_bit( + &raw mut (*coder).rc, + (&raw mut (*coder).is_rep as *mut probability) + .offset((*coder).state as isize) as *mut probability, + 0 as uint32_t, + ); + match_0(coder, pos_state, back.wrapping_sub(REPS as uint32_t), len); + } + } + (*mf).read_ahead = (*mf).read_ahead.wrapping_sub(len); +} +unsafe extern "C" fn encode_init( + mut coder: *mut lzma_lzma1_encoder, + mut mf: *mut lzma_mf, +) -> bool { + if (*mf).read_pos == (*mf).read_limit { + if (*mf).action as ::core::ffi::c_uint + == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint + { + return false_0 != 0; + } + } else { + mf_skip(mf, 1 as uint32_t); + (*mf).read_ahead = 0 as uint32_t; + rc_bit( + &raw mut (*coder).rc, + (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) + .offset(0 as ::core::ffi::c_int as isize) as *mut probability) + .offset(0 as ::core::ffi::c_int as isize) as *mut probability, + 0 as uint32_t, + ); + rc_bittree( + &raw mut (*coder).rc, + (&raw mut (*coder).literal as *mut probability) + .offset(0 as ::core::ffi::c_int as isize), + 8 as uint32_t, + *(*mf).buffer.offset(0 as ::core::ffi::c_int as isize) as uint32_t, + ); + (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(1); + } + (*coder).is_initialized = true_0 != 0; + return true_0 != 0; +} +unsafe extern "C" fn encode_eopm( + mut coder: *mut lzma_lzma1_encoder, + mut position: uint32_t, +) { + let pos_state: uint32_t = position & (*coder).pos_mask; + rc_bit( + &raw mut (*coder).rc, + (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) + .offset((*coder).state as isize) as *mut probability) + .offset(pos_state as isize) as *mut probability, + 1 as uint32_t, + ); + rc_bit( + &raw mut (*coder).rc, + (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) + as *mut probability, + 0 as uint32_t, + ); + match_0(coder, pos_state, UINT32_MAX as uint32_t, MATCH_LEN_MIN as uint32_t); +} +pub const LOOP_INPUT_MAX: ::core::ffi::c_int = OPTS + 1 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_encode( + mut coder: *mut lzma_lzma1_encoder, + mut mf: *mut lzma_mf, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut limit: uint32_t, +) -> lzma_ret { + if !(*coder).is_initialized && !encode_init(coder, mf) { + return LZMA_OK; + } + if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { + return LZMA_OK; + } + if (*coder).is_flushed { + return LZMA_STREAM_END; + } + while !(limit != UINT32_MAX as uint32_t + && ((*mf).read_pos.wrapping_sub((*mf).read_ahead) >= limit + || (*out_pos as uint64_t).wrapping_add(rc_pending(&raw mut (*coder).rc)) + >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX as ::core::ffi::c_uint) + as uint64_t)) + { + if (*mf).read_pos >= (*mf).read_limit { + if (*mf).action as ::core::ffi::c_uint + == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_OK; + } + if (*mf).read_ahead == 0 as uint32_t { + break; + } + } + let mut len: uint32_t = 0; + let mut back: uint32_t = 0; + if (*coder).fast_mode { + lzma_lzma_optimum_fast(coder, mf, &raw mut back, &raw mut len); + } else { + lzma_lzma_optimum_normal( + coder, + mf, + &raw mut back, + &raw mut len, + (*coder).uncomp_size as uint32_t, + ); + } + encode_symbol(coder, mf, back, len, (*coder).uncomp_size as uint32_t); + if (*coder).out_limit != 0 as uint64_t + && rc_encode_dummy(&raw mut (*coder).rc, (*coder).out_limit) + as ::core::ffi::c_int != 0 + { + rc_forget(&raw mut (*coder).rc); + break; + } else { + (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(len as uint64_t); + if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { + return LZMA_OK; + } + } + } + if !(*coder).uncomp_size_ptr.is_null() { + *(*coder).uncomp_size_ptr = (*coder).uncomp_size; + } + if (*coder).use_eopm { + encode_eopm(coder, (*coder).uncomp_size as uint32_t); + } + rc_flush(&raw mut (*coder).rc); + if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { + (*coder).is_flushed = true_0 != 0; + return LZMA_OK; + } + return LZMA_STREAM_END; +} +unsafe extern "C" fn lzma_encode( + mut coder: *mut ::core::ffi::c_void, + mut mf: *mut lzma_mf, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, +) -> lzma_ret { + if ((*mf).action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint) + as ::core::ffi::c_int as ::core::ffi::c_long != 0 + { + return LZMA_OPTIONS_ERROR; + } + return lzma_lzma_encode( + coder as *mut lzma_lzma1_encoder, + mf, + out, + out_pos, + out_size, + UINT32_MAX as uint32_t, + ); +} +unsafe extern "C" fn lzma_lzma_set_out_limit( + mut coder_ptr: *mut ::core::ffi::c_void, + mut uncomp_size: *mut uint64_t, + mut out_limit: uint64_t, +) -> lzma_ret { + if out_limit < 6 as uint64_t { + return LZMA_BUF_ERROR; + } + let mut coder: *mut lzma_lzma1_encoder = coder_ptr as *mut lzma_lzma1_encoder; + (*coder).out_limit = out_limit; + (*coder).uncomp_size_ptr = uncomp_size; + (*coder).use_eopm = false_0 != 0; + return LZMA_OK; +} +unsafe extern "C" fn is_options_valid(mut options: *const lzma_options_lzma) -> bool { + return is_lclppb_valid(options) as ::core::ffi::c_int != 0 + && (*options).nice_len >= MATCH_LEN_MIN as uint32_t + && (*options).nice_len <= MATCH_LEN_MAX as uint32_t + && ((*options).mode as ::core::ffi::c_uint + == LZMA_MODE_FAST as ::core::ffi::c_int as ::core::ffi::c_uint + || (*options).mode as ::core::ffi::c_uint + == LZMA_MODE_NORMAL as ::core::ffi::c_int as ::core::ffi::c_uint); +} +unsafe extern "C" fn set_lz_options( + mut lz_options: *mut lzma_lz_options, + mut options: *const lzma_options_lzma, +) { + (*lz_options).before_size = OPTS as size_t; + (*lz_options).dict_size = (*options).dict_size as size_t; + (*lz_options).after_size = LOOP_INPUT_MAX as size_t; + (*lz_options).match_len_max = MATCH_LEN_MAX as size_t; + (*lz_options).nice_len = (if mf_get_hash_bytes((*options).mf) > (*options).nice_len { + mf_get_hash_bytes((*options).mf) + } else { + (*options).nice_len + }) as size_t; + (*lz_options).match_finder = (*options).mf; + (*lz_options).depth = (*options).depth; + (*lz_options).preset_dict = (*options).preset_dict; + (*lz_options).preset_dict_size = (*options).preset_dict_size; +} +unsafe extern "C" fn length_encoder_reset( + mut lencoder: *mut lzma_length_encoder, + num_pos_states: uint32_t, + fast_mode: bool, +) { + (*lencoder).choice = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) as probability; + (*lencoder).choice2 = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) as probability; + let mut pos_state: size_t = 0 as size_t; + while pos_state < num_pos_states as size_t { + let mut bt_i: uint32_t = 0 as uint32_t; + while bt_i < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t { + (*lencoder).low[pos_state as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i = bt_i.wrapping_add(1); + } + let mut bt_i_0: uint32_t = 0 as uint32_t; + while bt_i_0 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t + { + (*lencoder).mid[pos_state as usize][bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_0 = bt_i_0.wrapping_add(1); + } + pos_state = pos_state.wrapping_add(1); + } + let mut bt_i_1: uint32_t = 0 as uint32_t; + while bt_i_1 < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t { + (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_1 = bt_i_1.wrapping_add(1); + } + if !fast_mode { + let mut pos_state_0: uint32_t = 0 as uint32_t; + while pos_state_0 < num_pos_states { + length_update_prices(lencoder, pos_state_0); + pos_state_0 = pos_state_0.wrapping_add(1); + } + } +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_encoder_reset( + mut coder: *mut lzma_lzma1_encoder, + mut options: *const lzma_options_lzma, +) -> lzma_ret { + if !is_options_valid(options) { + return LZMA_OPTIONS_ERROR; + } + (*coder).pos_mask = ((1 as ::core::ffi::c_uint) << (*options).pb) + .wrapping_sub(1 as ::core::ffi::c_uint) as uint32_t; + (*coder).literal_context_bits = (*options).lc; + (*coder).literal_mask = ((0x100 as ::core::ffi::c_uint) << (*options).lp) + .wrapping_sub(0x100 as ::core::ffi::c_uint >> (*options).lc) as uint32_t; + rc_reset(&raw mut (*coder).rc); + (*coder).state = STATE_LIT_LIT; + let mut i: size_t = 0 as size_t; + while i < REPS as size_t { + (*coder).reps[i as usize] = 0 as uint32_t; + i = i.wrapping_add(1); + } + literal_init( + &raw mut (*coder).literal as *mut probability, + (*options).lc, + (*options).lp, + ); + let mut i_0: size_t = 0 as size_t; + while i_0 < STATES as size_t { + let mut j: size_t = 0 as size_t; + while j <= (*coder).pos_mask as size_t { + (*coder).is_match[i_0 as usize][j as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + (*coder).is_rep0_long[i_0 as usize][j as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + j = j.wrapping_add(1); + } + (*coder).is_rep[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).is_rep0[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).is_rep1[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + (*coder).is_rep2[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) + as probability; + i_0 = i_0.wrapping_add(1); + } + let mut i_1: size_t = 0 as size_t; + while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as size_t { + (*coder).dist_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + i_1 = i_1.wrapping_add(1); + } + let mut i_2: size_t = 0 as size_t; + while i_2 < DIST_STATES as size_t { + let mut bt_i: uint32_t = 0 as uint32_t; + while bt_i < ((1 as ::core::ffi::c_int) << 6 as ::core::ffi::c_int) as uint32_t { + (*coder).dist_slot[i_2 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i = bt_i.wrapping_add(1); + } + i_2 = i_2.wrapping_add(1); + } + let mut bt_i_0: uint32_t = 0 as uint32_t; + while bt_i_0 < ((1 as ::core::ffi::c_int) << 4 as ::core::ffi::c_int) as uint32_t { + (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL + >> 1 as ::core::ffi::c_int) as probability; + bt_i_0 = bt_i_0.wrapping_add(1); + } + length_encoder_reset( + &raw mut (*coder).match_len_encoder, + (1 as uint32_t) << (*options).pb, + (*coder).fast_mode, + ); + length_encoder_reset( + &raw mut (*coder).rep_len_encoder, + (1 as uint32_t) << (*options).pb, + (*coder).fast_mode, + ); + (*coder).match_price_count = UINT32_MAX.wrapping_div(2 as ::core::ffi::c_uint) + as uint32_t; + (*coder).align_price_count = UINT32_MAX.wrapping_div(2 as ::core::ffi::c_uint) + as uint32_t; + (*coder).opts_end_index = 0 as uint32_t; + (*coder).opts_current_index = 0 as uint32_t; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_encoder_create( + mut coder_ptr: *mut *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut id: lzma_vli, + mut options: *const lzma_options_lzma, + mut lz_options: *mut lzma_lz_options, +) -> lzma_ret { + if (*coder_ptr).is_null() { + *coder_ptr = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ); + if (*coder_ptr).is_null() { + return LZMA_MEM_ERROR; + } + } + let mut coder: *mut lzma_lzma1_encoder = *coder_ptr as *mut lzma_lzma1_encoder; + match (*options).mode as ::core::ffi::c_uint { + 1 => { + (*coder).fast_mode = true_0 != 0; + } + 2 => { + (*coder).fast_mode = false_0 != 0; + if (*options).dict_size + > ((1 as uint32_t) << 30 as ::core::ffi::c_int) + .wrapping_add((1 as uint32_t) << 29 as ::core::ffi::c_int) + { + return LZMA_OPTIONS_ERROR; + } + let mut log_size: uint32_t = 0 as uint32_t; + while (1 as uint32_t) << log_size < (*options).dict_size { + log_size = log_size.wrapping_add(1); + } + (*coder).dist_table_size = log_size.wrapping_mul(2 as uint32_t); + let nice_len: uint32_t = if mf_get_hash_bytes((*options).mf) + > (*options).nice_len + { + mf_get_hash_bytes((*options).mf) as uint32_t + } else { + (*options).nice_len + }; + (*coder).match_len_encoder.table_size = nice_len + .wrapping_add(1 as uint32_t) + .wrapping_sub(MATCH_LEN_MIN as uint32_t); + (*coder).rep_len_encoder.table_size = nice_len + .wrapping_add(1 as uint32_t) + .wrapping_sub(MATCH_LEN_MIN as uint32_t); + } + _ => return LZMA_OPTIONS_ERROR, + } + (*coder).is_initialized = !(*options).preset_dict.is_null() + && (*options).preset_dict_size > 0 as uint32_t; + (*coder).is_flushed = false_0 != 0; + (*coder).uncomp_size = 0 as uint64_t; + (*coder).uncomp_size_ptr = ::core::ptr::null_mut::(); + (*coder).out_limit = 0 as uint64_t; + (*coder).use_eopm = id == LZMA_FILTER_LZMA1 as lzma_vli; + if id == LZMA_FILTER_LZMA1EXT as lzma_vli { + if (*options).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t) != 0 { + return LZMA_OPTIONS_ERROR; + } + (*coder).use_eopm = (*options).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t + != 0 as uint32_t; + } + set_lz_options(lz_options, options); + return lzma_lzma_encoder_reset(coder, options); +} +unsafe extern "C" fn lzma_encoder_init( + mut lz: *mut lzma_lz_encoder, + mut allocator: *const lzma_allocator, + mut id: lzma_vli, + mut options: *const ::core::ffi::c_void, + mut lz_options: *mut lzma_lz_options, +) -> lzma_ret { + if options.is_null() { + return LZMA_PROG_ERROR; + } + (*lz).code = Some( + lzma_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_mf, + *mut uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut lzma_mf, + *mut uint8_t, + *mut size_t, + size_t, + ) -> lzma_ret, + >; + (*lz).set_out_limit = Some( + lzma_lzma_set_out_limit + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >; + return lzma_lzma_encoder_create( + &raw mut (*lz).coder, + allocator, + id, + options as *const lzma_options_lzma, + lz_options, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return lzma_lz_encoder_init( + next, + allocator, + filters, + Some( + lzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_lz_encoder, + *const lzma_allocator, + lzma_vli, + *const ::core::ffi::c_void, + *mut lzma_lz_options, + ) -> lzma_ret, + ), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_encoder_memusage( + mut options: *const ::core::ffi::c_void, +) -> uint64_t { + if !is_options_valid(options as *const lzma_options_lzma) { + return UINT64_MAX as uint64_t; + } + let mut lz_options: lzma_lz_options = lzma_lz_options { + before_size: 0, + dict_size: 0, + after_size: 0, + match_len_max: 0, + nice_len: 0, + match_finder: 0 as lzma_match_finder, + depth: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + }; + set_lz_options(&raw mut lz_options, options as *const lzma_options_lzma); + let lz_memusage: uint64_t = lzma_lz_encoder_memusage(&raw mut lz_options) + as uint64_t; + if lz_memusage == UINT64_MAX as uint64_t { + return UINT64_MAX as uint64_t; + } + return (::core::mem::size_of::() as uint64_t) + .wrapping_add(lz_memusage); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_lclppb_encode( + mut options: *const lzma_options_lzma, + mut byte: *mut uint8_t, +) -> bool { + if !is_lclppb_valid(options) { + return true_0 != 0; + } + *byte = (*options) + .pb + .wrapping_mul(5 as uint32_t) + .wrapping_add((*options).lp) + .wrapping_mul(9 as uint32_t) + .wrapping_add((*options).lc) as uint8_t; + return false_0 != 0; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_props_encode( + mut options: *const ::core::ffi::c_void, + mut out: *mut uint8_t, +) -> lzma_ret { + if options.is_null() { + return LZMA_PROG_ERROR; + } + let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; + if lzma_lzma_lclppb_encode(opt, out) { + return LZMA_PROG_ERROR; + } + write32le(out.offset(1 as ::core::ffi::c_int as isize), (*opt).dict_size); + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_mode_is_supported(mut mode: lzma_mode) -> lzma_bool { + return (mode as ::core::ffi::c_uint + == LZMA_MODE_FAST as ::core::ffi::c_int as ::core::ffi::c_uint + || mode as ::core::ffi::c_uint + == LZMA_MODE_NORMAL as ::core::ffi::c_int as ::core::ffi::c_uint) + as ::core::ffi::c_int as lzma_bool; +} diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs new file mode 100644 index 00000000..19037dfd --- /dev/null +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -0,0 +1,366 @@ +extern "C" { + fn memcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: size_t, + ) -> ::core::ffi::c_int; + fn lzma_mf_find( + mf: *mut lzma_mf, + count: *mut uint32_t, + matches: *mut lzma_match, + ) -> uint32_t; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_match { + pub len: uint32_t, + pub dist: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mf_s { + pub buffer: *mut uint8_t, + pub size: uint32_t, + pub keep_size_before: uint32_t, + pub keep_size_after: uint32_t, + pub offset: uint32_t, + pub read_pos: uint32_t, + pub read_ahead: uint32_t, + pub read_limit: uint32_t, + pub write_pos: uint32_t, + pub pending: uint32_t, + pub find: Option uint32_t>, + pub skip: Option ()>, + pub hash: *mut uint32_t, + pub son: *mut uint32_t, + pub cyclic_pos: uint32_t, + pub cyclic_size: uint32_t, + pub hash_mask: uint32_t, + pub depth: uint32_t, + pub nice_len: uint32_t, + pub match_len_max: uint32_t, + pub action: lzma_action, + pub hash_count: uint32_t, + pub sons_count: uint32_t, +} +pub type lzma_mf = lzma_mf_s; +pub type probability = uint16_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_range_encoder { + pub low: uint64_t, + pub cache_size: uint64_t, + pub range: uint32_t, + pub cache: uint8_t, + pub out_total: uint64_t, + pub count: size_t, + pub pos: size_t, + pub symbols: [C2RustUnnamed; 53], + pub probs: [*mut probability; 53], +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const RC_FLUSH: C2RustUnnamed = 4; +pub const RC_DIRECT_1: C2RustUnnamed = 3; +pub const RC_DIRECT_0: C2RustUnnamed = 2; +pub const RC_BIT_1: C2RustUnnamed = 1; +pub const RC_BIT_0: C2RustUnnamed = 0; +pub type lzma_lzma_state = ::core::ffi::c_uint; +pub const STATE_NONLIT_REP: lzma_lzma_state = 11; +pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; +pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; +pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; +pub const STATE_LIT_MATCH: lzma_lzma_state = 7; +pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; +pub const STATE_REP_LIT: lzma_lzma_state = 5; +pub const STATE_MATCH_LIT: lzma_lzma_state = 4; +pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; +pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; +pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; +pub const STATE_LIT_LIT: lzma_lzma_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lzma1_encoder_s { + pub rc: lzma_range_encoder, + pub uncomp_size: uint64_t, + pub out_limit: uint64_t, + pub uncomp_size_ptr: *mut uint64_t, + pub state: lzma_lzma_state, + pub reps: [uint32_t; 4], + pub matches: [lzma_match; 274], + pub matches_count: uint32_t, + pub longest_match_length: uint32_t, + pub fast_mode: bool, + pub is_initialized: bool, + pub is_flushed: bool, + pub use_eopm: bool, + pub pos_mask: uint32_t, + pub literal_context_bits: uint32_t, + pub literal_mask: uint32_t, + pub literal: [probability; 12288], + pub is_match: [[probability; 16]; 12], + pub is_rep: [probability; 12], + pub is_rep0: [probability; 12], + pub is_rep1: [probability; 12], + pub is_rep2: [probability; 12], + pub is_rep0_long: [[probability; 16]; 12], + pub dist_slot: [[probability; 64]; 4], + pub dist_special: [probability; 114], + pub dist_align: [probability; 16], + pub match_len_encoder: lzma_length_encoder, + pub rep_len_encoder: lzma_length_encoder, + pub dist_slot_prices: [[uint32_t; 64]; 4], + pub dist_prices: [[uint32_t; 128]; 4], + pub dist_table_size: uint32_t, + pub match_price_count: uint32_t, + pub align_prices: [uint32_t; 16], + pub align_price_count: uint32_t, + pub opts_end_index: uint32_t, + pub opts_current_index: uint32_t, + pub opts: [lzma_optimal; 4096], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_optimal { + pub state: lzma_lzma_state, + pub prev_1_is_literal: bool, + pub prev_2: bool, + pub pos_prev_2: uint32_t, + pub back_prev_2: uint32_t, + pub price: uint32_t, + pub pos_prev: uint32_t, + pub back_prev: uint32_t, + pub backs: [uint32_t; 4], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_length_encoder { + pub choice: probability, + pub choice2: probability, + pub low: [[probability; 8]; 16], + pub mid: [[probability; 8]; 16], + pub high: [probability; 256], + pub prices: [[uint32_t; 272]; 16], + pub table_size: uint32_t, + pub counters: [uint32_t; 16], +} +pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +#[inline] +unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const uint8_t { + return (*mf).buffer.offset((*mf).read_pos as isize); +} +#[inline] +unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> uint32_t { + return (*mf).write_pos.wrapping_sub((*mf).read_pos); +} +#[inline] +unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { + if amount != 0 as uint32_t { + (*mf).skip.expect("non-null function pointer")(mf, amount); + (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); + } +} +pub const REPS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +#[inline(always)] +unsafe extern "C" fn lzma_memcmplen( + mut buf1: *const uint8_t, + mut buf2: *const uint8_t, + mut len: uint32_t, + mut limit: uint32_t, +) -> uint32_t { + while len < limit + && *buf1.offset(len as isize) as ::core::ffi::c_int + == *buf2.offset(len as isize) as ::core::ffi::c_int + { + len = len.wrapping_add(1); + } + return len; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_optimum_fast( + mut coder: *mut lzma_lzma1_encoder, + mut mf: *mut lzma_mf, + mut back_res: *mut uint32_t, + mut len_res: *mut uint32_t, +) { + let nice_len: uint32_t = (*mf).nice_len; + let mut len_main: uint32_t = 0; + let mut matches_count: uint32_t = 0; + if (*mf).read_ahead == 0 as uint32_t { + len_main = lzma_mf_find( + mf, + &raw mut matches_count, + &raw mut (*coder).matches as *mut lzma_match, + ); + } else { + len_main = (*coder).longest_match_length; + matches_count = (*coder).matches_count; + } + let mut buf: *const uint8_t = mf_ptr(mf).offset(-(1 as ::core::ffi::c_int as isize)); + let buf_avail: uint32_t = if mf_avail(mf).wrapping_add(1 as uint32_t) + < (2 as ::core::ffi::c_int + + (((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int)) + - 1 as ::core::ffi::c_int) as uint32_t + { + (mf_avail(mf) as uint32_t).wrapping_add(1 as uint32_t) + } else { + (2 as ::core::ffi::c_int + + (((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int)) + - 1 as ::core::ffi::c_int) as uint32_t + }; + if buf_avail < 2 as uint32_t { + *back_res = UINT32_MAX as uint32_t; + *len_res = 1 as uint32_t; + return; + } + let mut rep_len: uint32_t = 0 as uint32_t; + let mut rep_index: uint32_t = 0 as uint32_t; + let mut i: uint32_t = 0 as uint32_t; + while i < REPS as uint32_t { + let buf_back: *const uint8_t = buf + .offset(-((*coder).reps[i as usize] as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + if !(*buf.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != *buf_back.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + || *buf.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != *buf_back.offset(1 as ::core::ffi::c_int as isize) + as ::core::ffi::c_int) + { + let len: uint32_t = lzma_memcmplen(buf, buf_back, 2 as uint32_t, buf_avail) + as uint32_t; + if len >= nice_len { + *back_res = i; + *len_res = len; + mf_skip(mf, len.wrapping_sub(1 as uint32_t)); + return; + } + if len > rep_len { + rep_index = i; + rep_len = len; + } + } + i = i.wrapping_add(1); + } + if len_main >= nice_len { + *back_res = (*coder) + .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] + .dist + .wrapping_add(REPS as uint32_t); + *len_res = len_main; + mf_skip(mf, len_main.wrapping_sub(1 as uint32_t)); + return; + } + let mut back_main: uint32_t = 0 as uint32_t; + if len_main >= 2 as uint32_t { + back_main = (*coder) + .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] + .dist; + while matches_count > 1 as uint32_t + && len_main + == (*coder) + .matches[matches_count.wrapping_sub(2 as uint32_t) as usize] + .len + .wrapping_add(1 as uint32_t) + { + if !(back_main >> 7 as ::core::ffi::c_int + > (*coder) + .matches[matches_count.wrapping_sub(2 as uint32_t) as usize] + .dist) + { + break; + } + matches_count = matches_count.wrapping_sub(1); + len_main = (*coder) + .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] + .len; + back_main = (*coder) + .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] + .dist; + } + if len_main == 2 as uint32_t && back_main >= 0x80 as uint32_t { + len_main = 1 as uint32_t; + } + } + if rep_len >= 2 as uint32_t { + if rep_len.wrapping_add(1 as uint32_t) >= len_main + || rep_len.wrapping_add(2 as uint32_t) >= len_main + && back_main > (1 as uint32_t) << 9 as ::core::ffi::c_int + || rep_len.wrapping_add(3 as uint32_t) >= len_main + && back_main > (1 as uint32_t) << 15 as ::core::ffi::c_int + { + *back_res = rep_index; + *len_res = rep_len; + mf_skip(mf, rep_len.wrapping_sub(1 as uint32_t)); + return; + } + } + if len_main < 2 as uint32_t || buf_avail <= 2 as uint32_t { + *back_res = UINT32_MAX as uint32_t; + *len_res = 1 as uint32_t; + return; + } + (*coder).longest_match_length = lzma_mf_find( + mf, + &raw mut (*coder).matches_count, + &raw mut (*coder).matches as *mut lzma_match, + ); + if (*coder).longest_match_length >= 2 as uint32_t { + let new_dist: uint32_t = (*coder) + .matches[(*coder).matches_count.wrapping_sub(1 as uint32_t) as usize] + .dist; + if (*coder).longest_match_length >= len_main && new_dist < back_main + || (*coder).longest_match_length == len_main.wrapping_add(1 as uint32_t) + && !(new_dist >> 7 as ::core::ffi::c_int > back_main) + || (*coder).longest_match_length > len_main.wrapping_add(1 as uint32_t) + || (*coder).longest_match_length.wrapping_add(1 as uint32_t) >= len_main + && len_main >= 3 as uint32_t + && back_main >> 7 as ::core::ffi::c_int > new_dist + { + *back_res = UINT32_MAX as uint32_t; + *len_res = 1 as uint32_t; + return; + } + } + buf = buf.offset(1); + let limit: uint32_t = if 2 as uint32_t > len_main.wrapping_sub(1 as uint32_t) { + 2 as uint32_t + } else { + len_main.wrapping_sub(1 as uint32_t) + }; + let mut i_0: uint32_t = 0 as uint32_t; + while i_0 < REPS as uint32_t { + if memcmp( + buf as *const ::core::ffi::c_void, + buf + .offset(-((*coder).reps[i_0 as usize] as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)) + as *const ::core::ffi::c_void, + limit as size_t, + ) == 0 as ::core::ffi::c_int + { + *back_res = UINT32_MAX as uint32_t; + *len_res = 1 as uint32_t; + return; + } + i_0 = i_0.wrapping_add(1); + } + *back_res = back_main.wrapping_add(REPS as uint32_t); + *len_res = len_main; + mf_skip(mf, len_main.wrapping_sub(2 as uint32_t)); +} diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs new file mode 100644 index 00000000..ed2fbb45 --- /dev/null +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -0,0 +1,1541 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_mf_find( + mf: *mut lzma_mf, + count: *mut uint32_t, + matches: *mut lzma_match, + ) -> uint32_t; + static lzma_rc_prices: [uint8_t; 128]; + static lzma_fastpos: [uint8_t; 8192]; +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_match { + pub len: uint32_t, + pub dist: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mf_s { + pub buffer: *mut uint8_t, + pub size: uint32_t, + pub keep_size_before: uint32_t, + pub keep_size_after: uint32_t, + pub offset: uint32_t, + pub read_pos: uint32_t, + pub read_ahead: uint32_t, + pub read_limit: uint32_t, + pub write_pos: uint32_t, + pub pending: uint32_t, + pub find: Option uint32_t>, + pub skip: Option ()>, + pub hash: *mut uint32_t, + pub son: *mut uint32_t, + pub cyclic_pos: uint32_t, + pub cyclic_size: uint32_t, + pub hash_mask: uint32_t, + pub depth: uint32_t, + pub nice_len: uint32_t, + pub match_len_max: uint32_t, + pub action: lzma_action, + pub hash_count: uint32_t, + pub sons_count: uint32_t, +} +pub type lzma_mf = lzma_mf_s; +pub type probability = uint16_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_range_encoder { + pub low: uint64_t, + pub cache_size: uint64_t, + pub range: uint32_t, + pub cache: uint8_t, + pub out_total: uint64_t, + pub count: size_t, + pub pos: size_t, + pub symbols: [C2RustUnnamed; 53], + pub probs: [*mut probability; 53], +} +pub type C2RustUnnamed = ::core::ffi::c_uint; +pub const RC_FLUSH: C2RustUnnamed = 4; +pub const RC_DIRECT_1: C2RustUnnamed = 3; +pub const RC_DIRECT_0: C2RustUnnamed = 2; +pub const RC_BIT_1: C2RustUnnamed = 1; +pub const RC_BIT_0: C2RustUnnamed = 0; +pub type lzma_lzma_state = ::core::ffi::c_uint; +pub const STATE_NONLIT_REP: lzma_lzma_state = 11; +pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; +pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; +pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; +pub const STATE_LIT_MATCH: lzma_lzma_state = 7; +pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; +pub const STATE_REP_LIT: lzma_lzma_state = 5; +pub const STATE_MATCH_LIT: lzma_lzma_state = 4; +pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; +pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; +pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; +pub const STATE_LIT_LIT: lzma_lzma_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lzma1_encoder_s { + pub rc: lzma_range_encoder, + pub uncomp_size: uint64_t, + pub out_limit: uint64_t, + pub uncomp_size_ptr: *mut uint64_t, + pub state: lzma_lzma_state, + pub reps: [uint32_t; 4], + pub matches: [lzma_match; 274], + pub matches_count: uint32_t, + pub longest_match_length: uint32_t, + pub fast_mode: bool, + pub is_initialized: bool, + pub is_flushed: bool, + pub use_eopm: bool, + pub pos_mask: uint32_t, + pub literal_context_bits: uint32_t, + pub literal_mask: uint32_t, + pub literal: [probability; 12288], + pub is_match: [[probability; 16]; 12], + pub is_rep: [probability; 12], + pub is_rep0: [probability; 12], + pub is_rep1: [probability; 12], + pub is_rep2: [probability; 12], + pub is_rep0_long: [[probability; 16]; 12], + pub dist_slot: [[probability; 64]; 4], + pub dist_special: [probability; 114], + pub dist_align: [probability; 16], + pub match_len_encoder: lzma_length_encoder, + pub rep_len_encoder: lzma_length_encoder, + pub dist_slot_prices: [[uint32_t; 64]; 4], + pub dist_prices: [[uint32_t; 128]; 4], + pub dist_table_size: uint32_t, + pub match_price_count: uint32_t, + pub align_prices: [uint32_t; 16], + pub align_price_count: uint32_t, + pub opts_end_index: uint32_t, + pub opts_current_index: uint32_t, + pub opts: [lzma_optimal; 4096], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_optimal { + pub state: lzma_lzma_state, + pub prev_1_is_literal: bool, + pub prev_2: bool, + pub pos_prev_2: uint32_t, + pub back_prev_2: uint32_t, + pub price: uint32_t, + pub pos_prev: uint32_t, + pub back_prev: uint32_t, + pub backs: [uint32_t; 4], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_length_encoder { + pub choice: probability, + pub choice2: probability, + pub low: [[probability; 8]; 16], + pub mid: [[probability; 8]; 16], + pub high: [probability; 256], + pub prices: [[uint32_t; 272]; 16], + pub table_size: uint32_t, + pub counters: [uint32_t; 16], +} +pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; +pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const uint8_t { + return (*mf).buffer.offset((*mf).read_pos as isize); +} +#[inline] +unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> uint32_t { + return (*mf).write_pos.wrapping_sub((*mf).read_pos); +} +#[inline] +unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { + if amount != 0 as uint32_t { + (*mf).skip.expect("non-null function pointer")(mf, amount); + (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); + } +} +pub const RC_BIT_MODEL_TOTAL_BITS: ::core::ffi::c_int = 11 as ::core::ffi::c_int; +pub const RC_BIT_MODEL_TOTAL: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_MOVE_REDUCING_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const RC_BIT_PRICE_SHIFT_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const RC_INFINITY_PRICE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 30 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn rc_bit_price(prob: probability, bit: uint32_t) -> uint32_t { + return lzma_rc_prices[((prob as uint32_t + ^ (0 as uint32_t).wrapping_sub(bit) + & (RC_BIT_MODEL_TOTAL as uint32_t).wrapping_sub(1 as uint32_t)) + >> RC_MOVE_REDUCING_BITS) as usize] as uint32_t; +} +#[inline] +unsafe extern "C" fn rc_bit_0_price(prob: probability) -> uint32_t { + return lzma_rc_prices[(prob as ::core::ffi::c_int >> RC_MOVE_REDUCING_BITS) as usize] + as uint32_t; +} +#[inline] +unsafe extern "C" fn rc_bit_1_price(prob: probability) -> uint32_t { + return lzma_rc_prices[((prob as ::core::ffi::c_uint + ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1 as ::core::ffi::c_uint)) + >> RC_MOVE_REDUCING_BITS) as usize] as uint32_t; +} +#[inline] +unsafe extern "C" fn rc_bittree_price( + probs: *const probability, + bit_levels: uint32_t, + mut symbol: uint32_t, +) -> uint32_t { + let mut price: uint32_t = 0 as uint32_t; + symbol = (symbol as ::core::ffi::c_uint) + .wrapping_add((1 as ::core::ffi::c_uint) << bit_levels) as uint32_t as uint32_t; + loop { + let bit: uint32_t = symbol & 1 as uint32_t; + symbol >>= 1 as ::core::ffi::c_int; + price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); + if !(symbol != 1 as uint32_t) { + break; + } + } + return price; +} +#[inline] +unsafe extern "C" fn rc_bittree_reverse_price( + probs: *const probability, + mut bit_levels: uint32_t, + mut symbol: uint32_t, +) -> uint32_t { + let mut price: uint32_t = 0 as uint32_t; + let mut model_index: uint32_t = 1 as uint32_t; + loop { + let bit: uint32_t = symbol & 1 as uint32_t; + symbol >>= 1 as ::core::ffi::c_int; + price = price + .wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); + model_index = (model_index << 1 as ::core::ffi::c_int).wrapping_add(bit); + bit_levels = bit_levels.wrapping_sub(1); + if !(bit_levels != 0 as uint32_t) { + break; + } + } + return price; +} +#[inline] +unsafe extern "C" fn rc_direct_price(bits: uint32_t) -> uint32_t { + return bits << RC_BIT_PRICE_SHIFT_BITS; +} +pub const LIT_STATES: ::core::ffi::c_int = 7 as ::core::ffi::c_int; +pub const MATCH_LEN_MIN: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const DIST_STATES: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const DIST_SLOT_BITS: ::core::ffi::c_int = 6 as ::core::ffi::c_int; +pub const DIST_MODEL_START: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const DIST_MODEL_END: ::core::ffi::c_int = 14 as ::core::ffi::c_int; +pub const FULL_DISTANCES_BITS: ::core::ffi::c_int = DIST_MODEL_END + / 2 as ::core::ffi::c_int; +pub const FULL_DISTANCES: ::core::ffi::c_int = (1 as ::core::ffi::c_int) + << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const ALIGN_SIZE: ::core::ffi::c_int = (1 as ::core::ffi::c_int) << ALIGN_BITS; +pub const ALIGN_MASK: ::core::ffi::c_int = ALIGN_SIZE - 1 as ::core::ffi::c_int; +pub const REPS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const FASTPOS_BITS: ::core::ffi::c_int = 13 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn get_dist_slot(mut dist: uint32_t) -> uint32_t { + if dist + < (1 as uint32_t) + << FASTPOS_BITS + + (0 as ::core::ffi::c_int + + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + { + return lzma_fastpos[dist as usize] as uint32_t; + } + if dist + < (1 as uint32_t) + << FASTPOS_BITS + + (0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + { + return (lzma_fastpos[(dist + >> 0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (0 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); + } + return (lzma_fastpos[(dist + >> 0 as ::core::ffi::c_int + + 2 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (0 as ::core::ffi::c_int + + 2 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); +} +#[inline] +unsafe extern "C" fn get_dist_slot_2(mut dist: uint32_t) -> uint32_t { + if dist + < (1 as uint32_t) + << FASTPOS_BITS + + (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int + - 1 as ::core::ffi::c_int + + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + { + return (lzma_fastpos[(dist + >> 14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int + - 1 as ::core::ffi::c_int + + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int + - 1 as ::core::ffi::c_int + + 0 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); + } + if dist + < (1 as uint32_t) + << FASTPOS_BITS + + (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int + - 1 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + { + return (lzma_fastpos[(dist + >> 14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int + - 1 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int + - 1 as ::core::ffi::c_int + + 1 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); + } + return (lzma_fastpos[(dist + >> 14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int + + 2 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + as usize] as uint32_t) + .wrapping_add( + (2 as ::core::ffi::c_int + * (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int + - 1 as ::core::ffi::c_int + + 2 as ::core::ffi::c_int + * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + ); +} +#[inline(always)] +unsafe extern "C" fn lzma_memcmplen( + mut buf1: *const uint8_t, + mut buf2: *const uint8_t, + mut len: uint32_t, + mut limit: uint32_t, +) -> uint32_t { + while len < limit + && *buf1.offset(len as isize) as ::core::ffi::c_int + == *buf2.offset(len as isize) as ::core::ffi::c_int + { + len = len.wrapping_add(1); + } + return len; +} +unsafe extern "C" fn get_literal_price( + coder: *const lzma_lzma1_encoder, + pos: uint32_t, + prev_byte: uint32_t, + match_mode: bool, + mut match_byte: uint32_t, + mut symbol: uint32_t, +) -> uint32_t { + let subcoder: *const probability = (&raw const (*coder).literal + as *const probability) + .offset( + (3 as uint32_t) + .wrapping_mul( + ((pos << 8 as ::core::ffi::c_int).wrapping_add(prev_byte) + & (*coder).literal_mask) << (*coder).literal_context_bits, + ) as isize, + ); + let mut price: uint32_t = 0 as uint32_t; + if !match_mode { + price = rc_bittree_price(subcoder, 8 as uint32_t, symbol); + } else { + let mut offset: uint32_t = 0x100 as uint32_t; + symbol = (symbol as ::core::ffi::c_uint) + .wrapping_add((1 as ::core::ffi::c_uint) << 8 as ::core::ffi::c_int) + as uint32_t as uint32_t; + loop { + match_byte <<= 1 as ::core::ffi::c_int; + let match_bit: uint32_t = match_byte & offset; + let subcoder_index: uint32_t = offset + .wrapping_add(match_bit) + .wrapping_add(symbol >> 8 as ::core::ffi::c_int); + let bit: uint32_t = symbol >> 7 as ::core::ffi::c_int & 1 as uint32_t; + price = price + .wrapping_add( + rc_bit_price(*subcoder.offset(subcoder_index as isize), bit), + ); + symbol <<= 1 as ::core::ffi::c_int; + offset &= !(match_byte ^ symbol); + if !(symbol < (1 as uint32_t) << 16 as ::core::ffi::c_int) { + break; + } + } + } + return price; +} +#[inline] +unsafe extern "C" fn get_len_price( + lencoder: *const lzma_length_encoder, + len: uint32_t, + pos_state: uint32_t, +) -> uint32_t { + return (*lencoder) + .prices[pos_state + as usize][len.wrapping_sub(MATCH_LEN_MIN as uint32_t) as usize]; +} +#[inline] +unsafe extern "C" fn get_short_rep_price( + coder: *const lzma_lzma1_encoder, + state: lzma_lzma_state, + pos_state: uint32_t, +) -> uint32_t { + return rc_bit_0_price((*coder).is_rep0[state as usize]) + .wrapping_add( + rc_bit_0_price((*coder).is_rep0_long[state as usize][pos_state as usize]), + ); +} +#[inline] +unsafe extern "C" fn get_pure_rep_price( + coder: *const lzma_lzma1_encoder, + rep_index: uint32_t, + state: lzma_lzma_state, + mut pos_state: uint32_t, +) -> uint32_t { + let mut price: uint32_t = 0; + if rep_index == 0 as uint32_t { + price = rc_bit_0_price((*coder).is_rep0[state as usize]); + price = price + .wrapping_add( + rc_bit_1_price((*coder).is_rep0_long[state as usize][pos_state as usize]), + ); + } else { + price = rc_bit_1_price((*coder).is_rep0[state as usize]); + if rep_index == 1 as uint32_t { + price = price.wrapping_add(rc_bit_0_price((*coder).is_rep1[state as usize])); + } else { + price = price.wrapping_add(rc_bit_1_price((*coder).is_rep1[state as usize])); + price = price + .wrapping_add( + rc_bit_price( + (*coder).is_rep2[state as usize], + rep_index.wrapping_sub(2 as uint32_t), + ), + ); + } + } + return price; +} +#[inline] +unsafe extern "C" fn get_rep_price( + coder: *const lzma_lzma1_encoder, + rep_index: uint32_t, + len: uint32_t, + state: lzma_lzma_state, + pos_state: uint32_t, +) -> uint32_t { + return get_len_price(&raw const (*coder).rep_len_encoder, len, pos_state) + .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state)); +} +#[inline] +unsafe extern "C" fn get_dist_len_price( + coder: *const lzma_lzma1_encoder, + dist: uint32_t, + len: uint32_t, + pos_state: uint32_t, +) -> uint32_t { + let dist_state: uint32_t = if len < (DIST_STATES + MATCH_LEN_MIN) as uint32_t { + len.wrapping_sub(MATCH_LEN_MIN as uint32_t) + } else { + (DIST_STATES - 1 as ::core::ffi::c_int) as uint32_t + }; + let mut price: uint32_t = 0; + if dist < FULL_DISTANCES as uint32_t { + price = (*coder).dist_prices[dist_state as usize][dist as usize]; + } else { + let dist_slot: uint32_t = get_dist_slot_2(dist) as uint32_t; + price = (*coder) + .dist_slot_prices[dist_state as usize][dist_slot as usize] + .wrapping_add( + (*coder).align_prices[(dist & ALIGN_MASK as uint32_t) as usize], + ); + } + price = price + .wrapping_add( + get_len_price(&raw const (*coder).match_len_encoder, len, pos_state), + ); + return price; +} +unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { + let mut dist_state: uint32_t = 0 as uint32_t; + while dist_state < DIST_STATES as uint32_t { + let dist_slot_prices: *mut uint32_t = &raw mut *(&raw mut (*coder) + .dist_slot_prices as *mut [uint32_t; 64]) + .offset(dist_state as isize) as *mut uint32_t; + let mut dist_slot: uint32_t = 0 as uint32_t; + while dist_slot < (*coder).dist_table_size { + *dist_slot_prices.offset(dist_slot as isize) = rc_bittree_price( + &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) + .offset(dist_state as isize) as *mut probability, + DIST_SLOT_BITS as uint32_t, + dist_slot, + ); + dist_slot = dist_slot.wrapping_add(1); + } + let mut dist_slot_0: uint32_t = DIST_MODEL_END as uint32_t; + while dist_slot_0 < (*coder).dist_table_size { + let ref mut fresh1 = *dist_slot_prices.offset(dist_slot_0 as isize); + *fresh1 = (*fresh1) + .wrapping_add( + rc_direct_price( + (dist_slot_0 >> 1 as ::core::ffi::c_int) + .wrapping_sub(1 as uint32_t) + .wrapping_sub(ALIGN_BITS as uint32_t), + ), + ); + dist_slot_0 = dist_slot_0.wrapping_add(1); + } + let mut i: uint32_t = 0 as uint32_t; + while i < DIST_MODEL_START as uint32_t { + (*coder).dist_prices[dist_state as usize][i as usize] = *dist_slot_prices + .offset(i as isize); + i = i.wrapping_add(1); + } + dist_state = dist_state.wrapping_add(1); + } + let mut i_0: uint32_t = DIST_MODEL_START as uint32_t; + while i_0 < FULL_DISTANCES as uint32_t { + let dist_slot_1: uint32_t = get_dist_slot(i_0) as uint32_t; + let footer_bits: uint32_t = (dist_slot_1 >> 1 as ::core::ffi::c_int) + .wrapping_sub(1 as uint32_t); + let base: uint32_t = (2 as uint32_t | dist_slot_1 & 1 as uint32_t) + << footer_bits; + let price: uint32_t = rc_bittree_reverse_price( + (&raw mut (*coder).dist_special as *mut probability) + .offset(base as isize) + .offset(-(dist_slot_1 as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)), + footer_bits, + i_0.wrapping_sub(base), + ) as uint32_t; + let mut dist_state_0: uint32_t = 0 as uint32_t; + while dist_state_0 < DIST_STATES as uint32_t { + (*coder).dist_prices[dist_state_0 as usize][i_0 as usize] = price + .wrapping_add( + (*coder) + .dist_slot_prices[dist_state_0 as usize][dist_slot_1 as usize], + ); + dist_state_0 = dist_state_0.wrapping_add(1); + } + i_0 = i_0.wrapping_add(1); + } + (*coder).match_price_count = 0 as uint32_t; +} +unsafe extern "C" fn fill_align_prices(mut coder: *mut lzma_lzma1_encoder) { + let mut i: uint32_t = 0 as uint32_t; + while i < ALIGN_SIZE as uint32_t { + (*coder).align_prices[i as usize] = rc_bittree_reverse_price( + &raw mut (*coder).dist_align as *mut probability, + ALIGN_BITS as uint32_t, + i, + ); + i = i.wrapping_add(1); + } + (*coder).align_price_count = 0 as uint32_t; +} +#[inline] +unsafe extern "C" fn make_literal(mut optimal: *mut lzma_optimal) { + (*optimal).back_prev = UINT32_MAX as uint32_t; + (*optimal).prev_1_is_literal = false_0 != 0; +} +#[inline] +unsafe extern "C" fn make_short_rep(mut optimal: *mut lzma_optimal) { + (*optimal).back_prev = 0 as uint32_t; + (*optimal).prev_1_is_literal = false_0 != 0; +} +unsafe extern "C" fn backward( + mut coder: *mut lzma_lzma1_encoder, + mut len_res: *mut uint32_t, + mut back_res: *mut uint32_t, + mut cur: uint32_t, +) { + (*coder).opts_end_index = cur; + let mut pos_mem: uint32_t = (*coder).opts[cur as usize].pos_prev; + let mut back_mem: uint32_t = (*coder).opts[cur as usize].back_prev; + loop { + if (*coder).opts[cur as usize].prev_1_is_literal { + make_literal( + (&raw mut (*coder).opts as *mut lzma_optimal).offset(pos_mem as isize) + as *mut lzma_optimal, + ); + (*coder).opts[pos_mem as usize].pos_prev = pos_mem + .wrapping_sub(1 as uint32_t); + if (*coder).opts[cur as usize].prev_2 { + (*coder) + .opts[pos_mem.wrapping_sub(1 as uint32_t) as usize] + .prev_1_is_literal = false_0 != 0; + (*coder).opts[pos_mem.wrapping_sub(1 as uint32_t) as usize].pos_prev = (*coder) + .opts[cur as usize] + .pos_prev_2; + (*coder).opts[pos_mem.wrapping_sub(1 as uint32_t) as usize].back_prev = (*coder) + .opts[cur as usize] + .back_prev_2; + } + } + let pos_prev: uint32_t = pos_mem; + let back_cur: uint32_t = back_mem; + back_mem = (*coder).opts[pos_prev as usize].back_prev; + pos_mem = (*coder).opts[pos_prev as usize].pos_prev; + (*coder).opts[pos_prev as usize].back_prev = back_cur; + (*coder).opts[pos_prev as usize].pos_prev = cur; + cur = pos_prev; + if !(cur != 0 as uint32_t) { + break; + } + } + (*coder).opts_current_index = (*coder) + .opts[0 as ::core::ffi::c_int as usize] + .pos_prev; + *len_res = (*coder).opts[0 as ::core::ffi::c_int as usize].pos_prev; + *back_res = (*coder).opts[0 as ::core::ffi::c_int as usize].back_prev; +} +#[inline] +unsafe extern "C" fn helper1( + mut coder: *mut lzma_lzma1_encoder, + mut mf: *mut lzma_mf, + mut back_res: *mut uint32_t, + mut len_res: *mut uint32_t, + mut position: uint32_t, +) -> uint32_t { + let nice_len: uint32_t = (*mf).nice_len; + let mut len_main: uint32_t = 0; + let mut matches_count: uint32_t = 0; + if (*mf).read_ahead == 0 as uint32_t { + len_main = lzma_mf_find( + mf, + &raw mut matches_count, + &raw mut (*coder).matches as *mut lzma_match, + ); + } else { + len_main = (*coder).longest_match_length; + matches_count = (*coder).matches_count; + } + let buf_avail: uint32_t = if mf_avail(mf).wrapping_add(1 as uint32_t) + < (2 as ::core::ffi::c_int + + (((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int)) + - 1 as ::core::ffi::c_int) as uint32_t + { + (mf_avail(mf) as uint32_t).wrapping_add(1 as uint32_t) + } else { + (2 as ::core::ffi::c_int + + (((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) + + ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int)) + - 1 as ::core::ffi::c_int) as uint32_t + }; + if buf_avail < 2 as uint32_t { + *back_res = UINT32_MAX as uint32_t; + *len_res = 1 as uint32_t; + return UINT32_MAX as uint32_t; + } + let buf: *const uint8_t = mf_ptr(mf).offset(-(1 as ::core::ffi::c_int as isize)); + let mut rep_lens: [uint32_t; 4] = [0; 4]; + let mut rep_max_index: uint32_t = 0 as uint32_t; + let mut i: uint32_t = 0 as uint32_t; + while i < REPS as uint32_t { + let buf_back: *const uint8_t = buf + .offset(-((*coder).reps[i as usize] as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + if *buf.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != *buf_back.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + || *buf.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != *buf_back.offset(1 as ::core::ffi::c_int as isize) + as ::core::ffi::c_int + { + rep_lens[i as usize] = 0 as uint32_t; + } else { + rep_lens[i as usize] = lzma_memcmplen( + buf, + buf_back, + 2 as uint32_t, + buf_avail, + ); + if rep_lens[i as usize] > rep_lens[rep_max_index as usize] { + rep_max_index = i; + } + } + i = i.wrapping_add(1); + } + if rep_lens[rep_max_index as usize] >= nice_len { + *back_res = rep_max_index; + *len_res = rep_lens[rep_max_index as usize]; + mf_skip(mf, (*len_res).wrapping_sub(1 as uint32_t)); + return UINT32_MAX as uint32_t; + } + if len_main >= nice_len { + *back_res = (*coder) + .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] + .dist + .wrapping_add(REPS as uint32_t); + *len_res = len_main; + mf_skip(mf, len_main.wrapping_sub(1 as uint32_t)); + return UINT32_MAX as uint32_t; + } + let current_byte: uint8_t = *buf; + let match_byte: uint8_t = *buf + .offset(-((*coder).reps[0 as ::core::ffi::c_int as usize] as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + if len_main < 2 as uint32_t + && current_byte as ::core::ffi::c_int != match_byte as ::core::ffi::c_int + && rep_lens[rep_max_index as usize] < 2 as uint32_t + { + *back_res = UINT32_MAX as uint32_t; + *len_res = 1 as uint32_t; + return UINT32_MAX as uint32_t; + } + (*coder).opts[0 as ::core::ffi::c_int as usize].state = (*coder).state; + let pos_state: uint32_t = position & (*coder).pos_mask; + (*coder).opts[1 as ::core::ffi::c_int as usize].price = rc_bit_0_price( + (*coder).is_match[(*coder).state as usize][pos_state as usize], + ) + .wrapping_add( + get_literal_price( + coder, + position, + *buf.offset(-(1 as ::core::ffi::c_int) as isize) as uint32_t, + !(((*coder).state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint), + match_byte as uint32_t, + current_byte as uint32_t, + ), + ); + make_literal( + (&raw mut (*coder).opts as *mut lzma_optimal) + .offset(1 as ::core::ffi::c_int as isize) as *mut lzma_optimal, + ); + let match_price: uint32_t = rc_bit_1_price( + (*coder).is_match[(*coder).state as usize][pos_state as usize], + ) as uint32_t; + let rep_match_price: uint32_t = match_price + .wrapping_add( + rc_bit_1_price((*coder).is_rep[(*coder).state as usize]) as uint32_t, + ); + if match_byte as ::core::ffi::c_int == current_byte as ::core::ffi::c_int { + let short_rep_price: uint32_t = rep_match_price + .wrapping_add( + get_short_rep_price(coder, (*coder).state, pos_state) as uint32_t, + ); + if short_rep_price < (*coder).opts[1 as ::core::ffi::c_int as usize].price { + (*coder).opts[1 as ::core::ffi::c_int as usize].price = short_rep_price; + make_short_rep( + (&raw mut (*coder).opts as *mut lzma_optimal) + .offset(1 as ::core::ffi::c_int as isize) as *mut lzma_optimal, + ); + } + } + let len_end: uint32_t = if len_main > rep_lens[rep_max_index as usize] { + len_main + } else { + rep_lens[rep_max_index as usize] + }; + if len_end < 2 as uint32_t { + *back_res = (*coder).opts[1 as ::core::ffi::c_int as usize].back_prev; + *len_res = 1 as uint32_t; + return UINT32_MAX as uint32_t; + } + (*coder).opts[1 as ::core::ffi::c_int as usize].pos_prev = 0 as uint32_t; + let mut i_0: uint32_t = 0 as uint32_t; + while i_0 < REPS as uint32_t { + (*coder).opts[0 as ::core::ffi::c_int as usize].backs[i_0 as usize] = (*coder) + .reps[i_0 as usize]; + i_0 = i_0.wrapping_add(1); + } + let mut len: uint32_t = len_end; + loop { + (*coder).opts[len as usize].price = RC_INFINITY_PRICE as uint32_t; + len = len.wrapping_sub(1); + if !(len >= 2 as uint32_t) { + break; + } + } + let mut i_1: uint32_t = 0 as uint32_t; + while i_1 < REPS as uint32_t { + let mut rep_len: uint32_t = rep_lens[i_1 as usize]; + if !(rep_len < 2 as uint32_t) { + let price: uint32_t = rep_match_price + .wrapping_add( + get_pure_rep_price(coder, i_1, (*coder).state, pos_state) as uint32_t, + ); + loop { + let cur_and_len_price: uint32_t = price + .wrapping_add( + get_len_price( + &raw mut (*coder).rep_len_encoder, + rep_len, + pos_state, + ) as uint32_t, + ); + if cur_and_len_price < (*coder).opts[rep_len as usize].price { + (*coder).opts[rep_len as usize].price = cur_and_len_price; + (*coder).opts[rep_len as usize].pos_prev = 0 as uint32_t; + (*coder).opts[rep_len as usize].back_prev = i_1; + (*coder).opts[rep_len as usize].prev_1_is_literal = false_0 != 0; + } + rep_len = rep_len.wrapping_sub(1); + if !(rep_len >= 2 as uint32_t) { + break; + } + } + } + i_1 = i_1.wrapping_add(1); + } + let normal_match_price: uint32_t = match_price + .wrapping_add( + rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as uint32_t, + ); + len = if rep_lens[0 as ::core::ffi::c_int as usize] >= 2 as uint32_t { + rep_lens[0 as ::core::ffi::c_int as usize].wrapping_add(1 as uint32_t) + } else { + 2 as uint32_t + }; + if len <= len_main { + let mut i_2: uint32_t = 0 as uint32_t; + while len > (*coder).matches[i_2 as usize].len { + i_2 = i_2.wrapping_add(1); + } + loop { + let dist: uint32_t = (*coder).matches[i_2 as usize].dist; + let cur_and_len_price_0: uint32_t = normal_match_price + .wrapping_add( + get_dist_len_price(coder, dist, len, pos_state) as uint32_t, + ); + if cur_and_len_price_0 < (*coder).opts[len as usize].price { + (*coder).opts[len as usize].price = cur_and_len_price_0; + (*coder).opts[len as usize].pos_prev = 0 as uint32_t; + (*coder).opts[len as usize].back_prev = dist + .wrapping_add(REPS as uint32_t); + (*coder).opts[len as usize].prev_1_is_literal = false_0 != 0; + } + if len == (*coder).matches[i_2 as usize].len { + i_2 = i_2.wrapping_add(1); + if i_2 == matches_count { + break; + } + } + len = len.wrapping_add(1); + } + } + return len_end; +} +#[inline] +unsafe extern "C" fn helper2( + mut coder: *mut lzma_lzma1_encoder, + mut reps: *mut uint32_t, + mut buf: *const uint8_t, + mut len_end: uint32_t, + mut position: uint32_t, + cur: uint32_t, + nice_len: uint32_t, + buf_avail_full: uint32_t, +) -> uint32_t { + let mut matches_count: uint32_t = (*coder).matches_count; + let mut new_len: uint32_t = (*coder).longest_match_length; + let mut pos_prev: uint32_t = (*coder).opts[cur as usize].pos_prev; + let mut state: lzma_lzma_state = STATE_LIT_LIT; + if (*coder).opts[cur as usize].prev_1_is_literal { + pos_prev = pos_prev.wrapping_sub(1); + if (*coder).opts[cur as usize].prev_2 { + state = (*coder).opts[(*coder).opts[cur as usize].pos_prev_2 as usize].state; + if (*coder).opts[cur as usize].back_prev_2 < REPS as uint32_t { + state = (if (state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_LONGREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as lzma_lzma_state; + } else { + state = (if (state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_MATCH as ::core::ffi::c_int + } else { + STATE_NONLIT_MATCH as ::core::ffi::c_int + }) as lzma_lzma_state; + } + } else { + state = (*coder).opts[pos_prev as usize].state; + } + state = (if state as ::core::ffi::c_uint + <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + { + STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + } else if state as ::core::ffi::c_uint + <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint + { + (state as ::core::ffi::c_uint).wrapping_sub(3 as ::core::ffi::c_uint) + } else { + (state as ::core::ffi::c_uint).wrapping_sub(6 as ::core::ffi::c_uint) + }) as lzma_lzma_state; + } else { + state = (*coder).opts[pos_prev as usize].state; + } + if pos_prev == cur.wrapping_sub(1 as uint32_t) { + if (*coder).opts[cur as usize].back_prev == 0 as uint32_t { + state = (if (state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_SHORTREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as lzma_lzma_state; + } else { + state = (if state as ::core::ffi::c_uint + <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + { + STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + } else if state as ::core::ffi::c_uint + <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint + { + (state as ::core::ffi::c_uint).wrapping_sub(3 as ::core::ffi::c_uint) + } else { + (state as ::core::ffi::c_uint).wrapping_sub(6 as ::core::ffi::c_uint) + }) as lzma_lzma_state; + } + } else { + let mut pos: uint32_t = 0; + if (*coder).opts[cur as usize].prev_1_is_literal as ::core::ffi::c_int != 0 + && (*coder).opts[cur as usize].prev_2 as ::core::ffi::c_int != 0 + { + pos_prev = (*coder).opts[cur as usize].pos_prev_2; + pos = (*coder).opts[cur as usize].back_prev_2; + state = (if (state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_LONGREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as lzma_lzma_state; + } else { + pos = (*coder).opts[cur as usize].back_prev; + if pos < REPS as uint32_t { + state = (if (state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_LONGREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as lzma_lzma_state; + } else { + state = (if (state as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_MATCH as ::core::ffi::c_int + } else { + STATE_NONLIT_MATCH as ::core::ffi::c_int + }) as lzma_lzma_state; + } + } + if pos < REPS as uint32_t { + *reps.offset(0 as ::core::ffi::c_int as isize) = (*coder) + .opts[pos_prev as usize] + .backs[pos as usize]; + let mut i: uint32_t = 0; + i = 1 as uint32_t; + while i <= pos { + *reps.offset(i as isize) = (*coder) + .opts[pos_prev as usize] + .backs[i.wrapping_sub(1 as uint32_t) as usize]; + i = i.wrapping_add(1); + } + while i < REPS as uint32_t { + *reps.offset(i as isize) = (*coder) + .opts[pos_prev as usize] + .backs[i as usize]; + i = i.wrapping_add(1); + } + } else { + *reps.offset(0 as ::core::ffi::c_int as isize) = pos + .wrapping_sub(REPS as uint32_t); + let mut i_0: uint32_t = 1 as uint32_t; + while i_0 < REPS as uint32_t { + *reps.offset(i_0 as isize) = (*coder) + .opts[pos_prev as usize] + .backs[i_0.wrapping_sub(1 as uint32_t) as usize]; + i_0 = i_0.wrapping_add(1); + } + } + } + (*coder).opts[cur as usize].state = state; + let mut i_1: uint32_t = 0 as uint32_t; + while i_1 < REPS as uint32_t { + (*coder).opts[cur as usize].backs[i_1 as usize] = *reps.offset(i_1 as isize); + i_1 = i_1.wrapping_add(1); + } + let cur_price: uint32_t = (*coder).opts[cur as usize].price; + let current_byte: uint8_t = *buf; + let match_byte: uint8_t = *buf + .offset(-(*reps.offset(0 as ::core::ffi::c_int as isize) as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + let pos_state: uint32_t = position & (*coder).pos_mask; + let cur_and_1_price: uint32_t = cur_price + .wrapping_add( + rc_bit_0_price((*coder).is_match[state as usize][pos_state as usize]) + as uint32_t, + ) + .wrapping_add( + get_literal_price( + coder, + position, + *buf.offset(-(1 as ::core::ffi::c_int) as isize) as uint32_t, + !((state as ::core::ffi::c_uint) < LIT_STATES as ::core::ffi::c_uint), + match_byte as uint32_t, + current_byte as uint32_t, + ) as uint32_t, + ); + let mut next_is_literal: bool = false_0 != 0; + if cur_and_1_price < (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].price { + (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].price = cur_and_1_price; + (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].pos_prev = cur; + make_literal( + (&raw mut (*coder).opts as *mut lzma_optimal) + .offset(cur.wrapping_add(1 as uint32_t) as isize) as *mut lzma_optimal, + ); + next_is_literal = true_0 != 0; + } + let match_price: uint32_t = cur_price + .wrapping_add( + rc_bit_1_price((*coder).is_match[state as usize][pos_state as usize]) + as uint32_t, + ); + let rep_match_price: uint32_t = match_price + .wrapping_add(rc_bit_1_price((*coder).is_rep[state as usize]) as uint32_t); + if match_byte as ::core::ffi::c_int == current_byte as ::core::ffi::c_int + && !((*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].pos_prev < cur + && (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].back_prev + == 0 as uint32_t) + { + let short_rep_price: uint32_t = rep_match_price + .wrapping_add(get_short_rep_price(coder, state, pos_state) as uint32_t); + if short_rep_price + <= (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].price + { + (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].price = short_rep_price; + (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].pos_prev = cur; + make_short_rep( + (&raw mut (*coder).opts as *mut lzma_optimal) + .offset(cur.wrapping_add(1 as uint32_t) as isize) + as *mut lzma_optimal, + ); + next_is_literal = true_0 != 0; + } + } + if buf_avail_full < 2 as uint32_t { + return len_end; + } + let buf_avail: uint32_t = if buf_avail_full < nice_len { + buf_avail_full + } else { + nice_len + }; + if !next_is_literal + && match_byte as ::core::ffi::c_int != current_byte as ::core::ffi::c_int + { + let buf_back: *const uint8_t = buf + .offset(-(*reps.offset(0 as ::core::ffi::c_int as isize) as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + let limit: uint32_t = if buf_avail_full < nice_len.wrapping_add(1 as uint32_t) { + buf_avail_full + } else { + nice_len.wrapping_add(1 as uint32_t) + }; + let len_test: uint32_t = (lzma_memcmplen(buf, buf_back, 1 as uint32_t, limit) + as uint32_t) + .wrapping_sub(1 as uint32_t); + if len_test >= 2 as uint32_t { + let mut state_2: lzma_lzma_state = state; + state_2 = (if state_2 as ::core::ffi::c_uint + <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + { + STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + } else if state_2 as ::core::ffi::c_uint + <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint + { + (state_2 as ::core::ffi::c_uint).wrapping_sub(3 as ::core::ffi::c_uint) + } else { + (state_2 as ::core::ffi::c_uint).wrapping_sub(6 as ::core::ffi::c_uint) + }) as lzma_lzma_state; + let pos_state_next: uint32_t = position.wrapping_add(1 as uint32_t) + & (*coder).pos_mask; + let next_rep_match_price: uint32_t = cur_and_1_price + .wrapping_add( + rc_bit_1_price( + (*coder).is_match[state_2 as usize][pos_state_next as usize], + ) as uint32_t, + ) + .wrapping_add( + rc_bit_1_price((*coder).is_rep[state_2 as usize]) as uint32_t, + ); + let offset: uint32_t = cur + .wrapping_add(1 as uint32_t) + .wrapping_add(len_test); + while len_end < offset { + len_end = len_end.wrapping_add(1); + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as uint32_t; + } + let cur_and_len_price: uint32_t = next_rep_match_price + .wrapping_add( + get_rep_price( + coder, + 0 as uint32_t, + len_test, + state_2, + pos_state_next, + ) as uint32_t, + ); + if cur_and_len_price < (*coder).opts[offset as usize].price { + (*coder).opts[offset as usize].price = cur_and_len_price; + (*coder).opts[offset as usize].pos_prev = cur + .wrapping_add(1 as uint32_t); + (*coder).opts[offset as usize].back_prev = 0 as uint32_t; + (*coder).opts[offset as usize].prev_1_is_literal = true_0 != 0; + (*coder).opts[offset as usize].prev_2 = false_0 != 0; + } + } + } + let mut start_len: uint32_t = 2 as uint32_t; + let mut rep_index: uint32_t = 0 as uint32_t; + while rep_index < REPS as uint32_t { + let buf_back_0: *const uint8_t = buf + .offset(-(*reps.offset(rep_index as isize) as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + if !(*buf.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != *buf_back_0.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + || *buf.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != *buf_back_0.offset(1 as ::core::ffi::c_int as isize) + as ::core::ffi::c_int) + { + let mut len_test_0: uint32_t = lzma_memcmplen( + buf, + buf_back_0, + 2 as uint32_t, + buf_avail, + ); + while len_end < cur.wrapping_add(len_test_0) { + len_end = len_end.wrapping_add(1); + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as uint32_t; + } + let len_test_temp: uint32_t = len_test_0; + let price: uint32_t = rep_match_price + .wrapping_add( + get_pure_rep_price(coder, rep_index, state, pos_state) as uint32_t, + ); + loop { + let cur_and_len_price_0: uint32_t = price + .wrapping_add( + get_len_price( + &raw mut (*coder).rep_len_encoder, + len_test_0, + pos_state, + ) as uint32_t, + ); + if cur_and_len_price_0 + < (*coder).opts[cur.wrapping_add(len_test_0) as usize].price + { + (*coder).opts[cur.wrapping_add(len_test_0) as usize].price = cur_and_len_price_0; + (*coder).opts[cur.wrapping_add(len_test_0) as usize].pos_prev = cur; + (*coder).opts[cur.wrapping_add(len_test_0) as usize].back_prev = rep_index; + (*coder) + .opts[cur.wrapping_add(len_test_0) as usize] + .prev_1_is_literal = false_0 != 0; + } + len_test_0 = len_test_0.wrapping_sub(1); + if !(len_test_0 >= 2 as uint32_t) { + break; + } + } + len_test_0 = len_test_temp; + if rep_index == 0 as uint32_t { + start_len = len_test_0.wrapping_add(1 as uint32_t); + } + let mut len_test_2: uint32_t = len_test_0.wrapping_add(1 as uint32_t); + let limit_0: uint32_t = if buf_avail_full < len_test_2.wrapping_add(nice_len) + { + buf_avail_full + } else { + len_test_2.wrapping_add(nice_len) + }; + if len_test_2 < limit_0 { + len_test_2 = lzma_memcmplen(buf, buf_back_0, len_test_2, limit_0); + } + len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1 as uint32_t)); + if len_test_2 >= 2 as uint32_t { + let mut state_2_0: lzma_lzma_state = state; + state_2_0 = (if (state_2_0 as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_LONGREP as ::core::ffi::c_int + } else { + STATE_NONLIT_REP as ::core::ffi::c_int + }) as lzma_lzma_state; + let mut pos_state_next_0: uint32_t = position.wrapping_add(len_test_0) + & (*coder).pos_mask; + let cur_and_len_literal_price: uint32_t = price + .wrapping_add( + get_len_price( + &raw mut (*coder).rep_len_encoder, + len_test_0, + pos_state, + ) as uint32_t, + ) + .wrapping_add( + rc_bit_0_price( + (*coder) + .is_match[state_2_0 as usize][pos_state_next_0 as usize], + ) as uint32_t, + ) + .wrapping_add( + get_literal_price( + coder, + position.wrapping_add(len_test_0), + *buf.offset(len_test_0.wrapping_sub(1 as uint32_t) as isize) + as uint32_t, + true_0 != 0, + *buf_back_0.offset(len_test_0 as isize) as uint32_t, + *buf.offset(len_test_0 as isize) as uint32_t, + ) as uint32_t, + ); + state_2_0 = (if state_2_0 as ::core::ffi::c_uint + <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int + as ::core::ffi::c_uint + { + STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + } else if state_2_0 as ::core::ffi::c_uint + <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint + { + (state_2_0 as ::core::ffi::c_uint) + .wrapping_sub(3 as ::core::ffi::c_uint) + } else { + (state_2_0 as ::core::ffi::c_uint) + .wrapping_sub(6 as ::core::ffi::c_uint) + }) as lzma_lzma_state; + pos_state_next_0 = position + .wrapping_add(len_test_0) + .wrapping_add(1 as uint32_t) & (*coder).pos_mask; + let next_rep_match_price_0: uint32_t = cur_and_len_literal_price + .wrapping_add( + rc_bit_1_price( + (*coder) + .is_match[state_2_0 as usize][pos_state_next_0 as usize], + ) as uint32_t, + ) + .wrapping_add( + rc_bit_1_price((*coder).is_rep[state_2_0 as usize]) as uint32_t, + ); + let offset_0: uint32_t = cur + .wrapping_add(len_test_0) + .wrapping_add(1 as uint32_t) + .wrapping_add(len_test_2); + while len_end < offset_0 { + len_end = len_end.wrapping_add(1); + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE + as uint32_t; + } + let cur_and_len_price_1: uint32_t = next_rep_match_price_0 + .wrapping_add( + get_rep_price( + coder, + 0 as uint32_t, + len_test_2, + state_2_0, + pos_state_next_0, + ) as uint32_t, + ); + if cur_and_len_price_1 < (*coder).opts[offset_0 as usize].price { + (*coder).opts[offset_0 as usize].price = cur_and_len_price_1; + (*coder).opts[offset_0 as usize].pos_prev = cur + .wrapping_add(len_test_0) + .wrapping_add(1 as uint32_t); + (*coder).opts[offset_0 as usize].back_prev = 0 as uint32_t; + (*coder).opts[offset_0 as usize].prev_1_is_literal = true_0 != 0; + (*coder).opts[offset_0 as usize].prev_2 = true_0 != 0; + (*coder).opts[offset_0 as usize].pos_prev_2 = cur; + (*coder).opts[offset_0 as usize].back_prev_2 = rep_index; + } + } + } + rep_index = rep_index.wrapping_add(1); + } + if new_len > buf_avail { + new_len = buf_avail; + matches_count = 0 as uint32_t; + while new_len > (*coder).matches[matches_count as usize].len { + matches_count = matches_count.wrapping_add(1); + } + let fresh0 = matches_count; + matches_count = matches_count.wrapping_add(1); + (*coder).matches[fresh0 as usize].len = new_len; + } + if new_len >= start_len { + let normal_match_price: uint32_t = match_price + .wrapping_add(rc_bit_0_price((*coder).is_rep[state as usize]) as uint32_t); + while len_end < cur.wrapping_add(new_len) { + len_end = len_end.wrapping_add(1); + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as uint32_t; + } + let mut i_2: uint32_t = 0 as uint32_t; + while start_len > (*coder).matches[i_2 as usize].len { + i_2 = i_2.wrapping_add(1); + } + let mut len_test_1: uint32_t = start_len; + loop { + let cur_back: uint32_t = (*coder).matches[i_2 as usize].dist; + let mut cur_and_len_price_2: uint32_t = normal_match_price + .wrapping_add( + get_dist_len_price(coder, cur_back, len_test_1, pos_state), + ); + if cur_and_len_price_2 + < (*coder).opts[cur.wrapping_add(len_test_1) as usize].price + { + (*coder).opts[cur.wrapping_add(len_test_1) as usize].price = cur_and_len_price_2; + (*coder).opts[cur.wrapping_add(len_test_1) as usize].pos_prev = cur; + (*coder).opts[cur.wrapping_add(len_test_1) as usize].back_prev = cur_back + .wrapping_add(REPS as uint32_t); + (*coder).opts[cur.wrapping_add(len_test_1) as usize].prev_1_is_literal = false_0 + != 0; + } + if len_test_1 == (*coder).matches[i_2 as usize].len { + let buf_back_1: *const uint8_t = buf + .offset(-(cur_back as isize)) + .offset(-(1 as ::core::ffi::c_int as isize)); + let mut len_test_2_0: uint32_t = len_test_1.wrapping_add(1 as uint32_t); + let limit_1: uint32_t = if buf_avail_full + < len_test_2_0.wrapping_add(nice_len) + { + buf_avail_full + } else { + len_test_2_0.wrapping_add(nice_len) + }; + if len_test_2_0 < limit_1 { + len_test_2_0 = lzma_memcmplen( + buf, + buf_back_1, + len_test_2_0, + limit_1, + ); + } + len_test_2_0 = len_test_2_0 + .wrapping_sub(len_test_1.wrapping_add(1 as uint32_t)); + if len_test_2_0 >= 2 as uint32_t { + let mut state_2_1: lzma_lzma_state = state; + state_2_1 = (if (state_2_1 as ::core::ffi::c_uint) + < LIT_STATES as ::core::ffi::c_uint + { + STATE_LIT_MATCH as ::core::ffi::c_int + } else { + STATE_NONLIT_MATCH as ::core::ffi::c_int + }) as lzma_lzma_state; + let mut pos_state_next_1: uint32_t = position + .wrapping_add(len_test_1) & (*coder).pos_mask; + let cur_and_len_literal_price_0: uint32_t = cur_and_len_price_2 + .wrapping_add( + rc_bit_0_price( + (*coder) + .is_match[state_2_1 as usize][pos_state_next_1 as usize], + ) as uint32_t, + ) + .wrapping_add( + get_literal_price( + coder, + position.wrapping_add(len_test_1), + *buf.offset(len_test_1.wrapping_sub(1 as uint32_t) as isize) + as uint32_t, + true_0 != 0, + *buf_back_1.offset(len_test_1 as isize) as uint32_t, + *buf.offset(len_test_1 as isize) as uint32_t, + ) as uint32_t, + ); + state_2_1 = (if state_2_1 as ::core::ffi::c_uint + <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int + as ::core::ffi::c_uint + { + STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + } else if state_2_1 as ::core::ffi::c_uint + <= STATE_LIT_SHORTREP as ::core::ffi::c_int + as ::core::ffi::c_uint + { + (state_2_1 as ::core::ffi::c_uint) + .wrapping_sub(3 as ::core::ffi::c_uint) + } else { + (state_2_1 as ::core::ffi::c_uint) + .wrapping_sub(6 as ::core::ffi::c_uint) + }) as lzma_lzma_state; + pos_state_next_1 = pos_state_next_1.wrapping_add(1 as uint32_t) + & (*coder).pos_mask; + let next_rep_match_price_1: uint32_t = cur_and_len_literal_price_0 + .wrapping_add( + rc_bit_1_price( + (*coder) + .is_match[state_2_1 as usize][pos_state_next_1 as usize], + ) as uint32_t, + ) + .wrapping_add( + rc_bit_1_price((*coder).is_rep[state_2_1 as usize]) + as uint32_t, + ); + let offset_1: uint32_t = cur + .wrapping_add(len_test_1) + .wrapping_add(1 as uint32_t) + .wrapping_add(len_test_2_0); + while len_end < offset_1 { + len_end = len_end.wrapping_add(1); + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE + as uint32_t; + } + cur_and_len_price_2 = next_rep_match_price_1 + .wrapping_add( + get_rep_price( + coder, + 0 as uint32_t, + len_test_2_0, + state_2_1, + pos_state_next_1, + ), + ); + if cur_and_len_price_2 < (*coder).opts[offset_1 as usize].price { + (*coder).opts[offset_1 as usize].price = cur_and_len_price_2; + (*coder).opts[offset_1 as usize].pos_prev = cur + .wrapping_add(len_test_1) + .wrapping_add(1 as uint32_t); + (*coder).opts[offset_1 as usize].back_prev = 0 as uint32_t; + (*coder).opts[offset_1 as usize].prev_1_is_literal = true_0 != 0; + (*coder).opts[offset_1 as usize].prev_2 = true_0 != 0; + (*coder).opts[offset_1 as usize].pos_prev_2 = cur; + (*coder).opts[offset_1 as usize].back_prev_2 = cur_back + .wrapping_add(REPS as uint32_t); + } + } + i_2 = i_2.wrapping_add(1); + if i_2 == matches_count { + break; + } + } + len_test_1 = len_test_1.wrapping_add(1); + } + } + return len_end; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_optimum_normal( + mut coder: *mut lzma_lzma1_encoder, + mut mf: *mut lzma_mf, + mut back_res: *mut uint32_t, + mut len_res: *mut uint32_t, + mut position: uint32_t, +) { + if (*coder).opts_end_index != (*coder).opts_current_index { + *len_res = (*coder) + .opts[(*coder).opts_current_index as usize] + .pos_prev + .wrapping_sub((*coder).opts_current_index); + *back_res = (*coder).opts[(*coder).opts_current_index as usize].back_prev; + (*coder).opts_current_index = (*coder) + .opts[(*coder).opts_current_index as usize] + .pos_prev; + return; + } + if (*mf).read_ahead == 0 as uint32_t { + if (*coder).match_price_count + >= ((1 as ::core::ffi::c_int) << 7 as ::core::ffi::c_int) as uint32_t + { + fill_dist_prices(coder); + } + if (*coder).align_price_count >= ALIGN_SIZE as uint32_t { + fill_align_prices(coder); + } + } + let mut len_end: uint32_t = helper1(coder, mf, back_res, len_res, position); + if len_end == UINT32_MAX as uint32_t { + return; + } + let mut reps: [uint32_t; 4] = [0; 4]; + memcpy( + &raw mut reps as *mut uint32_t as *mut ::core::ffi::c_void, + &raw mut (*coder).reps as *mut uint32_t as *const ::core::ffi::c_void, + ::core::mem::size_of::<[uint32_t; 4]>() as size_t, + ); + let mut cur: uint32_t = 0; + cur = 1 as uint32_t; + while cur < len_end { + (*coder).longest_match_length = lzma_mf_find( + mf, + &raw mut (*coder).matches_count, + &raw mut (*coder).matches as *mut lzma_match, + ); + if (*coder).longest_match_length >= (*mf).nice_len { + break; + } + len_end = helper2( + coder, + &raw mut reps as *mut uint32_t, + mf_ptr(mf).offset(-(1 as ::core::ffi::c_int as isize)), + len_end, + position.wrapping_add(cur), + cur, + (*mf).nice_len, + if mf_avail(mf).wrapping_add(1 as uint32_t) + < ((((1 as ::core::ffi::c_int) << 12 as ::core::ffi::c_int) + - 1 as ::core::ffi::c_int) as uint32_t) + .wrapping_sub(cur) + { + mf_avail(mf).wrapping_add(1 as uint32_t) + } else { + ((((1 as ::core::ffi::c_int) << 12 as ::core::ffi::c_int) + - 1 as ::core::ffi::c_int) as uint32_t) + .wrapping_sub(cur) + }, + ); + cur = cur.wrapping_add(1); + } + backward(coder, len_res, back_res, cur); +} diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs new file mode 100644 index 00000000..8bfafcd6 --- /dev/null +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -0,0 +1,128 @@ +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type lzma_bool = ::core::ffi::c_uchar; +pub type lzma_reserved_enum = ::core::ffi::c_uint; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub type lzma_match_finder = ::core::ffi::c_uint; +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub type lzma_mode = ::core::ffi::c_uint; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: uint32_t, + pub preset_dict: *const uint8_t, + pub preset_dict_size: uint32_t, + pub lc: uint32_t, + pub lp: uint32_t, + pub pb: uint32_t, + pub mode: lzma_mode, + pub nice_len: uint32_t, + pub mf: lzma_match_finder, + pub depth: uint32_t, + pub ext_flags: uint32_t, + pub ext_size_low: uint32_t, + pub ext_size_high: uint32_t, + pub reserved_int4: uint32_t, + pub reserved_int5: uint32_t, + pub reserved_int6: uint32_t, + pub reserved_int7: uint32_t, + pub reserved_int8: uint32_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut ::core::ffi::c_void, + pub reserved_ptr2: *mut ::core::ffi::c_void, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_LC_DEFAULT: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +pub const LZMA_LP_DEFAULT: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_PB_DEFAULT: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const LZMA_PRESET_LEVEL_MASK: ::core::ffi::c_uint = 0x1f as ::core::ffi::c_uint; +pub const LZMA_PRESET_EXTREME: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) + << 31 as ::core::ffi::c_int; +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_preset( + mut options: *mut lzma_options_lzma, + mut preset: uint32_t, +) -> lzma_bool { + let level: uint32_t = preset & LZMA_PRESET_LEVEL_MASK as uint32_t; + let flags: uint32_t = preset & !(LZMA_PRESET_LEVEL_MASK as uint32_t); + let supported_flags: uint32_t = LZMA_PRESET_EXTREME as uint32_t; + if level > 9 as uint32_t || flags & !supported_flags != 0 { + return true_0 as lzma_bool; + } + (*options).preset_dict = ::core::ptr::null::(); + (*options).preset_dict_size = 0 as uint32_t; + (*options).lc = LZMA_LC_DEFAULT as uint32_t; + (*options).lp = LZMA_LP_DEFAULT as uint32_t; + (*options).pb = LZMA_PB_DEFAULT as uint32_t; + static mut dict_pow2: [uint8_t; 10] = [ + 18 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 26 as ::core::ffi::c_int as uint8_t, + ]; + (*options).dict_size = ((1 as ::core::ffi::c_uint) + << dict_pow2[level as usize] as ::core::ffi::c_int) as uint32_t; + if level <= 3 as uint32_t { + (*options).mode = LZMA_MODE_FAST; + (*options).mf = (if level == 0 as uint32_t { + LZMA_MF_HC3 as ::core::ffi::c_int + } else { + LZMA_MF_HC4 as ::core::ffi::c_int + }) as lzma_match_finder; + (*options).nice_len = (if level <= 1 as uint32_t { + 128 as ::core::ffi::c_int + } else { + 273 as ::core::ffi::c_int + }) as uint32_t; + static mut depths: [uint8_t; 4] = [ + 4 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 48 as ::core::ffi::c_int as uint8_t, + ]; + (*options).depth = depths[level as usize] as uint32_t; + } else { + (*options).mode = LZMA_MODE_NORMAL; + (*options).mf = LZMA_MF_BT4; + (*options).nice_len = (if level == 4 as uint32_t { + 16 as ::core::ffi::c_int + } else if level == 5 as uint32_t { + 32 as ::core::ffi::c_int + } else { + 64 as ::core::ffi::c_int + }) as uint32_t; + (*options).depth = 0 as uint32_t; + } + if flags & LZMA_PRESET_EXTREME as uint32_t != 0 { + (*options).mode = LZMA_MODE_NORMAL; + (*options).mf = LZMA_MF_BT4; + if level == 3 as uint32_t || level == 5 as uint32_t { + (*options).nice_len = 192 as uint32_t; + (*options).depth = 0 as uint32_t; + } else { + (*options).nice_len = 273 as uint32_t; + (*options).depth = 512 as uint32_t; + } + } + return false_0 as lzma_bool; +} diff --git a/liblzma-rs/src/lzma/mod.rs b/liblzma-rs/src/lzma/mod.rs new file mode 100644 index 00000000..0a3c817d --- /dev/null +++ b/liblzma-rs/src/lzma/mod.rs @@ -0,0 +1,8 @@ +pub mod fastpos_table; +pub mod lzma2_decoder; +pub mod lzma2_encoder; +pub mod lzma_decoder; +pub mod lzma_encoder; +pub mod lzma_encoder_optimum_fast; +pub mod lzma_encoder_optimum_normal; +pub mod lzma_encoder_presets; diff --git a/liblzma-rs/src/rangecoder/mod.rs b/liblzma-rs/src/rangecoder/mod.rs new file mode 100644 index 00000000..f6f18e9e --- /dev/null +++ b/liblzma-rs/src/rangecoder/mod.rs @@ -0,0 +1 @@ +pub mod price_table; diff --git a/liblzma-rs/src/rangecoder/price_table.rs b/liblzma-rs/src/rangecoder/price_table.rs new file mode 100644 index 00000000..7e1e149b --- /dev/null +++ b/liblzma-rs/src/rangecoder/price_table.rs @@ -0,0 +1,132 @@ +pub type uint8_t = u8; +#[no_mangle] +pub static mut lzma_rc_prices: [uint8_t; 128] = [ + 128 as ::core::ffi::c_int as uint8_t, + 103 as ::core::ffi::c_int as uint8_t, + 91 as ::core::ffi::c_int as uint8_t, + 84 as ::core::ffi::c_int as uint8_t, + 78 as ::core::ffi::c_int as uint8_t, + 73 as ::core::ffi::c_int as uint8_t, + 69 as ::core::ffi::c_int as uint8_t, + 66 as ::core::ffi::c_int as uint8_t, + 63 as ::core::ffi::c_int as uint8_t, + 61 as ::core::ffi::c_int as uint8_t, + 58 as ::core::ffi::c_int as uint8_t, + 56 as ::core::ffi::c_int as uint8_t, + 54 as ::core::ffi::c_int as uint8_t, + 52 as ::core::ffi::c_int as uint8_t, + 51 as ::core::ffi::c_int as uint8_t, + 49 as ::core::ffi::c_int as uint8_t, + 48 as ::core::ffi::c_int as uint8_t, + 46 as ::core::ffi::c_int as uint8_t, + 45 as ::core::ffi::c_int as uint8_t, + 44 as ::core::ffi::c_int as uint8_t, + 43 as ::core::ffi::c_int as uint8_t, + 42 as ::core::ffi::c_int as uint8_t, + 41 as ::core::ffi::c_int as uint8_t, + 40 as ::core::ffi::c_int as uint8_t, + 39 as ::core::ffi::c_int as uint8_t, + 38 as ::core::ffi::c_int as uint8_t, + 37 as ::core::ffi::c_int as uint8_t, + 36 as ::core::ffi::c_int as uint8_t, + 35 as ::core::ffi::c_int as uint8_t, + 34 as ::core::ffi::c_int as uint8_t, + 34 as ::core::ffi::c_int as uint8_t, + 33 as ::core::ffi::c_int as uint8_t, + 32 as ::core::ffi::c_int as uint8_t, + 31 as ::core::ffi::c_int as uint8_t, + 31 as ::core::ffi::c_int as uint8_t, + 30 as ::core::ffi::c_int as uint8_t, + 29 as ::core::ffi::c_int as uint8_t, + 29 as ::core::ffi::c_int as uint8_t, + 28 as ::core::ffi::c_int as uint8_t, + 28 as ::core::ffi::c_int as uint8_t, + 27 as ::core::ffi::c_int as uint8_t, + 26 as ::core::ffi::c_int as uint8_t, + 26 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 25 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 24 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 23 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 22 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 21 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 20 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 19 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 18 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 17 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 16 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 15 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 14 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 13 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 12 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 11 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 10 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 9 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 8 as ::core::ffi::c_int as uint8_t, + 7 as ::core::ffi::c_int as uint8_t, + 7 as ::core::ffi::c_int as uint8_t, + 7 as ::core::ffi::c_int as uint8_t, + 7 as ::core::ffi::c_int as uint8_t, + 6 as ::core::ffi::c_int as uint8_t, + 6 as ::core::ffi::c_int as uint8_t, + 6 as ::core::ffi::c_int as uint8_t, + 6 as ::core::ffi::c_int as uint8_t, + 5 as ::core::ffi::c_int as uint8_t, + 5 as ::core::ffi::c_int as uint8_t, + 5 as ::core::ffi::c_int as uint8_t, + 5 as ::core::ffi::c_int as uint8_t, + 5 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 4 as ::core::ffi::c_int as uint8_t, + 3 as ::core::ffi::c_int as uint8_t, + 3 as ::core::ffi::c_int as uint8_t, + 3 as ::core::ffi::c_int as uint8_t, + 3 as ::core::ffi::c_int as uint8_t, + 3 as ::core::ffi::c_int as uint8_t, + 2 as ::core::ffi::c_int as uint8_t, + 2 as ::core::ffi::c_int as uint8_t, + 2 as ::core::ffi::c_int as uint8_t, + 2 as ::core::ffi::c_int as uint8_t, + 2 as ::core::ffi::c_int as uint8_t, + 2 as ::core::ffi::c_int as uint8_t, + 1 as ::core::ffi::c_int as uint8_t, + 1 as ::core::ffi::c_int as uint8_t, + 1 as ::core::ffi::c_int as uint8_t, + 1 as ::core::ffi::c_int as uint8_t, + 1 as ::core::ffi::c_int as uint8_t, +]; diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs new file mode 100644 index 00000000..2bf04aa2 --- /dev/null +++ b/liblzma-rs/src/simple/arm.rs @@ -0,0 +1,242 @@ +extern "C" { + fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + simple_size: size_t, + unfiltered_max: size_t, + alignment: uint32_t, + is_encoder: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn arm_code( + mut simple: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + size &= !(3 as ::core::ffi::c_int as size_t); + let mut i: size_t = 0; + i = 0 as size_t; + while i < size { + if *buffer.offset(i.wrapping_add(3 as size_t) as isize) as ::core::ffi::c_int + == 0xeb as ::core::ffi::c_int + { + let mut src: uint32_t = (*buffer.offset(i.wrapping_add(2 as size_t) as isize) + as uint32_t) << 16 as ::core::ffi::c_int + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) + << 8 as ::core::ffi::c_int + | *buffer.offset(i.wrapping_add(0 as size_t) as isize) as uint32_t; + src <<= 2 as ::core::ffi::c_int; + let mut dest: uint32_t = 0; + if is_encoder { + dest = now_pos + .wrapping_add(i as uint32_t) + .wrapping_add(8 as uint32_t) + .wrapping_add(src); + } else { + dest = src + .wrapping_sub( + now_pos.wrapping_add(i as uint32_t).wrapping_add(8 as uint32_t), + ); + } + dest >>= 2 as ::core::ffi::c_int; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest + >> 16 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest + >> 8 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = dest as uint8_t; + } + i = i.wrapping_add(4 as size_t); + } + return i; +} +unsafe extern "C" fn arm_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut is_encoder: bool, +) -> lzma_ret { + return lzma_simple_coder_init( + next, + allocator, + filters, + Some( + arm_code + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + 0 as size_t, + 4 as size_t, + 4 as uint32_t, + is_encoder, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_arm_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return arm_coder_init(next, allocator, filters, true_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_arm_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return arm_coder_init(next, allocator, filters, false_0 != 0); +} diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs new file mode 100644 index 00000000..35585152 --- /dev/null +++ b/liblzma-rs/src/simple/arm64.rs @@ -0,0 +1,262 @@ +extern "C" { + fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + simple_size: size_t, + unfiltered_max: size_t, + alignment: uint32_t, + is_encoder: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, size_t, size_t) -> *mut ::core::ffi::c_void, + >, + pub free: + Option ()>, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: + Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: + Option lzma_ret>, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = + Option ()>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::<::core::ffi::c_void>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { + let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; + num |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) << 8 as ::core::ffi::c_int; + num |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) << 16 as ::core::ffi::c_int; + num |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) << 24 as ::core::ffi::c_int; + return num; +} +#[inline] +unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { + *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; + *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) as uint8_t; + *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) as uint8_t; + *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) as uint8_t; +} +unsafe extern "C" fn arm64_code( + mut simple: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + size &= !(3 as ::core::ffi::c_int as size_t); + let mut i: size_t = 0; + i = 0 as size_t; + while i < size { + let mut pc: uint32_t = (now_pos as size_t).wrapping_add(i) as uint32_t; + let mut instr: uint32_t = read32le(buffer.offset(i as isize)); + if instr >> 26 as ::core::ffi::c_int == 0x25 as uint32_t { + let src: uint32_t = instr; + instr = 0x94000000 as ::core::ffi::c_uint as uint32_t; + pc >>= 2 as ::core::ffi::c_int; + if !is_encoder { + pc = (0 as uint32_t).wrapping_sub(pc); + } + instr |= src.wrapping_add(pc) & 0x3ffffff as uint32_t; + write32le(buffer.offset(i as isize), instr); + } else if instr & 0x9f000000 as uint32_t == 0x90000000 as uint32_t { + let src_0: uint32_t = instr >> 29 as ::core::ffi::c_int & 3 as uint32_t + | instr >> 3 as ::core::ffi::c_int & 0x1ffffc as uint32_t; + if !(src_0.wrapping_add(0x20000 as uint32_t) & 0x1c0000 as uint32_t != 0) { + instr = + (instr as ::core::ffi::c_uint & 0x9000001f as ::core::ffi::c_uint) as uint32_t; + pc >>= 12 as ::core::ffi::c_int; + if !is_encoder { + pc = (0 as uint32_t).wrapping_sub(pc); + } + let dest: uint32_t = src_0.wrapping_add(pc); + instr |= (dest & 3 as uint32_t) << 29 as ::core::ffi::c_int; + instr |= (dest & 0x3fffc as uint32_t) << 3 as ::core::ffi::c_int; + instr = (instr as ::core::ffi::c_uint + | ((0 as uint32_t).wrapping_sub(dest & 0x20000 as uint32_t) + & 0xe00000 as uint32_t) as ::core::ffi::c_uint) + as uint32_t; + write32le(buffer.offset(i as isize), instr); + } + } + i = i.wrapping_add(4 as size_t); + } + return i; +} +unsafe extern "C" fn arm64_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut is_encoder: bool, +) -> lzma_ret { + return lzma_simple_coder_init( + next, + allocator, + filters, + Some( + arm64_code + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + 0 as size_t, + 4 as size_t, + 4 as uint32_t, + is_encoder, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return arm64_coder_init(next, allocator, filters, true_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_bcj_arm64_encode( + mut start_offset: uint32_t, + mut buf: *mut uint8_t, + mut size: size_t, +) -> size_t { + start_offset = (start_offset as ::core::ffi::c_uint & !(3 as ::core::ffi::c_uint)) as uint32_t; + return arm64_code(NULL, start_offset, true_0 != 0, buf, size); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return arm64_coder_init(next, allocator, filters, false_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_bcj_arm64_decode( + mut start_offset: uint32_t, + mut buf: *mut uint8_t, + mut size: size_t, +) -> size_t { + start_offset = (start_offset as ::core::ffi::c_uint & !(3 as ::core::ffi::c_uint)) as uint32_t; + return arm64_code(NULL, start_offset, false_0 != 0, buf, size); +} diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs new file mode 100644 index 00000000..d9083001 --- /dev/null +++ b/liblzma-rs/src/simple/armthumb.rs @@ -0,0 +1,252 @@ +extern "C" { + fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + simple_size: size_t, + unfiltered_max: size_t, + alignment: uint32_t, + is_encoder: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn armthumb_code( + mut simple: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + if size < 4 as size_t { + return 0 as size_t; + } + size = size.wrapping_sub(4 as size_t); + let mut i: size_t = 0; + i = 0 as size_t; + while i <= size { + if *buffer.offset(i.wrapping_add(1 as size_t) as isize) as ::core::ffi::c_int + & 0xf8 as ::core::ffi::c_int == 0xf0 as ::core::ffi::c_int + && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as ::core::ffi::c_int + & 0xf8 as ::core::ffi::c_int == 0xf8 as ::core::ffi::c_int + { + let mut src: uint32_t = (*buffer.offset(i.wrapping_add(1 as size_t) as isize) + as uint32_t & 7 as uint32_t) << 19 as ::core::ffi::c_int + | (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as uint32_t) + << 11 as ::core::ffi::c_int + | (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t + & 7 as uint32_t) << 8 as ::core::ffi::c_int + | *buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t; + src <<= 1 as ::core::ffi::c_int; + let mut dest: uint32_t = 0; + if is_encoder { + dest = now_pos + .wrapping_add(i as uint32_t) + .wrapping_add(4 as uint32_t) + .wrapping_add(src); + } else { + dest = src + .wrapping_sub( + now_pos.wrapping_add(i as uint32_t).wrapping_add(4 as uint32_t), + ); + } + dest >>= 1 as ::core::ffi::c_int; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (0xf0 as uint32_t + | dest >> 19 as ::core::ffi::c_int & 0x7 as uint32_t) as uint8_t; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest + >> 11 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(3 as size_t) as isize) = (0xf8 as uint32_t + | dest >> 8 as ::core::ffi::c_int & 0x7 as uint32_t) as uint8_t; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = dest as uint8_t; + i = i.wrapping_add(2 as size_t); + } + i = i.wrapping_add(2 as size_t); + } + return i; +} +unsafe extern "C" fn armthumb_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut is_encoder: bool, +) -> lzma_ret { + return lzma_simple_coder_init( + next, + allocator, + filters, + Some( + armthumb_code + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + 0 as size_t, + 4 as size_t, + 2 as uint32_t, + is_encoder, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_armthumb_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return armthumb_coder_init(next, allocator, filters, true_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_armthumb_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return armthumb_coder_init(next, allocator, filters, false_0 != 0); +} diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs new file mode 100644 index 00000000..910f4922 --- /dev/null +++ b/liblzma-rs/src/simple/ia64.rs @@ -0,0 +1,314 @@ +extern "C" { + fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + simple_size: size_t, + unfiltered_max: size_t, + alignment: uint32_t, + is_encoder: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn ia64_code( + mut simple: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + static mut BRANCH_TABLE: [uint32_t; 32] = [ + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 4 as ::core::ffi::c_int as uint32_t, + 4 as ::core::ffi::c_int as uint32_t, + 6 as ::core::ffi::c_int as uint32_t, + 6 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 7 as ::core::ffi::c_int as uint32_t, + 7 as ::core::ffi::c_int as uint32_t, + 4 as ::core::ffi::c_int as uint32_t, + 4 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 4 as ::core::ffi::c_int as uint32_t, + 4 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + 0 as ::core::ffi::c_int as uint32_t, + ]; + size &= !(15 as ::core::ffi::c_int as size_t); + let mut i: size_t = 0; + i = 0 as size_t; + while i < size { + let instr_template: uint32_t = (*buffer.offset(i as isize) as ::core::ffi::c_int + & 0x1f as ::core::ffi::c_int) as uint32_t; + let mask: uint32_t = BRANCH_TABLE[instr_template as usize]; + let mut bit_pos: uint32_t = 5 as uint32_t; + let mut slot: size_t = 0 as size_t; + while slot < 3 as size_t { + if !(mask >> slot & 1 as uint32_t == 0 as uint32_t) { + let byte_pos: size_t = (bit_pos >> 3 as ::core::ffi::c_int) as size_t; + let bit_res: uint32_t = bit_pos & 0x7 as uint32_t; + let mut instruction: uint64_t = 0 as uint64_t; + let mut j: size_t = 0 as size_t; + while j < 6 as size_t { + instruction = instruction + .wrapping_add( + (*buffer + .offset(i.wrapping_add(j).wrapping_add(byte_pos) as isize) + as uint64_t) << (8 as size_t).wrapping_mul(j), + ); + j = j.wrapping_add(1); + } + let mut inst_norm: uint64_t = instruction >> bit_res; + if inst_norm >> 37 as ::core::ffi::c_int & 0xf as uint64_t + == 0x5 as uint64_t + && inst_norm >> 9 as ::core::ffi::c_int & 0x7 as uint64_t + == 0 as uint64_t + { + let mut src: uint32_t = (inst_norm >> 13 as ::core::ffi::c_int + & 0xfffff as uint64_t) as uint32_t; + src = (src as uint64_t + | (inst_norm >> 36 as ::core::ffi::c_int & 1 as uint64_t) + << 20 as ::core::ffi::c_int) as uint32_t; + src <<= 4 as ::core::ffi::c_int; + let mut dest: uint32_t = 0; + if is_encoder { + dest = now_pos.wrapping_add(i as uint32_t).wrapping_add(src); + } else { + dest = src.wrapping_sub(now_pos.wrapping_add(i as uint32_t)); + } + dest >>= 4 as ::core::ffi::c_int; + inst_norm + &= !((0x8fffff as ::core::ffi::c_int as uint64_t) + << 13 as ::core::ffi::c_int); + inst_norm + |= ((dest & 0xfffff as uint32_t) as uint64_t) + << 13 as ::core::ffi::c_int; + inst_norm + |= ((dest & 0x100000 as uint32_t) as uint64_t) + << 36 as ::core::ffi::c_int - 20 as ::core::ffi::c_int; + instruction + &= ((1 as ::core::ffi::c_uint) << bit_res) + .wrapping_sub(1 as ::core::ffi::c_uint) as uint64_t; + instruction |= inst_norm << bit_res; + let mut j_0: size_t = 0 as size_t; + while j_0 < 6 as size_t { + *buffer + .offset( + i.wrapping_add(j_0).wrapping_add(byte_pos) as isize, + ) = (instruction >> (8 as size_t).wrapping_mul(j_0)) + as uint8_t; + j_0 = j_0.wrapping_add(1); + } + } + } + slot = slot.wrapping_add(1); + bit_pos = bit_pos.wrapping_add(41 as uint32_t); + } + i = i.wrapping_add(16 as size_t); + } + return i; +} +unsafe extern "C" fn ia64_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut is_encoder: bool, +) -> lzma_ret { + return lzma_simple_coder_init( + next, + allocator, + filters, + Some( + ia64_code + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + 0 as size_t, + 16 as size_t, + 16 as uint32_t, + is_encoder, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_ia64_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return ia64_coder_init(next, allocator, filters, true_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_ia64_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return ia64_coder_init(next, allocator, filters, false_0 != 0); +} diff --git a/liblzma-rs/src/simple/mod.rs b/liblzma-rs/src/simple/mod.rs new file mode 100644 index 00000000..f3c7f3a8 --- /dev/null +++ b/liblzma-rs/src/simple/mod.rs @@ -0,0 +1,11 @@ +pub mod arm; +pub mod arm64; +pub mod armthumb; +pub mod ia64; +pub mod powerpc; +pub mod riscv; +pub mod simple_coder; +pub mod simple_decoder; +pub mod simple_encoder; +pub mod sparc; +pub mod x86; diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs new file mode 100644 index 00000000..aaa7042c --- /dev/null +++ b/liblzma-rs/src/simple/powerpc.rs @@ -0,0 +1,245 @@ +extern "C" { + fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + simple_size: size_t, + unfiltered_max: size_t, + alignment: uint32_t, + is_encoder: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn powerpc_code( + mut simple: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + size &= !(3 as ::core::ffi::c_int as size_t); + let mut i: size_t = 0; + i = 0 as size_t; + while i < size { + if *buffer.offset(i as isize) as ::core::ffi::c_int >> 2 as ::core::ffi::c_int + == 0x12 as ::core::ffi::c_int + && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as ::core::ffi::c_int + & 3 as ::core::ffi::c_int == 1 as ::core::ffi::c_int + { + let src: uint32_t = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) + as uint32_t & 3 as uint32_t) << 24 as ::core::ffi::c_int + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) + << 16 as ::core::ffi::c_int + | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t) + << 8 as ::core::ffi::c_int + | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t + & !(3 as uint32_t); + let mut dest: uint32_t = 0; + if is_encoder { + dest = now_pos.wrapping_add(i as uint32_t).wrapping_add(src); + } else { + dest = src.wrapping_sub(now_pos.wrapping_add(i as uint32_t)); + } + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (0x48 as uint32_t + | dest >> 24 as ::core::ffi::c_int & 0x3 as uint32_t) as uint8_t; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest + >> 16 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest + >> 8 as ::core::ffi::c_int) as uint8_t; + let ref mut fresh0 = *buffer.offset(i.wrapping_add(3 as size_t) as isize); + *fresh0 = (*fresh0 as ::core::ffi::c_int & 0x3 as ::core::ffi::c_int) + as uint8_t; + let ref mut fresh1 = *buffer.offset(i.wrapping_add(3 as size_t) as isize); + *fresh1 = (*fresh1 as uint32_t | dest) as uint8_t; + } + i = i.wrapping_add(4 as size_t); + } + return i; +} +unsafe extern "C" fn powerpc_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut is_encoder: bool, +) -> lzma_ret { + return lzma_simple_coder_init( + next, + allocator, + filters, + Some( + powerpc_code + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + 0 as size_t, + 4 as size_t, + 4 as uint32_t, + is_encoder, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_powerpc_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return powerpc_coder_init(next, allocator, filters, true_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_powerpc_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return powerpc_coder_init(next, allocator, filters, false_0 != 0); +} diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs new file mode 100644 index 00000000..5814a12d --- /dev/null +++ b/liblzma-rs/src/simple/riscv.rs @@ -0,0 +1,479 @@ +extern "C" { + fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + simple_size: size_t, + unfiltered_max: size_t, + alignment: uint32_t, + is_encoder: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, size_t, size_t) -> *mut ::core::ffi::c_void, + >, + pub free: + Option ()>, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: + Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: + Option lzma_ret>, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = + Option ()>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::<::core::ffi::c_void>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +#[inline] +unsafe extern "C" fn read32be(mut buf: *const uint8_t) -> uint32_t { + let mut num: uint32_t = + (*buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t) << 24 as ::core::ffi::c_int; + num |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) << 16 as ::core::ffi::c_int; + num |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) << 8 as ::core::ffi::c_int; + num |= *buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t; + return num; +} +#[inline] +unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { + let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; + num |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) << 8 as ::core::ffi::c_int; + num |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) << 16 as ::core::ffi::c_int; + num |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) << 24 as ::core::ffi::c_int; + return num; +} +#[inline] +unsafe extern "C" fn write32be(mut buf: *mut uint8_t, mut num: uint32_t) { + *buf.offset(0 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) as uint8_t; + *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) as uint8_t; + *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) as uint8_t; + *buf.offset(3 as ::core::ffi::c_int as isize) = num as uint8_t; +} +#[inline] +unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { + *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; + *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) as uint8_t; + *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) as uint8_t; + *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) as uint8_t; +} +unsafe extern "C" fn riscv_encode( + mut simple: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + if size < 8 as size_t { + return 0 as size_t; + } + size = size.wrapping_sub(8 as size_t); + let mut i: size_t = 0; + let mut current_block_22: u64; + i = 0 as size_t; + while i <= size { + let mut inst: uint32_t = *buffer.offset(i as isize) as uint32_t; + if inst == 0xef as uint32_t { + let b1: uint32_t = *buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t; + if !(b1 & 0xd as uint32_t != 0 as uint32_t) { + let b2: uint32_t = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t; + let b3: uint32_t = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t; + let pc: uint32_t = now_pos.wrapping_add(i as uint32_t); + let mut addr: uint32_t = (b1 & 0xf0 as uint32_t) << 8 as ::core::ffi::c_int + | (b2 & 0xf as uint32_t) << 16 as ::core::ffi::c_int + | (b2 & 0x10 as uint32_t) << 7 as ::core::ffi::c_int + | (b2 & 0xe0 as uint32_t) >> 4 as ::core::ffi::c_int + | (b3 & 0x7f as uint32_t) << 4 as ::core::ffi::c_int + | (b3 & 0x80 as uint32_t) << 13 as ::core::ffi::c_int; + addr = addr.wrapping_add(pc); + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (b1 & 0xf as uint32_t + | addr >> 13 as ::core::ffi::c_int & 0xf0 as uint32_t) + as uint8_t; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = + (addr >> 9 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(3 as size_t) as isize) = + (addr >> 1 as ::core::ffi::c_int) as uint8_t; + i = i.wrapping_add((4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t); + } + } else if inst & 0x7f as uint32_t == 0x17 as uint32_t { + inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t) + << 16 as ::core::ffi::c_int; + inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t) + << 24 as ::core::ffi::c_int; + if inst & 0xe80 as uint32_t != 0 { + let mut inst2: uint32_t = read32le( + buffer + .offset(i as isize) + .offset(4 as ::core::ffi::c_int as isize), + ); + if (inst << 8 as ::core::ffi::c_int ^ inst2.wrapping_sub(3 as uint32_t)) + & 0xf8003 as uint32_t + != 0 + { + i = i.wrapping_add( + (6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, + ); + current_block_22 = 12517898123489920830; + } else { + let mut addr_0: uint32_t = inst & 0xfffff000 as uint32_t; + addr_0 = addr_0.wrapping_add( + (inst2 >> 20 as ::core::ffi::c_int) + .wrapping_sub(inst2 >> 19 as ::core::ffi::c_int & 0x1000 as uint32_t), + ); + addr_0 = addr_0.wrapping_add(now_pos.wrapping_add(i as uint32_t)); + inst = (0x17 as ::core::ffi::c_int + | (2 as ::core::ffi::c_int) << 7 as ::core::ffi::c_int) + as uint32_t + | inst2 << 12 as ::core::ffi::c_int; + write32le(buffer.offset(i as isize), inst); + write32be( + buffer + .offset(i as isize) + .offset(4 as ::core::ffi::c_int as isize), + addr_0, + ); + current_block_22 = 15125582407903384992; + } + } else { + let fake_rs1: uint32_t = inst >> 27 as ::core::ffi::c_int; + if inst.wrapping_sub(0x3117 as uint32_t) << 18 as ::core::ffi::c_int + >= fake_rs1 & 0x1d as uint32_t + { + i = i.wrapping_add( + (4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, + ); + current_block_22 = 12517898123489920830; + } else { + let fake_addr: uint32_t = read32le( + buffer + .offset(i as isize) + .offset(4 as ::core::ffi::c_int as isize), + ) as uint32_t; + let fake_inst2: uint32_t = + inst >> 12 as ::core::ffi::c_int | fake_addr << 20 as ::core::ffi::c_int; + inst = 0x17 as uint32_t + | fake_rs1 << 7 as ::core::ffi::c_int + | fake_addr & 0xfffff000 as uint32_t; + write32le(buffer.offset(i as isize), inst); + write32le( + buffer + .offset(i as isize) + .offset(4 as ::core::ffi::c_int as isize), + fake_inst2, + ); + current_block_22 = 15125582407903384992; + } + } + match current_block_22 { + 12517898123489920830 => {} + _ => { + i = i.wrapping_add( + (8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, + ); + } + } + } + i = i.wrapping_add(2 as size_t); + } + return i; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return lzma_simple_coder_init( + next, + allocator, + filters, + Some( + riscv_encode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + 0 as size_t, + 8 as size_t, + 2 as uint32_t, + true_0 != 0, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_bcj_riscv_encode( + mut start_offset: uint32_t, + mut buf: *mut uint8_t, + mut size: size_t, +) -> size_t { + start_offset = (start_offset as ::core::ffi::c_uint & !(1 as ::core::ffi::c_uint)) as uint32_t; + return riscv_encode(NULL, start_offset, true_0 != 0, buf, size); +} +unsafe extern "C" fn riscv_decode( + mut simple: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + if size < 8 as size_t { + return 0 as size_t; + } + size = size.wrapping_sub(8 as size_t); + let mut i: size_t = 0; + let mut current_block_23: u64; + i = 0 as size_t; + while i <= size { + let mut inst: uint32_t = *buffer.offset(i as isize) as uint32_t; + if inst == 0xef as uint32_t { + let b1: uint32_t = *buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t; + if !(b1 & 0xd as uint32_t != 0 as uint32_t) { + let b2: uint32_t = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t; + let b3: uint32_t = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t; + let pc: uint32_t = now_pos.wrapping_add(i as uint32_t); + let mut addr: uint32_t = (b1 & 0xf0 as uint32_t) << 13 as ::core::ffi::c_int + | b2 << 9 as ::core::ffi::c_int + | b3 << 1 as ::core::ffi::c_int; + addr = addr.wrapping_sub(pc); + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (b1 & 0xf as uint32_t + | addr >> 8 as ::core::ffi::c_int & 0xf0 as uint32_t) + as uint8_t; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = + (addr >> 16 as ::core::ffi::c_int & 0xf as uint32_t + | addr >> 7 as ::core::ffi::c_int & 0x10 as uint32_t + | addr << 4 as ::core::ffi::c_int & 0xe0 as uint32_t) + as uint8_t; + *buffer.offset(i.wrapping_add(3 as size_t) as isize) = + (addr >> 4 as ::core::ffi::c_int & 0x7f as uint32_t + | addr >> 13 as ::core::ffi::c_int & 0x80 as uint32_t) + as uint8_t; + i = i.wrapping_add((4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t); + } + } else if inst & 0x7f as uint32_t == 0x17 as uint32_t { + let mut inst2: uint32_t = 0; + inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t) + << 16 as ::core::ffi::c_int; + inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t) + << 24 as ::core::ffi::c_int; + if inst & 0xe80 as uint32_t != 0 { + inst2 = read32le( + buffer + .offset(i as isize) + .offset(4 as ::core::ffi::c_int as isize), + ); + if (inst << 8 as ::core::ffi::c_int ^ inst2.wrapping_sub(3 as uint32_t)) + & 0xf8003 as uint32_t + != 0 + { + i = i.wrapping_add( + (6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, + ); + current_block_23 = 12517898123489920830; + } else { + let mut addr_0: uint32_t = inst & 0xfffff000 as uint32_t; + addr_0 = addr_0.wrapping_add(inst2 >> 20 as ::core::ffi::c_int); + inst = (0x17 as ::core::ffi::c_int + | (2 as ::core::ffi::c_int) << 7 as ::core::ffi::c_int) + as uint32_t + | inst2 << 12 as ::core::ffi::c_int; + inst2 = addr_0; + current_block_23 = 6669252993407410313; + } + } else { + let inst2_rs1: uint32_t = inst >> 27 as ::core::ffi::c_int; + if inst.wrapping_sub(0x3117 as uint32_t) << 18 as ::core::ffi::c_int + >= inst2_rs1 & 0x1d as uint32_t + { + i = i.wrapping_add( + (4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, + ); + current_block_23 = 12517898123489920830; + } else { + let mut addr_1: uint32_t = read32be( + buffer + .offset(i as isize) + .offset(4 as ::core::ffi::c_int as isize), + ); + addr_1 = addr_1.wrapping_sub(now_pos.wrapping_add(i as uint32_t)); + inst2 = inst >> 12 as ::core::ffi::c_int | addr_1 << 20 as ::core::ffi::c_int; + inst = 0x17 as uint32_t + | inst2_rs1 << 7 as ::core::ffi::c_int + | addr_1.wrapping_add(0x800 as uint32_t) & 0xfffff000 as uint32_t; + current_block_23 = 6669252993407410313; + } + } + match current_block_23 { + 12517898123489920830 => {} + _ => { + write32le(buffer.offset(i as isize), inst); + write32le( + buffer + .offset(i as isize) + .offset(4 as ::core::ffi::c_int as isize), + inst2, + ); + i = i.wrapping_add( + (8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, + ); + } + } + } + i = i.wrapping_add(2 as size_t); + } + return i; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return lzma_simple_coder_init( + next, + allocator, + filters, + Some( + riscv_decode + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + 0 as size_t, + 8 as size_t, + 2 as uint32_t, + false_0 != 0, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_bcj_riscv_decode( + mut start_offset: uint32_t, + mut buf: *mut uint8_t, + mut size: size_t, +) -> size_t { + start_offset = (start_offset as ::core::ffi::c_uint & !(1 as ::core::ffi::c_uint)) as uint32_t; + return riscv_decode(NULL, start_offset, false_0 != 0, buf, size); +} diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs new file mode 100644 index 00000000..6cdbc4b4 --- /dev/null +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -0,0 +1,540 @@ +extern "C" { + fn memcpy( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: size_t, + ) -> *mut ::core::ffi::c_void; + fn memmove( + __dst: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __len: size_t, + ) -> *mut ::core::ffi::c_void; + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + fn lzma_next_filter_update( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + reversed_filters: *const lzma_filter, + ) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const uint8_t, + in_pos: *mut size_t, + in_size: size_t, + out: *mut uint8_t, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_bcj { + pub start_offset: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_simple_coder { + pub next: lzma_next_coder, + pub end_was_reached: bool, + pub is_encoder: bool, + pub filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + pub simple: *mut ::core::ffi::c_void, + pub now_pos: uint32_t, + pub allocated: size_t, + pub pos: size_t, + pub filtered: size_t, + pub size: size_t, + pub buffer: [uint8_t; 0], +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 + as ::core::ffi::c_ulonglong; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +unsafe extern "C" fn copy_or_code( + mut coder: *mut lzma_simple_coder, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + if (*coder).next.code.is_none() { + lzma_bufcpy(in_0, in_pos, in_size, out, out_pos, out_size); + if (*coder).is_encoder as ::core::ffi::c_int != 0 + && action as ::core::ffi::c_uint + == LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + && *in_pos == in_size + { + (*coder).end_was_reached = true_0 != 0; + } + } else { + let ret: lzma_ret = (*coder) + .next + .code + .expect( + "non-null function pointer", + )( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + if ret as ::core::ffi::c_uint + == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint + { + (*coder).end_was_reached = true_0 != 0; + } else if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret + } + } + return LZMA_OK; +} +unsafe extern "C" fn call_filter( + mut coder: *mut lzma_simple_coder, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + let filtered: size_t = (*coder) + .filter + .expect( + "non-null function pointer", + )((*coder).simple, (*coder).now_pos, (*coder).is_encoder, buffer, size) + as size_t; + (*coder).now_pos = ((*coder).now_pos as size_t).wrapping_add(filtered) as uint32_t + as uint32_t; + return filtered; +} +unsafe extern "C" fn simple_code( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const uint8_t, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut uint8_t, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; + if action as ::core::ffi::c_uint + == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + { + return LZMA_OPTIONS_ERROR; + } + if (*coder).pos < (*coder).filtered { + lzma_bufcpy( + &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).pos, + (*coder).filtered, + out, + out_pos, + out_size, + ); + if (*coder).pos < (*coder).filtered { + return LZMA_OK; + } + if (*coder).end_was_reached { + return LZMA_STREAM_END; + } + } + (*coder).filtered = 0 as size_t; + let out_avail: size_t = out_size.wrapping_sub(*out_pos); + let buf_avail: size_t = (*coder).size.wrapping_sub((*coder).pos); + if out_avail > buf_avail || buf_avail == 0 as size_t { + let out_start: size_t = *out_pos; + if buf_avail > 0 as size_t { + memcpy( + out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, + (&raw mut (*coder).buffer as *mut uint8_t).offset((*coder).pos as isize) + as *const ::core::ffi::c_void, + buf_avail, + ); + } + *out_pos = (*out_pos).wrapping_add(buf_avail); + let ret: lzma_ret = copy_or_code( + coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + if ret as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret; + } + let size: size_t = (*out_pos).wrapping_sub(out_start); + let filtered: size_t = if size == 0 as size_t { + 0 as size_t + } else { + call_filter(coder, out.offset(out_start as isize), size) as size_t + }; + let unfiltered: size_t = size.wrapping_sub(filtered); + (*coder).pos = 0 as size_t; + (*coder).size = unfiltered; + if (*coder).end_was_reached { + (*coder).size = 0 as size_t; + } else if unfiltered > 0 as size_t { + *out_pos = (*out_pos).wrapping_sub(unfiltered); + memcpy( + &raw mut (*coder).buffer as *mut uint8_t as *mut ::core::ffi::c_void, + out.offset(*out_pos as isize) as *const ::core::ffi::c_void, + unfiltered, + ); + } + } else if (*coder).pos > 0 as size_t { + memmove( + &raw mut (*coder).buffer as *mut uint8_t as *mut ::core::ffi::c_void, + (&raw mut (*coder).buffer as *mut uint8_t).offset((*coder).pos as isize) + as *const ::core::ffi::c_void, + buf_avail, + ); + (*coder).size = (*coder).size.wrapping_sub((*coder).pos); + (*coder).pos = 0 as size_t; + } + if (*coder).size > 0 as size_t { + let ret_0: lzma_ret = copy_or_code( + coder, + allocator, + in_0, + in_pos, + in_size, + &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).size, + (*coder).allocated, + action, + ) as lzma_ret; + if ret_0 as ::core::ffi::c_uint + != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + return ret_0; + } + (*coder).filtered = call_filter( + coder, + &raw mut (*coder).buffer as *mut uint8_t, + (*coder).size, + ); + if (*coder).end_was_reached { + (*coder).filtered = (*coder).size; + } + lzma_bufcpy( + &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).pos, + (*coder).filtered, + out, + out_pos, + out_size, + ); + } + if (*coder).end_was_reached as ::core::ffi::c_int != 0 + && (*coder).pos == (*coder).size + { + return LZMA_STREAM_END; + } + return LZMA_OK; +} +unsafe extern "C" fn simple_coder_end( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; + lzma_next_end(&raw mut (*coder).next, allocator); + lzma_free((*coder).simple, allocator); + lzma_free(coder as *mut ::core::ffi::c_void, allocator); +} +unsafe extern "C" fn simple_coder_update( + mut coder_ptr: *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut filters_null: *const lzma_filter, + mut reversed_filters: *const lzma_filter, +) -> lzma_ret { + let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; + return lzma_next_filter_update( + &raw mut (*coder).next, + allocator, + reversed_filters.offset(1 as ::core::ffi::c_int as isize), + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + mut simple_size: size_t, + mut unfiltered_max: size_t, + mut alignment: uint32_t, + mut is_encoder: bool, +) -> lzma_ret { + let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; + if coder.is_null() { + coder = lzma_alloc( + (::core::mem::size_of::() as size_t) + .wrapping_add((2 as size_t).wrapping_mul(unfiltered_max)), + allocator, + ) as *mut lzma_simple_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).code = Some( + simple_code + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + simple_coder_end + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + ) -> (), + ) as lzma_end_function; + (*next).update = Some( + simple_coder_update + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >; + (*coder).next = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*coder).filter = filter; + (*coder).allocated = (2 as size_t).wrapping_mul(unfiltered_max); + if simple_size > 0 as size_t { + (*coder).simple = lzma_alloc(simple_size, allocator); + if (*coder).simple.is_null() { + return LZMA_MEM_ERROR; + } + } else { + (*coder).simple = NULL; + } + } + if !(*filters.offset(0 as ::core::ffi::c_int as isize)).options.is_null() { + let mut simple: *const lzma_options_bcj = (*filters + .offset(0 as ::core::ffi::c_int as isize)) + .options as *const lzma_options_bcj; + (*coder).now_pos = (*simple).start_offset; + if (*coder).now_pos & alignment.wrapping_sub(1 as uint32_t) != 0 { + return LZMA_OPTIONS_ERROR; + } + } else { + (*coder).now_pos = 0 as uint32_t; + } + (*coder).is_encoder = is_encoder; + (*coder).end_was_reached = false_0 != 0; + (*coder).pos = 0 as size_t; + (*coder).filtered = 0 as size_t; + (*coder).size = 0 as size_t; + return lzma_next_filter_init( + &raw mut (*coder).next, + allocator, + filters.offset(1 as ::core::ffi::c_int as isize), + ); +} diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs new file mode 100644 index 00000000..2d3f6e54 --- /dev/null +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -0,0 +1,99 @@ +extern "C" { + fn lzma_alloc( + size: size_t, + allocator: *const lzma_allocator, + ) -> *mut ::core::ffi::c_void; + fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); +} +pub type __darwin_size_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_bcj { + pub start_offset: uint32_t, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +#[inline] +unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { + let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; + num + |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) + << 8 as ::core::ffi::c_int; + num + |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) + << 16 as ::core::ffi::c_int; + num + |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) + << 24 as ::core::ffi::c_int; + return num; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_props_decode( + mut options: *mut *mut ::core::ffi::c_void, + mut allocator: *const lzma_allocator, + mut props: *const uint8_t, + mut props_size: size_t, +) -> lzma_ret { + if props_size == 0 as size_t { + return LZMA_OK; + } + if props_size != 4 as size_t { + return LZMA_OPTIONS_ERROR; + } + let mut opt: *mut lzma_options_bcj = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_options_bcj; + if opt.is_null() { + return LZMA_MEM_ERROR; + } + (*opt).start_offset = read32le(props); + if (*opt).start_offset == 0 as uint32_t { + lzma_free(opt as *mut ::core::ffi::c_void, allocator); + } else { + *options = opt as *mut ::core::ffi::c_void; + } + return LZMA_OK; +} diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs new file mode 100644 index 00000000..80a8b7d5 --- /dev/null +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -0,0 +1,68 @@ +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_bcj { + pub start_offset: uint32_t, +} +pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< + ::core::ffi::c_void, +>(); +pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +#[inline] +unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { + *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; + *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) + as uint8_t; + *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) + as uint8_t; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_props_size( + mut size: *mut uint32_t, + mut options: *const ::core::ffi::c_void, +) -> lzma_ret { + let opt: *const lzma_options_bcj = options as *const lzma_options_bcj; + *size = (if opt.is_null() || (*opt).start_offset == 0 as uint32_t { + 0 as ::core::ffi::c_int + } else { + 4 as ::core::ffi::c_int + }) as uint32_t; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_props_encode( + mut options: *const ::core::ffi::c_void, + mut out: *mut uint8_t, +) -> lzma_ret { + let opt: *const lzma_options_bcj = options as *const lzma_options_bcj; + if opt.is_null() || (*opt).start_offset == 0 as uint32_t { + return LZMA_OK; + } + write32le(out, (*opt).start_offset); + return LZMA_OK; +} diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs new file mode 100644 index 00000000..7f6b91ec --- /dev/null +++ b/liblzma-rs/src/simple/sparc.rs @@ -0,0 +1,250 @@ +extern "C" { + fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + simple_size: size_t, + unfiltered_max: size_t, + alignment: uint32_t, + is_encoder: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn sparc_code( + mut simple: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + size &= !(3 as ::core::ffi::c_int as size_t); + let mut i: size_t = 0; + i = 0 as size_t; + while i < size { + if *buffer.offset(i as isize) as ::core::ffi::c_int == 0x40 as ::core::ffi::c_int + && *buffer.offset(i.wrapping_add(1 as size_t) as isize) as ::core::ffi::c_int + & 0xc0 as ::core::ffi::c_int == 0 as ::core::ffi::c_int + || *buffer.offset(i as isize) as ::core::ffi::c_int + == 0x7f as ::core::ffi::c_int + && *buffer.offset(i.wrapping_add(1 as size_t) as isize) + as ::core::ffi::c_int & 0xc0 as ::core::ffi::c_int + == 0xc0 as ::core::ffi::c_int + { + let mut src: uint32_t = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) + as uint32_t) << 24 as ::core::ffi::c_int + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) + << 16 as ::core::ffi::c_int + | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t) + << 8 as ::core::ffi::c_int + | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t; + src <<= 2 as ::core::ffi::c_int; + let mut dest: uint32_t = 0; + if is_encoder { + dest = now_pos.wrapping_add(i as uint32_t).wrapping_add(src); + } else { + dest = src.wrapping_sub(now_pos.wrapping_add(i as uint32_t)); + } + dest >>= 2 as ::core::ffi::c_int; + dest = (0 as uint32_t) + .wrapping_sub(dest >> 22 as ::core::ffi::c_int & 1 as uint32_t) + << 22 as ::core::ffi::c_int & 0x3fffffff as uint32_t + | dest & 0x3fffff as uint32_t | 0x40000000 as uint32_t; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest + >> 24 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest + >> 16 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest + >> 8 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(3 as size_t) as isize) = dest as uint8_t; + } + i = i.wrapping_add(4 as size_t); + } + return i; +} +unsafe extern "C" fn sparc_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut is_encoder: bool, +) -> lzma_ret { + return lzma_simple_coder_init( + next, + allocator, + filters, + Some( + sparc_code + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + 0 as size_t, + 4 as size_t, + 4 as uint32_t, + is_encoder, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_sparc_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return sparc_coder_init(next, allocator, filters, true_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_sparc_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return sparc_coder_init(next, allocator, filters, false_0 != 0); +} diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs new file mode 100644 index 00000000..a66005f9 --- /dev/null +++ b/liblzma-rs/src/simple/x86.rs @@ -0,0 +1,393 @@ +extern "C" { + fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + simple_size: size_t, + unfiltered_max: size_t, + alignment: uint32_t, + is_encoder: bool, + ) -> lzma_ret; +} +pub type __darwin_size_t = usize; +pub type uintptr_t = usize; +pub type size_t = __darwin_size_t; +pub type uint8_t = u8; +pub type uint32_t = u32; +pub type uint64_t = u64; +pub type lzma_ret = ::core::ffi::c_uint; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub type lzma_action = ::core::ffi::c_uint; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + size_t, + size_t, + ) -> *mut ::core::ffi::c_void, + >, + pub free: Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), + >, + pub opaque: *mut ::core::ffi::c_void, +} +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut ::core::ffi::c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + ) -> (), + >, + pub get_check: Option< + unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, + >, + pub memconfig: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, + pub update: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *mut uint64_t, + uint64_t, + ) -> lzma_ret, + >, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_vli = uint64_t; +pub type lzma_check = ::core::ffi::c_uint; +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option< + unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), +>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + *const lzma_allocator, + *const uint8_t, + *mut size_t, + size_t, + *mut uint8_t, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_simple_x86 { + pub prev_mask: uint32_t, + pub prev_pos: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut ::core::ffi::c_void, +} +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +pub type lzma_filter_info = lzma_filter_info_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_simple_coder { + pub next: lzma_next_coder, + pub end_was_reached: bool, + pub is_encoder: bool, + pub filter: Option< + unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + >, + pub simple: *mut ::core::ffi::c_void, + pub now_pos: uint32_t, + pub allocated: size_t, + pub pos: size_t, + pub filtered: size_t, + pub size: size_t, + pub buffer: [uint8_t; 0], +} +pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +unsafe extern "C" fn x86_code( + mut simple_ptr: *mut ::core::ffi::c_void, + mut now_pos: uint32_t, + mut is_encoder: bool, + mut buffer: *mut uint8_t, + mut size: size_t, +) -> size_t { + static mut MASK_TO_BIT_NUMBER: [uint32_t; 5] = [ + 0 as ::core::ffi::c_int as uint32_t, + 1 as ::core::ffi::c_int as uint32_t, + 2 as ::core::ffi::c_int as uint32_t, + 2 as ::core::ffi::c_int as uint32_t, + 3 as ::core::ffi::c_int as uint32_t, + ]; + let mut simple: *mut lzma_simple_x86 = simple_ptr as *mut lzma_simple_x86; + let mut prev_mask: uint32_t = (*simple).prev_mask; + let mut prev_pos: uint32_t = (*simple).prev_pos; + if size < 5 as size_t { + return 0 as size_t; + } + if now_pos.wrapping_sub(prev_pos) > 5 as uint32_t { + prev_pos = now_pos.wrapping_sub(5 as uint32_t); + } + let limit: size_t = size.wrapping_sub(5 as size_t); + let mut buffer_pos: size_t = 0 as size_t; + while buffer_pos <= limit { + let mut b: uint8_t = *buffer.offset(buffer_pos as isize); + if b as ::core::ffi::c_int != 0xe8 as ::core::ffi::c_int + && b as ::core::ffi::c_int != 0xe9 as ::core::ffi::c_int + { + buffer_pos = buffer_pos.wrapping_add(1); + } else { + let offset: uint32_t = now_pos + .wrapping_add(buffer_pos as uint32_t) + .wrapping_sub(prev_pos); + prev_pos = now_pos.wrapping_add(buffer_pos as uint32_t); + if offset > 5 as uint32_t { + prev_mask = 0 as uint32_t; + } else { + let mut i: uint32_t = 0 as uint32_t; + while i < offset { + prev_mask &= 0x77 as uint32_t; + prev_mask <<= 1 as ::core::ffi::c_int; + i = i.wrapping_add(1); + } + } + b = *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize); + if (b as ::core::ffi::c_int == 0 as ::core::ffi::c_int + || b as ::core::ffi::c_int == 0xff as ::core::ffi::c_int) + && prev_mask >> 1 as ::core::ffi::c_int <= 4 as uint32_t + && prev_mask >> 1 as ::core::ffi::c_int != 3 as uint32_t + { + let mut src: uint32_t = (b as uint32_t) << 24 as ::core::ffi::c_int + | (*buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) + as uint32_t) << 16 as ::core::ffi::c_int + | (*buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) + as uint32_t) << 8 as ::core::ffi::c_int + | *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) + as uint32_t; + let mut dest: uint32_t = 0; + loop { + if is_encoder { + dest = src + .wrapping_add( + now_pos + .wrapping_add(buffer_pos as uint32_t) + .wrapping_add(5 as uint32_t), + ); + } else { + dest = src + .wrapping_sub( + now_pos + .wrapping_add(buffer_pos as uint32_t) + .wrapping_add(5 as uint32_t), + ); + } + if prev_mask == 0 as uint32_t { + break; + } + let i_0: uint32_t = MASK_TO_BIT_NUMBER[(prev_mask + >> 1 as ::core::ffi::c_int) as usize]; + b = (dest + >> (24 as uint32_t) + .wrapping_sub(i_0.wrapping_mul(8 as uint32_t))) as uint8_t; + if !(b as ::core::ffi::c_int == 0 as ::core::ffi::c_int + || b as ::core::ffi::c_int == 0xff as ::core::ffi::c_int) + { + break; + } + src = dest + ^ ((1 as uint32_t) + << (32 as uint32_t) + .wrapping_sub(i_0.wrapping_mul(8 as uint32_t))) + .wrapping_sub(1 as uint32_t); + } + *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize) = !(dest + >> 24 as ::core::ffi::c_int & 1 as uint32_t) + .wrapping_sub(1 as uint32_t) as uint8_t; + *buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) = (dest + >> 16 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) = (dest + >> 8 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) = dest + as uint8_t; + buffer_pos = buffer_pos.wrapping_add(5 as size_t); + prev_mask = 0 as uint32_t; + } else { + buffer_pos = buffer_pos.wrapping_add(1); + prev_mask |= 1 as uint32_t; + if b as ::core::ffi::c_int == 0 as ::core::ffi::c_int + || b as ::core::ffi::c_int == 0xff as ::core::ffi::c_int + { + prev_mask |= 0x10 as uint32_t; + } + } + } + } + (*simple).prev_mask = prev_mask; + (*simple).prev_pos = prev_pos; + return buffer_pos; +} +unsafe extern "C" fn x86_coder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, + mut is_encoder: bool, +) -> lzma_ret { + let ret: lzma_ret = lzma_simple_coder_init( + next, + allocator, + filters, + Some( + x86_code + as unsafe extern "C" fn( + *mut ::core::ffi::c_void, + uint32_t, + bool, + *mut uint8_t, + size_t, + ) -> size_t, + ), + ::core::mem::size_of::() as size_t, + 5 as size_t, + 1 as uint32_t, + is_encoder, + ) as lzma_ret; + if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + { + let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; + let mut simple: *mut lzma_simple_x86 = (*coder).simple as *mut lzma_simple_x86; + (*simple).prev_mask = 0 as uint32_t; + (*simple).prev_pos = -(5 as ::core::ffi::c_int) as uint32_t; + } + return ret; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_x86_encoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return x86_coder_init(next, allocator, filters, true_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_bcj_x86_encode( + mut start_offset: uint32_t, + mut buf: *mut uint8_t, + mut size: size_t, +) -> size_t { + let mut simple: lzma_simple_x86 = lzma_simple_x86 { + prev_mask: 0 as uint32_t, + prev_pos: -(5 as ::core::ffi::c_int) as uint32_t, + }; + return x86_code( + &raw mut simple as *mut ::core::ffi::c_void, + start_offset, + true_0 != 0, + buf, + size, + ); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_simple_x86_decoder_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter_info, +) -> lzma_ret { + return x86_coder_init(next, allocator, filters, false_0 != 0); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_bcj_x86_decode( + mut start_offset: uint32_t, + mut buf: *mut uint8_t, + mut size: size_t, +) -> size_t { + let mut simple: lzma_simple_x86 = lzma_simple_x86 { + prev_mask: 0 as uint32_t, + prev_pos: -(5 as ::core::ffi::c_int) as uint32_t, + }; + return x86_code( + &raw mut simple as *mut ::core::ffi::c_void, + start_offset, + false_0 != 0, + buf, + size, + ); +} diff --git a/liblzma-rs/src/tuklib/mod.rs b/liblzma-rs/src/tuklib/mod.rs new file mode 100644 index 00000000..fadc9769 --- /dev/null +++ b/liblzma-rs/src/tuklib/mod.rs @@ -0,0 +1,2 @@ +pub mod tuklib_cpucores; +pub mod tuklib_physmem; diff --git a/liblzma-rs/src/tuklib/tuklib_cpucores.rs b/liblzma-rs/src/tuklib/tuklib_cpucores.rs new file mode 100644 index 00000000..c6019781 --- /dev/null +++ b/liblzma-rs/src/tuklib/tuklib_cpucores.rs @@ -0,0 +1,9 @@ +pub type uint32_t = u32; + +#[no_mangle] +pub unsafe extern "C" fn tuklib_cpucores() -> uint32_t { + match std::thread::available_parallelism() { + Ok(n) => n.get() as uint32_t, + Err(_) => 0, + } +} diff --git a/liblzma-rs/src/tuklib/tuklib_physmem.rs b/liblzma-rs/src/tuklib/tuklib_physmem.rs new file mode 100644 index 00000000..f1181bd8 --- /dev/null +++ b/liblzma-rs/src/tuklib/tuklib_physmem.rs @@ -0,0 +1,45 @@ +pub type uint64_t = u64; + +#[no_mangle] +pub unsafe extern "C" fn tuklib_physmem() -> uint64_t { + #[cfg(target_os = "macos")] + { + let mut memsize: u64 = 0; + let mut len = core::mem::size_of::() as libc::size_t; + let mut mib: [libc::c_int; 2] = [libc::CTL_HW, libc::HW_MEMSIZE]; + if libc::sysctl( + mib.as_mut_ptr(), + 2, + &mut memsize as *mut u64 as *mut libc::c_void, + &mut len, + core::ptr::null_mut(), + 0, + ) == 0 + { + return memsize; + } + 0 + } + + #[cfg(target_os = "linux")] + { + let pages = libc::sysconf(libc::_SC_PHYS_PAGES); + let page_size = libc::sysconf(libc::_SC_PAGESIZE); + if pages > 0 && page_size > 0 { + return (pages as u64).wrapping_mul(page_size as u64); + } + 0 + } + + #[cfg(target_os = "windows")] + { + // On Windows, use GetSystemInfo-based approach or return 0 + // Windows support would need winapi/windows-sys crate + 0 + } + + #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))] + { + 0 + } +} diff --git a/systest/Cargo.toml b/systest/Cargo.toml index 4da58c2e..46aedd25 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -7,11 +7,15 @@ edition = "2021" publish = false [dependencies] -liblzma-sys = { path = "../liblzma-sys" } +liblzma-c-sys = { package = "liblzma-sys", path = "../liblzma-sys", optional = true } +liblzma-rs-sys = { path = "../liblzma-rs-sys", optional = true } libc = "0.2" [build-dependencies] ctest2 = "0.4" [features] -bindgen = ["liblzma-sys/bindgen"] +default = ["c-sys"] +c-sys = ["dep:liblzma-c-sys"] +rs-sys = ["dep:liblzma-rs-sys"] +bindgen = ["c-sys", "liblzma-c-sys/bindgen"] diff --git a/systest/build.rs b/systest/build.rs index 9539fdc4..736a65d4 100644 --- a/systest/build.rs +++ b/systest/build.rs @@ -1,14 +1,32 @@ use std::env; fn main() { + let use_c_sys = env::var_os("CARGO_FEATURE_C_SYS").is_some(); + let use_rs_sys = env::var_os("CARGO_FEATURE_RS_SYS").is_some(); + match (use_c_sys, use_rs_sys) { + (true, false) | (false, true) => {} + _ => panic!("Enable exactly one of features: c-sys or rs-sys"), + } + let mut cfg = ctest2::TestGenerator::new(); - if let Ok(out) = env::var("DEP_LZMA_INCLUDE") { - cfg.include(&out); + if use_c_sys { + if let Ok(out) = env::var("DEP_LZMA_INCLUDE") { + cfg.include(&out); + } + } else { + // Reuse vendored upstream headers to verify C header compatibility. + cfg.include("../liblzma-sys/xz/src/liblzma/api"); } cfg.header("lzma.h"); cfg.type_name(|n, _s, _| n.to_string()); cfg.define("LZMA_API_STATIC", None); cfg.skip_type(|n| n == "__enum_ty"); - cfg.generate("../liblzma-sys/src/lib.rs", "all.rs"); + + let rust_api = if use_c_sys { + "../liblzma-sys/src/lib.rs" + } else { + "../liblzma-rs-sys/src/lib.rs" + }; + cfg.generate(rust_api, "all.rs"); } diff --git a/systest/src/main.rs b/systest/src/main.rs index ce7f47c8..81b91f5d 100644 --- a/systest/src/main.rs +++ b/systest/src/main.rs @@ -1,4 +1,13 @@ #![allow(bad_style)] -use liblzma_sys::*; + +#[cfg(all(feature = "c-sys", feature = "rs-sys"))] +compile_error!("Enable exactly one backend feature: c-sys or rs-sys"); +#[cfg(not(any(feature = "c-sys", feature = "rs-sys")))] +compile_error!("Enable one backend feature: c-sys or rs-sys"); + +#[cfg(feature = "c-sys")] +use liblzma_c_sys::*; +#[cfg(feature = "rs-sys")] +use liblzma_rs_sys::*; include!(concat!(env!("OUT_DIR"), "/all.rs")); diff --git a/tests/sys_equivalence.rs b/tests/sys_equivalence.rs new file mode 100644 index 00000000..f36549ed --- /dev/null +++ b/tests/sys_equivalence.rs @@ -0,0 +1,584 @@ +use std::collections::BTreeMap; +use std::fs; +use std::path::Path; +use std::ptr; + +use liblzma_c_sys_test as c_sys; +use liblzma_sys as rs_sys; + +fn parse_feature_table(cargo_toml: &str) -> BTreeMap> { + let mut in_features = false; + let mut features = BTreeMap::new(); + + for raw_line in cargo_toml.lines() { + let line = raw_line.trim(); + if line.starts_with('[') && line.ends_with(']') { + in_features = line == "[features]"; + continue; + } + if !in_features || line.is_empty() || line.starts_with('#') { + continue; + } + + let line = line.split('#').next().unwrap_or("").trim(); + if line.is_empty() { + continue; + } + + let (name, rhs) = line + .split_once('=') + .expect("feature entry must contain '='"); + let name = name.trim().to_owned(); + let rhs = rhs.trim(); + let mut deps = Vec::new(); + + if rhs != "[]" { + assert!( + rhs.starts_with('[') && rhs.ends_with(']'), + "feature value must be an array: {name} = {rhs}", + ); + let inner = &rhs[1..rhs.len() - 1]; + for item in inner.split(',') { + let item = item.trim(); + if item.is_empty() { + continue; + } + let item = item + .strip_prefix('"') + .and_then(|s| s.strip_suffix('"')) + .unwrap_or_else(|| panic!("feature dependency must be quoted: {item}")); + deps.push(item.to_owned()); + } + } + + features.insert(name, deps); + } + + features +} + +#[test] +fn rs_sys_avoids_literal_lzma_const_defs() { + let src = include_str!("../liblzma-rs-sys/src/lib.rs"); + let mut stmt = String::new(); + let mut start_line = 0usize; + let mut in_const = false; + + for (idx, line) in src.lines().enumerate() { + let trimmed = line.trim_start(); + if !in_const && trimmed.starts_with("pub const LZMA_") { + in_const = true; + start_line = idx + 1; + stmt.clear(); + } + + if in_const { + stmt.push_str(trimmed); + stmt.push(' '); + if trimmed.ends_with(';') { + assert!( + stmt.contains("= liblzma_rs::"), + "LZMA const must alias liblzma_rs symbol, not use local literal (line {}): {}", + start_line, + stmt + ); + in_const = false; + } + } + } +} + +#[test] +fn rs_sys_uses_libc_size_t() { + let src = include_str!("../liblzma-rs-sys/src/lib.rs"); + assert!( + src.contains("use libc::size_t;"), + "liblzma-rs-sys must import libc::size_t directly" + ); + assert!( + !src.contains("type size_t ="), + "local size_t alias is forbidden; use libc::size_t" + ); +} + +#[test] +fn cargo_features_match_c_backend() { + let c_sys_features = parse_feature_table(include_str!("../liblzma-sys/Cargo.toml")); + let rs_sys_features = parse_feature_table(include_str!("../liblzma-rs-sys/Cargo.toml")); + + assert_eq!( + rs_sys_features, c_sys_features, + "liblzma-rs-sys feature table must stay compatible with liblzma-sys", + ); +} + +#[test] +fn api_constants_match_c_backend() { + macro_rules! assert_const_eq { + ($($name:ident),+ $(,)?) => { + $( + assert_eq!( + rs_sys::$name as u128, + c_sys::$name as u128, + "constant mismatch: {}", + stringify!($name) + ); + )+ + }; + } + + assert_const_eq!( + LZMA_OK, + LZMA_STREAM_END, + LZMA_NO_CHECK, + LZMA_UNSUPPORTED_CHECK, + LZMA_GET_CHECK, + LZMA_MEM_ERROR, + LZMA_MEMLIMIT_ERROR, + LZMA_FORMAT_ERROR, + LZMA_OPTIONS_ERROR, + LZMA_DATA_ERROR, + LZMA_BUF_ERROR, + LZMA_PROG_ERROR, + LZMA_SEEK_NEEDED, + LZMA_RUN, + LZMA_SYNC_FLUSH, + LZMA_FULL_FLUSH, + LZMA_FULL_BARRIER, + LZMA_FINISH, + LZMA_CHECK_NONE, + LZMA_CHECK_CRC32, + LZMA_CHECK_CRC64, + LZMA_CHECK_SHA256, + LZMA_MODE_FAST, + LZMA_MODE_NORMAL, + LZMA_MF_HC3, + LZMA_MF_HC4, + LZMA_MF_BT2, + LZMA_MF_BT3, + LZMA_MF_BT4, + LZMA_TELL_NO_CHECK, + LZMA_TELL_UNSUPPORTED_CHECK, + LZMA_TELL_ANY_CHECK, + LZMA_IGNORE_CHECK, + LZMA_CONCATENATED, + LZMA_PRESET_DEFAULT, + LZMA_PRESET_LEVEL_MASK, + LZMA_PRESET_EXTREME, + LZMA_DICT_SIZE_MIN, + LZMA_DICT_SIZE_DEFAULT, + LZMA_LCLP_MIN, + LZMA_LCLP_MAX, + LZMA_LC_DEFAULT, + LZMA_LP_DEFAULT, + LZMA_PB_MIN, + LZMA_PB_MAX, + LZMA_PB_DEFAULT, + LZMA_BACKWARD_SIZE_MIN, + LZMA_BACKWARD_SIZE_MAX, + LZMA_VLI_MAX, + LZMA_VLI_UNKNOWN, + LZMA_VLI_BYTES_MAX, + LZMA_FILTER_X86, + LZMA_FILTER_POWERPC, + LZMA_FILTER_IA64, + LZMA_FILTER_ARM, + LZMA_FILTER_ARMTHUMB, + LZMA_FILTER_SPARC, + LZMA_FILTER_ARM64, + LZMA_FILTER_DELTA, + LZMA_FILTER_RISCV, + LZMA_FILTER_LZMA1, + LZMA_FILTER_LZMA2, + LZMA_STREAM_HEADER_SIZE, + ); +} + +#[test] +fn api_constant_types_match_c_backend() { + fn assert_same_type(_: T, _: T) {} + + macro_rules! assert_const_type_eq { + ($($name:ident),+ $(,)?) => { + $( + assert_same_type(c_sys::$name, rs_sys::$name); + )+ + }; + } + + assert_const_type_eq!( + LZMA_OK, + LZMA_STREAM_END, + LZMA_NO_CHECK, + LZMA_UNSUPPORTED_CHECK, + LZMA_GET_CHECK, + LZMA_MEM_ERROR, + LZMA_MEMLIMIT_ERROR, + LZMA_FORMAT_ERROR, + LZMA_OPTIONS_ERROR, + LZMA_DATA_ERROR, + LZMA_BUF_ERROR, + LZMA_PROG_ERROR, + LZMA_SEEK_NEEDED, + LZMA_RUN, + LZMA_SYNC_FLUSH, + LZMA_FULL_FLUSH, + LZMA_FULL_BARRIER, + LZMA_FINISH, + LZMA_CHECK_NONE, + LZMA_CHECK_CRC32, + LZMA_CHECK_CRC64, + LZMA_CHECK_SHA256, + LZMA_MODE_FAST, + LZMA_MODE_NORMAL, + LZMA_MF_HC3, + LZMA_MF_HC4, + LZMA_MF_BT2, + LZMA_MF_BT3, + LZMA_MF_BT4, + LZMA_TELL_NO_CHECK, + LZMA_TELL_UNSUPPORTED_CHECK, + LZMA_TELL_ANY_CHECK, + LZMA_IGNORE_CHECK, + LZMA_CONCATENATED, + LZMA_PRESET_DEFAULT, + LZMA_PRESET_LEVEL_MASK, + LZMA_PRESET_EXTREME, + LZMA_DICT_SIZE_MIN, + LZMA_DICT_SIZE_DEFAULT, + LZMA_LCLP_MIN, + LZMA_LCLP_MAX, + LZMA_LC_DEFAULT, + LZMA_LP_DEFAULT, + LZMA_PB_MIN, + LZMA_PB_MAX, + LZMA_PB_DEFAULT, + LZMA_BACKWARD_SIZE_MIN, + LZMA_BACKWARD_SIZE_MAX, + LZMA_VLI_MAX, + LZMA_VLI_UNKNOWN, + LZMA_VLI_BYTES_MAX, + LZMA_FILTER_X86, + LZMA_FILTER_POWERPC, + LZMA_FILTER_IA64, + LZMA_FILTER_ARM, + LZMA_FILTER_ARMTHUMB, + LZMA_FILTER_SPARC, + LZMA_FILTER_ARM64, + LZMA_FILTER_DELTA, + LZMA_FILTER_RISCV, + LZMA_FILTER_LZMA1, + LZMA_FILTER_LZMA2, + LZMA_STREAM_HEADER_SIZE, + ); +} + +#[test] +fn api_type_layout_matches_c_backend() { + macro_rules! assert_layout_eq { + ($name:ident) => { + assert_eq!( + std::mem::size_of::(), + std::mem::size_of::(), + "size mismatch: {}", + stringify!($name) + ); + assert_eq!( + std::mem::align_of::(), + std::mem::align_of::(), + "align mismatch: {}", + stringify!($name) + ); + }; + } + + assert_layout_eq!(lzma_bool); + assert_layout_eq!(lzma_ret); + assert_layout_eq!(lzma_action); + assert_layout_eq!(lzma_check); + assert_layout_eq!(lzma_vli); + assert_layout_eq!(lzma_mode); + assert_layout_eq!(lzma_match_finder); + assert_layout_eq!(lzma_allocator); + assert_layout_eq!(lzma_stream); + assert_layout_eq!(lzma_filter); + assert_layout_eq!(lzma_options_lzma); + assert_layout_eq!(lzma_stream_flags); + assert_layout_eq!(lzma_options_bcj); + + #[cfg(feature = "parallel")] + assert_layout_eq!(lzma_mt); + + // Opaque types can have intentionally different concrete representations. + let _: *mut rs_sys::lzma_internal = std::ptr::null_mut(); + let _: *mut c_sys::lzma_internal = std::ptr::null_mut(); + let _: *mut rs_sys::lzma_index = std::ptr::null_mut(); + let _: *mut c_sys::lzma_index = std::ptr::null_mut(); +} + +#[test] +fn api_functions_are_exported() { + macro_rules! assert_fn_exported { + ($($name:ident),+ $(,)?) => { + $( + let _ = c_sys::$name as *const () as usize; + let _ = rs_sys::$name as *const () as usize; + )+ + }; + } + + assert_fn_exported!( + lzma_code, + lzma_end, + lzma_get_progress, + lzma_memusage, + lzma_memlimit_get, + lzma_memlimit_set, + lzma_easy_encoder_memusage, + lzma_easy_decoder_memusage, + lzma_easy_encoder, + lzma_easy_buffer_encode, + lzma_stream_encoder, + lzma_alone_encoder, + lzma_stream_buffer_bound, + lzma_stream_buffer_encode, + lzma_stream_decoder, + lzma_auto_decoder, + lzma_alone_decoder, + lzma_lzip_decoder, + lzma_stream_buffer_decode, + lzma_check_is_supported, + lzma_check_size, + lzma_crc32, + lzma_crc64, + lzma_get_check, + lzma_filter_encoder_is_supported, + lzma_filter_decoder_is_supported, + lzma_filters_copy, + lzma_raw_encoder_memusage, + lzma_raw_decoder_memusage, + lzma_raw_encoder, + lzma_raw_decoder, + lzma_filters_update, + lzma_raw_buffer_encode, + lzma_raw_buffer_decode, + lzma_properties_size, + lzma_properties_encode, + lzma_properties_decode, + lzma_physmem, + lzma_cputhreads, + lzma_stream_header_encode, + lzma_stream_footer_encode, + lzma_stream_header_decode, + lzma_stream_footer_decode, + lzma_stream_flags_compare, + lzma_version_number, + lzma_version_string, + lzma_vli_encode, + lzma_vli_decode, + lzma_vli_size, + lzma_lzma_preset, + lzma_mf_is_supported, + lzma_index_buffer_decode, + lzma_index_uncompressed_size, + lzma_index_end, + ); + + #[cfg(feature = "parallel")] + assert_fn_exported!( + lzma_stream_encoder_mt_memusage, + lzma_stream_encoder_mt, + lzma_stream_decoder_mt, + lzma_mt_block_size, + ); +} + +#[inline] +unsafe fn c_encode_easy(input: &[u8]) -> (u32, Vec) { + let bound = c_sys::lzma_stream_buffer_bound(input.len()); + let mut out = vec![0u8; bound]; + let mut out_pos: usize = 0; + let ret = c_sys::lzma_easy_buffer_encode( + 6, + c_sys::LZMA_CHECK_CRC64, + ptr::null(), + input.as_ptr(), + input.len(), + out.as_mut_ptr(), + &mut out_pos, + out.len(), + ); + out.truncate(out_pos); + (ret as u32, out) +} + +#[inline] +unsafe fn rs_encode_easy(input: &[u8]) -> (u32, Vec) { + let bound = rs_sys::lzma_stream_buffer_bound(input.len()); + let mut out = vec![0u8; bound]; + let mut out_pos: usize = 0; + let ret = rs_sys::lzma_easy_buffer_encode( + 6, + rs_sys::LZMA_CHECK_CRC64, + ptr::null(), + input.as_ptr(), + input.len(), + out.as_mut_ptr(), + &mut out_pos, + out.len(), + ); + out.truncate(out_pos); + (ret as u32, out) +} + +#[inline] +unsafe fn c_decode_stream_buffer(input: &[u8], expected_size_hint: usize) -> (u32, Vec) { + let mut cap = expected_size_hint.max(input.len() * 6 + 128).max(256); + let max_cap = 64 * 1024 * 1024; + + loop { + let mut out = vec![0u8; cap]; + let mut memlimit = u64::MAX; + let mut in_pos = 0usize; + let mut out_pos = 0usize; + let ret = c_sys::lzma_stream_buffer_decode( + &mut memlimit, + 0, + ptr::null(), + input.as_ptr(), + &mut in_pos, + input.len(), + out.as_mut_ptr(), + &mut out_pos, + out.len(), + ); + if ret as u32 == c_sys::LZMA_BUF_ERROR as u32 && cap < max_cap { + cap = (cap * 2).min(max_cap); + continue; + } + out.truncate(out_pos); + return (ret as u32, out); + } +} + +#[inline] +unsafe fn rs_decode_stream_buffer(input: &[u8], expected_size_hint: usize) -> (u32, Vec) { + let mut cap = expected_size_hint.max(input.len() * 6 + 128).max(256); + let max_cap = 64 * 1024 * 1024; + + loop { + let mut out = vec![0u8; cap]; + let mut memlimit = u64::MAX; + let mut in_pos = 0usize; + let mut out_pos = 0usize; + let ret = rs_sys::lzma_stream_buffer_decode( + &mut memlimit, + 0, + ptr::null(), + input.as_ptr(), + &mut in_pos, + input.len(), + out.as_mut_ptr(), + &mut out_pos, + out.len(), + ); + if ret as u32 == rs_sys::LZMA_BUF_ERROR as u32 && cap < max_cap { + cap = (cap * 2).min(max_cap); + continue; + } + out.truncate(out_pos); + return (ret as u32, out); + } +} + +fn deterministic_payload(case: usize) -> Vec { + let len = match case % 7 { + 0 => 0, + 1 => 1, + 2 => 3, + 3 => 31, + 4 => 257, + 5 => 4096, + _ => 16384, + }; + let mut x = (0x9E3779B97F4A7C15u64 ^ (case as u64).wrapping_mul(0xD6E8FEB86659FD93)).max(1); + let mut out = Vec::with_capacity(len); + for _ in 0..len { + x ^= x >> 12; + x ^= x << 25; + x ^= x >> 27; + out.push((x.wrapping_mul(0x2545F4914F6CDD1D) & 0xFF) as u8); + } + out +} + +#[test] +fn differential_roundtrip_across_backends() { + for case in 0..128usize { + let input = deterministic_payload(case); + unsafe { + let (c_enc_ret, c_encoded) = c_encode_easy(&input); + let (rs_enc_ret, rs_encoded) = rs_encode_easy(&input); + assert_eq!( + c_enc_ret, + rs_enc_ret, + "encoder ret mismatch at case {case}: c={c_enc_ret} rs={rs_enc_ret}" + ); + assert_eq!( + c_enc_ret, + c_sys::LZMA_OK as u32, + "C encoder failed at case {case} with ret {c_enc_ret}" + ); + + let (c_from_c_ret, c_from_c) = c_decode_stream_buffer(&c_encoded, input.len()); + let (rs_from_c_ret, rs_from_c) = rs_decode_stream_buffer(&c_encoded, input.len()); + let (c_from_rs_ret, c_from_rs) = c_decode_stream_buffer(&rs_encoded, input.len()); + let (rs_from_rs_ret, rs_from_rs) = rs_decode_stream_buffer(&rs_encoded, input.len()); + + assert_eq!( + c_from_c_ret, rs_from_c_ret, + "decode(c_encoded) ret mismatch at case {case}: c={c_from_c_ret} rs={rs_from_c_ret}" + ); + assert_eq!( + c_from_rs_ret, rs_from_rs_ret, + "decode(rs_encoded) ret mismatch at case {case}: c={c_from_rs_ret} rs={rs_from_rs_ret}" + ); + + assert_eq!(c_from_c, input, "C decode(C encode) payload mismatch at case {case}"); + assert_eq!(rs_from_c, input, "RS decode(C encode) payload mismatch at case {case}"); + assert_eq!(c_from_rs, input, "C decode(RS encode) payload mismatch at case {case}"); + assert_eq!(rs_from_rs, input, "RS decode(RS encode) payload mismatch at case {case}"); + } + } +} + +#[test] +fn differential_error_codes_on_invalid_corpus() { + let files_dir = Path::new("liblzma-sys/xz/tests/files"); + for entry in fs::read_dir(files_dir).expect("read xz test corpus directory") { + let path = entry.expect("dir entry").path(); + if path.extension().and_then(|s| s.to_str()) != Some("xz") { + continue; + } + + let filename = path.file_name().and_then(|s| s.to_str()).unwrap_or(""); + if !(filename.starts_with("bad") || filename.starts_with("unsupported")) { + continue; + } + if filename.contains("unsupported-check") { + // This is implementation-defined in existing tests. + continue; + } + + let data = fs::read(&path).expect("read corpus file"); + unsafe { + let (c_ret, _) = c_decode_stream_buffer(&data, 4096); + let (rs_ret, _) = rs_decode_stream_buffer(&data, 4096); + assert_eq!( + c_ret, rs_ret, + "error ret mismatch for {}: c={} rs={}", + path.display(), c_ret, rs_ret + ); + } + } +} From 8512162e3dd5262a98b9c43c7f15eaaf9ada6d62 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Feb 2026 15:01:33 +0900 Subject: [PATCH 02/51] replace C types with Rust types --- benches/backend_comparison.rs | 40 +- liblzma-rs-sys/Cargo.toml | 3 + liblzma-rs-sys/src/lib.rs | 174 +- liblzma-rs/src/check/check.rs | 98 +- liblzma-rs/src/check/crc32_fast.rs | 2421 +---- liblzma-rs/src/check/crc64_fast.rs | 2110 ++-- liblzma-rs/src/check/sha256.rs | 4912 ++++------ liblzma-rs/src/common/alone_decoder.rs | 377 +- liblzma-rs/src/common/alone_encoder.rs | 319 +- liblzma-rs/src/common/auto_decoder.rs | 356 +- liblzma-rs/src/common/block_buffer_decoder.rs | 136 +- liblzma-rs/src/common/block_buffer_encoder.rs | 419 +- liblzma-rs/src/common/block_decoder.rs | 380 +- liblzma-rs/src/common/block_encoder.rs | 322 +- liblzma-rs/src/common/block_header_decoder.rs | 137 +- liblzma-rs/src/common/block_header_encoder.rs | 159 +- liblzma-rs/src/common/block_util.rs | 80 +- liblzma-rs/src/common/common.rs | 423 +- liblzma-rs/src/common/easy_buffer_encoder.rs | 85 +- .../src/common/easy_decoder_memusage.rs | 65 +- liblzma-rs/src/common/easy_encoder.rs | 150 +- .../src/common/easy_encoder_memusage.rs | 65 +- liblzma-rs/src/common/easy_preset.rs | 72 +- liblzma-rs/src/common/file_info.rs | 639 +- .../src/common/filter_buffer_decoder.rs | 126 +- .../src/common/filter_buffer_encoder.rs | 112 +- liblzma-rs/src/common/filter_common.rs | 282 +- liblzma-rs/src/common/filter_decoder.rs | 289 +- liblzma-rs/src/common/filter_encoder.rs | 448 +- liblzma-rs/src/common/filter_flags_decoder.rs | 47 +- liblzma-rs/src/common/filter_flags_encoder.rs | 59 +- liblzma-rs/src/common/hardware_cputhreads.rs | 6 +- liblzma-rs/src/common/hardware_physmem.rs | 6 +- liblzma-rs/src/common/index.rs | 605 +- liblzma-rs/src/common/index_decoder.rs | 359 +- liblzma-rs/src/common/index_encoder.rs | 309 +- liblzma-rs/src/common/index_hash.rs | 242 +- liblzma-rs/src/common/lzip_decoder.rs | 547 +- liblzma-rs/src/common/microlzma_decoder.rs | 349 +- liblzma-rs/src/common/microlzma_encoder.rs | 272 +- liblzma-rs/src/common/mod.rs | 3 + liblzma-rs/src/common/outqueue.rs | 127 +- .../src/common/stream_buffer_decoder.rs | 149 +- .../src/common/stream_buffer_encoder.rs | 153 +- liblzma-rs/src/common/stream_decoder.rs | 488 +- liblzma-rs/src/common/stream_decoder_mt.rs | 2151 +++++ liblzma-rs/src/common/stream_encoder.rs | 413 +- liblzma-rs/src/common/stream_encoder_mt.rs | 1961 ++++ liblzma-rs/src/common/stream_flags_common.rs | 54 +- liblzma-rs/src/common/stream_flags_decoder.rs | 131 +- liblzma-rs/src/common/stream_flags_encoder.rs | 128 +- liblzma-rs/src/common/stream_mt.rs | 6 + liblzma-rs/src/common/string_conversion.rs | 1503 ++- liblzma-rs/src/common/vli_decoder.rs | 44 +- liblzma-rs/src/common/vli_encoder.rs | 41 +- liblzma-rs/src/common/vli_size.rs | 19 +- liblzma-rs/src/delta/delta_common.rs | 171 +- liblzma-rs/src/delta/delta_decoder.rs | 146 +- liblzma-rs/src/delta/delta_encoder.rs | 186 +- liblzma-rs/src/lib.rs | 4 +- liblzma-rs/src/lz/lz_decoder.rs | 335 +- liblzma-rs/src/lz/lz_encoder.rs | 696 +- liblzma-rs/src/lz/lz_encoder_mf.rs | 1024 +- liblzma-rs/src/lzma/fastpos_table.rs | 8538 +---------------- liblzma-rs/src/lzma/lzma2_decoder.rs | 384 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 579 +- liblzma-rs/src/lzma/lzma_decoder.rs | 5789 ++++++----- liblzma-rs/src/lzma/lzma_encoder.rs | 1372 ++- .../src/lzma/lzma_encoder_optimum_fast.rs | 338 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 1616 ++-- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 153 +- liblzma-rs/src/rangecoder/price_table.rs | 138 +- liblzma-rs/src/simple/arm.rs | 146 +- liblzma-rs/src/simple/arm64.rs | 172 +- liblzma-rs/src/simple/armthumb.rs | 155 +- liblzma-rs/src/simple/ia64.rs | 224 +- liblzma-rs/src/simple/powerpc.rs | 149 +- liblzma-rs/src/simple/riscv.rs | 398 +- liblzma-rs/src/simple/simple_coder.rs | 285 +- liblzma-rs/src/simple/simple_decoder.rs | 62 +- liblzma-rs/src/simple/simple_encoder.rs | 44 +- liblzma-rs/src/simple/sparc.rs | 165 +- liblzma-rs/src/simple/x86.rs | 282 +- liblzma-rs/src/tuklib/tuklib_cpucores.rs | 6 +- liblzma-rs/src/tuklib/tuklib_physmem.rs | 5 +- liblzma-rs/src/types.rs | 18 + tests/sys_equivalence.rs | 30 +- 87 files changed, 18307 insertions(+), 30674 deletions(-) create mode 100644 liblzma-rs/src/common/stream_decoder_mt.rs create mode 100644 liblzma-rs/src/common/stream_encoder_mt.rs create mode 100644 liblzma-rs/src/common/stream_mt.rs create mode 100644 liblzma-rs/src/types.rs diff --git a/benches/backend_comparison.rs b/benches/backend_comparison.rs index 371ef7cd..10fb5637 100644 --- a/benches/backend_comparison.rs +++ b/benches/backend_comparison.rs @@ -94,11 +94,7 @@ unsafe fn rs_decode(compressed: &[u8], out_size: usize) -> Vec { } fn bench_encode(c: &mut Criterion) { - let sizes: &[(usize, &str)] = &[ - (1024, "1KB"), - (64 * 1024, "64KB"), - (1024 * 1024, "1MB"), - ]; + let sizes: &[(usize, &str)] = &[(1024, "1KB"), (64 * 1024, "64KB"), (1024 * 1024, "1MB")]; let mut group = c.benchmark_group("encode"); for &(size, label) in sizes { @@ -116,11 +112,7 @@ fn bench_encode(c: &mut Criterion) { } fn bench_decode(c: &mut Criterion) { - let sizes: &[(usize, &str)] = &[ - (1024, "1KB"), - (64 * 1024, "64KB"), - (1024 * 1024, "1MB"), - ]; + let sizes: &[(usize, &str)] = &[(1024, "1KB"), (64 * 1024, "64KB"), (1024 * 1024, "1MB")]; let mut group = c.benchmark_group("decode"); for &(size, label) in sizes { @@ -132,19 +124,17 @@ fn bench_decode(c: &mut Criterion) { group.bench_with_input(BenchmarkId::new("c", label), &c_compressed, |b, data| { b.iter(|| unsafe { c_decode(black_box(data), size) }) }); - group.bench_with_input(BenchmarkId::new("rust", label), &rs_compressed, |b, data| { - b.iter(|| unsafe { rs_decode(black_box(data), size) }) - }); + group.bench_with_input( + BenchmarkId::new("rust", label), + &rs_compressed, + |b, data| b.iter(|| unsafe { rs_decode(black_box(data), size) }), + ); } group.finish(); } fn bench_crc32(c: &mut Criterion) { - let sizes: &[(usize, &str)] = &[ - (1024, "1KB"), - (64 * 1024, "64KB"), - (1024 * 1024, "1MB"), - ]; + let sizes: &[(usize, &str)] = &[(1024, "1KB"), (64 * 1024, "64KB"), (1024 * 1024, "1MB")]; let mut group = c.benchmark_group("crc32"); for &(size, label) in sizes { @@ -162,11 +152,7 @@ fn bench_crc32(c: &mut Criterion) { } fn bench_crc64(c: &mut Criterion) { - let sizes: &[(usize, &str)] = &[ - (1024, "1KB"), - (64 * 1024, "64KB"), - (1024 * 1024, "1MB"), - ]; + let sizes: &[(usize, &str)] = &[(1024, "1KB"), (64 * 1024, "64KB"), (1024 * 1024, "1MB")]; let mut group = c.benchmark_group("crc64"); for &(size, label) in sizes { @@ -183,5 +169,11 @@ fn bench_crc64(c: &mut Criterion) { group.finish(); } -criterion_group!(benches, bench_encode, bench_decode, bench_crc32, bench_crc64); +criterion_group!( + benches, + bench_encode, + bench_decode, + bench_crc32, + bench_crc64 +); criterion_main!(benches); diff --git a/liblzma-rs-sys/Cargo.toml b/liblzma-rs-sys/Cargo.toml index 46ce6e1d..84ad32c1 100644 --- a/liblzma-rs-sys/Cargo.toml +++ b/liblzma-rs-sys/Cargo.toml @@ -5,6 +5,9 @@ edition = "2021" license = "MIT OR Apache-2.0" description = "liblzma-sys compatible API layer backed by pure Rust liblzma-rs" +[lib] +crate-type = ["rlib", "staticlib"] + [features] default = ["bindgen"] # Feature stubs matching liblzma-sys for smooth migration diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs index 150aa277..02001e11 100644 --- a/liblzma-rs-sys/src/lib.rs +++ b/liblzma-rs-sys/src/lib.rs @@ -12,7 +12,7 @@ non_snake_case, non_upper_case_globals, unused_imports, - clippy::all, + clippy::all )] use core::ffi::{c_char, c_uchar, c_uint, c_void}; @@ -36,12 +36,12 @@ pub type lzma_bool = c_uchar; pub type lzma_vli = u64; // === Canonical struct re-exports === -pub use liblzma_rs::common::common::lzma_stream; pub use liblzma_rs::common::common::lzma_allocator; +pub use liblzma_rs::common::common::lzma_stream; pub use liblzma_rs::common::filter_common::lzma_options_lzma; -pub use liblzma_rs::delta::delta_common::lzma_filter; pub use liblzma_rs::common::index_decoder::lzma_index; pub use liblzma_rs::common::stream_flags_decoder::lzma_stream_flags; +pub use liblzma_rs::delta::delta_common::lzma_filter; #[repr(C)] pub struct lzma_options_bcj { @@ -65,18 +65,15 @@ pub const LZMA_MEM_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_MEM_ERROR pub const LZMA_MEMLIMIT_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_MEMLIMIT_ERROR as lzma_ret; pub const LZMA_FORMAT_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_FORMAT_ERROR as lzma_ret; -pub const LZMA_OPTIONS_ERROR: lzma_ret = - liblzma_rs::common::common::LZMA_OPTIONS_ERROR as lzma_ret; +pub const LZMA_OPTIONS_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_OPTIONS_ERROR as lzma_ret; pub const LZMA_DATA_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_DATA_ERROR as lzma_ret; pub const LZMA_BUF_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_BUF_ERROR as lzma_ret; pub const LZMA_PROG_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_PROG_ERROR as lzma_ret; pub const LZMA_SEEK_NEEDED: lzma_ret = liblzma_rs::common::common::LZMA_SEEK_NEEDED as lzma_ret; pub const LZMA_RUN: lzma_action = liblzma_rs::common::common::LZMA_RUN as lzma_action; -pub const LZMA_SYNC_FLUSH: lzma_action = - liblzma_rs::common::common::LZMA_SYNC_FLUSH as lzma_action; -pub const LZMA_FULL_FLUSH: lzma_action = - liblzma_rs::common::common::LZMA_FULL_FLUSH as lzma_action; +pub const LZMA_SYNC_FLUSH: lzma_action = liblzma_rs::common::common::LZMA_SYNC_FLUSH as lzma_action; +pub const LZMA_FULL_FLUSH: lzma_action = liblzma_rs::common::common::LZMA_FULL_FLUSH as lzma_action; pub const LZMA_FULL_BARRIER: lzma_action = liblzma_rs::common::common::LZMA_FULL_BARRIER as lzma_action; pub const LZMA_FINISH: lzma_action = liblzma_rs::common::common::LZMA_FINISH as lzma_action; @@ -85,8 +82,7 @@ pub const LZMA_FINISH: lzma_action = liblzma_rs::common::common::LZMA_FINISH as pub const LZMA_CHECK_NONE: lzma_check = liblzma_rs::check::check::LZMA_CHECK_NONE as lzma_check; pub const LZMA_CHECK_CRC32: lzma_check = liblzma_rs::check::check::LZMA_CHECK_CRC32 as lzma_check; pub const LZMA_CHECK_CRC64: lzma_check = liblzma_rs::check::check::LZMA_CHECK_CRC64 as lzma_check; -pub const LZMA_CHECK_SHA256: lzma_check = - liblzma_rs::check::check::LZMA_CHECK_SHA256 as lzma_check; +pub const LZMA_CHECK_SHA256: lzma_check = liblzma_rs::check::check::LZMA_CHECK_SHA256 as lzma_check; // --- Modes / match finders / filter IDs --- pub const LZMA_MODE_FAST: lzma_mode = @@ -128,8 +124,7 @@ pub const LZMA_FILTER_LZMA2: lzma_vli = liblzma_rs::common::filter_common::LZMA_FILTER_LZMA2 as lzma_vli; // --- Decoder flags --- -pub const LZMA_TELL_NO_CHECK: u32 = - liblzma_rs::common::auto_decoder::LZMA_TELL_NO_CHECK as u32; +pub const LZMA_TELL_NO_CHECK: u32 = liblzma_rs::common::auto_decoder::LZMA_TELL_NO_CHECK as u32; pub const LZMA_TELL_UNSUPPORTED_CHECK: u32 = liblzma_rs::common::auto_decoder::LZMA_TELL_UNSUPPORTED_CHECK as u32; pub const LZMA_TELL_ANY_CHECK: u32 = liblzma_rs::common::auto_decoder::LZMA_TELL_ANY_CHECK as u32; @@ -149,14 +144,11 @@ pub const LZMA_DICT_SIZE_DEFAULT: u32 = liblzma_rs::common::string_conversion::LZMA_DICT_SIZE_DEFAULT as u32; pub const LZMA_LCLP_MIN: u32 = liblzma_rs::common::string_conversion::LZMA_LCLP_MIN as u32; pub const LZMA_LCLP_MAX: u32 = liblzma_rs::common::string_conversion::LZMA_LCLP_MAX as u32; -pub const LZMA_LC_DEFAULT: u32 = - liblzma_rs::lzma::lzma_encoder_presets::LZMA_LC_DEFAULT as u32; -pub const LZMA_LP_DEFAULT: u32 = - liblzma_rs::lzma::lzma_encoder_presets::LZMA_LP_DEFAULT as u32; +pub const LZMA_LC_DEFAULT: u32 = liblzma_rs::lzma::lzma_encoder_presets::LZMA_LC_DEFAULT as u32; +pub const LZMA_LP_DEFAULT: u32 = liblzma_rs::lzma::lzma_encoder_presets::LZMA_LP_DEFAULT as u32; pub const LZMA_PB_MIN: u32 = liblzma_rs::common::string_conversion::LZMA_PB_MIN as u32; pub const LZMA_PB_MAX: u32 = liblzma_rs::common::string_conversion::LZMA_PB_MAX as u32; -pub const LZMA_PB_DEFAULT: u32 = - liblzma_rs::lzma::lzma_encoder_presets::LZMA_PB_DEFAULT as u32; +pub const LZMA_PB_DEFAULT: u32 = liblzma_rs::lzma::lzma_encoder_presets::LZMA_PB_DEFAULT as u32; // --- Backward size / VLI --- pub const LZMA_BACKWARD_SIZE_MIN: lzma_vli = @@ -180,9 +172,7 @@ pub const LZMA_STREAM_HEADER_SIZE: u32 = liblzma_rs::common::index::LZMA_STREAM_ // but nominally different, so we provide thin wrappers with pointer casts. // --- Direct re-exports (canonical types from common::common) --- -pub use liblzma_rs::common::common::{ - lzma_code, lzma_end, lzma_memlimit_get, lzma_memlimit_set, -}; +pub use liblzma_rs::common::common::{lzma_code, lzma_end, lzma_memlimit_get, lzma_memlimit_set}; // --- Version --- @@ -272,7 +262,14 @@ pub unsafe fn lzma_easy_buffer_encode( out_size: size_t, ) -> lzma_ret { liblzma_rs::common::easy_buffer_encoder::lzma_easy_buffer_encode( - preset, check, allocator.cast(), input, in_size, out, out_pos, out_size, + preset, + check, + allocator.cast(), + input, + in_size, + out, + out_pos, + out_size, ) } @@ -288,11 +285,7 @@ pub unsafe fn lzma_stream_encoder( } #[inline] -pub unsafe fn lzma_stream_decoder( - strm: *mut lzma_stream, - memlimit: u64, - flags: u32, -) -> lzma_ret { +pub unsafe fn lzma_stream_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { liblzma_rs::common::stream_decoder::lzma_stream_decoder(strm.cast(), memlimit, flags) } @@ -307,30 +300,19 @@ pub unsafe fn lzma_alone_encoder( } #[inline] -pub unsafe fn lzma_alone_decoder( - strm: *mut lzma_stream, - memlimit: u64, -) -> lzma_ret { +pub unsafe fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { liblzma_rs::common::alone_decoder::lzma_alone_decoder(strm.cast(), memlimit) } // --- Auto/lzip decoder --- #[inline] -pub unsafe fn lzma_auto_decoder( - strm: *mut lzma_stream, - memlimit: u64, - flags: u32, -) -> lzma_ret { +pub unsafe fn lzma_auto_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { liblzma_rs::common::auto_decoder::lzma_auto_decoder(strm.cast(), memlimit, flags) } #[inline] -pub unsafe fn lzma_lzip_decoder( - strm: *mut lzma_stream, - memlimit: u64, - flags: u32, -) -> lzma_ret { +pub unsafe fn lzma_lzip_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { liblzma_rs::common::lzip_decoder::lzma_lzip_decoder(strm.cast(), memlimit, flags) } @@ -353,7 +335,14 @@ pub unsafe fn lzma_stream_buffer_encode( out_size: size_t, ) -> lzma_ret { liblzma_rs::common::stream_buffer_encoder::lzma_stream_buffer_encode( - filters.cast(), check, allocator.cast(), input, in_size, out, out_pos, out_size, + filters.cast(), + check, + allocator.cast(), + input, + in_size, + out, + out_pos, + out_size, ) } @@ -370,7 +359,15 @@ pub unsafe fn lzma_stream_buffer_decode( out_size: size_t, ) -> lzma_ret { liblzma_rs::common::stream_buffer_decoder::lzma_stream_buffer_decode( - memlimit, flags, allocator.cast(), input, in_pos, in_size, out, out_pos, out_size, + memlimit, + flags, + allocator.cast(), + input, + in_pos, + in_size, + out, + out_pos, + out_size, ) } @@ -392,9 +389,7 @@ pub unsafe fn lzma_filters_copy( dest: *mut lzma_filter, allocator: *const lzma_allocator, ) -> lzma_ret { - liblzma_rs::common::filter_common::lzma_filters_copy( - src.cast(), dest.cast(), allocator.cast(), - ) + liblzma_rs::common::filter_common::lzma_filters_copy(src.cast(), dest.cast(), allocator.cast()) } #[inline] @@ -408,26 +403,17 @@ pub unsafe fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { } #[inline] -pub unsafe fn lzma_raw_encoder( - strm: *mut lzma_stream, - filters: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_raw_encoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_raw_encoder(strm.cast(), filters.cast()) } #[inline] -pub unsafe fn lzma_raw_decoder( - strm: *mut lzma_stream, - filters: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_raw_decoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { liblzma_rs::common::filter_decoder::lzma_raw_decoder(strm.cast(), filters.cast()) } #[inline] -pub unsafe fn lzma_filters_update( - strm: *mut lzma_stream, - filters: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_filters_update(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_filters_update(strm.cast(), filters.cast()) } @@ -444,7 +430,13 @@ pub unsafe fn lzma_raw_buffer_encode( out_size: size_t, ) -> lzma_ret { liblzma_rs::common::filter_buffer_encoder::lzma_raw_buffer_encode( - filters.cast(), allocator.cast(), input, in_size, out, out_pos, out_size, + filters.cast(), + allocator.cast(), + input, + in_size, + out, + out_pos, + out_size, ) } @@ -460,25 +452,26 @@ pub unsafe fn lzma_raw_buffer_decode( out_size: size_t, ) -> lzma_ret { liblzma_rs::common::filter_buffer_decoder::lzma_raw_buffer_decode( - filters.cast(), allocator.cast(), input, in_pos, in_size, out, out_pos, out_size, + filters.cast(), + allocator.cast(), + input, + in_pos, + in_size, + out, + out_pos, + out_size, ) } // --- Properties --- #[inline] -pub unsafe fn lzma_properties_size( - size: *mut u32, - filter: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_properties_size(size, filter.cast()) } #[inline] -pub unsafe fn lzma_properties_encode( - filter: *const lzma_filter, - props: *mut u8, -) -> lzma_ret { +pub unsafe fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_properties_encode(filter.cast(), props) } @@ -490,24 +483,22 @@ pub unsafe fn lzma_properties_decode( props_size: size_t, ) -> lzma_ret { liblzma_rs::common::filter_decoder::lzma_properties_decode( - filter.cast(), allocator.cast(), props, props_size, + filter.cast(), + allocator.cast(), + props, + props_size, ) } #[inline] -pub unsafe fn lzma_mt_block_size( - filters: *const lzma_filter, -) -> u64 { +pub unsafe fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { liblzma_rs::common::filter_encoder::lzma_mt_block_size(filters.cast()) } // --- LZMA preset --- #[inline] -pub unsafe fn lzma_lzma_preset( - options: *mut lzma_options_lzma, - preset: u32, -) -> lzma_bool { +pub unsafe fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool { liblzma_rs::lzma::lzma_encoder_presets::lzma_lzma_preset(options.cast(), preset) } @@ -611,7 +602,12 @@ pub unsafe fn lzma_index_buffer_decode( in_size: size_t, ) -> lzma_ret { liblzma_rs::common::index_decoder::lzma_index_buffer_decode( - i.cast(), memlimit, allocator.cast(), input, in_pos, in_size, + i.cast(), + memlimit, + allocator.cast(), + input, + in_pos, + in_size, ) } @@ -626,7 +622,7 @@ pub unsafe fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocato } // ========================================================================= -// Multithreaded (stubs - _mt files not yet transpiled) +// Multithreaded API // ========================================================================= #[cfg(feature = "parallel")] @@ -657,24 +653,16 @@ pub struct lzma_mt { } #[cfg(feature = "parallel")] -pub unsafe fn lzma_stream_encoder_mt( - _strm: *mut lzma_stream, - _options: *const lzma_mt, -) -> lzma_ret { - unimplemented!("lzma_stream_encoder_mt not yet available in liblzma-rs") +pub unsafe fn lzma_stream_encoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { + liblzma_rs::common::stream_mt::lzma_stream_encoder_mt(strm.cast(), options.cast()) } #[cfg(feature = "parallel")] -pub unsafe fn lzma_stream_decoder_mt( - _strm: *mut lzma_stream, - _options: *const lzma_mt, -) -> lzma_ret { - unimplemented!("lzma_stream_decoder_mt not yet available in liblzma-rs") +pub unsafe fn lzma_stream_decoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { + liblzma_rs::common::stream_mt::lzma_stream_decoder_mt(strm.cast(), options.cast()) } #[cfg(feature = "parallel")] -pub unsafe fn lzma_stream_encoder_mt_memusage( - _options: *const lzma_mt, -) -> u64 { - unimplemented!("lzma_stream_encoder_mt_memusage not yet available in liblzma-rs") +pub unsafe fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64 { + liblzma_rs::common::stream_mt::lzma_stream_encoder_mt_memusage(options.cast()) } diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index 493f2033..105c9dfb 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -1,21 +1,12 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint}; extern "C" { - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; - fn lzma_crc64(buf: *const uint8_t, size: size_t, crc: uint64_t) -> uint64_t; + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; + fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64; fn lzma_sha256_init(check: *mut lzma_check_state); - fn lzma_sha256_update( - buf: *const uint8_t, - size: size_t, - check: *mut lzma_check_state, - ); + fn lzma_sha256_update(buf: *const u8, size: size_t, check: *mut lzma_check_state); fn lzma_sha256_finish(check: *mut lzma_check_state); } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -23,8 +14,8 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_sha256_state { - pub state: [uint32_t; 8], - pub size: uint64_t, + pub state: [u32; 8], + pub size: u64, } #[derive(Copy, Clone)] #[repr(C)] @@ -35,24 +26,24 @@ pub struct lzma_check_state { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed { - pub crc32: uint32_t, - pub crc64: uint64_t, + pub crc32: u32, + pub crc64: u64, pub sha256: lzma_sha256_state, } #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_0 { - pub u8_0: [uint8_t; 64], - pub u32_0: [uint32_t; 16], - pub u64_0: [uint64_t; 8], + pub u8_0: [u8; 64], + pub u32_0: [u32; 16], + pub u64_0: [u64; 8], } -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_check_is_supported(mut type_0: lzma_check) -> lzma_bool { - if type_0 as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint { + if type_0 as c_uint > LZMA_CHECK_ID_MAX as c_uint { return false_0 as lzma_bool; } static mut available_checks: [lzma_bool; 16] = [ @@ -73,44 +64,27 @@ pub unsafe extern "C" fn lzma_check_is_supported(mut type_0: lzma_check) -> lzma false_0 as lzma_bool, false_0 as lzma_bool, ]; - return available_checks[type_0 as ::core::ffi::c_uint as usize]; + return available_checks[type_0 as c_uint as usize]; } #[no_mangle] -pub unsafe extern "C" fn lzma_check_size(mut type_0: lzma_check) -> uint32_t { - if type_0 as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint { - return UINT32_MAX as uint32_t; +pub unsafe extern "C" fn lzma_check_size(mut type_0: lzma_check) -> u32 { + if type_0 as c_uint > LZMA_CHECK_ID_MAX as c_uint { + return UINT32_MAX as u32; } - static mut check_sizes: [uint8_t; 16] = [ - 0 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 32 as ::core::ffi::c_int as uint8_t, - 32 as ::core::ffi::c_int as uint8_t, - 32 as ::core::ffi::c_int as uint8_t, - 64 as ::core::ffi::c_int as uint8_t, - 64 as ::core::ffi::c_int as uint8_t, - 64 as ::core::ffi::c_int as uint8_t, + static mut check_sizes: [u8; 16] = [ + 0 as u8, 4 as u8, 4 as u8, 4 as u8, 8 as u8, 8 as u8, 8 as u8, 16 as u8, 16 as u8, + 16 as u8, 32 as u8, 32 as u8, 32 as u8, 64 as u8, 64 as u8, 64 as u8, ]; - return check_sizes[type_0 as ::core::ffi::c_uint as usize] as uint32_t; + return check_sizes[type_0 as c_uint as usize] as u32; } #[no_mangle] -pub unsafe extern "C" fn lzma_check_init( - mut check: *mut lzma_check_state, - mut type_0: lzma_check, -) { - match type_0 as ::core::ffi::c_uint { +pub unsafe extern "C" fn lzma_check_init(mut check: *mut lzma_check_state, mut type_0: lzma_check) { + match type_0 as c_uint { 1 => { - (*check).state.crc32 = 0 as uint32_t; + (*check).state.crc32 = 0 as u32; } 4 => { - (*check).state.crc64 = 0 as uint64_t; + (*check).state.crc64 = 0 as u64; } 10 => { lzma_sha256_init(check); @@ -122,10 +96,10 @@ pub unsafe extern "C" fn lzma_check_init( pub unsafe extern "C" fn lzma_check_update( mut check: *mut lzma_check_state, mut type_0: lzma_check, - mut buf: *const uint8_t, + mut buf: *const u8, mut size: size_t, ) { - match type_0 as ::core::ffi::c_uint { + match type_0 as c_uint { 1 => { (*check).state.crc32 = lzma_crc32(buf, size, (*check).state.crc32); } @@ -143,16 +117,12 @@ pub unsafe extern "C" fn lzma_check_finish( mut check: *mut lzma_check_state, mut type_0: lzma_check, ) { - match type_0 as ::core::ffi::c_uint { + match type_0 as c_uint { 1 => { - (*check).buffer.u32_0[0 as ::core::ffi::c_int as usize] = (*check) - .state - .crc32; + (*check).buffer.u32_0[0 as usize] = (*check).state.crc32; } 4 => { - (*check).buffer.u64_0[0 as ::core::ffi::c_int as usize] = (*check) - .state - .crc64; + (*check).buffer.u64_0[0 as usize] = (*check).state.crc64; } 10 => { lzma_sha256_finish(check); diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index eab475cf..34584723 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -1,2122 +1,350 @@ -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; +use crate::types::*; +use core::ffi::{c_int, c_uint}; #[inline] -unsafe extern "C" fn aligned_read32ne(mut buf: *const uint8_t) -> uint32_t { - return *(buf as *const uint32_t); +unsafe extern "C" fn aligned_read32ne(mut buf: *const u8) -> u32 { + return *(buf as *const u32); } #[no_mangle] -pub static mut lzma_crc32_table: [[uint32_t; 256]; 8] = [ +pub static mut lzma_crc32_table: [[u32; 256]; 8] = [ [ - 0 as ::core::ffi::c_int as uint32_t, - 0x77073096 as ::core::ffi::c_int as uint32_t, - 0xee0e612c as ::core::ffi::c_uint, - 0x990951ba as ::core::ffi::c_uint, - 0x76dc419 as ::core::ffi::c_int as uint32_t, - 0x706af48f as ::core::ffi::c_int as uint32_t, - 0xe963a535 as ::core::ffi::c_uint, - 0x9e6495a3 as ::core::ffi::c_uint, - 0xedb8832 as ::core::ffi::c_int as uint32_t, - 0x79dcb8a4 as ::core::ffi::c_int as uint32_t, - 0xe0d5e91e as ::core::ffi::c_uint, - 0x97d2d988 as ::core::ffi::c_uint, - 0x9b64c2b as ::core::ffi::c_int as uint32_t, - 0x7eb17cbd as ::core::ffi::c_int as uint32_t, - 0xe7b82d07 as ::core::ffi::c_uint, - 0x90bf1d91 as ::core::ffi::c_uint, - 0x1db71064 as ::core::ffi::c_int as uint32_t, - 0x6ab020f2 as ::core::ffi::c_int as uint32_t, - 0xf3b97148 as ::core::ffi::c_uint, - 0x84be41de as ::core::ffi::c_uint, - 0x1adad47d as ::core::ffi::c_int as uint32_t, - 0x6ddde4eb as ::core::ffi::c_int as uint32_t, - 0xf4d4b551 as ::core::ffi::c_uint, - 0x83d385c7 as ::core::ffi::c_uint, - 0x136c9856 as ::core::ffi::c_int as uint32_t, - 0x646ba8c0 as ::core::ffi::c_int as uint32_t, - 0xfd62f97a as ::core::ffi::c_uint, - 0x8a65c9ec as ::core::ffi::c_uint, - 0x14015c4f as ::core::ffi::c_int as uint32_t, - 0x63066cd9 as ::core::ffi::c_int as uint32_t, - 0xfa0f3d63 as ::core::ffi::c_uint, - 0x8d080df5 as ::core::ffi::c_uint, - 0x3b6e20c8 as ::core::ffi::c_int as uint32_t, - 0x4c69105e as ::core::ffi::c_int as uint32_t, - 0xd56041e4 as ::core::ffi::c_uint, - 0xa2677172 as ::core::ffi::c_uint, - 0x3c03e4d1 as ::core::ffi::c_int as uint32_t, - 0x4b04d447 as ::core::ffi::c_int as uint32_t, - 0xd20d85fd as ::core::ffi::c_uint, - 0xa50ab56b as ::core::ffi::c_uint, - 0x35b5a8fa as ::core::ffi::c_int as uint32_t, - 0x42b2986c as ::core::ffi::c_int as uint32_t, - 0xdbbbc9d6 as ::core::ffi::c_uint, - 0xacbcf940 as ::core::ffi::c_uint, - 0x32d86ce3 as ::core::ffi::c_int as uint32_t, - 0x45df5c75 as ::core::ffi::c_int as uint32_t, - 0xdcd60dcf as ::core::ffi::c_uint, - 0xabd13d59 as ::core::ffi::c_uint, - 0x26d930ac as ::core::ffi::c_int as uint32_t, - 0x51de003a as ::core::ffi::c_int as uint32_t, - 0xc8d75180 as ::core::ffi::c_uint, - 0xbfd06116 as ::core::ffi::c_uint, - 0x21b4f4b5 as ::core::ffi::c_int as uint32_t, - 0x56b3c423 as ::core::ffi::c_int as uint32_t, - 0xcfba9599 as ::core::ffi::c_uint, - 0xb8bda50f as ::core::ffi::c_uint, - 0x2802b89e as ::core::ffi::c_int as uint32_t, - 0x5f058808 as ::core::ffi::c_int as uint32_t, - 0xc60cd9b2 as ::core::ffi::c_uint, - 0xb10be924 as ::core::ffi::c_uint, - 0x2f6f7c87 as ::core::ffi::c_int as uint32_t, - 0x58684c11 as ::core::ffi::c_int as uint32_t, - 0xc1611dab as ::core::ffi::c_uint, - 0xb6662d3d as ::core::ffi::c_uint, - 0x76dc4190 as ::core::ffi::c_int as uint32_t, - 0x1db7106 as ::core::ffi::c_int as uint32_t, - 0x98d220bc as ::core::ffi::c_uint, - 0xefd5102a as ::core::ffi::c_uint, - 0x71b18589 as ::core::ffi::c_int as uint32_t, - 0x6b6b51f as ::core::ffi::c_int as uint32_t, - 0x9fbfe4a5 as ::core::ffi::c_uint, - 0xe8b8d433 as ::core::ffi::c_uint, - 0x7807c9a2 as ::core::ffi::c_int as uint32_t, - 0xf00f934 as ::core::ffi::c_int as uint32_t, - 0x9609a88e as ::core::ffi::c_uint, - 0xe10e9818 as ::core::ffi::c_uint, - 0x7f6a0dbb as ::core::ffi::c_int as uint32_t, - 0x86d3d2d as ::core::ffi::c_int as uint32_t, - 0x91646c97 as ::core::ffi::c_uint, - 0xe6635c01 as ::core::ffi::c_uint, - 0x6b6b51f4 as ::core::ffi::c_int as uint32_t, - 0x1c6c6162 as ::core::ffi::c_int as uint32_t, - 0x856530d8 as ::core::ffi::c_uint, - 0xf262004e as ::core::ffi::c_uint, - 0x6c0695ed as ::core::ffi::c_int as uint32_t, - 0x1b01a57b as ::core::ffi::c_int as uint32_t, - 0x8208f4c1 as ::core::ffi::c_uint, - 0xf50fc457 as ::core::ffi::c_uint, - 0x65b0d9c6 as ::core::ffi::c_int as uint32_t, - 0x12b7e950 as ::core::ffi::c_int as uint32_t, - 0x8bbeb8ea as ::core::ffi::c_uint, - 0xfcb9887c as ::core::ffi::c_uint, - 0x62dd1ddf as ::core::ffi::c_int as uint32_t, - 0x15da2d49 as ::core::ffi::c_int as uint32_t, - 0x8cd37cf3 as ::core::ffi::c_uint, - 0xfbd44c65 as ::core::ffi::c_uint, - 0x4db26158 as ::core::ffi::c_int as uint32_t, - 0x3ab551ce as ::core::ffi::c_int as uint32_t, - 0xa3bc0074 as ::core::ffi::c_uint, - 0xd4bb30e2 as ::core::ffi::c_uint, - 0x4adfa541 as ::core::ffi::c_int as uint32_t, - 0x3dd895d7 as ::core::ffi::c_int as uint32_t, - 0xa4d1c46d as ::core::ffi::c_uint, - 0xd3d6f4fb as ::core::ffi::c_uint, - 0x4369e96a as ::core::ffi::c_int as uint32_t, - 0x346ed9fc as ::core::ffi::c_int as uint32_t, - 0xad678846 as ::core::ffi::c_uint, - 0xda60b8d0 as ::core::ffi::c_uint, - 0x44042d73 as ::core::ffi::c_int as uint32_t, - 0x33031de5 as ::core::ffi::c_int as uint32_t, - 0xaa0a4c5f as ::core::ffi::c_uint, - 0xdd0d7cc9 as ::core::ffi::c_uint, - 0x5005713c as ::core::ffi::c_int as uint32_t, - 0x270241aa as ::core::ffi::c_int as uint32_t, - 0xbe0b1010 as ::core::ffi::c_uint, - 0xc90c2086 as ::core::ffi::c_uint, - 0x5768b525 as ::core::ffi::c_int as uint32_t, - 0x206f85b3 as ::core::ffi::c_int as uint32_t, - 0xb966d409 as ::core::ffi::c_uint, - 0xce61e49f as ::core::ffi::c_uint, - 0x5edef90e as ::core::ffi::c_int as uint32_t, - 0x29d9c998 as ::core::ffi::c_int as uint32_t, - 0xb0d09822 as ::core::ffi::c_uint, - 0xc7d7a8b4 as ::core::ffi::c_uint, - 0x59b33d17 as ::core::ffi::c_int as uint32_t, - 0x2eb40d81 as ::core::ffi::c_int as uint32_t, - 0xb7bd5c3b as ::core::ffi::c_uint, - 0xc0ba6cad as ::core::ffi::c_uint, - 0xedb88320 as ::core::ffi::c_uint, - 0x9abfb3b6 as ::core::ffi::c_uint, - 0x3b6e20c as ::core::ffi::c_int as uint32_t, - 0x74b1d29a as ::core::ffi::c_int as uint32_t, - 0xead54739 as ::core::ffi::c_uint, - 0x9dd277af as ::core::ffi::c_uint, - 0x4db2615 as ::core::ffi::c_int as uint32_t, - 0x73dc1683 as ::core::ffi::c_int as uint32_t, - 0xe3630b12 as ::core::ffi::c_uint, - 0x94643b84 as ::core::ffi::c_uint, - 0xd6d6a3e as ::core::ffi::c_int as uint32_t, - 0x7a6a5aa8 as ::core::ffi::c_int as uint32_t, - 0xe40ecf0b as ::core::ffi::c_uint, - 0x9309ff9d as ::core::ffi::c_uint, - 0xa00ae27 as ::core::ffi::c_int as uint32_t, - 0x7d079eb1 as ::core::ffi::c_int as uint32_t, - 0xf00f9344 as ::core::ffi::c_uint, - 0x8708a3d2 as ::core::ffi::c_uint, - 0x1e01f268 as ::core::ffi::c_int as uint32_t, - 0x6906c2fe as ::core::ffi::c_int as uint32_t, - 0xf762575d as ::core::ffi::c_uint, - 0x806567cb as ::core::ffi::c_uint, - 0x196c3671 as ::core::ffi::c_int as uint32_t, - 0x6e6b06e7 as ::core::ffi::c_int as uint32_t, - 0xfed41b76 as ::core::ffi::c_uint, - 0x89d32be0 as ::core::ffi::c_uint, - 0x10da7a5a as ::core::ffi::c_int as uint32_t, - 0x67dd4acc as ::core::ffi::c_int as uint32_t, - 0xf9b9df6f as ::core::ffi::c_uint, - 0x8ebeeff9 as ::core::ffi::c_uint, - 0x17b7be43 as ::core::ffi::c_int as uint32_t, - 0x60b08ed5 as ::core::ffi::c_int as uint32_t, - 0xd6d6a3e8 as ::core::ffi::c_uint, - 0xa1d1937e as ::core::ffi::c_uint, - 0x38d8c2c4 as ::core::ffi::c_int as uint32_t, - 0x4fdff252 as ::core::ffi::c_int as uint32_t, - 0xd1bb67f1 as ::core::ffi::c_uint, - 0xa6bc5767 as ::core::ffi::c_uint, - 0x3fb506dd as ::core::ffi::c_int as uint32_t, - 0x48b2364b as ::core::ffi::c_int as uint32_t, - 0xd80d2bda as ::core::ffi::c_uint, - 0xaf0a1b4c as ::core::ffi::c_uint, - 0x36034af6 as ::core::ffi::c_int as uint32_t, - 0x41047a60 as ::core::ffi::c_int as uint32_t, - 0xdf60efc3 as ::core::ffi::c_uint, - 0xa867df55 as ::core::ffi::c_uint, - 0x316e8eef as ::core::ffi::c_int as uint32_t, - 0x4669be79 as ::core::ffi::c_int as uint32_t, - 0xcb61b38c as ::core::ffi::c_uint, - 0xbc66831a as ::core::ffi::c_uint, - 0x256fd2a0 as ::core::ffi::c_int as uint32_t, - 0x5268e236 as ::core::ffi::c_int as uint32_t, - 0xcc0c7795 as ::core::ffi::c_uint, - 0xbb0b4703 as ::core::ffi::c_uint, - 0x220216b9 as ::core::ffi::c_int as uint32_t, - 0x5505262f as ::core::ffi::c_int as uint32_t, - 0xc5ba3bbe as ::core::ffi::c_uint, - 0xb2bd0b28 as ::core::ffi::c_uint, - 0x2bb45a92 as ::core::ffi::c_int as uint32_t, - 0x5cb36a04 as ::core::ffi::c_int as uint32_t, - 0xc2d7ffa7 as ::core::ffi::c_uint, - 0xb5d0cf31 as ::core::ffi::c_uint, - 0x2cd99e8b as ::core::ffi::c_int as uint32_t, - 0x5bdeae1d as ::core::ffi::c_int as uint32_t, - 0x9b64c2b0 as ::core::ffi::c_uint, - 0xec63f226 as ::core::ffi::c_uint, - 0x756aa39c as ::core::ffi::c_int as uint32_t, - 0x26d930a as ::core::ffi::c_int as uint32_t, - 0x9c0906a9 as ::core::ffi::c_uint, - 0xeb0e363f as ::core::ffi::c_uint, - 0x72076785 as ::core::ffi::c_int as uint32_t, - 0x5005713 as ::core::ffi::c_int as uint32_t, - 0x95bf4a82 as ::core::ffi::c_uint, - 0xe2b87a14 as ::core::ffi::c_uint, - 0x7bb12bae as ::core::ffi::c_int as uint32_t, - 0xcb61b38 as ::core::ffi::c_int as uint32_t, - 0x92d28e9b as ::core::ffi::c_uint, - 0xe5d5be0d as ::core::ffi::c_uint, - 0x7cdcefb7 as ::core::ffi::c_int as uint32_t, - 0xbdbdf21 as ::core::ffi::c_int as uint32_t, - 0x86d3d2d4 as ::core::ffi::c_uint, - 0xf1d4e242 as ::core::ffi::c_uint, - 0x68ddb3f8 as ::core::ffi::c_int as uint32_t, - 0x1fda836e as ::core::ffi::c_int as uint32_t, - 0x81be16cd as ::core::ffi::c_uint, - 0xf6b9265b as ::core::ffi::c_uint, - 0x6fb077e1 as ::core::ffi::c_int as uint32_t, - 0x18b74777 as ::core::ffi::c_int as uint32_t, - 0x88085ae6 as ::core::ffi::c_uint, - 0xff0f6a70 as ::core::ffi::c_uint, - 0x66063bca as ::core::ffi::c_int as uint32_t, - 0x11010b5c as ::core::ffi::c_int as uint32_t, - 0x8f659eff as ::core::ffi::c_uint, - 0xf862ae69 as ::core::ffi::c_uint, - 0x616bffd3 as ::core::ffi::c_int as uint32_t, - 0x166ccf45 as ::core::ffi::c_int as uint32_t, - 0xa00ae278 as ::core::ffi::c_uint, - 0xd70dd2ee as ::core::ffi::c_uint, - 0x4e048354 as ::core::ffi::c_int as uint32_t, - 0x3903b3c2 as ::core::ffi::c_int as uint32_t, - 0xa7672661 as ::core::ffi::c_uint, - 0xd06016f7 as ::core::ffi::c_uint, - 0x4969474d as ::core::ffi::c_int as uint32_t, - 0x3e6e77db as ::core::ffi::c_int as uint32_t, - 0xaed16a4a as ::core::ffi::c_uint, - 0xd9d65adc as ::core::ffi::c_uint, - 0x40df0b66 as ::core::ffi::c_int as uint32_t, - 0x37d83bf0 as ::core::ffi::c_int as uint32_t, - 0xa9bcae53 as ::core::ffi::c_uint, - 0xdebb9ec5 as ::core::ffi::c_uint, - 0x47b2cf7f as ::core::ffi::c_int as uint32_t, - 0x30b5ffe9 as ::core::ffi::c_int as uint32_t, - 0xbdbdf21c as ::core::ffi::c_uint, - 0xcabac28a as ::core::ffi::c_uint, - 0x53b39330 as ::core::ffi::c_int as uint32_t, - 0x24b4a3a6 as ::core::ffi::c_int as uint32_t, - 0xbad03605 as ::core::ffi::c_uint, - 0xcdd70693 as ::core::ffi::c_uint, - 0x54de5729 as ::core::ffi::c_int as uint32_t, - 0x23d967bf as ::core::ffi::c_int as uint32_t, - 0xb3667a2e as ::core::ffi::c_uint, - 0xc4614ab8 as ::core::ffi::c_uint, - 0x5d681b02 as ::core::ffi::c_int as uint32_t, - 0x2a6f2b94 as ::core::ffi::c_int as uint32_t, - 0xb40bbe37 as ::core::ffi::c_uint, - 0xc30c8ea1 as ::core::ffi::c_uint, - 0x5a05df1b as ::core::ffi::c_int as uint32_t, - 0x2d02ef8d as ::core::ffi::c_int as uint32_t, + 0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0xedb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x9b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, + 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, + 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, + 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, + 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x1db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x6b6b51f, 0x9fbfe4a5, + 0xe8b8d433, 0x7807c9a2, 0xf00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x86d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, + 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, + 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, + 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, + 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, + 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x3b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, + 0x4db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0xd6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, + 0x9309ff9d, 0xa00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, + 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, + 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, + 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x26d930a, 0x9c0906a9, + 0xeb0e363f, 0x72076785, 0x5005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0xcb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0xbdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, + 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, + 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, + 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, + 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, ], [ - 0 as ::core::ffi::c_int as uint32_t, - 0x191b3141 as ::core::ffi::c_int as uint32_t, - 0x32366282 as ::core::ffi::c_int as uint32_t, - 0x2b2d53c3 as ::core::ffi::c_int as uint32_t, - 0x646cc504 as ::core::ffi::c_int as uint32_t, - 0x7d77f445 as ::core::ffi::c_int as uint32_t, - 0x565aa786 as ::core::ffi::c_int as uint32_t, - 0x4f4196c7 as ::core::ffi::c_int as uint32_t, - 0xc8d98a08 as ::core::ffi::c_uint, - 0xd1c2bb49 as ::core::ffi::c_uint, - 0xfaefe88a as ::core::ffi::c_uint, - 0xe3f4d9cb as ::core::ffi::c_uint, - 0xacb54f0c as ::core::ffi::c_uint, - 0xb5ae7e4d as ::core::ffi::c_uint, - 0x9e832d8e as ::core::ffi::c_uint, - 0x87981ccf as ::core::ffi::c_uint, - 0x4ac21251 as ::core::ffi::c_int as uint32_t, - 0x53d92310 as ::core::ffi::c_int as uint32_t, - 0x78f470d3 as ::core::ffi::c_int as uint32_t, - 0x61ef4192 as ::core::ffi::c_int as uint32_t, - 0x2eaed755 as ::core::ffi::c_int as uint32_t, - 0x37b5e614 as ::core::ffi::c_int as uint32_t, - 0x1c98b5d7 as ::core::ffi::c_int as uint32_t, - 0x5838496 as ::core::ffi::c_int as uint32_t, - 0x821b9859 as ::core::ffi::c_uint, - 0x9b00a918 as ::core::ffi::c_uint, - 0xb02dfadb as ::core::ffi::c_uint, - 0xa936cb9a as ::core::ffi::c_uint, - 0xe6775d5d as ::core::ffi::c_uint, - 0xff6c6c1c as ::core::ffi::c_uint, - 0xd4413fdf as ::core::ffi::c_uint, - 0xcd5a0e9e as ::core::ffi::c_uint, - 0x958424a2 as ::core::ffi::c_uint, - 0x8c9f15e3 as ::core::ffi::c_uint, - 0xa7b24620 as ::core::ffi::c_uint, - 0xbea97761 as ::core::ffi::c_uint, - 0xf1e8e1a6 as ::core::ffi::c_uint, - 0xe8f3d0e7 as ::core::ffi::c_uint, - 0xc3de8324 as ::core::ffi::c_uint, - 0xdac5b265 as ::core::ffi::c_uint, - 0x5d5daeaa as ::core::ffi::c_int as uint32_t, - 0x44469feb as ::core::ffi::c_int as uint32_t, - 0x6f6bcc28 as ::core::ffi::c_int as uint32_t, - 0x7670fd69 as ::core::ffi::c_int as uint32_t, - 0x39316bae as ::core::ffi::c_int as uint32_t, - 0x202a5aef as ::core::ffi::c_int as uint32_t, - 0xb07092c as ::core::ffi::c_int as uint32_t, - 0x121c386d as ::core::ffi::c_int as uint32_t, - 0xdf4636f3 as ::core::ffi::c_uint, - 0xc65d07b2 as ::core::ffi::c_uint, - 0xed705471 as ::core::ffi::c_uint, - 0xf46b6530 as ::core::ffi::c_uint, - 0xbb2af3f7 as ::core::ffi::c_uint, - 0xa231c2b6 as ::core::ffi::c_uint, - 0x891c9175 as ::core::ffi::c_uint, - 0x9007a034 as ::core::ffi::c_uint, - 0x179fbcfb as ::core::ffi::c_int as uint32_t, - 0xe848dba as ::core::ffi::c_int as uint32_t, - 0x25a9de79 as ::core::ffi::c_int as uint32_t, - 0x3cb2ef38 as ::core::ffi::c_int as uint32_t, - 0x73f379ff as ::core::ffi::c_int as uint32_t, - 0x6ae848be as ::core::ffi::c_int as uint32_t, - 0x41c51b7d as ::core::ffi::c_int as uint32_t, - 0x58de2a3c as ::core::ffi::c_int as uint32_t, - 0xf0794f05 as ::core::ffi::c_uint, - 0xe9627e44 as ::core::ffi::c_uint, - 0xc24f2d87 as ::core::ffi::c_uint, - 0xdb541cc6 as ::core::ffi::c_uint, - 0x94158a01 as ::core::ffi::c_uint, - 0x8d0ebb40 as ::core::ffi::c_uint, - 0xa623e883 as ::core::ffi::c_uint, - 0xbf38d9c2 as ::core::ffi::c_uint, - 0x38a0c50d as ::core::ffi::c_int as uint32_t, - 0x21bbf44c as ::core::ffi::c_int as uint32_t, - 0xa96a78f as ::core::ffi::c_int as uint32_t, - 0x138d96ce as ::core::ffi::c_int as uint32_t, - 0x5ccc0009 as ::core::ffi::c_int as uint32_t, - 0x45d73148 as ::core::ffi::c_int as uint32_t, - 0x6efa628b as ::core::ffi::c_int as uint32_t, - 0x77e153ca as ::core::ffi::c_int as uint32_t, - 0xbabb5d54 as ::core::ffi::c_uint, - 0xa3a06c15 as ::core::ffi::c_uint, - 0x888d3fd6 as ::core::ffi::c_uint, - 0x91960e97 as ::core::ffi::c_uint, - 0xded79850 as ::core::ffi::c_uint, - 0xc7cca911 as ::core::ffi::c_uint, - 0xece1fad2 as ::core::ffi::c_uint, - 0xf5facb93 as ::core::ffi::c_uint, - 0x7262d75c as ::core::ffi::c_int as uint32_t, - 0x6b79e61d as ::core::ffi::c_int as uint32_t, - 0x4054b5de as ::core::ffi::c_int as uint32_t, - 0x594f849f as ::core::ffi::c_int as uint32_t, - 0x160e1258 as ::core::ffi::c_int as uint32_t, - 0xf152319 as ::core::ffi::c_int as uint32_t, - 0x243870da as ::core::ffi::c_int as uint32_t, - 0x3d23419b as ::core::ffi::c_int as uint32_t, - 0x65fd6ba7 as ::core::ffi::c_int as uint32_t, - 0x7ce65ae6 as ::core::ffi::c_int as uint32_t, - 0x57cb0925 as ::core::ffi::c_int as uint32_t, - 0x4ed03864 as ::core::ffi::c_int as uint32_t, - 0x191aea3 as ::core::ffi::c_int as uint32_t, - 0x188a9fe2 as ::core::ffi::c_int as uint32_t, - 0x33a7cc21 as ::core::ffi::c_int as uint32_t, - 0x2abcfd60 as ::core::ffi::c_int as uint32_t, - 0xad24e1af as ::core::ffi::c_uint, - 0xb43fd0ee as ::core::ffi::c_uint, - 0x9f12832d as ::core::ffi::c_uint, - 0x8609b26c as ::core::ffi::c_uint, - 0xc94824ab as ::core::ffi::c_uint, - 0xd05315ea as ::core::ffi::c_uint, - 0xfb7e4629 as ::core::ffi::c_uint, - 0xe2657768 as ::core::ffi::c_uint, - 0x2f3f79f6 as ::core::ffi::c_int as uint32_t, - 0x362448b7 as ::core::ffi::c_int as uint32_t, - 0x1d091b74 as ::core::ffi::c_int as uint32_t, - 0x4122a35 as ::core::ffi::c_int as uint32_t, - 0x4b53bcf2 as ::core::ffi::c_int as uint32_t, - 0x52488db3 as ::core::ffi::c_int as uint32_t, - 0x7965de70 as ::core::ffi::c_int as uint32_t, - 0x607eef31 as ::core::ffi::c_int as uint32_t, - 0xe7e6f3fe as ::core::ffi::c_uint, - 0xfefdc2bf as ::core::ffi::c_uint, - 0xd5d0917c as ::core::ffi::c_uint, - 0xcccba03d as ::core::ffi::c_uint, - 0x838a36fa as ::core::ffi::c_uint, - 0x9a9107bb as ::core::ffi::c_uint, - 0xb1bc5478 as ::core::ffi::c_uint, - 0xa8a76539 as ::core::ffi::c_uint, - 0x3b83984b as ::core::ffi::c_int as uint32_t, - 0x2298a90a as ::core::ffi::c_int as uint32_t, - 0x9b5fac9 as ::core::ffi::c_int as uint32_t, - 0x10aecb88 as ::core::ffi::c_int as uint32_t, - 0x5fef5d4f as ::core::ffi::c_int as uint32_t, - 0x46f46c0e as ::core::ffi::c_int as uint32_t, - 0x6dd93fcd as ::core::ffi::c_int as uint32_t, - 0x74c20e8c as ::core::ffi::c_int as uint32_t, - 0xf35a1243 as ::core::ffi::c_uint, - 0xea412302 as ::core::ffi::c_uint, - 0xc16c70c1 as ::core::ffi::c_uint, - 0xd8774180 as ::core::ffi::c_uint, - 0x9736d747 as ::core::ffi::c_uint, - 0x8e2de606 as ::core::ffi::c_uint, - 0xa500b5c5 as ::core::ffi::c_uint, - 0xbc1b8484 as ::core::ffi::c_uint, - 0x71418a1a as ::core::ffi::c_int as uint32_t, - 0x685abb5b as ::core::ffi::c_int as uint32_t, - 0x4377e898 as ::core::ffi::c_int as uint32_t, - 0x5a6cd9d9 as ::core::ffi::c_int as uint32_t, - 0x152d4f1e as ::core::ffi::c_int as uint32_t, - 0xc367e5f as ::core::ffi::c_int as uint32_t, - 0x271b2d9c as ::core::ffi::c_int as uint32_t, - 0x3e001cdd as ::core::ffi::c_int as uint32_t, - 0xb9980012 as ::core::ffi::c_uint, - 0xa0833153 as ::core::ffi::c_uint, - 0x8bae6290 as ::core::ffi::c_uint, - 0x92b553d1 as ::core::ffi::c_uint, - 0xddf4c516 as ::core::ffi::c_uint, - 0xc4eff457 as ::core::ffi::c_uint, - 0xefc2a794 as ::core::ffi::c_uint, - 0xf6d996d5 as ::core::ffi::c_uint, - 0xae07bce9 as ::core::ffi::c_uint, - 0xb71c8da8 as ::core::ffi::c_uint, - 0x9c31de6b as ::core::ffi::c_uint, - 0x852aef2a as ::core::ffi::c_uint, - 0xca6b79ed as ::core::ffi::c_uint, - 0xd37048ac as ::core::ffi::c_uint, - 0xf85d1b6f as ::core::ffi::c_uint, - 0xe1462a2e as ::core::ffi::c_uint, - 0x66de36e1 as ::core::ffi::c_int as uint32_t, - 0x7fc507a0 as ::core::ffi::c_int as uint32_t, - 0x54e85463 as ::core::ffi::c_int as uint32_t, - 0x4df36522 as ::core::ffi::c_int as uint32_t, - 0x2b2f3e5 as ::core::ffi::c_int as uint32_t, - 0x1ba9c2a4 as ::core::ffi::c_int as uint32_t, - 0x30849167 as ::core::ffi::c_int as uint32_t, - 0x299fa026 as ::core::ffi::c_int as uint32_t, - 0xe4c5aeb8 as ::core::ffi::c_uint, - 0xfdde9ff9 as ::core::ffi::c_uint, - 0xd6f3cc3a as ::core::ffi::c_uint, - 0xcfe8fd7b as ::core::ffi::c_uint, - 0x80a96bbc as ::core::ffi::c_uint, - 0x99b25afd as ::core::ffi::c_uint, - 0xb29f093e as ::core::ffi::c_uint, - 0xab84387f as ::core::ffi::c_uint, - 0x2c1c24b0 as ::core::ffi::c_int as uint32_t, - 0x350715f1 as ::core::ffi::c_int as uint32_t, - 0x1e2a4632 as ::core::ffi::c_int as uint32_t, - 0x7317773 as ::core::ffi::c_int as uint32_t, - 0x4870e1b4 as ::core::ffi::c_int as uint32_t, - 0x516bd0f5 as ::core::ffi::c_int as uint32_t, - 0x7a468336 as ::core::ffi::c_int as uint32_t, - 0x635db277 as ::core::ffi::c_int as uint32_t, - 0xcbfad74e as ::core::ffi::c_uint, - 0xd2e1e60f as ::core::ffi::c_uint, - 0xf9ccb5cc as ::core::ffi::c_uint, - 0xe0d7848d as ::core::ffi::c_uint, - 0xaf96124a as ::core::ffi::c_uint, - 0xb68d230b as ::core::ffi::c_uint, - 0x9da070c8 as ::core::ffi::c_uint, - 0x84bb4189 as ::core::ffi::c_uint, - 0x3235d46 as ::core::ffi::c_int as uint32_t, - 0x1a386c07 as ::core::ffi::c_int as uint32_t, - 0x31153fc4 as ::core::ffi::c_int as uint32_t, - 0x280e0e85 as ::core::ffi::c_int as uint32_t, - 0x674f9842 as ::core::ffi::c_int as uint32_t, - 0x7e54a903 as ::core::ffi::c_int as uint32_t, - 0x5579fac0 as ::core::ffi::c_int as uint32_t, - 0x4c62cb81 as ::core::ffi::c_int as uint32_t, - 0x8138c51f as ::core::ffi::c_uint, - 0x9823f45e as ::core::ffi::c_uint, - 0xb30ea79d as ::core::ffi::c_uint, - 0xaa1596dc as ::core::ffi::c_uint, - 0xe554001b as ::core::ffi::c_uint, - 0xfc4f315a as ::core::ffi::c_uint, - 0xd7626299 as ::core::ffi::c_uint, - 0xce7953d8 as ::core::ffi::c_uint, - 0x49e14f17 as ::core::ffi::c_int as uint32_t, - 0x50fa7e56 as ::core::ffi::c_int as uint32_t, - 0x7bd72d95 as ::core::ffi::c_int as uint32_t, - 0x62cc1cd4 as ::core::ffi::c_int as uint32_t, - 0x2d8d8a13 as ::core::ffi::c_int as uint32_t, - 0x3496bb52 as ::core::ffi::c_int as uint32_t, - 0x1fbbe891 as ::core::ffi::c_int as uint32_t, - 0x6a0d9d0 as ::core::ffi::c_int as uint32_t, - 0x5e7ef3ec as ::core::ffi::c_int as uint32_t, - 0x4765c2ad as ::core::ffi::c_int as uint32_t, - 0x6c48916e as ::core::ffi::c_int as uint32_t, - 0x7553a02f as ::core::ffi::c_int as uint32_t, - 0x3a1236e8 as ::core::ffi::c_int as uint32_t, - 0x230907a9 as ::core::ffi::c_int as uint32_t, - 0x824546a as ::core::ffi::c_int as uint32_t, - 0x113f652b as ::core::ffi::c_int as uint32_t, - 0x96a779e4 as ::core::ffi::c_uint, - 0x8fbc48a5 as ::core::ffi::c_uint, - 0xa4911b66 as ::core::ffi::c_uint, - 0xbd8a2a27 as ::core::ffi::c_uint, - 0xf2cbbce0 as ::core::ffi::c_uint, - 0xebd08da1 as ::core::ffi::c_uint, - 0xc0fdde62 as ::core::ffi::c_uint, - 0xd9e6ef23 as ::core::ffi::c_uint, - 0x14bce1bd as ::core::ffi::c_int as uint32_t, - 0xda7d0fc as ::core::ffi::c_int as uint32_t, - 0x268a833f as ::core::ffi::c_int as uint32_t, - 0x3f91b27e as ::core::ffi::c_int as uint32_t, - 0x70d024b9 as ::core::ffi::c_int as uint32_t, - 0x69cb15f8 as ::core::ffi::c_int as uint32_t, - 0x42e6463b as ::core::ffi::c_int as uint32_t, - 0x5bfd777a as ::core::ffi::c_int as uint32_t, - 0xdc656bb5 as ::core::ffi::c_uint, - 0xc57e5af4 as ::core::ffi::c_uint, - 0xee530937 as ::core::ffi::c_uint, - 0xf7483876 as ::core::ffi::c_uint, - 0xb809aeb1 as ::core::ffi::c_uint, - 0xa1129ff0 as ::core::ffi::c_uint, - 0x8a3fcc33 as ::core::ffi::c_uint, - 0x9324fd72 as ::core::ffi::c_uint, + 0, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, + 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, + 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, 0x2eaed755, 0x37b5e614, + 0x1c98b5d7, 0x5838496, 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, + 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761, + 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, + 0x7670fd69, 0x39316bae, 0x202a5aef, 0xb07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, + 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034, 0x179fbcfb, + 0xe848dba, 0x25a9de79, 0x3cb2ef38, 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, + 0xf0794f05, 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, 0xa623e883, + 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0xa96a78f, 0x138d96ce, 0x5ccc0009, 0x45d73148, + 0x6efa628b, 0x77e153ca, 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, + 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, 0x4054b5de, 0x594f849f, + 0x160e1258, 0xf152319, 0x243870da, 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, + 0x4ed03864, 0x191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, 0xb43fd0ee, + 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, 0xfb7e4629, 0xe2657768, 0x2f3f79f6, + 0x362448b7, 0x1d091b74, 0x4122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, + 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, 0x9a9107bb, 0xb1bc5478, + 0xa8a76539, 0x3b83984b, 0x2298a90a, 0x9b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, + 0x6dd93fcd, 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, 0x9736d747, + 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, 0x685abb5b, 0x4377e898, 0x5a6cd9d9, + 0x152d4f1e, 0xc367e5f, 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, + 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, 0xae07bce9, 0xb71c8da8, + 0x9c31de6b, 0x852aef2a, 0xca6b79ed, 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, + 0x7fc507a0, 0x54e85463, 0x4df36522, 0x2b2f3e5, 0x1ba9c2a4, 0x30849167, 0x299fa026, + 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, 0x80a96bbc, 0x99b25afd, 0xb29f093e, + 0xab84387f, 0x2c1c24b0, 0x350715f1, 0x1e2a4632, 0x7317773, 0x4870e1b4, 0x516bd0f5, + 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d, 0xaf96124a, + 0xb68d230b, 0x9da070c8, 0x84bb4189, 0x3235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, + 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, 0xb30ea79d, + 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8, 0x49e14f17, 0x50fa7e56, + 0x7bd72d95, 0x62cc1cd4, 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x6a0d9d0, 0x5e7ef3ec, + 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, 0x824546a, 0x113f652b, + 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, + 0xd9e6ef23, 0x14bce1bd, 0xda7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, 0x69cb15f8, + 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876, 0xb809aeb1, + 0xa1129ff0, 0x8a3fcc33, 0x9324fd72, ], [ - 0 as ::core::ffi::c_int as uint32_t, - 0x1c26a37 as ::core::ffi::c_int as uint32_t, - 0x384d46e as ::core::ffi::c_int as uint32_t, - 0x246be59 as ::core::ffi::c_int as uint32_t, - 0x709a8dc as ::core::ffi::c_int as uint32_t, - 0x6cbc2eb as ::core::ffi::c_int as uint32_t, - 0x48d7cb2 as ::core::ffi::c_int as uint32_t, - 0x54f1685 as ::core::ffi::c_int as uint32_t, - 0xe1351b8 as ::core::ffi::c_int as uint32_t, - 0xfd13b8f as ::core::ffi::c_int as uint32_t, - 0xd9785d6 as ::core::ffi::c_int as uint32_t, - 0xc55efe1 as ::core::ffi::c_int as uint32_t, - 0x91af964 as ::core::ffi::c_int as uint32_t, - 0x8d89353 as ::core::ffi::c_int as uint32_t, - 0xa9e2d0a as ::core::ffi::c_int as uint32_t, - 0xb5c473d as ::core::ffi::c_int as uint32_t, - 0x1c26a370 as ::core::ffi::c_int as uint32_t, - 0x1de4c947 as ::core::ffi::c_int as uint32_t, - 0x1fa2771e as ::core::ffi::c_int as uint32_t, - 0x1e601d29 as ::core::ffi::c_int as uint32_t, - 0x1b2f0bac as ::core::ffi::c_int as uint32_t, - 0x1aed619b as ::core::ffi::c_int as uint32_t, - 0x18abdfc2 as ::core::ffi::c_int as uint32_t, - 0x1969b5f5 as ::core::ffi::c_int as uint32_t, - 0x1235f2c8 as ::core::ffi::c_int as uint32_t, - 0x13f798ff as ::core::ffi::c_int as uint32_t, - 0x11b126a6 as ::core::ffi::c_int as uint32_t, - 0x10734c91 as ::core::ffi::c_int as uint32_t, - 0x153c5a14 as ::core::ffi::c_int as uint32_t, - 0x14fe3023 as ::core::ffi::c_int as uint32_t, - 0x16b88e7a as ::core::ffi::c_int as uint32_t, - 0x177ae44d as ::core::ffi::c_int as uint32_t, - 0x384d46e0 as ::core::ffi::c_int as uint32_t, - 0x398f2cd7 as ::core::ffi::c_int as uint32_t, - 0x3bc9928e as ::core::ffi::c_int as uint32_t, - 0x3a0bf8b9 as ::core::ffi::c_int as uint32_t, - 0x3f44ee3c as ::core::ffi::c_int as uint32_t, - 0x3e86840b as ::core::ffi::c_int as uint32_t, - 0x3cc03a52 as ::core::ffi::c_int as uint32_t, - 0x3d025065 as ::core::ffi::c_int as uint32_t, - 0x365e1758 as ::core::ffi::c_int as uint32_t, - 0x379c7d6f as ::core::ffi::c_int as uint32_t, - 0x35dac336 as ::core::ffi::c_int as uint32_t, - 0x3418a901 as ::core::ffi::c_int as uint32_t, - 0x3157bf84 as ::core::ffi::c_int as uint32_t, - 0x3095d5b3 as ::core::ffi::c_int as uint32_t, - 0x32d36bea as ::core::ffi::c_int as uint32_t, - 0x331101dd as ::core::ffi::c_int as uint32_t, - 0x246be590 as ::core::ffi::c_int as uint32_t, - 0x25a98fa7 as ::core::ffi::c_int as uint32_t, - 0x27ef31fe as ::core::ffi::c_int as uint32_t, - 0x262d5bc9 as ::core::ffi::c_int as uint32_t, - 0x23624d4c as ::core::ffi::c_int as uint32_t, - 0x22a0277b as ::core::ffi::c_int as uint32_t, - 0x20e69922 as ::core::ffi::c_int as uint32_t, - 0x2124f315 as ::core::ffi::c_int as uint32_t, - 0x2a78b428 as ::core::ffi::c_int as uint32_t, - 0x2bbade1f as ::core::ffi::c_int as uint32_t, - 0x29fc6046 as ::core::ffi::c_int as uint32_t, - 0x283e0a71 as ::core::ffi::c_int as uint32_t, - 0x2d711cf4 as ::core::ffi::c_int as uint32_t, - 0x2cb376c3 as ::core::ffi::c_int as uint32_t, - 0x2ef5c89a as ::core::ffi::c_int as uint32_t, - 0x2f37a2ad as ::core::ffi::c_int as uint32_t, - 0x709a8dc0 as ::core::ffi::c_int as uint32_t, - 0x7158e7f7 as ::core::ffi::c_int as uint32_t, - 0x731e59ae as ::core::ffi::c_int as uint32_t, - 0x72dc3399 as ::core::ffi::c_int as uint32_t, - 0x7793251c as ::core::ffi::c_int as uint32_t, - 0x76514f2b as ::core::ffi::c_int as uint32_t, - 0x7417f172 as ::core::ffi::c_int as uint32_t, - 0x75d59b45 as ::core::ffi::c_int as uint32_t, - 0x7e89dc78 as ::core::ffi::c_int as uint32_t, - 0x7f4bb64f as ::core::ffi::c_int as uint32_t, - 0x7d0d0816 as ::core::ffi::c_int as uint32_t, - 0x7ccf6221 as ::core::ffi::c_int as uint32_t, - 0x798074a4 as ::core::ffi::c_int as uint32_t, - 0x78421e93 as ::core::ffi::c_int as uint32_t, - 0x7a04a0ca as ::core::ffi::c_int as uint32_t, - 0x7bc6cafd as ::core::ffi::c_int as uint32_t, - 0x6cbc2eb0 as ::core::ffi::c_int as uint32_t, - 0x6d7e4487 as ::core::ffi::c_int as uint32_t, - 0x6f38fade as ::core::ffi::c_int as uint32_t, - 0x6efa90e9 as ::core::ffi::c_int as uint32_t, - 0x6bb5866c as ::core::ffi::c_int as uint32_t, - 0x6a77ec5b as ::core::ffi::c_int as uint32_t, - 0x68315202 as ::core::ffi::c_int as uint32_t, - 0x69f33835 as ::core::ffi::c_int as uint32_t, - 0x62af7f08 as ::core::ffi::c_int as uint32_t, - 0x636d153f as ::core::ffi::c_int as uint32_t, - 0x612bab66 as ::core::ffi::c_int as uint32_t, - 0x60e9c151 as ::core::ffi::c_int as uint32_t, - 0x65a6d7d4 as ::core::ffi::c_int as uint32_t, - 0x6464bde3 as ::core::ffi::c_int as uint32_t, - 0x662203ba as ::core::ffi::c_int as uint32_t, - 0x67e0698d as ::core::ffi::c_int as uint32_t, - 0x48d7cb20 as ::core::ffi::c_int as uint32_t, - 0x4915a117 as ::core::ffi::c_int as uint32_t, - 0x4b531f4e as ::core::ffi::c_int as uint32_t, - 0x4a917579 as ::core::ffi::c_int as uint32_t, - 0x4fde63fc as ::core::ffi::c_int as uint32_t, - 0x4e1c09cb as ::core::ffi::c_int as uint32_t, - 0x4c5ab792 as ::core::ffi::c_int as uint32_t, - 0x4d98dda5 as ::core::ffi::c_int as uint32_t, - 0x46c49a98 as ::core::ffi::c_int as uint32_t, - 0x4706f0af as ::core::ffi::c_int as uint32_t, - 0x45404ef6 as ::core::ffi::c_int as uint32_t, - 0x448224c1 as ::core::ffi::c_int as uint32_t, - 0x41cd3244 as ::core::ffi::c_int as uint32_t, - 0x400f5873 as ::core::ffi::c_int as uint32_t, - 0x4249e62a as ::core::ffi::c_int as uint32_t, - 0x438b8c1d as ::core::ffi::c_int as uint32_t, - 0x54f16850 as ::core::ffi::c_int as uint32_t, - 0x55330267 as ::core::ffi::c_int as uint32_t, - 0x5775bc3e as ::core::ffi::c_int as uint32_t, - 0x56b7d609 as ::core::ffi::c_int as uint32_t, - 0x53f8c08c as ::core::ffi::c_int as uint32_t, - 0x523aaabb as ::core::ffi::c_int as uint32_t, - 0x507c14e2 as ::core::ffi::c_int as uint32_t, - 0x51be7ed5 as ::core::ffi::c_int as uint32_t, - 0x5ae239e8 as ::core::ffi::c_int as uint32_t, - 0x5b2053df as ::core::ffi::c_int as uint32_t, - 0x5966ed86 as ::core::ffi::c_int as uint32_t, - 0x58a487b1 as ::core::ffi::c_int as uint32_t, - 0x5deb9134 as ::core::ffi::c_int as uint32_t, - 0x5c29fb03 as ::core::ffi::c_int as uint32_t, - 0x5e6f455a as ::core::ffi::c_int as uint32_t, - 0x5fad2f6d as ::core::ffi::c_int as uint32_t, - 0xe1351b80 as ::core::ffi::c_uint, - 0xe0f771b7 as ::core::ffi::c_uint, - 0xe2b1cfee as ::core::ffi::c_uint, - 0xe373a5d9 as ::core::ffi::c_uint, - 0xe63cb35c as ::core::ffi::c_uint, - 0xe7fed96b as ::core::ffi::c_uint, - 0xe5b86732 as ::core::ffi::c_uint, - 0xe47a0d05 as ::core::ffi::c_uint, - 0xef264a38 as ::core::ffi::c_uint, - 0xeee4200f as ::core::ffi::c_uint, - 0xeca29e56 as ::core::ffi::c_uint, - 0xed60f461 as ::core::ffi::c_uint, - 0xe82fe2e4 as ::core::ffi::c_uint, - 0xe9ed88d3 as ::core::ffi::c_uint, - 0xebab368a as ::core::ffi::c_uint, - 0xea695cbd as ::core::ffi::c_uint, - 0xfd13b8f0 as ::core::ffi::c_uint, - 0xfcd1d2c7 as ::core::ffi::c_uint, - 0xfe976c9e as ::core::ffi::c_uint, - 0xff5506a9 as ::core::ffi::c_uint, - 0xfa1a102c as ::core::ffi::c_uint, - 0xfbd87a1b as ::core::ffi::c_uint, - 0xf99ec442 as ::core::ffi::c_uint, - 0xf85cae75 as ::core::ffi::c_uint, - 0xf300e948 as ::core::ffi::c_uint, - 0xf2c2837f as ::core::ffi::c_uint, - 0xf0843d26 as ::core::ffi::c_uint, - 0xf1465711 as ::core::ffi::c_uint, - 0xf4094194 as ::core::ffi::c_uint, - 0xf5cb2ba3 as ::core::ffi::c_uint, - 0xf78d95fa as ::core::ffi::c_uint, - 0xf64fffcd as ::core::ffi::c_uint, - 0xd9785d60 as ::core::ffi::c_uint, - 0xd8ba3757 as ::core::ffi::c_uint, - 0xdafc890e as ::core::ffi::c_uint, - 0xdb3ee339 as ::core::ffi::c_uint, - 0xde71f5bc as ::core::ffi::c_uint, - 0xdfb39f8b as ::core::ffi::c_uint, - 0xddf521d2 as ::core::ffi::c_uint, - 0xdc374be5 as ::core::ffi::c_uint, - 0xd76b0cd8 as ::core::ffi::c_uint, - 0xd6a966ef as ::core::ffi::c_uint, - 0xd4efd8b6 as ::core::ffi::c_uint, - 0xd52db281 as ::core::ffi::c_uint, - 0xd062a404 as ::core::ffi::c_uint, - 0xd1a0ce33 as ::core::ffi::c_uint, - 0xd3e6706a as ::core::ffi::c_uint, - 0xd2241a5d as ::core::ffi::c_uint, - 0xc55efe10 as ::core::ffi::c_uint, - 0xc49c9427 as ::core::ffi::c_uint, - 0xc6da2a7e as ::core::ffi::c_uint, - 0xc7184049 as ::core::ffi::c_uint, - 0xc25756cc as ::core::ffi::c_uint, - 0xc3953cfb as ::core::ffi::c_uint, - 0xc1d382a2 as ::core::ffi::c_uint, - 0xc011e895 as ::core::ffi::c_uint, - 0xcb4dafa8 as ::core::ffi::c_uint, - 0xca8fc59f as ::core::ffi::c_uint, - 0xc8c97bc6 as ::core::ffi::c_uint, - 0xc90b11f1 as ::core::ffi::c_uint, - 0xcc440774 as ::core::ffi::c_uint, - 0xcd866d43 as ::core::ffi::c_uint, - 0xcfc0d31a as ::core::ffi::c_uint, - 0xce02b92d as ::core::ffi::c_uint, - 0x91af9640 as ::core::ffi::c_uint, - 0x906dfc77 as ::core::ffi::c_uint, - 0x922b422e as ::core::ffi::c_uint, - 0x93e92819 as ::core::ffi::c_uint, - 0x96a63e9c as ::core::ffi::c_uint, - 0x976454ab as ::core::ffi::c_uint, - 0x9522eaf2 as ::core::ffi::c_uint, - 0x94e080c5 as ::core::ffi::c_uint, - 0x9fbcc7f8 as ::core::ffi::c_uint, - 0x9e7eadcf as ::core::ffi::c_uint, - 0x9c381396 as ::core::ffi::c_uint, - 0x9dfa79a1 as ::core::ffi::c_uint, - 0x98b56f24 as ::core::ffi::c_uint, - 0x99770513 as ::core::ffi::c_uint, - 0x9b31bb4a as ::core::ffi::c_uint, - 0x9af3d17d as ::core::ffi::c_uint, - 0x8d893530 as ::core::ffi::c_uint, - 0x8c4b5f07 as ::core::ffi::c_uint, - 0x8e0de15e as ::core::ffi::c_uint, - 0x8fcf8b69 as ::core::ffi::c_uint, - 0x8a809dec as ::core::ffi::c_uint, - 0x8b42f7db as ::core::ffi::c_uint, - 0x89044982 as ::core::ffi::c_uint, - 0x88c623b5 as ::core::ffi::c_uint, - 0x839a6488 as ::core::ffi::c_uint, - 0x82580ebf as ::core::ffi::c_uint, - 0x801eb0e6 as ::core::ffi::c_uint, - 0x81dcdad1 as ::core::ffi::c_uint, - 0x8493cc54 as ::core::ffi::c_uint, - 0x8551a663 as ::core::ffi::c_uint, - 0x8717183a as ::core::ffi::c_uint, - 0x86d5720d as ::core::ffi::c_uint, - 0xa9e2d0a0 as ::core::ffi::c_uint, - 0xa820ba97 as ::core::ffi::c_uint, - 0xaa6604ce as ::core::ffi::c_uint, - 0xaba46ef9 as ::core::ffi::c_uint, - 0xaeeb787c as ::core::ffi::c_uint, - 0xaf29124b as ::core::ffi::c_uint, - 0xad6fac12 as ::core::ffi::c_uint, - 0xacadc625 as ::core::ffi::c_uint, - 0xa7f18118 as ::core::ffi::c_uint, - 0xa633eb2f as ::core::ffi::c_uint, - 0xa4755576 as ::core::ffi::c_uint, - 0xa5b73f41 as ::core::ffi::c_uint, - 0xa0f829c4 as ::core::ffi::c_uint, - 0xa13a43f3 as ::core::ffi::c_uint, - 0xa37cfdaa as ::core::ffi::c_uint, - 0xa2be979d as ::core::ffi::c_uint, - 0xb5c473d0 as ::core::ffi::c_uint, - 0xb40619e7 as ::core::ffi::c_uint, - 0xb640a7be as ::core::ffi::c_uint, - 0xb782cd89 as ::core::ffi::c_uint, - 0xb2cddb0c as ::core::ffi::c_uint, - 0xb30fb13b as ::core::ffi::c_uint, - 0xb1490f62 as ::core::ffi::c_uint, - 0xb08b6555 as ::core::ffi::c_uint, - 0xbbd72268 as ::core::ffi::c_uint, - 0xba15485f as ::core::ffi::c_uint, - 0xb853f606 as ::core::ffi::c_uint, - 0xb9919c31 as ::core::ffi::c_uint, - 0xbcde8ab4 as ::core::ffi::c_uint, - 0xbd1ce083 as ::core::ffi::c_uint, - 0xbf5a5eda as ::core::ffi::c_uint, - 0xbe9834ed as ::core::ffi::c_uint, + 0, 0x1c26a37, 0x384d46e, 0x246be59, 0x709a8dc, 0x6cbc2eb, 0x48d7cb2, 0x54f1685, 0xe1351b8, + 0xfd13b8f, 0xd9785d6, 0xc55efe1, 0x91af964, 0x8d89353, 0xa9e2d0a, 0xb5c473d, 0x1c26a370, + 0x1de4c947, 0x1fa2771e, 0x1e601d29, 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, + 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, 0x16b88e7a, + 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, + 0x3cc03a52, 0x3d025065, 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, + 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9, + 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, + 0x283e0a71, 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, 0x7158e7f7, + 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, 0x7417f172, 0x75d59b45, 0x7e89dc78, + 0x7f4bb64f, 0x7d0d0816, 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, + 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, 0x6a77ec5b, 0x68315202, + 0x69f33835, 0x62af7f08, 0x636d153f, 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, + 0x662203ba, 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, 0x4fde63fc, + 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, 0x4706f0af, 0x45404ef6, 0x448224c1, + 0x41cd3244, 0x400f5873, 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, + 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, 0x5ae239e8, 0x5b2053df, + 0x5966ed86, 0x58a487b1, 0x5deb9134, 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, + 0xe0f771b7, 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, 0xe47a0d05, + 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, + 0xea695cbd, 0xfd13b8f0, 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, + 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, 0xf1465711, 0xf4094194, + 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, + 0xde71f5bc, 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, 0xd4efd8b6, + 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, 0xd2241a5d, 0xc55efe10, 0xc49c9427, + 0xc6da2a7e, 0xc7184049, 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, + 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, 0xcfc0d31a, 0xce02b92d, + 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, + 0x94e080c5, 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, 0x99770513, + 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, + 0x8b42f7db, 0x89044982, 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, + 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, + 0xaba46ef9, 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, + 0xa4755576, 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, 0xb5c473d0, + 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555, + 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, + 0xbe9834ed, ], [ - 0 as ::core::ffi::c_int as uint32_t, - 0xb8bc6765 as ::core::ffi::c_uint, - 0xaa09c88b as ::core::ffi::c_uint, - 0x12b5afee as ::core::ffi::c_int as uint32_t, - 0x8f629757 as ::core::ffi::c_uint, - 0x37def032 as ::core::ffi::c_int as uint32_t, - 0x256b5fdc as ::core::ffi::c_int as uint32_t, - 0x9dd738b9 as ::core::ffi::c_uint, - 0xc5b428ef as ::core::ffi::c_uint, - 0x7d084f8a as ::core::ffi::c_int as uint32_t, - 0x6fbde064 as ::core::ffi::c_int as uint32_t, - 0xd7018701 as ::core::ffi::c_uint, - 0x4ad6bfb8 as ::core::ffi::c_int as uint32_t, - 0xf26ad8dd as ::core::ffi::c_uint, - 0xe0df7733 as ::core::ffi::c_uint, - 0x58631056 as ::core::ffi::c_int as uint32_t, - 0x5019579f as ::core::ffi::c_int as uint32_t, - 0xe8a530fa as ::core::ffi::c_uint, - 0xfa109f14 as ::core::ffi::c_uint, - 0x42acf871 as ::core::ffi::c_int as uint32_t, - 0xdf7bc0c8 as ::core::ffi::c_uint, - 0x67c7a7ad as ::core::ffi::c_int as uint32_t, - 0x75720843 as ::core::ffi::c_int as uint32_t, - 0xcdce6f26 as ::core::ffi::c_uint, - 0x95ad7f70 as ::core::ffi::c_uint, - 0x2d111815 as ::core::ffi::c_int as uint32_t, - 0x3fa4b7fb as ::core::ffi::c_int as uint32_t, - 0x8718d09e as ::core::ffi::c_uint, - 0x1acfe827 as ::core::ffi::c_int as uint32_t, - 0xa2738f42 as ::core::ffi::c_uint, - 0xb0c620ac as ::core::ffi::c_uint, - 0x87a47c9 as ::core::ffi::c_int as uint32_t, - 0xa032af3e as ::core::ffi::c_uint, - 0x188ec85b as ::core::ffi::c_int as uint32_t, - 0xa3b67b5 as ::core::ffi::c_int as uint32_t, - 0xb28700d0 as ::core::ffi::c_uint, - 0x2f503869 as ::core::ffi::c_int as uint32_t, - 0x97ec5f0c as ::core::ffi::c_uint, - 0x8559f0e2 as ::core::ffi::c_uint, - 0x3de59787 as ::core::ffi::c_int as uint32_t, - 0x658687d1 as ::core::ffi::c_int as uint32_t, - 0xdd3ae0b4 as ::core::ffi::c_uint, - 0xcf8f4f5a as ::core::ffi::c_uint, - 0x7733283f as ::core::ffi::c_int as uint32_t, - 0xeae41086 as ::core::ffi::c_uint, - 0x525877e3 as ::core::ffi::c_int as uint32_t, - 0x40edd80d as ::core::ffi::c_int as uint32_t, - 0xf851bf68 as ::core::ffi::c_uint, - 0xf02bf8a1 as ::core::ffi::c_uint, - 0x48979fc4 as ::core::ffi::c_int as uint32_t, - 0x5a22302a as ::core::ffi::c_int as uint32_t, - 0xe29e574f as ::core::ffi::c_uint, - 0x7f496ff6 as ::core::ffi::c_int as uint32_t, - 0xc7f50893 as ::core::ffi::c_uint, - 0xd540a77d as ::core::ffi::c_uint, - 0x6dfcc018 as ::core::ffi::c_int as uint32_t, - 0x359fd04e as ::core::ffi::c_int as uint32_t, - 0x8d23b72b as ::core::ffi::c_uint, - 0x9f9618c5 as ::core::ffi::c_uint, - 0x272a7fa0 as ::core::ffi::c_int as uint32_t, - 0xbafd4719 as ::core::ffi::c_uint, - 0x241207c as ::core::ffi::c_int as uint32_t, - 0x10f48f92 as ::core::ffi::c_int as uint32_t, - 0xa848e8f7 as ::core::ffi::c_uint, - 0x9b14583d as ::core::ffi::c_uint, - 0x23a83f58 as ::core::ffi::c_int as uint32_t, - 0x311d90b6 as ::core::ffi::c_int as uint32_t, - 0x89a1f7d3 as ::core::ffi::c_uint, - 0x1476cf6a as ::core::ffi::c_int as uint32_t, - 0xaccaa80f as ::core::ffi::c_uint, - 0xbe7f07e1 as ::core::ffi::c_uint, - 0x6c36084 as ::core::ffi::c_int as uint32_t, - 0x5ea070d2 as ::core::ffi::c_int as uint32_t, - 0xe61c17b7 as ::core::ffi::c_uint, - 0xf4a9b859 as ::core::ffi::c_uint, - 0x4c15df3c as ::core::ffi::c_int as uint32_t, - 0xd1c2e785 as ::core::ffi::c_uint, - 0x697e80e0 as ::core::ffi::c_int as uint32_t, - 0x7bcb2f0e as ::core::ffi::c_int as uint32_t, - 0xc377486b as ::core::ffi::c_uint, - 0xcb0d0fa2 as ::core::ffi::c_uint, - 0x73b168c7 as ::core::ffi::c_int as uint32_t, - 0x6104c729 as ::core::ffi::c_int as uint32_t, - 0xd9b8a04c as ::core::ffi::c_uint, - 0x446f98f5 as ::core::ffi::c_int as uint32_t, - 0xfcd3ff90 as ::core::ffi::c_uint, - 0xee66507e as ::core::ffi::c_uint, - 0x56da371b as ::core::ffi::c_int as uint32_t, - 0xeb9274d as ::core::ffi::c_int as uint32_t, - 0xb6054028 as ::core::ffi::c_uint, - 0xa4b0efc6 as ::core::ffi::c_uint, - 0x1c0c88a3 as ::core::ffi::c_int as uint32_t, - 0x81dbb01a as ::core::ffi::c_uint, - 0x3967d77f as ::core::ffi::c_int as uint32_t, - 0x2bd27891 as ::core::ffi::c_int as uint32_t, - 0x936e1ff4 as ::core::ffi::c_uint, - 0x3b26f703 as ::core::ffi::c_int as uint32_t, - 0x839a9066 as ::core::ffi::c_uint, - 0x912f3f88 as ::core::ffi::c_uint, - 0x299358ed as ::core::ffi::c_int as uint32_t, - 0xb4446054 as ::core::ffi::c_uint, - 0xcf80731 as ::core::ffi::c_int as uint32_t, - 0x1e4da8df as ::core::ffi::c_int as uint32_t, - 0xa6f1cfba as ::core::ffi::c_uint, - 0xfe92dfec as ::core::ffi::c_uint, - 0x462eb889 as ::core::ffi::c_int as uint32_t, - 0x549b1767 as ::core::ffi::c_int as uint32_t, - 0xec277002 as ::core::ffi::c_uint, - 0x71f048bb as ::core::ffi::c_int as uint32_t, - 0xc94c2fde as ::core::ffi::c_uint, - 0xdbf98030 as ::core::ffi::c_uint, - 0x6345e755 as ::core::ffi::c_int as uint32_t, - 0x6b3fa09c as ::core::ffi::c_int as uint32_t, - 0xd383c7f9 as ::core::ffi::c_uint, - 0xc1366817 as ::core::ffi::c_uint, - 0x798a0f72 as ::core::ffi::c_int as uint32_t, - 0xe45d37cb as ::core::ffi::c_uint, - 0x5ce150ae as ::core::ffi::c_int as uint32_t, - 0x4e54ff40 as ::core::ffi::c_int as uint32_t, - 0xf6e89825 as ::core::ffi::c_uint, - 0xae8b8873 as ::core::ffi::c_uint, - 0x1637ef16 as ::core::ffi::c_int as uint32_t, - 0x48240f8 as ::core::ffi::c_int as uint32_t, - 0xbc3e279d as ::core::ffi::c_uint, - 0x21e91f24 as ::core::ffi::c_int as uint32_t, - 0x99557841 as ::core::ffi::c_uint, - 0x8be0d7af as ::core::ffi::c_uint, - 0x335cb0ca as ::core::ffi::c_int as uint32_t, - 0xed59b63b as ::core::ffi::c_uint, - 0x55e5d15e as ::core::ffi::c_int as uint32_t, - 0x47507eb0 as ::core::ffi::c_int as uint32_t, - 0xffec19d5 as ::core::ffi::c_uint, - 0x623b216c as ::core::ffi::c_int as uint32_t, - 0xda874609 as ::core::ffi::c_uint, - 0xc832e9e7 as ::core::ffi::c_uint, - 0x708e8e82 as ::core::ffi::c_int as uint32_t, - 0x28ed9ed4 as ::core::ffi::c_int as uint32_t, - 0x9051f9b1 as ::core::ffi::c_uint, - 0x82e4565f as ::core::ffi::c_uint, - 0x3a58313a as ::core::ffi::c_int as uint32_t, - 0xa78f0983 as ::core::ffi::c_uint, - 0x1f336ee6 as ::core::ffi::c_int as uint32_t, - 0xd86c108 as ::core::ffi::c_int as uint32_t, - 0xb53aa66d as ::core::ffi::c_uint, - 0xbd40e1a4 as ::core::ffi::c_uint, - 0x5fc86c1 as ::core::ffi::c_int as uint32_t, - 0x1749292f as ::core::ffi::c_int as uint32_t, - 0xaff54e4a as ::core::ffi::c_uint, - 0x322276f3 as ::core::ffi::c_int as uint32_t, - 0x8a9e1196 as ::core::ffi::c_uint, - 0x982bbe78 as ::core::ffi::c_uint, - 0x2097d91d as ::core::ffi::c_int as uint32_t, - 0x78f4c94b as ::core::ffi::c_int as uint32_t, - 0xc048ae2e as ::core::ffi::c_uint, - 0xd2fd01c0 as ::core::ffi::c_uint, - 0x6a4166a5 as ::core::ffi::c_int as uint32_t, - 0xf7965e1c as ::core::ffi::c_uint, - 0x4f2a3979 as ::core::ffi::c_int as uint32_t, - 0x5d9f9697 as ::core::ffi::c_int as uint32_t, - 0xe523f1f2 as ::core::ffi::c_uint, - 0x4d6b1905 as ::core::ffi::c_int as uint32_t, - 0xf5d77e60 as ::core::ffi::c_uint, - 0xe762d18e as ::core::ffi::c_uint, - 0x5fdeb6eb as ::core::ffi::c_int as uint32_t, - 0xc2098e52 as ::core::ffi::c_uint, - 0x7ab5e937 as ::core::ffi::c_int as uint32_t, - 0x680046d9 as ::core::ffi::c_int as uint32_t, - 0xd0bc21bc as ::core::ffi::c_uint, - 0x88df31ea as ::core::ffi::c_uint, - 0x3063568f as ::core::ffi::c_int as uint32_t, - 0x22d6f961 as ::core::ffi::c_int as uint32_t, - 0x9a6a9e04 as ::core::ffi::c_uint, - 0x7bda6bd as ::core::ffi::c_int as uint32_t, - 0xbf01c1d8 as ::core::ffi::c_uint, - 0xadb46e36 as ::core::ffi::c_uint, - 0x15080953 as ::core::ffi::c_int as uint32_t, - 0x1d724e9a as ::core::ffi::c_int as uint32_t, - 0xa5ce29ff as ::core::ffi::c_uint, - 0xb77b8611 as ::core::ffi::c_uint, - 0xfc7e174 as ::core::ffi::c_int as uint32_t, - 0x9210d9cd as ::core::ffi::c_uint, - 0x2aacbea8 as ::core::ffi::c_int as uint32_t, - 0x38191146 as ::core::ffi::c_int as uint32_t, - 0x80a57623 as ::core::ffi::c_uint, - 0xd8c66675 as ::core::ffi::c_uint, - 0x607a0110 as ::core::ffi::c_int as uint32_t, - 0x72cfaefe as ::core::ffi::c_int as uint32_t, - 0xca73c99b as ::core::ffi::c_uint, - 0x57a4f122 as ::core::ffi::c_int as uint32_t, - 0xef189647 as ::core::ffi::c_uint, - 0xfdad39a9 as ::core::ffi::c_uint, - 0x45115ecc as ::core::ffi::c_int as uint32_t, - 0x764dee06 as ::core::ffi::c_int as uint32_t, - 0xcef18963 as ::core::ffi::c_uint, - 0xdc44268d as ::core::ffi::c_uint, - 0x64f841e8 as ::core::ffi::c_int as uint32_t, - 0xf92f7951 as ::core::ffi::c_uint, - 0x41931e34 as ::core::ffi::c_int as uint32_t, - 0x5326b1da as ::core::ffi::c_int as uint32_t, - 0xeb9ad6bf as ::core::ffi::c_uint, - 0xb3f9c6e9 as ::core::ffi::c_uint, - 0xb45a18c as ::core::ffi::c_int as uint32_t, - 0x19f00e62 as ::core::ffi::c_int as uint32_t, - 0xa14c6907 as ::core::ffi::c_uint, - 0x3c9b51be as ::core::ffi::c_int as uint32_t, - 0x842736db as ::core::ffi::c_uint, - 0x96929935 as ::core::ffi::c_uint, - 0x2e2efe50 as ::core::ffi::c_int as uint32_t, - 0x2654b999 as ::core::ffi::c_int as uint32_t, - 0x9ee8defc as ::core::ffi::c_uint, - 0x8c5d7112 as ::core::ffi::c_uint, - 0x34e11677 as ::core::ffi::c_int as uint32_t, - 0xa9362ece as ::core::ffi::c_uint, - 0x118a49ab as ::core::ffi::c_int as uint32_t, - 0x33fe645 as ::core::ffi::c_int as uint32_t, - 0xbb838120 as ::core::ffi::c_uint, - 0xe3e09176 as ::core::ffi::c_uint, - 0x5b5cf613 as ::core::ffi::c_int as uint32_t, - 0x49e959fd as ::core::ffi::c_int as uint32_t, - 0xf1553e98 as ::core::ffi::c_uint, - 0x6c820621 as ::core::ffi::c_int as uint32_t, - 0xd43e6144 as ::core::ffi::c_uint, - 0xc68bceaa as ::core::ffi::c_uint, - 0x7e37a9cf as ::core::ffi::c_int as uint32_t, - 0xd67f4138 as ::core::ffi::c_uint, - 0x6ec3265d as ::core::ffi::c_int as uint32_t, - 0x7c7689b3 as ::core::ffi::c_int as uint32_t, - 0xc4caeed6 as ::core::ffi::c_uint, - 0x591dd66f as ::core::ffi::c_int as uint32_t, - 0xe1a1b10a as ::core::ffi::c_uint, - 0xf3141ee4 as ::core::ffi::c_uint, - 0x4ba87981 as ::core::ffi::c_int as uint32_t, - 0x13cb69d7 as ::core::ffi::c_int as uint32_t, - 0xab770eb2 as ::core::ffi::c_uint, - 0xb9c2a15c as ::core::ffi::c_uint, - 0x17ec639 as ::core::ffi::c_int as uint32_t, - 0x9ca9fe80 as ::core::ffi::c_uint, - 0x241599e5 as ::core::ffi::c_int as uint32_t, - 0x36a0360b as ::core::ffi::c_int as uint32_t, - 0x8e1c516e as ::core::ffi::c_uint, - 0x866616a7 as ::core::ffi::c_uint, - 0x3eda71c2 as ::core::ffi::c_int as uint32_t, - 0x2c6fde2c as ::core::ffi::c_int as uint32_t, - 0x94d3b949 as ::core::ffi::c_uint, - 0x90481f0 as ::core::ffi::c_int as uint32_t, - 0xb1b8e695 as ::core::ffi::c_uint, - 0xa30d497b as ::core::ffi::c_uint, - 0x1bb12e1e as ::core::ffi::c_int as uint32_t, - 0x43d23e48 as ::core::ffi::c_int as uint32_t, - 0xfb6e592d as ::core::ffi::c_uint, - 0xe9dbf6c3 as ::core::ffi::c_uint, - 0x516791a6 as ::core::ffi::c_int as uint32_t, - 0xccb0a91f as ::core::ffi::c_uint, - 0x740cce7a as ::core::ffi::c_int as uint32_t, - 0x66b96194 as ::core::ffi::c_int as uint32_t, - 0xde0506f1 as ::core::ffi::c_uint, + 0, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9, + 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, + 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, 0xdf7bc0c8, 0x67c7a7ad, + 0x75720843, 0xcdce6f26, 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, + 0xa2738f42, 0xb0c620ac, 0x87a47c9, 0xa032af3e, 0x188ec85b, 0xa3b67b5, 0xb28700d0, + 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, + 0x7733283f, 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, + 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018, 0x359fd04e, + 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, 0xbafd4719, 0x241207c, 0x10f48f92, 0xa848e8f7, + 0x9b14583d, 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, 0xbe7f07e1, + 0x6c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, 0x4c15df3c, 0xd1c2e785, 0x697e80e0, + 0x7bcb2f0e, 0xc377486b, 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, + 0xfcd3ff90, 0xee66507e, 0x56da371b, 0xeb9274d, 0xb6054028, 0xa4b0efc6, 0x1c0c88a3, + 0x81dbb01a, 0x3967d77f, 0x2bd27891, 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, + 0x299358ed, 0xb4446054, 0xcf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, 0x462eb889, + 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, 0xdbf98030, 0x6345e755, 0x6b3fa09c, + 0xd383c7f9, 0xc1366817, 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, + 0xae8b8873, 0x1637ef16, 0x48240f8, 0xbc3e279d, 0x21e91f24, 0x99557841, 0x8be0d7af, + 0x335cb0ca, 0xed59b63b, 0x55e5d15e, 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, + 0xc832e9e7, 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, 0xa78f0983, + 0x1f336ee6, 0xd86c108, 0xb53aa66d, 0xbd40e1a4, 0x5fc86c1, 0x1749292f, 0xaff54e4a, + 0x322276f3, 0x8a9e1196, 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, + 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, 0x4d6b1905, 0xf5d77e60, + 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, + 0x3063568f, 0x22d6f961, 0x9a6a9e04, 0x7bda6bd, 0xbf01c1d8, 0xadb46e36, 0x15080953, + 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0xfc7e174, 0x9210d9cd, 0x2aacbea8, 0x38191146, + 0x80a57623, 0xd8c66675, 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, + 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8, 0xf92f7951, + 0x41931e34, 0x5326b1da, 0xeb9ad6bf, 0xb3f9c6e9, 0xb45a18c, 0x19f00e62, 0xa14c6907, + 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, 0x8c5d7112, + 0x34e11677, 0xa9362ece, 0x118a49ab, 0x33fe645, 0xbb838120, 0xe3e09176, 0x5b5cf613, + 0x49e959fd, 0xf1553e98, 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, + 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981, + 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x17ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, + 0x8e1c516e, 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x90481f0, 0xb1b8e695, + 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, + 0x740cce7a, 0x66b96194, 0xde0506f1, ], [ - 0 as ::core::ffi::c_int as uint32_t, - 0x3d6029b0 as ::core::ffi::c_int as uint32_t, - 0x7ac05360 as ::core::ffi::c_int as uint32_t, - 0x47a07ad0 as ::core::ffi::c_int as uint32_t, - 0xf580a6c0 as ::core::ffi::c_uint, - 0xc8e08f70 as ::core::ffi::c_uint, - 0x8f40f5a0 as ::core::ffi::c_uint, - 0xb220dc10 as ::core::ffi::c_uint, - 0x30704bc1 as ::core::ffi::c_int as uint32_t, - 0xd106271 as ::core::ffi::c_int as uint32_t, - 0x4ab018a1 as ::core::ffi::c_int as uint32_t, - 0x77d03111 as ::core::ffi::c_int as uint32_t, - 0xc5f0ed01 as ::core::ffi::c_uint, - 0xf890c4b1 as ::core::ffi::c_uint, - 0xbf30be61 as ::core::ffi::c_uint, - 0x825097d1 as ::core::ffi::c_uint, - 0x60e09782 as ::core::ffi::c_int as uint32_t, - 0x5d80be32 as ::core::ffi::c_int as uint32_t, - 0x1a20c4e2 as ::core::ffi::c_int as uint32_t, - 0x2740ed52 as ::core::ffi::c_int as uint32_t, - 0x95603142 as ::core::ffi::c_uint, - 0xa80018f2 as ::core::ffi::c_uint, - 0xefa06222 as ::core::ffi::c_uint, - 0xd2c04b92 as ::core::ffi::c_uint, - 0x5090dc43 as ::core::ffi::c_int as uint32_t, - 0x6df0f5f3 as ::core::ffi::c_int as uint32_t, - 0x2a508f23 as ::core::ffi::c_int as uint32_t, - 0x1730a693 as ::core::ffi::c_int as uint32_t, - 0xa5107a83 as ::core::ffi::c_uint, - 0x98705333 as ::core::ffi::c_uint, - 0xdfd029e3 as ::core::ffi::c_uint, - 0xe2b00053 as ::core::ffi::c_uint, - 0xc1c12f04 as ::core::ffi::c_uint, - 0xfca106b4 as ::core::ffi::c_uint, - 0xbb017c64 as ::core::ffi::c_uint, - 0x866155d4 as ::core::ffi::c_uint, - 0x344189c4 as ::core::ffi::c_int as uint32_t, - 0x921a074 as ::core::ffi::c_int as uint32_t, - 0x4e81daa4 as ::core::ffi::c_int as uint32_t, - 0x73e1f314 as ::core::ffi::c_int as uint32_t, - 0xf1b164c5 as ::core::ffi::c_uint, - 0xccd14d75 as ::core::ffi::c_uint, - 0x8b7137a5 as ::core::ffi::c_uint, - 0xb6111e15 as ::core::ffi::c_uint, - 0x431c205 as ::core::ffi::c_int as uint32_t, - 0x3951ebb5 as ::core::ffi::c_int as uint32_t, - 0x7ef19165 as ::core::ffi::c_int as uint32_t, - 0x4391b8d5 as ::core::ffi::c_int as uint32_t, - 0xa121b886 as ::core::ffi::c_uint, - 0x9c419136 as ::core::ffi::c_uint, - 0xdbe1ebe6 as ::core::ffi::c_uint, - 0xe681c256 as ::core::ffi::c_uint, - 0x54a11e46 as ::core::ffi::c_int as uint32_t, - 0x69c137f6 as ::core::ffi::c_int as uint32_t, - 0x2e614d26 as ::core::ffi::c_int as uint32_t, - 0x13016496 as ::core::ffi::c_int as uint32_t, - 0x9151f347 as ::core::ffi::c_uint, - 0xac31daf7 as ::core::ffi::c_uint, - 0xeb91a027 as ::core::ffi::c_uint, - 0xd6f18997 as ::core::ffi::c_uint, - 0x64d15587 as ::core::ffi::c_int as uint32_t, - 0x59b17c37 as ::core::ffi::c_int as uint32_t, - 0x1e1106e7 as ::core::ffi::c_int as uint32_t, - 0x23712f57 as ::core::ffi::c_int as uint32_t, - 0x58f35849 as ::core::ffi::c_int as uint32_t, - 0x659371f9 as ::core::ffi::c_int as uint32_t, - 0x22330b29 as ::core::ffi::c_int as uint32_t, - 0x1f532299 as ::core::ffi::c_int as uint32_t, - 0xad73fe89 as ::core::ffi::c_uint, - 0x9013d739 as ::core::ffi::c_uint, - 0xd7b3ade9 as ::core::ffi::c_uint, - 0xead38459 as ::core::ffi::c_uint, - 0x68831388 as ::core::ffi::c_int as uint32_t, - 0x55e33a38 as ::core::ffi::c_int as uint32_t, - 0x124340e8 as ::core::ffi::c_int as uint32_t, - 0x2f236958 as ::core::ffi::c_int as uint32_t, - 0x9d03b548 as ::core::ffi::c_uint, - 0xa0639cf8 as ::core::ffi::c_uint, - 0xe7c3e628 as ::core::ffi::c_uint, - 0xdaa3cf98 as ::core::ffi::c_uint, - 0x3813cfcb as ::core::ffi::c_int as uint32_t, - 0x573e67b as ::core::ffi::c_int as uint32_t, - 0x42d39cab as ::core::ffi::c_int as uint32_t, - 0x7fb3b51b as ::core::ffi::c_int as uint32_t, - 0xcd93690b as ::core::ffi::c_uint, - 0xf0f340bb as ::core::ffi::c_uint, - 0xb7533a6b as ::core::ffi::c_uint, - 0x8a3313db as ::core::ffi::c_uint, - 0x863840a as ::core::ffi::c_int as uint32_t, - 0x3503adba as ::core::ffi::c_int as uint32_t, - 0x72a3d76a as ::core::ffi::c_int as uint32_t, - 0x4fc3feda as ::core::ffi::c_int as uint32_t, - 0xfde322ca as ::core::ffi::c_uint, - 0xc0830b7a as ::core::ffi::c_uint, - 0x872371aa as ::core::ffi::c_uint, - 0xba43581a as ::core::ffi::c_uint, - 0x9932774d as ::core::ffi::c_uint, - 0xa4525efd as ::core::ffi::c_uint, - 0xe3f2242d as ::core::ffi::c_uint, - 0xde920d9d as ::core::ffi::c_uint, - 0x6cb2d18d as ::core::ffi::c_int as uint32_t, - 0x51d2f83d as ::core::ffi::c_int as uint32_t, - 0x167282ed as ::core::ffi::c_int as uint32_t, - 0x2b12ab5d as ::core::ffi::c_int as uint32_t, - 0xa9423c8c as ::core::ffi::c_uint, - 0x9422153c as ::core::ffi::c_uint, - 0xd3826fec as ::core::ffi::c_uint, - 0xeee2465c as ::core::ffi::c_uint, - 0x5cc29a4c as ::core::ffi::c_int as uint32_t, - 0x61a2b3fc as ::core::ffi::c_int as uint32_t, - 0x2602c92c as ::core::ffi::c_int as uint32_t, - 0x1b62e09c as ::core::ffi::c_int as uint32_t, - 0xf9d2e0cf as ::core::ffi::c_uint, - 0xc4b2c97f as ::core::ffi::c_uint, - 0x8312b3af as ::core::ffi::c_uint, - 0xbe729a1f as ::core::ffi::c_uint, - 0xc52460f as ::core::ffi::c_int as uint32_t, - 0x31326fbf as ::core::ffi::c_int as uint32_t, - 0x7692156f as ::core::ffi::c_int as uint32_t, - 0x4bf23cdf as ::core::ffi::c_int as uint32_t, - 0xc9a2ab0e as ::core::ffi::c_uint, - 0xf4c282be as ::core::ffi::c_uint, - 0xb362f86e as ::core::ffi::c_uint, - 0x8e02d1de as ::core::ffi::c_uint, - 0x3c220dce as ::core::ffi::c_int as uint32_t, - 0x142247e as ::core::ffi::c_int as uint32_t, - 0x46e25eae as ::core::ffi::c_int as uint32_t, - 0x7b82771e as ::core::ffi::c_int as uint32_t, - 0xb1e6b092 as ::core::ffi::c_uint, - 0x8c869922 as ::core::ffi::c_uint, - 0xcb26e3f2 as ::core::ffi::c_uint, - 0xf646ca42 as ::core::ffi::c_uint, - 0x44661652 as ::core::ffi::c_int as uint32_t, - 0x79063fe2 as ::core::ffi::c_int as uint32_t, - 0x3ea64532 as ::core::ffi::c_int as uint32_t, - 0x3c66c82 as ::core::ffi::c_int as uint32_t, - 0x8196fb53 as ::core::ffi::c_uint, - 0xbcf6d2e3 as ::core::ffi::c_uint, - 0xfb56a833 as ::core::ffi::c_uint, - 0xc6368183 as ::core::ffi::c_uint, - 0x74165d93 as ::core::ffi::c_int as uint32_t, - 0x49767423 as ::core::ffi::c_int as uint32_t, - 0xed60ef3 as ::core::ffi::c_int as uint32_t, - 0x33b62743 as ::core::ffi::c_int as uint32_t, - 0xd1062710 as ::core::ffi::c_uint, - 0xec660ea0 as ::core::ffi::c_uint, - 0xabc67470 as ::core::ffi::c_uint, - 0x96a65dc0 as ::core::ffi::c_uint, - 0x248681d0 as ::core::ffi::c_int as uint32_t, - 0x19e6a860 as ::core::ffi::c_int as uint32_t, - 0x5e46d2b0 as ::core::ffi::c_int as uint32_t, - 0x6326fb00 as ::core::ffi::c_int as uint32_t, - 0xe1766cd1 as ::core::ffi::c_uint, - 0xdc164561 as ::core::ffi::c_uint, - 0x9bb63fb1 as ::core::ffi::c_uint, - 0xa6d61601 as ::core::ffi::c_uint, - 0x14f6ca11 as ::core::ffi::c_int as uint32_t, - 0x2996e3a1 as ::core::ffi::c_int as uint32_t, - 0x6e369971 as ::core::ffi::c_int as uint32_t, - 0x5356b0c1 as ::core::ffi::c_int as uint32_t, - 0x70279f96 as ::core::ffi::c_int as uint32_t, - 0x4d47b626 as ::core::ffi::c_int as uint32_t, - 0xae7ccf6 as ::core::ffi::c_int as uint32_t, - 0x3787e546 as ::core::ffi::c_int as uint32_t, - 0x85a73956 as ::core::ffi::c_uint, - 0xb8c710e6 as ::core::ffi::c_uint, - 0xff676a36 as ::core::ffi::c_uint, - 0xc2074386 as ::core::ffi::c_uint, - 0x4057d457 as ::core::ffi::c_int as uint32_t, - 0x7d37fde7 as ::core::ffi::c_int as uint32_t, - 0x3a978737 as ::core::ffi::c_int as uint32_t, - 0x7f7ae87 as ::core::ffi::c_int as uint32_t, - 0xb5d77297 as ::core::ffi::c_uint, - 0x88b75b27 as ::core::ffi::c_uint, - 0xcf1721f7 as ::core::ffi::c_uint, - 0xf2770847 as ::core::ffi::c_uint, - 0x10c70814 as ::core::ffi::c_int as uint32_t, - 0x2da721a4 as ::core::ffi::c_int as uint32_t, - 0x6a075b74 as ::core::ffi::c_int as uint32_t, - 0x576772c4 as ::core::ffi::c_int as uint32_t, - 0xe547aed4 as ::core::ffi::c_uint, - 0xd8278764 as ::core::ffi::c_uint, - 0x9f87fdb4 as ::core::ffi::c_uint, - 0xa2e7d404 as ::core::ffi::c_uint, - 0x20b743d5 as ::core::ffi::c_int as uint32_t, - 0x1dd76a65 as ::core::ffi::c_int as uint32_t, - 0x5a7710b5 as ::core::ffi::c_int as uint32_t, - 0x67173905 as ::core::ffi::c_int as uint32_t, - 0xd537e515 as ::core::ffi::c_uint, - 0xe857cca5 as ::core::ffi::c_uint, - 0xaff7b675 as ::core::ffi::c_uint, - 0x92979fc5 as ::core::ffi::c_uint, - 0xe915e8db as ::core::ffi::c_uint, - 0xd475c16b as ::core::ffi::c_uint, - 0x93d5bbbb as ::core::ffi::c_uint, - 0xaeb5920b as ::core::ffi::c_uint, - 0x1c954e1b as ::core::ffi::c_int as uint32_t, - 0x21f567ab as ::core::ffi::c_int as uint32_t, - 0x66551d7b as ::core::ffi::c_int as uint32_t, - 0x5b3534cb as ::core::ffi::c_int as uint32_t, - 0xd965a31a as ::core::ffi::c_uint, - 0xe4058aaa as ::core::ffi::c_uint, - 0xa3a5f07a as ::core::ffi::c_uint, - 0x9ec5d9ca as ::core::ffi::c_uint, - 0x2ce505da as ::core::ffi::c_int as uint32_t, - 0x11852c6a as ::core::ffi::c_int as uint32_t, - 0x562556ba as ::core::ffi::c_int as uint32_t, - 0x6b457f0a as ::core::ffi::c_int as uint32_t, - 0x89f57f59 as ::core::ffi::c_uint, - 0xb49556e9 as ::core::ffi::c_uint, - 0xf3352c39 as ::core::ffi::c_uint, - 0xce550589 as ::core::ffi::c_uint, - 0x7c75d999 as ::core::ffi::c_int as uint32_t, - 0x4115f029 as ::core::ffi::c_int as uint32_t, - 0x6b58af9 as ::core::ffi::c_int as uint32_t, - 0x3bd5a349 as ::core::ffi::c_int as uint32_t, - 0xb9853498 as ::core::ffi::c_uint, - 0x84e51d28 as ::core::ffi::c_uint, - 0xc34567f8 as ::core::ffi::c_uint, - 0xfe254e48 as ::core::ffi::c_uint, - 0x4c059258 as ::core::ffi::c_int as uint32_t, - 0x7165bbe8 as ::core::ffi::c_int as uint32_t, - 0x36c5c138 as ::core::ffi::c_int as uint32_t, - 0xba5e888 as ::core::ffi::c_int as uint32_t, - 0x28d4c7df as ::core::ffi::c_int as uint32_t, - 0x15b4ee6f as ::core::ffi::c_int as uint32_t, - 0x521494bf as ::core::ffi::c_int as uint32_t, - 0x6f74bd0f as ::core::ffi::c_int as uint32_t, - 0xdd54611f as ::core::ffi::c_uint, - 0xe03448af as ::core::ffi::c_uint, - 0xa794327f as ::core::ffi::c_uint, - 0x9af41bcf as ::core::ffi::c_uint, - 0x18a48c1e as ::core::ffi::c_int as uint32_t, - 0x25c4a5ae as ::core::ffi::c_int as uint32_t, - 0x6264df7e as ::core::ffi::c_int as uint32_t, - 0x5f04f6ce as ::core::ffi::c_int as uint32_t, - 0xed242ade as ::core::ffi::c_uint, - 0xd044036e as ::core::ffi::c_uint, - 0x97e479be as ::core::ffi::c_uint, - 0xaa84500e as ::core::ffi::c_uint, - 0x4834505d as ::core::ffi::c_int as uint32_t, - 0x755479ed as ::core::ffi::c_int as uint32_t, - 0x32f4033d as ::core::ffi::c_int as uint32_t, - 0xf942a8d as ::core::ffi::c_int as uint32_t, - 0xbdb4f69d as ::core::ffi::c_uint, - 0x80d4df2d as ::core::ffi::c_uint, - 0xc774a5fd as ::core::ffi::c_uint, - 0xfa148c4d as ::core::ffi::c_uint, - 0x78441b9c as ::core::ffi::c_int as uint32_t, - 0x4524322c as ::core::ffi::c_int as uint32_t, - 0x28448fc as ::core::ffi::c_int as uint32_t, - 0x3fe4614c as ::core::ffi::c_int as uint32_t, - 0x8dc4bd5c as ::core::ffi::c_uint, - 0xb0a494ec as ::core::ffi::c_uint, - 0xf704ee3c as ::core::ffi::c_uint, - 0xca64c78c as ::core::ffi::c_uint, + 0, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, + 0x30704bc1, 0xd106271, 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, + 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, 0x95603142, 0xa80018f2, + 0xefa06222, 0xd2c04b92, 0x5090dc43, 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, + 0x98705333, 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, 0x866155d4, + 0x344189c4, 0x921a074, 0x4e81daa4, 0x73e1f314, 0xf1b164c5, 0xccd14d75, 0x8b7137a5, + 0xb6111e15, 0x431c205, 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, + 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, 0x13016496, 0x9151f347, + 0xac31daf7, 0xeb91a027, 0xd6f18997, 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, + 0x58f35849, 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, 0xd7b3ade9, + 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, 0x2f236958, 0x9d03b548, 0xa0639cf8, + 0xe7c3e628, 0xdaa3cf98, 0x3813cfcb, 0x573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, + 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x863840a, 0x3503adba, 0x72a3d76a, 0x4fc3feda, + 0xfde322ca, 0xc0830b7a, 0x872371aa, 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, + 0xde920d9d, 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, 0x9422153c, + 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, + 0xc4b2c97f, 0x8312b3af, 0xbe729a1f, 0xc52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, + 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, 0x142247e, 0x46e25eae, + 0x7b82771e, 0xb1e6b092, 0x8c869922, 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, + 0x3ea64532, 0x3c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, 0x74165d93, + 0x49767423, 0xed60ef3, 0x33b62743, 0xd1062710, 0xec660ea0, 0xabc67470, 0x96a65dc0, + 0x248681d0, 0x19e6a860, 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, + 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, 0x70279f96, 0x4d47b626, + 0xae7ccf6, 0x3787e546, 0x85a73956, 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, + 0x7d37fde7, 0x3a978737, 0x7f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, 0xf2770847, + 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, 0xe547aed4, 0xd8278764, 0x9f87fdb4, + 0xa2e7d404, 0x20b743d5, 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, + 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, 0xaeb5920b, 0x1c954e1b, + 0x21f567ab, 0x66551d7b, 0x5b3534cb, 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, + 0x2ce505da, 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, 0xf3352c39, + 0xce550589, 0x7c75d999, 0x4115f029, 0x6b58af9, 0x3bd5a349, 0xb9853498, 0x84e51d28, + 0xc34567f8, 0xfe254e48, 0x4c059258, 0x7165bbe8, 0x36c5c138, 0xba5e888, 0x28d4c7df, + 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, 0xa794327f, 0x9af41bcf, + 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, + 0xaa84500e, 0x4834505d, 0x755479ed, 0x32f4033d, 0xf942a8d, 0xbdb4f69d, 0x80d4df2d, + 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, 0x28448fc, 0x3fe4614c, 0x8dc4bd5c, + 0xb0a494ec, 0xf704ee3c, 0xca64c78c, ], [ - 0 as ::core::ffi::c_int as uint32_t, - 0xcb5cd3a5 as ::core::ffi::c_uint, - 0x4dc8a10b as ::core::ffi::c_int as uint32_t, - 0x869472ae as ::core::ffi::c_uint, - 0x9b914216 as ::core::ffi::c_uint, - 0x50cd91b3 as ::core::ffi::c_int as uint32_t, - 0xd659e31d as ::core::ffi::c_uint, - 0x1d0530b8 as ::core::ffi::c_int as uint32_t, - 0xec53826d as ::core::ffi::c_uint, - 0x270f51c8 as ::core::ffi::c_int as uint32_t, - 0xa19b2366 as ::core::ffi::c_uint, - 0x6ac7f0c3 as ::core::ffi::c_int as uint32_t, - 0x77c2c07b as ::core::ffi::c_int as uint32_t, - 0xbc9e13de as ::core::ffi::c_uint, - 0x3a0a6170 as ::core::ffi::c_int as uint32_t, - 0xf156b2d5 as ::core::ffi::c_uint, - 0x3d6029b as ::core::ffi::c_int as uint32_t, - 0xc88ad13e as ::core::ffi::c_uint, - 0x4e1ea390 as ::core::ffi::c_int as uint32_t, - 0x85427035 as ::core::ffi::c_uint, - 0x9847408d as ::core::ffi::c_uint, - 0x531b9328 as ::core::ffi::c_int as uint32_t, - 0xd58fe186 as ::core::ffi::c_uint, - 0x1ed33223 as ::core::ffi::c_int as uint32_t, - 0xef8580f6 as ::core::ffi::c_uint, - 0x24d95353 as ::core::ffi::c_int as uint32_t, - 0xa24d21fd as ::core::ffi::c_uint, - 0x6911f258 as ::core::ffi::c_int as uint32_t, - 0x7414c2e0 as ::core::ffi::c_int as uint32_t, - 0xbf481145 as ::core::ffi::c_uint, - 0x39dc63eb as ::core::ffi::c_int as uint32_t, - 0xf280b04e as ::core::ffi::c_uint, - 0x7ac0536 as ::core::ffi::c_int as uint32_t, - 0xccf0d693 as ::core::ffi::c_uint, - 0x4a64a43d as ::core::ffi::c_int as uint32_t, - 0x81387798 as ::core::ffi::c_uint, - 0x9c3d4720 as ::core::ffi::c_uint, - 0x57619485 as ::core::ffi::c_int as uint32_t, - 0xd1f5e62b as ::core::ffi::c_uint, - 0x1aa9358e as ::core::ffi::c_int as uint32_t, - 0xebff875b as ::core::ffi::c_uint, - 0x20a354fe as ::core::ffi::c_int as uint32_t, - 0xa6372650 as ::core::ffi::c_uint, - 0x6d6bf5f5 as ::core::ffi::c_int as uint32_t, - 0x706ec54d as ::core::ffi::c_int as uint32_t, - 0xbb3216e8 as ::core::ffi::c_uint, - 0x3da66446 as ::core::ffi::c_int as uint32_t, - 0xf6fab7e3 as ::core::ffi::c_uint, - 0x47a07ad as ::core::ffi::c_int as uint32_t, - 0xcf26d408 as ::core::ffi::c_uint, - 0x49b2a6a6 as ::core::ffi::c_int as uint32_t, - 0x82ee7503 as ::core::ffi::c_uint, - 0x9feb45bb as ::core::ffi::c_uint, - 0x54b7961e as ::core::ffi::c_int as uint32_t, - 0xd223e4b0 as ::core::ffi::c_uint, - 0x197f3715 as ::core::ffi::c_int as uint32_t, - 0xe82985c0 as ::core::ffi::c_uint, - 0x23755665 as ::core::ffi::c_int as uint32_t, - 0xa5e124cb as ::core::ffi::c_uint, - 0x6ebdf76e as ::core::ffi::c_int as uint32_t, - 0x73b8c7d6 as ::core::ffi::c_int as uint32_t, - 0xb8e41473 as ::core::ffi::c_uint, - 0x3e7066dd as ::core::ffi::c_int as uint32_t, - 0xf52cb578 as ::core::ffi::c_uint, - 0xf580a6c as ::core::ffi::c_int as uint32_t, - 0xc404d9c9 as ::core::ffi::c_uint, - 0x4290ab67 as ::core::ffi::c_int as uint32_t, - 0x89cc78c2 as ::core::ffi::c_uint, - 0x94c9487a as ::core::ffi::c_uint, - 0x5f959bdf as ::core::ffi::c_int as uint32_t, - 0xd901e971 as ::core::ffi::c_uint, - 0x125d3ad4 as ::core::ffi::c_int as uint32_t, - 0xe30b8801 as ::core::ffi::c_uint, - 0x28575ba4 as ::core::ffi::c_int as uint32_t, - 0xaec3290a as ::core::ffi::c_uint, - 0x659ffaaf as ::core::ffi::c_int as uint32_t, - 0x789aca17 as ::core::ffi::c_int as uint32_t, - 0xb3c619b2 as ::core::ffi::c_uint, - 0x35526b1c as ::core::ffi::c_int as uint32_t, - 0xfe0eb8b9 as ::core::ffi::c_uint, - 0xc8e08f7 as ::core::ffi::c_int as uint32_t, - 0xc7d2db52 as ::core::ffi::c_uint, - 0x4146a9fc as ::core::ffi::c_int as uint32_t, - 0x8a1a7a59 as ::core::ffi::c_uint, - 0x971f4ae1 as ::core::ffi::c_uint, - 0x5c439944 as ::core::ffi::c_int as uint32_t, - 0xdad7ebea as ::core::ffi::c_uint, - 0x118b384f as ::core::ffi::c_int as uint32_t, - 0xe0dd8a9a as ::core::ffi::c_uint, - 0x2b81593f as ::core::ffi::c_int as uint32_t, - 0xad152b91 as ::core::ffi::c_uint, - 0x6649f834 as ::core::ffi::c_int as uint32_t, - 0x7b4cc88c as ::core::ffi::c_int as uint32_t, - 0xb0101b29 as ::core::ffi::c_uint, - 0x36846987 as ::core::ffi::c_int as uint32_t, - 0xfdd8ba22 as ::core::ffi::c_uint, - 0x8f40f5a as ::core::ffi::c_int as uint32_t, - 0xc3a8dcff as ::core::ffi::c_uint, - 0x453cae51 as ::core::ffi::c_int as uint32_t, - 0x8e607df4 as ::core::ffi::c_uint, - 0x93654d4c as ::core::ffi::c_uint, - 0x58399ee9 as ::core::ffi::c_int as uint32_t, - 0xdeadec47 as ::core::ffi::c_uint, - 0x15f13fe2 as ::core::ffi::c_int as uint32_t, - 0xe4a78d37 as ::core::ffi::c_uint, - 0x2ffb5e92 as ::core::ffi::c_int as uint32_t, - 0xa96f2c3c as ::core::ffi::c_uint, - 0x6233ff99 as ::core::ffi::c_int as uint32_t, - 0x7f36cf21 as ::core::ffi::c_int as uint32_t, - 0xb46a1c84 as ::core::ffi::c_uint, - 0x32fe6e2a as ::core::ffi::c_int as uint32_t, - 0xf9a2bd8f as ::core::ffi::c_uint, - 0xb220dc1 as ::core::ffi::c_int as uint32_t, - 0xc07ede64 as ::core::ffi::c_uint, - 0x46eaacca as ::core::ffi::c_int as uint32_t, - 0x8db67f6f as ::core::ffi::c_uint, - 0x90b34fd7 as ::core::ffi::c_uint, - 0x5bef9c72 as ::core::ffi::c_int as uint32_t, - 0xdd7beedc as ::core::ffi::c_uint, - 0x16273d79 as ::core::ffi::c_int as uint32_t, - 0xe7718fac as ::core::ffi::c_uint, - 0x2c2d5c09 as ::core::ffi::c_int as uint32_t, - 0xaab92ea7 as ::core::ffi::c_uint, - 0x61e5fd02 as ::core::ffi::c_int as uint32_t, - 0x7ce0cdba as ::core::ffi::c_int as uint32_t, - 0xb7bc1e1f as ::core::ffi::c_uint, - 0x31286cb1 as ::core::ffi::c_int as uint32_t, - 0xfa74bf14 as ::core::ffi::c_uint, - 0x1eb014d8 as ::core::ffi::c_int as uint32_t, - 0xd5ecc77d as ::core::ffi::c_uint, - 0x5378b5d3 as ::core::ffi::c_int as uint32_t, - 0x98246676 as ::core::ffi::c_uint, - 0x852156ce as ::core::ffi::c_uint, - 0x4e7d856b as ::core::ffi::c_int as uint32_t, - 0xc8e9f7c5 as ::core::ffi::c_uint, - 0x3b52460 as ::core::ffi::c_int as uint32_t, - 0xf2e396b5 as ::core::ffi::c_uint, - 0x39bf4510 as ::core::ffi::c_int as uint32_t, - 0xbf2b37be as ::core::ffi::c_uint, - 0x7477e41b as ::core::ffi::c_int as uint32_t, - 0x6972d4a3 as ::core::ffi::c_int as uint32_t, - 0xa22e0706 as ::core::ffi::c_uint, - 0x24ba75a8 as ::core::ffi::c_int as uint32_t, - 0xefe6a60d as ::core::ffi::c_uint, - 0x1d661643 as ::core::ffi::c_int as uint32_t, - 0xd63ac5e6 as ::core::ffi::c_uint, - 0x50aeb748 as ::core::ffi::c_int as uint32_t, - 0x9bf264ed as ::core::ffi::c_uint, - 0x86f75455 as ::core::ffi::c_uint, - 0x4dab87f0 as ::core::ffi::c_int as uint32_t, - 0xcb3ff55e as ::core::ffi::c_uint, - 0x6326fb as ::core::ffi::c_int as uint32_t, - 0xf135942e as ::core::ffi::c_uint, - 0x3a69478b as ::core::ffi::c_int as uint32_t, - 0xbcfd3525 as ::core::ffi::c_uint, - 0x77a1e680 as ::core::ffi::c_int as uint32_t, - 0x6aa4d638 as ::core::ffi::c_int as uint32_t, - 0xa1f8059d as ::core::ffi::c_uint, - 0x276c7733 as ::core::ffi::c_int as uint32_t, - 0xec30a496 as ::core::ffi::c_uint, - 0x191c11ee as ::core::ffi::c_int as uint32_t, - 0xd240c24b as ::core::ffi::c_uint, - 0x54d4b0e5 as ::core::ffi::c_int as uint32_t, - 0x9f886340 as ::core::ffi::c_uint, - 0x828d53f8 as ::core::ffi::c_uint, - 0x49d1805d as ::core::ffi::c_int as uint32_t, - 0xcf45f2f3 as ::core::ffi::c_uint, - 0x4192156 as ::core::ffi::c_int as uint32_t, - 0xf54f9383 as ::core::ffi::c_uint, - 0x3e134026 as ::core::ffi::c_int as uint32_t, - 0xb8873288 as ::core::ffi::c_uint, - 0x73dbe12d as ::core::ffi::c_int as uint32_t, - 0x6eded195 as ::core::ffi::c_int as uint32_t, - 0xa5820230 as ::core::ffi::c_uint, - 0x2316709e as ::core::ffi::c_int as uint32_t, - 0xe84aa33b as ::core::ffi::c_uint, - 0x1aca1375 as ::core::ffi::c_int as uint32_t, - 0xd196c0d0 as ::core::ffi::c_uint, - 0x5702b27e as ::core::ffi::c_int as uint32_t, - 0x9c5e61db as ::core::ffi::c_uint, - 0x815b5163 as ::core::ffi::c_uint, - 0x4a0782c6 as ::core::ffi::c_int as uint32_t, - 0xcc93f068 as ::core::ffi::c_uint, - 0x7cf23cd as ::core::ffi::c_int as uint32_t, - 0xf6999118 as ::core::ffi::c_uint, - 0x3dc542bd as ::core::ffi::c_int as uint32_t, - 0xbb513013 as ::core::ffi::c_uint, - 0x700de3b6 as ::core::ffi::c_int as uint32_t, - 0x6d08d30e as ::core::ffi::c_int as uint32_t, - 0xa65400ab as ::core::ffi::c_uint, - 0x20c07205 as ::core::ffi::c_int as uint32_t, - 0xeb9ca1a0 as ::core::ffi::c_uint, - 0x11e81eb4 as ::core::ffi::c_int as uint32_t, - 0xdab4cd11 as ::core::ffi::c_uint, - 0x5c20bfbf as ::core::ffi::c_int as uint32_t, - 0x977c6c1a as ::core::ffi::c_uint, - 0x8a795ca2 as ::core::ffi::c_uint, - 0x41258f07 as ::core::ffi::c_int as uint32_t, - 0xc7b1fda9 as ::core::ffi::c_uint, - 0xced2e0c as ::core::ffi::c_int as uint32_t, - 0xfdbb9cd9 as ::core::ffi::c_uint, - 0x36e74f7c as ::core::ffi::c_int as uint32_t, - 0xb0733dd2 as ::core::ffi::c_uint, - 0x7b2fee77 as ::core::ffi::c_int as uint32_t, - 0x662adecf as ::core::ffi::c_int as uint32_t, - 0xad760d6a as ::core::ffi::c_uint, - 0x2be27fc4 as ::core::ffi::c_int as uint32_t, - 0xe0beac61 as ::core::ffi::c_uint, - 0x123e1c2f as ::core::ffi::c_int as uint32_t, - 0xd962cf8a as ::core::ffi::c_uint, - 0x5ff6bd24 as ::core::ffi::c_int as uint32_t, - 0x94aa6e81 as ::core::ffi::c_uint, - 0x89af5e39 as ::core::ffi::c_uint, - 0x42f38d9c as ::core::ffi::c_int as uint32_t, - 0xc467ff32 as ::core::ffi::c_uint, - 0xf3b2c97 as ::core::ffi::c_int as uint32_t, - 0xfe6d9e42 as ::core::ffi::c_uint, - 0x35314de7 as ::core::ffi::c_int as uint32_t, - 0xb3a53f49 as ::core::ffi::c_uint, - 0x78f9ecec as ::core::ffi::c_int as uint32_t, - 0x65fcdc54 as ::core::ffi::c_int as uint32_t, - 0xaea00ff1 as ::core::ffi::c_uint, - 0x28347d5f as ::core::ffi::c_int as uint32_t, - 0xe368aefa as ::core::ffi::c_uint, - 0x16441b82 as ::core::ffi::c_int as uint32_t, - 0xdd18c827 as ::core::ffi::c_uint, - 0x5b8cba89 as ::core::ffi::c_int as uint32_t, - 0x90d0692c as ::core::ffi::c_uint, - 0x8dd55994 as ::core::ffi::c_uint, - 0x46898a31 as ::core::ffi::c_int as uint32_t, - 0xc01df89f as ::core::ffi::c_uint, - 0xb412b3a as ::core::ffi::c_int as uint32_t, - 0xfa1799ef as ::core::ffi::c_uint, - 0x314b4a4a as ::core::ffi::c_int as uint32_t, - 0xb7df38e4 as ::core::ffi::c_uint, - 0x7c83eb41 as ::core::ffi::c_int as uint32_t, - 0x6186dbf9 as ::core::ffi::c_int as uint32_t, - 0xaada085c as ::core::ffi::c_uint, - 0x2c4e7af2 as ::core::ffi::c_int as uint32_t, - 0xe712a957 as ::core::ffi::c_uint, - 0x15921919 as ::core::ffi::c_int as uint32_t, - 0xdececabc as ::core::ffi::c_uint, - 0x585ab812 as ::core::ffi::c_int as uint32_t, - 0x93066bb7 as ::core::ffi::c_uint, - 0x8e035b0f as ::core::ffi::c_uint, - 0x455f88aa as ::core::ffi::c_int as uint32_t, - 0xc3cbfa04 as ::core::ffi::c_uint, - 0x89729a1 as ::core::ffi::c_int as uint32_t, - 0xf9c19b74 as ::core::ffi::c_uint, - 0x329d48d1 as ::core::ffi::c_int as uint32_t, - 0xb4093a7f as ::core::ffi::c_uint, - 0x7f55e9da as ::core::ffi::c_int as uint32_t, - 0x6250d962 as ::core::ffi::c_int as uint32_t, - 0xa90c0ac7 as ::core::ffi::c_uint, - 0x2f987869 as ::core::ffi::c_int as uint32_t, - 0xe4c4abcc as ::core::ffi::c_uint, + 0, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, 0x50cd91b3, 0xd659e31d, 0x1d0530b8, + 0xec53826d, 0x270f51c8, 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, + 0xf156b2d5, 0x3d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, 0x9847408d, 0x531b9328, + 0xd58fe186, 0x1ed33223, 0xef8580f6, 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, + 0xbf481145, 0x39dc63eb, 0xf280b04e, 0x7ac0536, 0xccf0d693, 0x4a64a43d, 0x81387798, + 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, 0xebff875b, 0x20a354fe, 0xa6372650, + 0x6d6bf5f5, 0x706ec54d, 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x47a07ad, 0xcf26d408, + 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, 0x197f3715, 0xe82985c0, + 0x23755665, 0xa5e124cb, 0x6ebdf76e, 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, + 0xf580a6c, 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, 0xd901e971, + 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, 0x659ffaaf, 0x789aca17, 0xb3c619b2, + 0x35526b1c, 0xfe0eb8b9, 0xc8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, + 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, 0xad152b91, 0x6649f834, + 0x7b4cc88c, 0xb0101b29, 0x36846987, 0xfdd8ba22, 0x8f40f5a, 0xc3a8dcff, 0x453cae51, + 0x8e607df4, 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, 0x2ffb5e92, + 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, 0x32fe6e2a, 0xf9a2bd8f, 0xb220dc1, + 0xc07ede64, 0x46eaacca, 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, + 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, 0xb7bc1e1f, 0x31286cb1, + 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, + 0xc8e9f7c5, 0x3b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, 0x6972d4a3, + 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, + 0x86f75455, 0x4dab87f0, 0xcb3ff55e, 0x6326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, + 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, 0x191c11ee, 0xd240c24b, + 0x54d4b0e5, 0x9f886340, 0x828d53f8, 0x49d1805d, 0xcf45f2f3, 0x4192156, 0xf54f9383, + 0x3e134026, 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, 0xe84aa33b, + 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, 0x815b5163, 0x4a0782c6, 0xcc93f068, + 0x7cf23cd, 0xf6999118, 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, + 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, 0x977c6c1a, 0x8a795ca2, + 0x41258f07, 0xc7b1fda9, 0xced2e0c, 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, + 0x662adecf, 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, 0x5ff6bd24, + 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, 0xf3b2c97, 0xfe6d9e42, 0x35314de7, + 0xb3a53f49, 0x78f9ecec, 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, + 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, 0xc01df89f, 0xb412b3a, + 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, + 0xe712a957, 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, 0x455f88aa, + 0xc3cbfa04, 0x89729a1, 0xf9c19b74, 0x329d48d1, 0xb4093a7f, 0x7f55e9da, 0x6250d962, + 0xa90c0ac7, 0x2f987869, 0xe4c4abcc, ], [ - 0 as ::core::ffi::c_int as uint32_t, - 0xa6770bb4 as ::core::ffi::c_uint, - 0x979f1129 as ::core::ffi::c_uint, - 0x31e81a9d as ::core::ffi::c_int as uint32_t, - 0xf44f2413 as ::core::ffi::c_uint, - 0x52382fa7 as ::core::ffi::c_int as uint32_t, - 0x63d0353a as ::core::ffi::c_int as uint32_t, - 0xc5a73e8e as ::core::ffi::c_uint, - 0x33ef4e67 as ::core::ffi::c_int as uint32_t, - 0x959845d3 as ::core::ffi::c_uint, - 0xa4705f4e as ::core::ffi::c_uint, - 0x20754fa as ::core::ffi::c_int as uint32_t, - 0xc7a06a74 as ::core::ffi::c_uint, - 0x61d761c0 as ::core::ffi::c_int as uint32_t, - 0x503f7b5d as ::core::ffi::c_int as uint32_t, - 0xf64870e9 as ::core::ffi::c_uint, - 0x67de9cce as ::core::ffi::c_int as uint32_t, - 0xc1a9977a as ::core::ffi::c_uint, - 0xf0418de7 as ::core::ffi::c_uint, - 0x56368653 as ::core::ffi::c_int as uint32_t, - 0x9391b8dd as ::core::ffi::c_uint, - 0x35e6b369 as ::core::ffi::c_int as uint32_t, - 0x40ea9f4 as ::core::ffi::c_int as uint32_t, - 0xa279a240 as ::core::ffi::c_uint, - 0x5431d2a9 as ::core::ffi::c_int as uint32_t, - 0xf246d91d as ::core::ffi::c_uint, - 0xc3aec380 as ::core::ffi::c_uint, - 0x65d9c834 as ::core::ffi::c_int as uint32_t, - 0xa07ef6ba as ::core::ffi::c_uint, - 0x609fd0e as ::core::ffi::c_int as uint32_t, - 0x37e1e793 as ::core::ffi::c_int as uint32_t, - 0x9196ec27 as ::core::ffi::c_uint, - 0xcfbd399c as ::core::ffi::c_uint, - 0x69ca3228 as ::core::ffi::c_int as uint32_t, - 0x582228b5 as ::core::ffi::c_int as uint32_t, - 0xfe552301 as ::core::ffi::c_uint, - 0x3bf21d8f as ::core::ffi::c_int as uint32_t, - 0x9d85163b as ::core::ffi::c_uint, - 0xac6d0ca6 as ::core::ffi::c_uint, - 0xa1a0712 as ::core::ffi::c_int as uint32_t, - 0xfc5277fb as ::core::ffi::c_uint, - 0x5a257c4f as ::core::ffi::c_int as uint32_t, - 0x6bcd66d2 as ::core::ffi::c_int as uint32_t, - 0xcdba6d66 as ::core::ffi::c_uint, - 0x81d53e8 as ::core::ffi::c_int as uint32_t, - 0xae6a585c as ::core::ffi::c_uint, - 0x9f8242c1 as ::core::ffi::c_uint, - 0x39f54975 as ::core::ffi::c_int as uint32_t, - 0xa863a552 as ::core::ffi::c_uint, - 0xe14aee6 as ::core::ffi::c_int as uint32_t, - 0x3ffcb47b as ::core::ffi::c_int as uint32_t, - 0x998bbfcf as ::core::ffi::c_uint, - 0x5c2c8141 as ::core::ffi::c_int as uint32_t, - 0xfa5b8af5 as ::core::ffi::c_uint, - 0xcbb39068 as ::core::ffi::c_uint, - 0x6dc49bdc as ::core::ffi::c_int as uint32_t, - 0x9b8ceb35 as ::core::ffi::c_uint, - 0x3dfbe081 as ::core::ffi::c_int as uint32_t, - 0xc13fa1c as ::core::ffi::c_int as uint32_t, - 0xaa64f1a8 as ::core::ffi::c_uint, - 0x6fc3cf26 as ::core::ffi::c_int as uint32_t, - 0xc9b4c492 as ::core::ffi::c_uint, - 0xf85cde0f as ::core::ffi::c_uint, - 0x5e2bd5bb as ::core::ffi::c_int as uint32_t, - 0x440b7579 as ::core::ffi::c_int as uint32_t, - 0xe27c7ecd as ::core::ffi::c_uint, - 0xd3946450 as ::core::ffi::c_uint, - 0x75e36fe4 as ::core::ffi::c_int as uint32_t, - 0xb044516a as ::core::ffi::c_uint, - 0x16335ade as ::core::ffi::c_int as uint32_t, - 0x27db4043 as ::core::ffi::c_int as uint32_t, - 0x81ac4bf7 as ::core::ffi::c_uint, - 0x77e43b1e as ::core::ffi::c_int as uint32_t, - 0xd19330aa as ::core::ffi::c_uint, - 0xe07b2a37 as ::core::ffi::c_uint, - 0x460c2183 as ::core::ffi::c_int as uint32_t, - 0x83ab1f0d as ::core::ffi::c_uint, - 0x25dc14b9 as ::core::ffi::c_int as uint32_t, - 0x14340e24 as ::core::ffi::c_int as uint32_t, - 0xb2430590 as ::core::ffi::c_uint, - 0x23d5e9b7 as ::core::ffi::c_int as uint32_t, - 0x85a2e203 as ::core::ffi::c_uint, - 0xb44af89e as ::core::ffi::c_uint, - 0x123df32a as ::core::ffi::c_int as uint32_t, - 0xd79acda4 as ::core::ffi::c_uint, - 0x71edc610 as ::core::ffi::c_int as uint32_t, - 0x4005dc8d as ::core::ffi::c_int as uint32_t, - 0xe672d739 as ::core::ffi::c_uint, - 0x103aa7d0 as ::core::ffi::c_int as uint32_t, - 0xb64dac64 as ::core::ffi::c_uint, - 0x87a5b6f9 as ::core::ffi::c_uint, - 0x21d2bd4d as ::core::ffi::c_int as uint32_t, - 0xe47583c3 as ::core::ffi::c_uint, - 0x42028877 as ::core::ffi::c_int as uint32_t, - 0x73ea92ea as ::core::ffi::c_int as uint32_t, - 0xd59d995e as ::core::ffi::c_uint, - 0x8bb64ce5 as ::core::ffi::c_uint, - 0x2dc14751 as ::core::ffi::c_int as uint32_t, - 0x1c295dcc as ::core::ffi::c_int as uint32_t, - 0xba5e5678 as ::core::ffi::c_uint, - 0x7ff968f6 as ::core::ffi::c_int as uint32_t, - 0xd98e6342 as ::core::ffi::c_uint, - 0xe86679df as ::core::ffi::c_uint, - 0x4e11726b as ::core::ffi::c_int as uint32_t, - 0xb8590282 as ::core::ffi::c_uint, - 0x1e2e0936 as ::core::ffi::c_int as uint32_t, - 0x2fc613ab as ::core::ffi::c_int as uint32_t, - 0x89b1181f as ::core::ffi::c_uint, - 0x4c162691 as ::core::ffi::c_int as uint32_t, - 0xea612d25 as ::core::ffi::c_uint, - 0xdb8937b8 as ::core::ffi::c_uint, - 0x7dfe3c0c as ::core::ffi::c_int as uint32_t, - 0xec68d02b as ::core::ffi::c_uint, - 0x4a1fdb9f as ::core::ffi::c_int as uint32_t, - 0x7bf7c102 as ::core::ffi::c_int as uint32_t, - 0xdd80cab6 as ::core::ffi::c_uint, - 0x1827f438 as ::core::ffi::c_int as uint32_t, - 0xbe50ff8c as ::core::ffi::c_uint, - 0x8fb8e511 as ::core::ffi::c_uint, - 0x29cfeea5 as ::core::ffi::c_int as uint32_t, - 0xdf879e4c as ::core::ffi::c_uint, - 0x79f095f8 as ::core::ffi::c_int as uint32_t, - 0x48188f65 as ::core::ffi::c_int as uint32_t, - 0xee6f84d1 as ::core::ffi::c_uint, - 0x2bc8ba5f as ::core::ffi::c_int as uint32_t, - 0x8dbfb1eb as ::core::ffi::c_uint, - 0xbc57ab76 as ::core::ffi::c_uint, - 0x1a20a0c2 as ::core::ffi::c_int as uint32_t, - 0x8816eaf2 as ::core::ffi::c_uint, - 0x2e61e146 as ::core::ffi::c_int as uint32_t, - 0x1f89fbdb as ::core::ffi::c_int as uint32_t, - 0xb9fef06f as ::core::ffi::c_uint, - 0x7c59cee1 as ::core::ffi::c_int as uint32_t, - 0xda2ec555 as ::core::ffi::c_uint, - 0xebc6dfc8 as ::core::ffi::c_uint, - 0x4db1d47c as ::core::ffi::c_int as uint32_t, - 0xbbf9a495 as ::core::ffi::c_uint, - 0x1d8eaf21 as ::core::ffi::c_int as uint32_t, - 0x2c66b5bc as ::core::ffi::c_int as uint32_t, - 0x8a11be08 as ::core::ffi::c_uint, - 0x4fb68086 as ::core::ffi::c_int as uint32_t, - 0xe9c18b32 as ::core::ffi::c_uint, - 0xd82991af as ::core::ffi::c_uint, - 0x7e5e9a1b as ::core::ffi::c_int as uint32_t, - 0xefc8763c as ::core::ffi::c_uint, - 0x49bf7d88 as ::core::ffi::c_int as uint32_t, - 0x78576715 as ::core::ffi::c_int as uint32_t, - 0xde206ca1 as ::core::ffi::c_uint, - 0x1b87522f as ::core::ffi::c_int as uint32_t, - 0xbdf0599b as ::core::ffi::c_uint, - 0x8c184306 as ::core::ffi::c_uint, - 0x2a6f48b2 as ::core::ffi::c_int as uint32_t, - 0xdc27385b as ::core::ffi::c_uint, - 0x7a5033ef as ::core::ffi::c_int as uint32_t, - 0x4bb82972 as ::core::ffi::c_int as uint32_t, - 0xedcf22c6 as ::core::ffi::c_uint, - 0x28681c48 as ::core::ffi::c_int as uint32_t, - 0x8e1f17fc as ::core::ffi::c_uint, - 0xbff70d61 as ::core::ffi::c_uint, - 0x198006d5 as ::core::ffi::c_int as uint32_t, - 0x47abd36e as ::core::ffi::c_int as uint32_t, - 0xe1dcd8da as ::core::ffi::c_uint, - 0xd034c247 as ::core::ffi::c_uint, - 0x7643c9f3 as ::core::ffi::c_int as uint32_t, - 0xb3e4f77d as ::core::ffi::c_uint, - 0x1593fcc9 as ::core::ffi::c_int as uint32_t, - 0x247be654 as ::core::ffi::c_int as uint32_t, - 0x820cede0 as ::core::ffi::c_uint, - 0x74449d09 as ::core::ffi::c_int as uint32_t, - 0xd23396bd as ::core::ffi::c_uint, - 0xe3db8c20 as ::core::ffi::c_uint, - 0x45ac8794 as ::core::ffi::c_int as uint32_t, - 0x800bb91a as ::core::ffi::c_uint, - 0x267cb2ae as ::core::ffi::c_int as uint32_t, - 0x1794a833 as ::core::ffi::c_int as uint32_t, - 0xb1e3a387 as ::core::ffi::c_uint, - 0x20754fa0 as ::core::ffi::c_int as uint32_t, - 0x86024414 as ::core::ffi::c_uint, - 0xb7ea5e89 as ::core::ffi::c_uint, - 0x119d553d as ::core::ffi::c_int as uint32_t, - 0xd43a6bb3 as ::core::ffi::c_uint, - 0x724d6007 as ::core::ffi::c_int as uint32_t, - 0x43a57a9a as ::core::ffi::c_int as uint32_t, - 0xe5d2712e as ::core::ffi::c_uint, - 0x139a01c7 as ::core::ffi::c_int as uint32_t, - 0xb5ed0a73 as ::core::ffi::c_uint, - 0x840510ee as ::core::ffi::c_uint, - 0x22721b5a as ::core::ffi::c_int as uint32_t, - 0xe7d525d4 as ::core::ffi::c_uint, - 0x41a22e60 as ::core::ffi::c_int as uint32_t, - 0x704a34fd as ::core::ffi::c_int as uint32_t, - 0xd63d3f49 as ::core::ffi::c_uint, - 0xcc1d9f8b as ::core::ffi::c_uint, - 0x6a6a943f as ::core::ffi::c_int as uint32_t, - 0x5b828ea2 as ::core::ffi::c_int as uint32_t, - 0xfdf58516 as ::core::ffi::c_uint, - 0x3852bb98 as ::core::ffi::c_int as uint32_t, - 0x9e25b02c as ::core::ffi::c_uint, - 0xafcdaab1 as ::core::ffi::c_uint, - 0x9baa105 as ::core::ffi::c_int as uint32_t, - 0xfff2d1ec as ::core::ffi::c_uint, - 0x5985da58 as ::core::ffi::c_int as uint32_t, - 0x686dc0c5 as ::core::ffi::c_int as uint32_t, - 0xce1acb71 as ::core::ffi::c_uint, - 0xbbdf5ff as ::core::ffi::c_int as uint32_t, - 0xadcafe4b as ::core::ffi::c_uint, - 0x9c22e4d6 as ::core::ffi::c_uint, - 0x3a55ef62 as ::core::ffi::c_int as uint32_t, - 0xabc30345 as ::core::ffi::c_uint, - 0xdb408f1 as ::core::ffi::c_int as uint32_t, - 0x3c5c126c as ::core::ffi::c_int as uint32_t, - 0x9a2b19d8 as ::core::ffi::c_uint, - 0x5f8c2756 as ::core::ffi::c_int as uint32_t, - 0xf9fb2ce2 as ::core::ffi::c_uint, - 0xc813367f as ::core::ffi::c_uint, - 0x6e643dcb as ::core::ffi::c_int as uint32_t, - 0x982c4d22 as ::core::ffi::c_uint, - 0x3e5b4696 as ::core::ffi::c_int as uint32_t, - 0xfb35c0b as ::core::ffi::c_int as uint32_t, - 0xa9c457bf as ::core::ffi::c_uint, - 0x6c636931 as ::core::ffi::c_int as uint32_t, - 0xca146285 as ::core::ffi::c_uint, - 0xfbfc7818 as ::core::ffi::c_uint, - 0x5d8b73ac as ::core::ffi::c_int as uint32_t, - 0x3a0a617 as ::core::ffi::c_int as uint32_t, - 0xa5d7ada3 as ::core::ffi::c_uint, - 0x943fb73e as ::core::ffi::c_uint, - 0x3248bc8a as ::core::ffi::c_int as uint32_t, - 0xf7ef8204 as ::core::ffi::c_uint, - 0x519889b0 as ::core::ffi::c_int as uint32_t, - 0x6070932d as ::core::ffi::c_int as uint32_t, - 0xc6079899 as ::core::ffi::c_uint, - 0x304fe870 as ::core::ffi::c_int as uint32_t, - 0x9638e3c4 as ::core::ffi::c_uint, - 0xa7d0f959 as ::core::ffi::c_uint, - 0x1a7f2ed as ::core::ffi::c_int as uint32_t, - 0xc400cc63 as ::core::ffi::c_uint, - 0x6277c7d7 as ::core::ffi::c_int as uint32_t, - 0x539fdd4a as ::core::ffi::c_int as uint32_t, - 0xf5e8d6fe as ::core::ffi::c_uint, - 0x647e3ad9 as ::core::ffi::c_int as uint32_t, - 0xc209316d as ::core::ffi::c_uint, - 0xf3e12bf0 as ::core::ffi::c_uint, - 0x55962044 as ::core::ffi::c_int as uint32_t, - 0x90311eca as ::core::ffi::c_uint, - 0x3646157e as ::core::ffi::c_int as uint32_t, - 0x7ae0fe3 as ::core::ffi::c_int as uint32_t, - 0xa1d90457 as ::core::ffi::c_uint, - 0x579174be as ::core::ffi::c_int as uint32_t, - 0xf1e67f0a as ::core::ffi::c_uint, - 0xc00e6597 as ::core::ffi::c_uint, - 0x66796e23 as ::core::ffi::c_int as uint32_t, - 0xa3de50ad as ::core::ffi::c_uint, - 0x5a95b19 as ::core::ffi::c_int as uint32_t, - 0x34414184 as ::core::ffi::c_int as uint32_t, - 0x92364a30 as ::core::ffi::c_uint, + 0, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, 0x52382fa7, 0x63d0353a, 0xc5a73e8e, + 0x33ef4e67, 0x959845d3, 0xa4705f4e, 0x20754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, + 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, 0x9391b8dd, 0x35e6b369, + 0x40ea9f4, 0xa279a240, 0x5431d2a9, 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, + 0x609fd0e, 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, 0xfe552301, + 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0xa1a0712, 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, + 0xcdba6d66, 0x81d53e8, 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0xe14aee6, + 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, 0x6dc49bdc, 0x9b8ceb35, + 0x3dfbe081, 0xc13fa1c, 0xaa64f1a8, 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, + 0x440b7579, 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, 0x27db4043, + 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, 0x460c2183, 0x83ab1f0d, 0x25dc14b9, + 0x14340e24, 0xb2430590, 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, + 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, 0x87a5b6f9, 0x21d2bd4d, + 0xe47583c3, 0x42028877, 0x73ea92ea, 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, + 0xba5e5678, 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, 0x1e2e0936, + 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, + 0x4a1fdb9f, 0x7bf7c102, 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, + 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, 0x8dbfb1eb, 0xbc57ab76, + 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, + 0xebc6dfc8, 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, 0x4fb68086, + 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, 0x49bf7d88, 0x78576715, 0xde206ca1, + 0x1b87522f, 0xbdf0599b, 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, + 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, 0x47abd36e, 0xe1dcd8da, + 0xd034c247, 0x7643c9f3, 0xb3e4f77d, 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, + 0xd23396bd, 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, 0xb1e3a387, + 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, 0xd43a6bb3, 0x724d6007, 0x43a57a9a, + 0xe5d2712e, 0x139a01c7, 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, + 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, 0xfdf58516, 0x3852bb98, + 0x9e25b02c, 0xafcdaab1, 0x9baa105, 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, + 0xbbdf5ff, 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0xdb408f1, 0x3c5c126c, + 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, 0x6e643dcb, 0x982c4d22, 0x3e5b4696, + 0xfb35c0b, 0xa9c457bf, 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x3a0a617, + 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, 0x6070932d, 0xc6079899, + 0x304fe870, 0x9638e3c4, 0xa7d0f959, 0x1a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, + 0xf5e8d6fe, 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, 0x3646157e, + 0x7ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, 0xc00e6597, 0x66796e23, 0xa3de50ad, + 0x5a95b19, 0x34414184, 0x92364a30, ], [ - 0 as ::core::ffi::c_int as uint32_t, - 0xccaa009e as ::core::ffi::c_uint, - 0x4225077d as ::core::ffi::c_int as uint32_t, - 0x8e8f07e3 as ::core::ffi::c_uint, - 0x844a0efa as ::core::ffi::c_uint, - 0x48e00e64 as ::core::ffi::c_int as uint32_t, - 0xc66f0987 as ::core::ffi::c_uint, - 0xac50919 as ::core::ffi::c_int as uint32_t, - 0xd3e51bb5 as ::core::ffi::c_uint, - 0x1f4f1b2b as ::core::ffi::c_int as uint32_t, - 0x91c01cc8 as ::core::ffi::c_uint, - 0x5d6a1c56 as ::core::ffi::c_int as uint32_t, - 0x57af154f as ::core::ffi::c_int as uint32_t, - 0x9b0515d1 as ::core::ffi::c_uint, - 0x158a1232 as ::core::ffi::c_int as uint32_t, - 0xd92012ac as ::core::ffi::c_uint, - 0x7cbb312b as ::core::ffi::c_int as uint32_t, - 0xb01131b5 as ::core::ffi::c_uint, - 0x3e9e3656 as ::core::ffi::c_int as uint32_t, - 0xf23436c8 as ::core::ffi::c_uint, - 0xf8f13fd1 as ::core::ffi::c_uint, - 0x345b3f4f as ::core::ffi::c_int as uint32_t, - 0xbad438ac as ::core::ffi::c_uint, - 0x767e3832 as ::core::ffi::c_int as uint32_t, - 0xaf5e2a9e as ::core::ffi::c_uint, - 0x63f42a00 as ::core::ffi::c_int as uint32_t, - 0xed7b2de3 as ::core::ffi::c_uint, - 0x21d12d7d as ::core::ffi::c_int as uint32_t, - 0x2b142464 as ::core::ffi::c_int as uint32_t, - 0xe7be24fa as ::core::ffi::c_uint, - 0x69312319 as ::core::ffi::c_int as uint32_t, - 0xa59b2387 as ::core::ffi::c_uint, - 0xf9766256 as ::core::ffi::c_uint, - 0x35dc62c8 as ::core::ffi::c_int as uint32_t, - 0xbb53652b as ::core::ffi::c_uint, - 0x77f965b5 as ::core::ffi::c_int as uint32_t, - 0x7d3c6cac as ::core::ffi::c_int as uint32_t, - 0xb1966c32 as ::core::ffi::c_uint, - 0x3f196bd1 as ::core::ffi::c_int as uint32_t, - 0xf3b36b4f as ::core::ffi::c_uint, - 0x2a9379e3 as ::core::ffi::c_int as uint32_t, - 0xe639797d as ::core::ffi::c_uint, - 0x68b67e9e as ::core::ffi::c_int as uint32_t, - 0xa41c7e00 as ::core::ffi::c_uint, - 0xaed97719 as ::core::ffi::c_uint, - 0x62737787 as ::core::ffi::c_int as uint32_t, - 0xecfc7064 as ::core::ffi::c_uint, - 0x205670fa as ::core::ffi::c_int as uint32_t, - 0x85cd537d as ::core::ffi::c_uint, - 0x496753e3 as ::core::ffi::c_int as uint32_t, - 0xc7e85400 as ::core::ffi::c_uint, - 0xb42549e as ::core::ffi::c_int as uint32_t, - 0x1875d87 as ::core::ffi::c_int as uint32_t, - 0xcd2d5d19 as ::core::ffi::c_uint, - 0x43a25afa as ::core::ffi::c_int as uint32_t, - 0x8f085a64 as ::core::ffi::c_uint, - 0x562848c8 as ::core::ffi::c_int as uint32_t, - 0x9a824856 as ::core::ffi::c_uint, - 0x140d4fb5 as ::core::ffi::c_int as uint32_t, - 0xd8a74f2b as ::core::ffi::c_uint, - 0xd2624632 as ::core::ffi::c_uint, - 0x1ec846ac as ::core::ffi::c_int as uint32_t, - 0x9047414f as ::core::ffi::c_uint, - 0x5ced41d1 as ::core::ffi::c_int as uint32_t, - 0x299dc2ed as ::core::ffi::c_int as uint32_t, - 0xe537c273 as ::core::ffi::c_uint, - 0x6bb8c590 as ::core::ffi::c_int as uint32_t, - 0xa712c50e as ::core::ffi::c_uint, - 0xadd7cc17 as ::core::ffi::c_uint, - 0x617dcc89 as ::core::ffi::c_int as uint32_t, - 0xeff2cb6a as ::core::ffi::c_uint, - 0x2358cbf4 as ::core::ffi::c_int as uint32_t, - 0xfa78d958 as ::core::ffi::c_uint, - 0x36d2d9c6 as ::core::ffi::c_int as uint32_t, - 0xb85dde25 as ::core::ffi::c_uint, - 0x74f7debb as ::core::ffi::c_int as uint32_t, - 0x7e32d7a2 as ::core::ffi::c_int as uint32_t, - 0xb298d73c as ::core::ffi::c_uint, - 0x3c17d0df as ::core::ffi::c_int as uint32_t, - 0xf0bdd041 as ::core::ffi::c_uint, - 0x5526f3c6 as ::core::ffi::c_int as uint32_t, - 0x998cf358 as ::core::ffi::c_uint, - 0x1703f4bb as ::core::ffi::c_int as uint32_t, - 0xdba9f425 as ::core::ffi::c_uint, - 0xd16cfd3c as ::core::ffi::c_uint, - 0x1dc6fda2 as ::core::ffi::c_int as uint32_t, - 0x9349fa41 as ::core::ffi::c_uint, - 0x5fe3fadf as ::core::ffi::c_int as uint32_t, - 0x86c3e873 as ::core::ffi::c_uint, - 0x4a69e8ed as ::core::ffi::c_int as uint32_t, - 0xc4e6ef0e as ::core::ffi::c_uint, - 0x84cef90 as ::core::ffi::c_int as uint32_t, - 0x289e689 as ::core::ffi::c_int as uint32_t, - 0xce23e617 as ::core::ffi::c_uint, - 0x40ace1f4 as ::core::ffi::c_int as uint32_t, - 0x8c06e16a as ::core::ffi::c_uint, - 0xd0eba0bb as ::core::ffi::c_uint, - 0x1c41a025 as ::core::ffi::c_int as uint32_t, - 0x92cea7c6 as ::core::ffi::c_uint, - 0x5e64a758 as ::core::ffi::c_int as uint32_t, - 0x54a1ae41 as ::core::ffi::c_int as uint32_t, - 0x980baedf as ::core::ffi::c_uint, - 0x1684a93c as ::core::ffi::c_int as uint32_t, - 0xda2ea9a2 as ::core::ffi::c_uint, - 0x30ebb0e as ::core::ffi::c_int as uint32_t, - 0xcfa4bb90 as ::core::ffi::c_uint, - 0x412bbc73 as ::core::ffi::c_int as uint32_t, - 0x8d81bced as ::core::ffi::c_uint, - 0x8744b5f4 as ::core::ffi::c_uint, - 0x4beeb56a as ::core::ffi::c_int as uint32_t, - 0xc561b289 as ::core::ffi::c_uint, - 0x9cbb217 as ::core::ffi::c_int as uint32_t, - 0xac509190 as ::core::ffi::c_uint, - 0x60fa910e as ::core::ffi::c_int as uint32_t, - 0xee7596ed as ::core::ffi::c_uint, - 0x22df9673 as ::core::ffi::c_int as uint32_t, - 0x281a9f6a as ::core::ffi::c_int as uint32_t, - 0xe4b09ff4 as ::core::ffi::c_uint, - 0x6a3f9817 as ::core::ffi::c_int as uint32_t, - 0xa6959889 as ::core::ffi::c_uint, - 0x7fb58a25 as ::core::ffi::c_int as uint32_t, - 0xb31f8abb as ::core::ffi::c_uint, - 0x3d908d58 as ::core::ffi::c_int as uint32_t, - 0xf13a8dc6 as ::core::ffi::c_uint, - 0xfbff84df as ::core::ffi::c_uint, - 0x37558441 as ::core::ffi::c_int as uint32_t, - 0xb9da83a2 as ::core::ffi::c_uint, - 0x7570833c as ::core::ffi::c_int as uint32_t, - 0x533b85da as ::core::ffi::c_int as uint32_t, - 0x9f918544 as ::core::ffi::c_uint, - 0x111e82a7 as ::core::ffi::c_int as uint32_t, - 0xddb48239 as ::core::ffi::c_uint, - 0xd7718b20 as ::core::ffi::c_uint, - 0x1bdb8bbe as ::core::ffi::c_int as uint32_t, - 0x95548c5d as ::core::ffi::c_uint, - 0x59fe8cc3 as ::core::ffi::c_int as uint32_t, - 0x80de9e6f as ::core::ffi::c_uint, - 0x4c749ef1 as ::core::ffi::c_int as uint32_t, - 0xc2fb9912 as ::core::ffi::c_uint, - 0xe51998c as ::core::ffi::c_int as uint32_t, - 0x4949095 as ::core::ffi::c_int as uint32_t, - 0xc83e900b as ::core::ffi::c_uint, - 0x46b197e8 as ::core::ffi::c_int as uint32_t, - 0x8a1b9776 as ::core::ffi::c_uint, - 0x2f80b4f1 as ::core::ffi::c_int as uint32_t, - 0xe32ab46f as ::core::ffi::c_uint, - 0x6da5b38c as ::core::ffi::c_int as uint32_t, - 0xa10fb312 as ::core::ffi::c_uint, - 0xabcaba0b as ::core::ffi::c_uint, - 0x6760ba95 as ::core::ffi::c_int as uint32_t, - 0xe9efbd76 as ::core::ffi::c_uint, - 0x2545bde8 as ::core::ffi::c_int as uint32_t, - 0xfc65af44 as ::core::ffi::c_uint, - 0x30cfafda as ::core::ffi::c_int as uint32_t, - 0xbe40a839 as ::core::ffi::c_uint, - 0x72eaa8a7 as ::core::ffi::c_int as uint32_t, - 0x782fa1be as ::core::ffi::c_int as uint32_t, - 0xb485a120 as ::core::ffi::c_uint, - 0x3a0aa6c3 as ::core::ffi::c_int as uint32_t, - 0xf6a0a65d as ::core::ffi::c_uint, - 0xaa4de78c as ::core::ffi::c_uint, - 0x66e7e712 as ::core::ffi::c_int as uint32_t, - 0xe868e0f1 as ::core::ffi::c_uint, - 0x24c2e06f as ::core::ffi::c_int as uint32_t, - 0x2e07e976 as ::core::ffi::c_int as uint32_t, - 0xe2ade9e8 as ::core::ffi::c_uint, - 0x6c22ee0b as ::core::ffi::c_int as uint32_t, - 0xa088ee95 as ::core::ffi::c_uint, - 0x79a8fc39 as ::core::ffi::c_int as uint32_t, - 0xb502fca7 as ::core::ffi::c_uint, - 0x3b8dfb44 as ::core::ffi::c_int as uint32_t, - 0xf727fbda as ::core::ffi::c_uint, - 0xfde2f2c3 as ::core::ffi::c_uint, - 0x3148f25d as ::core::ffi::c_int as uint32_t, - 0xbfc7f5be as ::core::ffi::c_uint, - 0x736df520 as ::core::ffi::c_int as uint32_t, - 0xd6f6d6a7 as ::core::ffi::c_uint, - 0x1a5cd639 as ::core::ffi::c_int as uint32_t, - 0x94d3d1da as ::core::ffi::c_uint, - 0x5879d144 as ::core::ffi::c_int as uint32_t, - 0x52bcd85d as ::core::ffi::c_int as uint32_t, - 0x9e16d8c3 as ::core::ffi::c_uint, - 0x1099df20 as ::core::ffi::c_int as uint32_t, - 0xdc33dfbe as ::core::ffi::c_uint, - 0x513cd12 as ::core::ffi::c_int as uint32_t, - 0xc9b9cd8c as ::core::ffi::c_uint, - 0x4736ca6f as ::core::ffi::c_int as uint32_t, - 0x8b9ccaf1 as ::core::ffi::c_uint, - 0x8159c3e8 as ::core::ffi::c_uint, - 0x4df3c376 as ::core::ffi::c_int as uint32_t, - 0xc37cc495 as ::core::ffi::c_uint, - 0xfd6c40b as ::core::ffi::c_int as uint32_t, - 0x7aa64737 as ::core::ffi::c_int as uint32_t, - 0xb60c47a9 as ::core::ffi::c_uint, - 0x3883404a as ::core::ffi::c_int as uint32_t, - 0xf42940d4 as ::core::ffi::c_uint, - 0xfeec49cd as ::core::ffi::c_uint, - 0x32464953 as ::core::ffi::c_int as uint32_t, - 0xbcc94eb0 as ::core::ffi::c_uint, - 0x70634e2e as ::core::ffi::c_int as uint32_t, - 0xa9435c82 as ::core::ffi::c_uint, - 0x65e95c1c as ::core::ffi::c_int as uint32_t, - 0xeb665bff as ::core::ffi::c_uint, - 0x27cc5b61 as ::core::ffi::c_int as uint32_t, - 0x2d095278 as ::core::ffi::c_int as uint32_t, - 0xe1a352e6 as ::core::ffi::c_uint, - 0x6f2c5505 as ::core::ffi::c_int as uint32_t, - 0xa386559b as ::core::ffi::c_uint, - 0x61d761c as ::core::ffi::c_int as uint32_t, - 0xcab77682 as ::core::ffi::c_uint, - 0x44387161 as ::core::ffi::c_int as uint32_t, - 0x889271ff as ::core::ffi::c_uint, - 0x825778e6 as ::core::ffi::c_uint, - 0x4efd7878 as ::core::ffi::c_int as uint32_t, - 0xc0727f9b as ::core::ffi::c_uint, - 0xcd87f05 as ::core::ffi::c_int as uint32_t, - 0xd5f86da9 as ::core::ffi::c_uint, - 0x19526d37 as ::core::ffi::c_int as uint32_t, - 0x97dd6ad4 as ::core::ffi::c_uint, - 0x5b776a4a as ::core::ffi::c_int as uint32_t, - 0x51b26353 as ::core::ffi::c_int as uint32_t, - 0x9d1863cd as ::core::ffi::c_uint, - 0x1397642e as ::core::ffi::c_int as uint32_t, - 0xdf3d64b0 as ::core::ffi::c_uint, - 0x83d02561 as ::core::ffi::c_uint, - 0x4f7a25ff as ::core::ffi::c_int as uint32_t, - 0xc1f5221c as ::core::ffi::c_uint, - 0xd5f2282 as ::core::ffi::c_int as uint32_t, - 0x79a2b9b as ::core::ffi::c_int as uint32_t, - 0xcb302b05 as ::core::ffi::c_uint, - 0x45bf2ce6 as ::core::ffi::c_int as uint32_t, - 0x89152c78 as ::core::ffi::c_uint, - 0x50353ed4 as ::core::ffi::c_int as uint32_t, - 0x9c9f3e4a as ::core::ffi::c_uint, - 0x121039a9 as ::core::ffi::c_int as uint32_t, - 0xdeba3937 as ::core::ffi::c_uint, - 0xd47f302e as ::core::ffi::c_uint, - 0x18d530b0 as ::core::ffi::c_int as uint32_t, - 0x965a3753 as ::core::ffi::c_uint, - 0x5af037cd as ::core::ffi::c_int as uint32_t, - 0xff6b144a as ::core::ffi::c_uint, - 0x33c114d4 as ::core::ffi::c_int as uint32_t, - 0xbd4e1337 as ::core::ffi::c_uint, - 0x71e413a9 as ::core::ffi::c_int as uint32_t, - 0x7b211ab0 as ::core::ffi::c_int as uint32_t, - 0xb78b1a2e as ::core::ffi::c_uint, - 0x39041dcd as ::core::ffi::c_int as uint32_t, - 0xf5ae1d53 as ::core::ffi::c_uint, - 0x2c8e0fff as ::core::ffi::c_int as uint32_t, - 0xe0240f61 as ::core::ffi::c_uint, - 0x6eab0882 as ::core::ffi::c_int as uint32_t, - 0xa201081c as ::core::ffi::c_uint, - 0xa8c40105 as ::core::ffi::c_uint, - 0x646e019b as ::core::ffi::c_int as uint32_t, - 0xeae10678 as ::core::ffi::c_uint, - 0x264b06e6 as ::core::ffi::c_int as uint32_t, + 0, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, 0x48e00e64, 0xc66f0987, 0xac50919, + 0xd3e51bb5, 0x1f4f1b2b, 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, + 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, 0xf8f13fd1, 0x345b3f4f, + 0xbad438ac, 0x767e3832, 0xaf5e2a9e, 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, + 0xe7be24fa, 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, 0x77f965b5, + 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, 0x2a9379e3, 0xe639797d, 0x68b67e9e, + 0xa41c7e00, 0xaed97719, 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, + 0xc7e85400, 0xb42549e, 0x1875d87, 0xcd2d5d19, 0x43a25afa, 0x8f085a64, 0x562848c8, + 0x9a824856, 0x140d4fb5, 0xd8a74f2b, 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, + 0x299dc2ed, 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, 0xeff2cb6a, + 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, 0x74f7debb, 0x7e32d7a2, 0xb298d73c, + 0x3c17d0df, 0xf0bdd041, 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, + 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, 0xc4e6ef0e, 0x84cef90, + 0x289e689, 0xce23e617, 0x40ace1f4, 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, + 0x5e64a758, 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x30ebb0e, 0xcfa4bb90, + 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, 0xc561b289, 0x9cbb217, 0xac509190, + 0x60fa910e, 0xee7596ed, 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, + 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, 0x37558441, 0xb9da83a2, + 0x7570833c, 0x533b85da, 0x9f918544, 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, + 0x95548c5d, 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0xe51998c, 0x4949095, + 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, 0xe32ab46f, 0x6da5b38c, 0xa10fb312, + 0xabcaba0b, 0x6760ba95, 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, + 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, 0xaa4de78c, 0x66e7e712, + 0xe868e0f1, 0x24c2e06f, 0x2e07e976, 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, + 0xb502fca7, 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, 0x736df520, + 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, 0x52bcd85d, 0x9e16d8c3, 0x1099df20, + 0xdc33dfbe, 0x513cd12, 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, + 0xc37cc495, 0xfd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, 0xf42940d4, 0xfeec49cd, + 0x32464953, 0xbcc94eb0, 0x70634e2e, 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, + 0x2d095278, 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x61d761c, 0xcab77682, 0x44387161, + 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, 0xcd87f05, 0xd5f86da9, 0x19526d37, + 0x97dd6ad4, 0x5b776a4a, 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, + 0x4f7a25ff, 0xc1f5221c, 0xd5f2282, 0x79a2b9b, 0xcb302b05, 0x45bf2ce6, 0x89152c78, + 0x50353ed4, 0x9c9f3e4a, 0x121039a9, 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, + 0x5af037cd, 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, 0xb78b1a2e, + 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, 0x6eab0882, 0xa201081c, 0xa8c40105, + 0x646e019b, 0xeae10678, 0x264b06e6, ], ]; -unsafe extern "C" fn lzma_crc32_generic( - mut buf: *const uint8_t, - mut size: size_t, - mut crc: uint32_t, -) -> uint32_t { +unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mut crc: u32) -> u32 { crc = !crc; if size > 8 as size_t { - while buf as uintptr_t & 7 as ::core::ffi::c_int as uintptr_t != 0 { + while buf as uintptr_t & 7 as uintptr_t != 0 { let fresh0 = buf; buf = buf.offset(1); - crc = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][(*fresh0 as uint32_t ^ crc & 0xff as uint32_t) as usize] - ^ crc >> 8 as ::core::ffi::c_int; + crc = lzma_crc32_table[0 as usize][(*fresh0 as u32 ^ crc & 0xff) as usize] + ^ crc >> 8 as c_int; size = size.wrapping_sub(1); } - let limit: *const uint8_t = buf - .offset((size & !(7 as ::core::ffi::c_int as size_t)) as isize); - size &= 7 as ::core::ffi::c_int as size_t; + let limit: *const u8 = buf.offset((size & !(7 as size_t)) as isize); + size &= 7 as size_t; while buf < limit { crc ^= aligned_read32ne(buf); - buf = buf.offset(4 as ::core::ffi::c_int as isize); - crc = lzma_crc32_table[7 as ::core::ffi::c_int - as usize][(crc & 0xff as uint32_t) as usize] - ^ lzma_crc32_table[6 as ::core::ffi::c_int - as usize][(crc >> 8 as ::core::ffi::c_int & 0xff as uint32_t) - as usize] - ^ lzma_crc32_table[5 as ::core::ffi::c_int - as usize][(crc >> 16 as ::core::ffi::c_int & 0xff as uint32_t) - as usize] - ^ lzma_crc32_table[4 as ::core::ffi::c_int - as usize][(crc >> 24 as ::core::ffi::c_int) as usize]; - let tmp: uint32_t = aligned_read32ne(buf) as uint32_t; - buf = buf.offset(4 as ::core::ffi::c_int as isize); - crc = lzma_crc32_table[3 as ::core::ffi::c_int - as usize][(tmp & 0xff as uint32_t) as usize] - ^ lzma_crc32_table[2 as ::core::ffi::c_int - as usize][(tmp >> 8 as ::core::ffi::c_int & 0xff as uint32_t) - as usize] ^ crc - ^ lzma_crc32_table[1 as ::core::ffi::c_int - as usize][(tmp >> 16 as ::core::ffi::c_int & 0xff as uint32_t) - as usize] - ^ lzma_crc32_table[0 as ::core::ffi::c_int - as usize][(tmp >> 24 as ::core::ffi::c_int) as usize]; + buf = buf.offset(4 as isize); + crc = lzma_crc32_table[7 as usize][(crc & 0xff) as usize] + ^ lzma_crc32_table[6 as usize][(crc >> 8 as c_int & 0xff) as usize] + ^ lzma_crc32_table[5 as usize][(crc >> 16 as c_int & 0xff) as usize] + ^ lzma_crc32_table[4 as usize][(crc >> 24 as c_int) as usize]; + let tmp: u32 = aligned_read32ne(buf) as u32; + buf = buf.offset(4 as isize); + crc = lzma_crc32_table[3 as usize][(tmp & 0xff) as usize] + ^ lzma_crc32_table[2 as usize][(tmp >> 8 as c_int & 0xff) as usize] + ^ crc + ^ lzma_crc32_table[1 as usize][(tmp >> 16 as c_int & 0xff) as usize] + ^ lzma_crc32_table[0 as usize][(tmp >> 24 as c_int) as usize]; } } loop { @@ -2127,17 +355,12 @@ unsafe extern "C" fn lzma_crc32_generic( } let fresh2 = buf; buf = buf.offset(1); - crc = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][(*fresh2 as uint32_t ^ crc & 0xff as uint32_t) as usize] - ^ crc >> 8 as ::core::ffi::c_int; + crc = lzma_crc32_table[0 as usize][(*fresh2 as u32 ^ crc & 0xff) as usize] + ^ crc >> 8 as c_int; } return !crc; } #[no_mangle] -pub unsafe extern "C" fn lzma_crc32( - mut buf: *const uint8_t, - mut size: size_t, - mut crc: uint32_t, -) -> uint32_t { +pub unsafe extern "C" fn lzma_crc32(mut buf: *const u8, mut size: size_t, mut crc: u32) -> u32 { return lzma_crc32_generic(buf, size, crc); } diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index 325a15c3..978baf1a 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1,1079 +1,1064 @@ -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; +use crate::types::*; +use core::ffi::{c_int, c_ulonglong}; #[inline] -unsafe extern "C" fn aligned_read32ne(mut buf: *const uint8_t) -> uint32_t { - return *(buf as *const uint32_t); +unsafe extern "C" fn aligned_read32ne(mut buf: *const u8) -> u32 { + return *(buf as *const u32); } #[no_mangle] -pub static mut lzma_crc64_table: [[uint64_t; 256]; 4] = [ +pub static mut lzma_crc64_table: [[u64; 256]; 4] = [ [ - 0 as ::core::ffi::c_ulonglong, - 0xb32e4cbe03a75f6f as ::core::ffi::c_ulonglong, - 0xf4843657a840a05b as ::core::ffi::c_ulonglong, - 0x47aa7ae9abe7ff34 as ::core::ffi::c_ulonglong, - 0x7bd0c384ff8f5e33 as ::core::ffi::c_ulonglong, - 0xc8fe8f3afc28015c as ::core::ffi::c_ulonglong, - 0x8f54f5d357cffe68 as ::core::ffi::c_ulonglong, - 0x3c7ab96d5468a107 as ::core::ffi::c_ulonglong, - 0xf7a18709ff1ebc66 as ::core::ffi::c_ulonglong, - 0x448fcbb7fcb9e309 as ::core::ffi::c_ulonglong, - 0x325b15e575e1c3d as ::core::ffi::c_ulonglong, - 0xb00bfde054f94352 as ::core::ffi::c_ulonglong, - 0x8c71448d0091e255 as ::core::ffi::c_ulonglong, - 0x3f5f08330336bd3a as ::core::ffi::c_ulonglong, - 0x78f572daa8d1420e as ::core::ffi::c_ulonglong, - 0xcbdb3e64ab761d61 as ::core::ffi::c_ulonglong, - 0x7d9ba13851336649 as ::core::ffi::c_ulonglong, - 0xceb5ed8652943926 as ::core::ffi::c_ulonglong, - 0x891f976ff973c612 as ::core::ffi::c_ulonglong, - 0x3a31dbd1fad4997d as ::core::ffi::c_ulonglong, - 0x64b62bcaebc387a as ::core::ffi::c_ulonglong, - 0xb5652e02ad1b6715 as ::core::ffi::c_ulonglong, - 0xf2cf54eb06fc9821 as ::core::ffi::c_ulonglong, - 0x41e11855055bc74e as ::core::ffi::c_ulonglong, - 0x8a3a2631ae2dda2f as ::core::ffi::c_ulonglong, - 0x39146a8fad8a8540 as ::core::ffi::c_ulonglong, - 0x7ebe1066066d7a74 as ::core::ffi::c_ulonglong, - 0xcd905cd805ca251b as ::core::ffi::c_ulonglong, - 0xf1eae5b551a2841c as ::core::ffi::c_ulonglong, - 0x42c4a90b5205db73 as ::core::ffi::c_ulonglong, - 0x56ed3e2f9e22447 as ::core::ffi::c_ulonglong, - 0xb6409f5cfa457b28 as ::core::ffi::c_ulonglong, - 0xfb374270a266cc92 as ::core::ffi::c_ulonglong, - 0x48190ecea1c193fd as ::core::ffi::c_ulonglong, - 0xfb374270a266cc9 as ::core::ffi::c_ulonglong, - 0xbc9d3899098133a6 as ::core::ffi::c_ulonglong, - 0x80e781f45de992a1 as ::core::ffi::c_ulonglong, - 0x33c9cd4a5e4ecdce as ::core::ffi::c_ulonglong, - 0x7463b7a3f5a932fa as ::core::ffi::c_ulonglong, - 0xc74dfb1df60e6d95 as ::core::ffi::c_ulonglong, - 0xc96c5795d7870f4 as ::core::ffi::c_ulonglong, - 0xbfb889c75edf2f9b as ::core::ffi::c_ulonglong, - 0xf812f32ef538d0af as ::core::ffi::c_ulonglong, - 0x4b3cbf90f69f8fc0 as ::core::ffi::c_ulonglong, - 0x774606fda2f72ec7 as ::core::ffi::c_ulonglong, - 0xc4684a43a15071a8 as ::core::ffi::c_ulonglong, - 0x83c230aa0ab78e9c as ::core::ffi::c_ulonglong, - 0x30ec7c140910d1f3 as ::core::ffi::c_ulonglong, - 0x86ace348f355aadb as ::core::ffi::c_ulonglong, - 0x3582aff6f0f2f5b4 as ::core::ffi::c_ulonglong, - 0x7228d51f5b150a80 as ::core::ffi::c_ulonglong, - 0xc10699a158b255ef as ::core::ffi::c_ulonglong, - 0xfd7c20cc0cdaf4e8 as ::core::ffi::c_ulonglong, - 0x4e526c720f7dab87 as ::core::ffi::c_ulonglong, - 0x9f8169ba49a54b3 as ::core::ffi::c_ulonglong, - 0xbad65a25a73d0bdc as ::core::ffi::c_ulonglong, - 0x710d64410c4b16bd as ::core::ffi::c_ulonglong, - 0xc22328ff0fec49d2 as ::core::ffi::c_ulonglong, - 0x85895216a40bb6e6 as ::core::ffi::c_ulonglong, - 0x36a71ea8a7ace989 as ::core::ffi::c_ulonglong, - 0xadda7c5f3c4488e as ::core::ffi::c_ulonglong, - 0xb9f3eb7bf06317e1 as ::core::ffi::c_ulonglong, - 0xfe5991925b84e8d5 as ::core::ffi::c_ulonglong, - 0x4d77dd2c5823b7ba as ::core::ffi::c_ulonglong, - 0x64b62bcaebc387a1 as ::core::ffi::c_ulonglong, - 0xd7986774e864d8ce as ::core::ffi::c_ulonglong, - 0x90321d9d438327fa as ::core::ffi::c_ulonglong, - 0x231c512340247895 as ::core::ffi::c_ulonglong, - 0x1f66e84e144cd992 as ::core::ffi::c_ulonglong, - 0xac48a4f017eb86fd as ::core::ffi::c_ulonglong, - 0xebe2de19bc0c79c9 as ::core::ffi::c_ulonglong, - 0x58cc92a7bfab26a6 as ::core::ffi::c_ulonglong, - 0x9317acc314dd3bc7 as ::core::ffi::c_ulonglong, - 0x2039e07d177a64a8 as ::core::ffi::c_ulonglong, - 0x67939a94bc9d9b9c as ::core::ffi::c_ulonglong, - 0xd4bdd62abf3ac4f3 as ::core::ffi::c_ulonglong, - 0xe8c76f47eb5265f4 as ::core::ffi::c_ulonglong, - 0x5be923f9e8f53a9b as ::core::ffi::c_ulonglong, - 0x1c4359104312c5af as ::core::ffi::c_ulonglong, - 0xaf6d15ae40b59ac0 as ::core::ffi::c_ulonglong, - 0x192d8af2baf0e1e8 as ::core::ffi::c_ulonglong, - 0xaa03c64cb957be87 as ::core::ffi::c_ulonglong, - 0xeda9bca512b041b3 as ::core::ffi::c_ulonglong, - 0x5e87f01b11171edc as ::core::ffi::c_ulonglong, - 0x62fd4976457fbfdb as ::core::ffi::c_ulonglong, - 0xd1d305c846d8e0b4 as ::core::ffi::c_ulonglong, - 0x96797f21ed3f1f80 as ::core::ffi::c_ulonglong, - 0x2557339fee9840ef as ::core::ffi::c_ulonglong, - 0xee8c0dfb45ee5d8e as ::core::ffi::c_ulonglong, - 0x5da24145464902e1 as ::core::ffi::c_ulonglong, - 0x1a083bacedaefdd5 as ::core::ffi::c_ulonglong, - 0xa9267712ee09a2ba as ::core::ffi::c_ulonglong, - 0x955cce7fba6103bd as ::core::ffi::c_ulonglong, - 0x267282c1b9c65cd2 as ::core::ffi::c_ulonglong, - 0x61d8f8281221a3e6 as ::core::ffi::c_ulonglong, - 0xd2f6b4961186fc89 as ::core::ffi::c_ulonglong, - 0x9f8169ba49a54b33 as ::core::ffi::c_ulonglong, - 0x2caf25044a02145c as ::core::ffi::c_ulonglong, - 0x6b055fede1e5eb68 as ::core::ffi::c_ulonglong, - 0xd82b1353e242b407 as ::core::ffi::c_ulonglong, - 0xe451aa3eb62a1500 as ::core::ffi::c_ulonglong, - 0x577fe680b58d4a6f as ::core::ffi::c_ulonglong, - 0x10d59c691e6ab55b as ::core::ffi::c_ulonglong, - 0xa3fbd0d71dcdea34 as ::core::ffi::c_ulonglong, - 0x6820eeb3b6bbf755 as ::core::ffi::c_ulonglong, - 0xdb0ea20db51ca83a as ::core::ffi::c_ulonglong, - 0x9ca4d8e41efb570e as ::core::ffi::c_ulonglong, - 0x2f8a945a1d5c0861 as ::core::ffi::c_ulonglong, - 0x13f02d374934a966 as ::core::ffi::c_ulonglong, - 0xa0de61894a93f609 as ::core::ffi::c_ulonglong, - 0xe7741b60e174093d as ::core::ffi::c_ulonglong, - 0x545a57dee2d35652 as ::core::ffi::c_ulonglong, - 0xe21ac88218962d7a as ::core::ffi::c_ulonglong, - 0x5134843c1b317215 as ::core::ffi::c_ulonglong, - 0x169efed5b0d68d21 as ::core::ffi::c_ulonglong, - 0xa5b0b26bb371d24e as ::core::ffi::c_ulonglong, - 0x99ca0b06e7197349 as ::core::ffi::c_ulonglong, - 0x2ae447b8e4be2c26 as ::core::ffi::c_ulonglong, - 0x6d4e3d514f59d312 as ::core::ffi::c_ulonglong, - 0xde6071ef4cfe8c7d as ::core::ffi::c_ulonglong, - 0x15bb4f8be788911c as ::core::ffi::c_ulonglong, - 0xa6950335e42fce73 as ::core::ffi::c_ulonglong, - 0xe13f79dc4fc83147 as ::core::ffi::c_ulonglong, - 0x521135624c6f6e28 as ::core::ffi::c_ulonglong, - 0x6e6b8c0f1807cf2f as ::core::ffi::c_ulonglong, - 0xdd45c0b11ba09040 as ::core::ffi::c_ulonglong, - 0x9aefba58b0476f74 as ::core::ffi::c_ulonglong, - 0x29c1f6e6b3e0301b as ::core::ffi::c_ulonglong, - 0xc96c5795d7870f42 as ::core::ffi::c_ulonglong, - 0x7a421b2bd420502d as ::core::ffi::c_ulonglong, - 0x3de861c27fc7af19 as ::core::ffi::c_ulonglong, - 0x8ec62d7c7c60f076 as ::core::ffi::c_ulonglong, - 0xb2bc941128085171 as ::core::ffi::c_ulonglong, - 0x192d8af2baf0e1e as ::core::ffi::c_ulonglong, - 0x4638a2468048f12a as ::core::ffi::c_ulonglong, - 0xf516eef883efae45 as ::core::ffi::c_ulonglong, - 0x3ecdd09c2899b324 as ::core::ffi::c_ulonglong, - 0x8de39c222b3eec4b as ::core::ffi::c_ulonglong, - 0xca49e6cb80d9137f as ::core::ffi::c_ulonglong, - 0x7967aa75837e4c10 as ::core::ffi::c_ulonglong, - 0x451d1318d716ed17 as ::core::ffi::c_ulonglong, - 0xf6335fa6d4b1b278 as ::core::ffi::c_ulonglong, - 0xb199254f7f564d4c as ::core::ffi::c_ulonglong, - 0x2b769f17cf11223 as ::core::ffi::c_ulonglong, - 0xb4f7f6ad86b4690b as ::core::ffi::c_ulonglong, - 0x7d9ba1385133664 as ::core::ffi::c_ulonglong, - 0x4073c0fa2ef4c950 as ::core::ffi::c_ulonglong, - 0xf35d8c442d53963f as ::core::ffi::c_ulonglong, - 0xcf273529793b3738 as ::core::ffi::c_ulonglong, - 0x7c0979977a9c6857 as ::core::ffi::c_ulonglong, - 0x3ba3037ed17b9763 as ::core::ffi::c_ulonglong, - 0x888d4fc0d2dcc80c as ::core::ffi::c_ulonglong, - 0x435671a479aad56d as ::core::ffi::c_ulonglong, - 0xf0783d1a7a0d8a02 as ::core::ffi::c_ulonglong, - 0xb7d247f3d1ea7536 as ::core::ffi::c_ulonglong, - 0x4fc0b4dd24d2a59 as ::core::ffi::c_ulonglong, - 0x3886b22086258b5e as ::core::ffi::c_ulonglong, - 0x8ba8fe9e8582d431 as ::core::ffi::c_ulonglong, - 0xcc0284772e652b05 as ::core::ffi::c_ulonglong, - 0x7f2cc8c92dc2746a as ::core::ffi::c_ulonglong, - 0x325b15e575e1c3d0 as ::core::ffi::c_ulonglong, - 0x8175595b76469cbf as ::core::ffi::c_ulonglong, - 0xc6df23b2dda1638b as ::core::ffi::c_ulonglong, - 0x75f16f0cde063ce4 as ::core::ffi::c_ulonglong, - 0x498bd6618a6e9de3 as ::core::ffi::c_ulonglong, - 0xfaa59adf89c9c28c as ::core::ffi::c_ulonglong, - 0xbd0fe036222e3db8 as ::core::ffi::c_ulonglong, - 0xe21ac88218962d7 as ::core::ffi::c_ulonglong, - 0xc5fa92ec8aff7fb6 as ::core::ffi::c_ulonglong, - 0x76d4de52895820d9 as ::core::ffi::c_ulonglong, - 0x317ea4bb22bfdfed as ::core::ffi::c_ulonglong, - 0x8250e80521188082 as ::core::ffi::c_ulonglong, - 0xbe2a516875702185 as ::core::ffi::c_ulonglong, - 0xd041dd676d77eea as ::core::ffi::c_ulonglong, - 0x4aae673fdd3081de as ::core::ffi::c_ulonglong, - 0xf9802b81de97deb1 as ::core::ffi::c_ulonglong, - 0x4fc0b4dd24d2a599 as ::core::ffi::c_ulonglong, - 0xfceef8632775faf6 as ::core::ffi::c_ulonglong, - 0xbb44828a8c9205c2 as ::core::ffi::c_ulonglong, - 0x86ace348f355aad as ::core::ffi::c_ulonglong, - 0x34107759db5dfbaa as ::core::ffi::c_ulonglong, - 0x873e3be7d8faa4c5 as ::core::ffi::c_ulonglong, - 0xc094410e731d5bf1 as ::core::ffi::c_ulonglong, - 0x73ba0db070ba049e as ::core::ffi::c_ulonglong, - 0xb86133d4dbcc19ff as ::core::ffi::c_ulonglong, - 0xb4f7f6ad86b4690 as ::core::ffi::c_ulonglong, - 0x4ce50583738cb9a4 as ::core::ffi::c_ulonglong, - 0xffcb493d702be6cb as ::core::ffi::c_ulonglong, - 0xc3b1f050244347cc as ::core::ffi::c_ulonglong, - 0x709fbcee27e418a3 as ::core::ffi::c_ulonglong, - 0x3735c6078c03e797 as ::core::ffi::c_ulonglong, - 0x841b8ab98fa4b8f8 as ::core::ffi::c_ulonglong, - 0xadda7c5f3c4488e3 as ::core::ffi::c_ulonglong, - 0x1ef430e13fe3d78c as ::core::ffi::c_ulonglong, - 0x595e4a08940428b8 as ::core::ffi::c_ulonglong, - 0xea7006b697a377d7 as ::core::ffi::c_ulonglong, - 0xd60abfdbc3cbd6d0 as ::core::ffi::c_ulonglong, - 0x6524f365c06c89bf as ::core::ffi::c_ulonglong, - 0x228e898c6b8b768b as ::core::ffi::c_ulonglong, - 0x91a0c532682c29e4 as ::core::ffi::c_ulonglong, - 0x5a7bfb56c35a3485 as ::core::ffi::c_ulonglong, - 0xe955b7e8c0fd6bea as ::core::ffi::c_ulonglong, - 0xaeffcd016b1a94de as ::core::ffi::c_ulonglong, - 0x1dd181bf68bdcbb1 as ::core::ffi::c_ulonglong, - 0x21ab38d23cd56ab6 as ::core::ffi::c_ulonglong, - 0x9285746c3f7235d9 as ::core::ffi::c_ulonglong, - 0xd52f0e859495caed as ::core::ffi::c_ulonglong, - 0x6601423b97329582 as ::core::ffi::c_ulonglong, - 0xd041dd676d77eeaa as ::core::ffi::c_ulonglong, - 0x636f91d96ed0b1c5 as ::core::ffi::c_ulonglong, - 0x24c5eb30c5374ef1 as ::core::ffi::c_ulonglong, - 0x97eba78ec690119e as ::core::ffi::c_ulonglong, - 0xab911ee392f8b099 as ::core::ffi::c_ulonglong, - 0x18bf525d915feff6 as ::core::ffi::c_ulonglong, - 0x5f1528b43ab810c2 as ::core::ffi::c_ulonglong, - 0xec3b640a391f4fad as ::core::ffi::c_ulonglong, - 0x27e05a6e926952cc as ::core::ffi::c_ulonglong, - 0x94ce16d091ce0da3 as ::core::ffi::c_ulonglong, - 0xd3646c393a29f297 as ::core::ffi::c_ulonglong, - 0x604a2087398eadf8 as ::core::ffi::c_ulonglong, - 0x5c3099ea6de60cff as ::core::ffi::c_ulonglong, - 0xef1ed5546e415390 as ::core::ffi::c_ulonglong, - 0xa8b4afbdc5a6aca4 as ::core::ffi::c_ulonglong, - 0x1b9ae303c601f3cb as ::core::ffi::c_ulonglong, - 0x56ed3e2f9e224471 as ::core::ffi::c_ulonglong, - 0xe5c372919d851b1e as ::core::ffi::c_ulonglong, - 0xa26908783662e42a as ::core::ffi::c_ulonglong, - 0x114744c635c5bb45 as ::core::ffi::c_ulonglong, - 0x2d3dfdab61ad1a42 as ::core::ffi::c_ulonglong, - 0x9e13b115620a452d as ::core::ffi::c_ulonglong, - 0xd9b9cbfcc9edba19 as ::core::ffi::c_ulonglong, - 0x6a978742ca4ae576 as ::core::ffi::c_ulonglong, - 0xa14cb926613cf817 as ::core::ffi::c_ulonglong, - 0x1262f598629ba778 as ::core::ffi::c_ulonglong, - 0x55c88f71c97c584c as ::core::ffi::c_ulonglong, - 0xe6e6c3cfcadb0723 as ::core::ffi::c_ulonglong, - 0xda9c7aa29eb3a624 as ::core::ffi::c_ulonglong, - 0x69b2361c9d14f94b as ::core::ffi::c_ulonglong, - 0x2e184cf536f3067f as ::core::ffi::c_ulonglong, - 0x9d36004b35545910 as ::core::ffi::c_ulonglong, - 0x2b769f17cf112238 as ::core::ffi::c_ulonglong, - 0x9858d3a9ccb67d57 as ::core::ffi::c_ulonglong, - 0xdff2a94067518263 as ::core::ffi::c_ulonglong, - 0x6cdce5fe64f6dd0c as ::core::ffi::c_ulonglong, - 0x50a65c93309e7c0b as ::core::ffi::c_ulonglong, - 0xe388102d33392364 as ::core::ffi::c_ulonglong, - 0xa4226ac498dedc50 as ::core::ffi::c_ulonglong, - 0x170c267a9b79833f as ::core::ffi::c_ulonglong, - 0xdcd7181e300f9e5e as ::core::ffi::c_ulonglong, - 0x6ff954a033a8c131 as ::core::ffi::c_ulonglong, - 0x28532e49984f3e05 as ::core::ffi::c_ulonglong, - 0x9b7d62f79be8616a as ::core::ffi::c_ulonglong, - 0xa707db9acf80c06d as ::core::ffi::c_ulonglong, - 0x14299724cc279f02 as ::core::ffi::c_ulonglong, - 0x5383edcd67c06036 as ::core::ffi::c_ulonglong, - 0xe0ada17364673f59 as ::core::ffi::c_ulonglong, + 0, + 0xb32e4cbe03a75f6f, + 0xf4843657a840a05b, + 0x47aa7ae9abe7ff34, + 0x7bd0c384ff8f5e33, + 0xc8fe8f3afc28015c, + 0x8f54f5d357cffe68, + 0x3c7ab96d5468a107, + 0xf7a18709ff1ebc66, + 0x448fcbb7fcb9e309, + 0x325b15e575e1c3d, + 0xb00bfde054f94352, + 0x8c71448d0091e255, + 0x3f5f08330336bd3a, + 0x78f572daa8d1420e, + 0xcbdb3e64ab761d61, + 0x7d9ba13851336649, + 0xceb5ed8652943926, + 0x891f976ff973c612, + 0x3a31dbd1fad4997d, + 0x64b62bcaebc387a, + 0xb5652e02ad1b6715, + 0xf2cf54eb06fc9821, + 0x41e11855055bc74e, + 0x8a3a2631ae2dda2f, + 0x39146a8fad8a8540, + 0x7ebe1066066d7a74, + 0xcd905cd805ca251b, + 0xf1eae5b551a2841c, + 0x42c4a90b5205db73, + 0x56ed3e2f9e22447, + 0xb6409f5cfa457b28, + 0xfb374270a266cc92, + 0x48190ecea1c193fd, + 0xfb374270a266cc9, + 0xbc9d3899098133a6, + 0x80e781f45de992a1, + 0x33c9cd4a5e4ecdce, + 0x7463b7a3f5a932fa, + 0xc74dfb1df60e6d95, + 0xc96c5795d7870f4, + 0xbfb889c75edf2f9b, + 0xf812f32ef538d0af, + 0x4b3cbf90f69f8fc0, + 0x774606fda2f72ec7, + 0xc4684a43a15071a8, + 0x83c230aa0ab78e9c, + 0x30ec7c140910d1f3, + 0x86ace348f355aadb, + 0x3582aff6f0f2f5b4, + 0x7228d51f5b150a80, + 0xc10699a158b255ef, + 0xfd7c20cc0cdaf4e8, + 0x4e526c720f7dab87, + 0x9f8169ba49a54b3, + 0xbad65a25a73d0bdc, + 0x710d64410c4b16bd, + 0xc22328ff0fec49d2, + 0x85895216a40bb6e6, + 0x36a71ea8a7ace989, + 0xadda7c5f3c4488e, + 0xb9f3eb7bf06317e1, + 0xfe5991925b84e8d5, + 0x4d77dd2c5823b7ba, + 0x64b62bcaebc387a1, + 0xd7986774e864d8ce, + 0x90321d9d438327fa, + 0x231c512340247895, + 0x1f66e84e144cd992, + 0xac48a4f017eb86fd, + 0xebe2de19bc0c79c9, + 0x58cc92a7bfab26a6, + 0x9317acc314dd3bc7, + 0x2039e07d177a64a8, + 0x67939a94bc9d9b9c, + 0xd4bdd62abf3ac4f3, + 0xe8c76f47eb5265f4, + 0x5be923f9e8f53a9b, + 0x1c4359104312c5af, + 0xaf6d15ae40b59ac0, + 0x192d8af2baf0e1e8, + 0xaa03c64cb957be87, + 0xeda9bca512b041b3, + 0x5e87f01b11171edc, + 0x62fd4976457fbfdb, + 0xd1d305c846d8e0b4, + 0x96797f21ed3f1f80, + 0x2557339fee9840ef, + 0xee8c0dfb45ee5d8e, + 0x5da24145464902e1, + 0x1a083bacedaefdd5, + 0xa9267712ee09a2ba, + 0x955cce7fba6103bd, + 0x267282c1b9c65cd2, + 0x61d8f8281221a3e6, + 0xd2f6b4961186fc89, + 0x9f8169ba49a54b33, + 0x2caf25044a02145c, + 0x6b055fede1e5eb68, + 0xd82b1353e242b407, + 0xe451aa3eb62a1500, + 0x577fe680b58d4a6f, + 0x10d59c691e6ab55b, + 0xa3fbd0d71dcdea34, + 0x6820eeb3b6bbf755, + 0xdb0ea20db51ca83a, + 0x9ca4d8e41efb570e, + 0x2f8a945a1d5c0861, + 0x13f02d374934a966, + 0xa0de61894a93f609, + 0xe7741b60e174093d, + 0x545a57dee2d35652, + 0xe21ac88218962d7a, + 0x5134843c1b317215, + 0x169efed5b0d68d21, + 0xa5b0b26bb371d24e, + 0x99ca0b06e7197349, + 0x2ae447b8e4be2c26, + 0x6d4e3d514f59d312, + 0xde6071ef4cfe8c7d, + 0x15bb4f8be788911c, + 0xa6950335e42fce73, + 0xe13f79dc4fc83147, + 0x521135624c6f6e28, + 0x6e6b8c0f1807cf2f, + 0xdd45c0b11ba09040, + 0x9aefba58b0476f74, + 0x29c1f6e6b3e0301b, + 0xc96c5795d7870f42, + 0x7a421b2bd420502d, + 0x3de861c27fc7af19, + 0x8ec62d7c7c60f076, + 0xb2bc941128085171, + 0x192d8af2baf0e1e, + 0x4638a2468048f12a, + 0xf516eef883efae45, + 0x3ecdd09c2899b324, + 0x8de39c222b3eec4b, + 0xca49e6cb80d9137f, + 0x7967aa75837e4c10, + 0x451d1318d716ed17, + 0xf6335fa6d4b1b278, + 0xb199254f7f564d4c, + 0x2b769f17cf11223, + 0xb4f7f6ad86b4690b, + 0x7d9ba1385133664, + 0x4073c0fa2ef4c950, + 0xf35d8c442d53963f, + 0xcf273529793b3738, + 0x7c0979977a9c6857, + 0x3ba3037ed17b9763, + 0x888d4fc0d2dcc80c, + 0x435671a479aad56d, + 0xf0783d1a7a0d8a02, + 0xb7d247f3d1ea7536, + 0x4fc0b4dd24d2a59, + 0x3886b22086258b5e, + 0x8ba8fe9e8582d431, + 0xcc0284772e652b05, + 0x7f2cc8c92dc2746a, + 0x325b15e575e1c3d0, + 0x8175595b76469cbf, + 0xc6df23b2dda1638b, + 0x75f16f0cde063ce4, + 0x498bd6618a6e9de3, + 0xfaa59adf89c9c28c, + 0xbd0fe036222e3db8, + 0xe21ac88218962d7, + 0xc5fa92ec8aff7fb6, + 0x76d4de52895820d9, + 0x317ea4bb22bfdfed, + 0x8250e80521188082, + 0xbe2a516875702185, + 0xd041dd676d77eea, + 0x4aae673fdd3081de, + 0xf9802b81de97deb1, + 0x4fc0b4dd24d2a599, + 0xfceef8632775faf6, + 0xbb44828a8c9205c2, + 0x86ace348f355aad, + 0x34107759db5dfbaa, + 0x873e3be7d8faa4c5, + 0xc094410e731d5bf1, + 0x73ba0db070ba049e, + 0xb86133d4dbcc19ff, + 0xb4f7f6ad86b4690, + 0x4ce50583738cb9a4, + 0xffcb493d702be6cb, + 0xc3b1f050244347cc, + 0x709fbcee27e418a3, + 0x3735c6078c03e797, + 0x841b8ab98fa4b8f8, + 0xadda7c5f3c4488e3, + 0x1ef430e13fe3d78c, + 0x595e4a08940428b8, + 0xea7006b697a377d7, + 0xd60abfdbc3cbd6d0, + 0x6524f365c06c89bf, + 0x228e898c6b8b768b, + 0x91a0c532682c29e4, + 0x5a7bfb56c35a3485, + 0xe955b7e8c0fd6bea, + 0xaeffcd016b1a94de, + 0x1dd181bf68bdcbb1, + 0x21ab38d23cd56ab6, + 0x9285746c3f7235d9, + 0xd52f0e859495caed, + 0x6601423b97329582, + 0xd041dd676d77eeaa, + 0x636f91d96ed0b1c5, + 0x24c5eb30c5374ef1, + 0x97eba78ec690119e, + 0xab911ee392f8b099, + 0x18bf525d915feff6, + 0x5f1528b43ab810c2, + 0xec3b640a391f4fad, + 0x27e05a6e926952cc, + 0x94ce16d091ce0da3, + 0xd3646c393a29f297, + 0x604a2087398eadf8, + 0x5c3099ea6de60cff, + 0xef1ed5546e415390, + 0xa8b4afbdc5a6aca4, + 0x1b9ae303c601f3cb, + 0x56ed3e2f9e224471, + 0xe5c372919d851b1e, + 0xa26908783662e42a, + 0x114744c635c5bb45, + 0x2d3dfdab61ad1a42, + 0x9e13b115620a452d, + 0xd9b9cbfcc9edba19, + 0x6a978742ca4ae576, + 0xa14cb926613cf817, + 0x1262f598629ba778, + 0x55c88f71c97c584c, + 0xe6e6c3cfcadb0723, + 0xda9c7aa29eb3a624, + 0x69b2361c9d14f94b, + 0x2e184cf536f3067f, + 0x9d36004b35545910, + 0x2b769f17cf112238, + 0x9858d3a9ccb67d57, + 0xdff2a94067518263, + 0x6cdce5fe64f6dd0c, + 0x50a65c93309e7c0b, + 0xe388102d33392364, + 0xa4226ac498dedc50, + 0x170c267a9b79833f, + 0xdcd7181e300f9e5e, + 0x6ff954a033a8c131, + 0x28532e49984f3e05, + 0x9b7d62f79be8616a, + 0xa707db9acf80c06d, + 0x14299724cc279f02, + 0x5383edcd67c06036, + 0xe0ada17364673f59, ], [ - 0 as ::core::ffi::c_ulonglong, - 0x54e979925cd0f10d as ::core::ffi::c_ulonglong, - 0xa9d2f324b9a1e21a as ::core::ffi::c_ulonglong, - 0xfd3b8ab6e5711317 as ::core::ffi::c_ulonglong, - 0xc17d4962dc4ddab1 as ::core::ffi::c_ulonglong, - 0x959430f0809d2bbc as ::core::ffi::c_ulonglong, - 0x68afba4665ec38ab as ::core::ffi::c_ulonglong, - 0x3c46c3d4393cc9a6 as ::core::ffi::c_ulonglong, - 0x10223dee1795abe7 as ::core::ffi::c_ulonglong, - 0x44cb447c4b455aea as ::core::ffi::c_ulonglong, - 0xb9f0cecaae3449fd as ::core::ffi::c_ulonglong, - 0xed19b758f2e4b8f0 as ::core::ffi::c_ulonglong, - 0xd15f748ccbd87156 as ::core::ffi::c_ulonglong, - 0x85b60d1e9708805b as ::core::ffi::c_ulonglong, - 0x788d87a87279934c as ::core::ffi::c_ulonglong, - 0x2c64fe3a2ea96241 as ::core::ffi::c_ulonglong, - 0x20447bdc2f2b57ce as ::core::ffi::c_ulonglong, - 0x74ad024e73fba6c3 as ::core::ffi::c_ulonglong, - 0x899688f8968ab5d4 as ::core::ffi::c_ulonglong, - 0xdd7ff16aca5a44d9 as ::core::ffi::c_ulonglong, - 0xe13932bef3668d7f as ::core::ffi::c_ulonglong, - 0xb5d04b2cafb67c72 as ::core::ffi::c_ulonglong, - 0x48ebc19a4ac76f65 as ::core::ffi::c_ulonglong, - 0x1c02b80816179e68 as ::core::ffi::c_ulonglong, - 0x3066463238befc29 as ::core::ffi::c_ulonglong, - 0x648f3fa0646e0d24 as ::core::ffi::c_ulonglong, - 0x99b4b516811f1e33 as ::core::ffi::c_ulonglong, - 0xcd5dcc84ddcfef3e as ::core::ffi::c_ulonglong, - 0xf11b0f50e4f32698 as ::core::ffi::c_ulonglong, - 0xa5f276c2b823d795 as ::core::ffi::c_ulonglong, - 0x58c9fc745d52c482 as ::core::ffi::c_ulonglong, - 0xc2085e60182358f as ::core::ffi::c_ulonglong, - 0x4088f7b85e56af9c as ::core::ffi::c_ulonglong, - 0x14618e2a02865e91 as ::core::ffi::c_ulonglong, - 0xe95a049ce7f74d86 as ::core::ffi::c_ulonglong, - 0xbdb37d0ebb27bc8b as ::core::ffi::c_ulonglong, - 0x81f5beda821b752d as ::core::ffi::c_ulonglong, - 0xd51cc748decb8420 as ::core::ffi::c_ulonglong, - 0x28274dfe3bba9737 as ::core::ffi::c_ulonglong, - 0x7cce346c676a663a as ::core::ffi::c_ulonglong, - 0x50aaca5649c3047b as ::core::ffi::c_ulonglong, - 0x443b3c41513f576 as ::core::ffi::c_ulonglong, - 0xf9783972f062e661 as ::core::ffi::c_ulonglong, - 0xad9140e0acb2176c as ::core::ffi::c_ulonglong, - 0x91d78334958edeca as ::core::ffi::c_ulonglong, - 0xc53efaa6c95e2fc7 as ::core::ffi::c_ulonglong, - 0x380570102c2f3cd0 as ::core::ffi::c_ulonglong, - 0x6cec098270ffcddd as ::core::ffi::c_ulonglong, - 0x60cc8c64717df852 as ::core::ffi::c_ulonglong, - 0x3425f5f62dad095f as ::core::ffi::c_ulonglong, - 0xc91e7f40c8dc1a48 as ::core::ffi::c_ulonglong, - 0x9df706d2940ceb45 as ::core::ffi::c_ulonglong, - 0xa1b1c506ad3022e3 as ::core::ffi::c_ulonglong, - 0xf558bc94f1e0d3ee as ::core::ffi::c_ulonglong, - 0x86336221491c0f9 as ::core::ffi::c_ulonglong, - 0x5c8a4fb0484131f4 as ::core::ffi::c_ulonglong, - 0x70eeb18a66e853b5 as ::core::ffi::c_ulonglong, - 0x2407c8183a38a2b8 as ::core::ffi::c_ulonglong, - 0xd93c42aedf49b1af as ::core::ffi::c_ulonglong, - 0x8dd53b3c839940a2 as ::core::ffi::c_ulonglong, - 0xb193f8e8baa58904 as ::core::ffi::c_ulonglong, - 0xe57a817ae6757809 as ::core::ffi::c_ulonglong, - 0x18410bcc03046b1e as ::core::ffi::c_ulonglong, - 0x4ca8725e5fd49a13 as ::core::ffi::c_ulonglong, - 0x8111ef70bcad5f38 as ::core::ffi::c_ulonglong, - 0xd5f896e2e07dae35 as ::core::ffi::c_ulonglong, - 0x28c31c54050cbd22 as ::core::ffi::c_ulonglong, - 0x7c2a65c659dc4c2f as ::core::ffi::c_ulonglong, - 0x406ca61260e08589 as ::core::ffi::c_ulonglong, - 0x1485df803c307484 as ::core::ffi::c_ulonglong, - 0xe9be5536d9416793 as ::core::ffi::c_ulonglong, - 0xbd572ca48591969e as ::core::ffi::c_ulonglong, - 0x9133d29eab38f4df as ::core::ffi::c_ulonglong, - 0xc5daab0cf7e805d2 as ::core::ffi::c_ulonglong, - 0x38e121ba129916c5 as ::core::ffi::c_ulonglong, - 0x6c0858284e49e7c8 as ::core::ffi::c_ulonglong, - 0x504e9bfc77752e6e as ::core::ffi::c_ulonglong, - 0x4a7e26e2ba5df63 as ::core::ffi::c_ulonglong, - 0xf99c68d8ced4cc74 as ::core::ffi::c_ulonglong, - 0xad75114a92043d79 as ::core::ffi::c_ulonglong, - 0xa15594ac938608f6 as ::core::ffi::c_ulonglong, - 0xf5bced3ecf56f9fb as ::core::ffi::c_ulonglong, - 0x88767882a27eaec as ::core::ffi::c_ulonglong, - 0x5c6e1e1a76f71be1 as ::core::ffi::c_ulonglong, - 0x6028ddce4fcbd247 as ::core::ffi::c_ulonglong, - 0x34c1a45c131b234a as ::core::ffi::c_ulonglong, - 0xc9fa2eeaf66a305d as ::core::ffi::c_ulonglong, - 0x9d135778aabac150 as ::core::ffi::c_ulonglong, - 0xb177a9428413a311 as ::core::ffi::c_ulonglong, - 0xe59ed0d0d8c3521c as ::core::ffi::c_ulonglong, - 0x18a55a663db2410b as ::core::ffi::c_ulonglong, - 0x4c4c23f46162b006 as ::core::ffi::c_ulonglong, - 0x700ae020585e79a0 as ::core::ffi::c_ulonglong, - 0x24e399b2048e88ad as ::core::ffi::c_ulonglong, - 0xd9d81304e1ff9bba as ::core::ffi::c_ulonglong, - 0x8d316a96bd2f6ab7 as ::core::ffi::c_ulonglong, - 0xc19918c8e2fbf0a4 as ::core::ffi::c_ulonglong, - 0x9570615abe2b01a9 as ::core::ffi::c_ulonglong, - 0x684bebec5b5a12be as ::core::ffi::c_ulonglong, - 0x3ca2927e078ae3b3 as ::core::ffi::c_ulonglong, - 0xe451aa3eb62a15 as ::core::ffi::c_ulonglong, - 0x540d28386266db18 as ::core::ffi::c_ulonglong, - 0xa936a28e8717c80f as ::core::ffi::c_ulonglong, - 0xfddfdb1cdbc73902 as ::core::ffi::c_ulonglong, - 0xd1bb2526f56e5b43 as ::core::ffi::c_ulonglong, - 0x85525cb4a9beaa4e as ::core::ffi::c_ulonglong, - 0x7869d6024ccfb959 as ::core::ffi::c_ulonglong, - 0x2c80af90101f4854 as ::core::ffi::c_ulonglong, - 0x10c66c44292381f2 as ::core::ffi::c_ulonglong, - 0x442f15d675f370ff as ::core::ffi::c_ulonglong, - 0xb9149f60908263e8 as ::core::ffi::c_ulonglong, - 0xedfde6f2cc5292e5 as ::core::ffi::c_ulonglong, - 0xe1dd6314cdd0a76a as ::core::ffi::c_ulonglong, - 0xb5341a8691005667 as ::core::ffi::c_ulonglong, - 0x480f903074714570 as ::core::ffi::c_ulonglong, - 0x1ce6e9a228a1b47d as ::core::ffi::c_ulonglong, - 0x20a02a76119d7ddb as ::core::ffi::c_ulonglong, - 0x744953e44d4d8cd6 as ::core::ffi::c_ulonglong, - 0x8972d952a83c9fc1 as ::core::ffi::c_ulonglong, - 0xdd9ba0c0f4ec6ecc as ::core::ffi::c_ulonglong, - 0xf1ff5efada450c8d as ::core::ffi::c_ulonglong, - 0xa51627688695fd80 as ::core::ffi::c_ulonglong, - 0x582dadde63e4ee97 as ::core::ffi::c_ulonglong, - 0xcc4d44c3f341f9a as ::core::ffi::c_ulonglong, - 0x308217980608d63c as ::core::ffi::c_ulonglong, - 0x646b6e0a5ad82731 as ::core::ffi::c_ulonglong, - 0x9950e4bcbfa93426 as ::core::ffi::c_ulonglong, - 0xcdb99d2ee379c52b as ::core::ffi::c_ulonglong, - 0x90fb71cad654a0f5 as ::core::ffi::c_ulonglong, - 0xc41208588a8451f8 as ::core::ffi::c_ulonglong, - 0x392982ee6ff542ef as ::core::ffi::c_ulonglong, - 0x6dc0fb7c3325b3e2 as ::core::ffi::c_ulonglong, - 0x518638a80a197a44 as ::core::ffi::c_ulonglong, - 0x56f413a56c98b49 as ::core::ffi::c_ulonglong, - 0xf854cb8cb3b8985e as ::core::ffi::c_ulonglong, - 0xacbdb21eef686953 as ::core::ffi::c_ulonglong, - 0x80d94c24c1c10b12 as ::core::ffi::c_ulonglong, - 0xd43035b69d11fa1f as ::core::ffi::c_ulonglong, - 0x290bbf007860e908 as ::core::ffi::c_ulonglong, - 0x7de2c69224b01805 as ::core::ffi::c_ulonglong, - 0x41a405461d8cd1a3 as ::core::ffi::c_ulonglong, - 0x154d7cd4415c20ae as ::core::ffi::c_ulonglong, - 0xe876f662a42d33b9 as ::core::ffi::c_ulonglong, - 0xbc9f8ff0f8fdc2b4 as ::core::ffi::c_ulonglong, - 0xb0bf0a16f97ff73b as ::core::ffi::c_ulonglong, - 0xe4567384a5af0636 as ::core::ffi::c_ulonglong, - 0x196df93240de1521 as ::core::ffi::c_ulonglong, - 0x4d8480a01c0ee42c as ::core::ffi::c_ulonglong, - 0x71c2437425322d8a as ::core::ffi::c_ulonglong, - 0x252b3ae679e2dc87 as ::core::ffi::c_ulonglong, - 0xd810b0509c93cf90 as ::core::ffi::c_ulonglong, - 0x8cf9c9c2c0433e9d as ::core::ffi::c_ulonglong, - 0xa09d37f8eeea5cdc as ::core::ffi::c_ulonglong, - 0xf4744e6ab23aadd1 as ::core::ffi::c_ulonglong, - 0x94fc4dc574bbec6 as ::core::ffi::c_ulonglong, - 0x5da6bd4e0b9b4fcb as ::core::ffi::c_ulonglong, - 0x61e07e9a32a7866d as ::core::ffi::c_ulonglong, - 0x350907086e777760 as ::core::ffi::c_ulonglong, - 0xc8328dbe8b066477 as ::core::ffi::c_ulonglong, - 0x9cdbf42cd7d6957a as ::core::ffi::c_ulonglong, - 0xd073867288020f69 as ::core::ffi::c_ulonglong, - 0x849affe0d4d2fe64 as ::core::ffi::c_ulonglong, - 0x79a1755631a3ed73 as ::core::ffi::c_ulonglong, - 0x2d480cc46d731c7e as ::core::ffi::c_ulonglong, - 0x110ecf10544fd5d8 as ::core::ffi::c_ulonglong, - 0x45e7b682089f24d5 as ::core::ffi::c_ulonglong, - 0xb8dc3c34edee37c2 as ::core::ffi::c_ulonglong, - 0xec3545a6b13ec6cf as ::core::ffi::c_ulonglong, - 0xc051bb9c9f97a48e as ::core::ffi::c_ulonglong, - 0x94b8c20ec3475583 as ::core::ffi::c_ulonglong, - 0x698348b826364694 as ::core::ffi::c_ulonglong, - 0x3d6a312a7ae6b799 as ::core::ffi::c_ulonglong, - 0x12cf2fe43da7e3f as ::core::ffi::c_ulonglong, - 0x55c58b6c1f0a8f32 as ::core::ffi::c_ulonglong, - 0xa8fe01dafa7b9c25 as ::core::ffi::c_ulonglong, - 0xfc177848a6ab6d28 as ::core::ffi::c_ulonglong, - 0xf037fdaea72958a7 as ::core::ffi::c_ulonglong, - 0xa4de843cfbf9a9aa as ::core::ffi::c_ulonglong, - 0x59e50e8a1e88babd as ::core::ffi::c_ulonglong, - 0xd0c771842584bb0 as ::core::ffi::c_ulonglong, - 0x314ab4cc7b648216 as ::core::ffi::c_ulonglong, - 0x65a3cd5e27b4731b as ::core::ffi::c_ulonglong, - 0x989847e8c2c5600c as ::core::ffi::c_ulonglong, - 0xcc713e7a9e159101 as ::core::ffi::c_ulonglong, - 0xe015c040b0bcf340 as ::core::ffi::c_ulonglong, - 0xb4fcb9d2ec6c024d as ::core::ffi::c_ulonglong, - 0x49c73364091d115a as ::core::ffi::c_ulonglong, - 0x1d2e4af655cde057 as ::core::ffi::c_ulonglong, - 0x216889226cf129f1 as ::core::ffi::c_ulonglong, - 0x7581f0b03021d8fc as ::core::ffi::c_ulonglong, - 0x88ba7a06d550cbeb as ::core::ffi::c_ulonglong, - 0xdc53039489803ae6 as ::core::ffi::c_ulonglong, - 0x11ea9eba6af9ffcd as ::core::ffi::c_ulonglong, - 0x4503e72836290ec0 as ::core::ffi::c_ulonglong, - 0xb8386d9ed3581dd7 as ::core::ffi::c_ulonglong, - 0xecd1140c8f88ecda as ::core::ffi::c_ulonglong, - 0xd097d7d8b6b4257c as ::core::ffi::c_ulonglong, - 0x847eae4aea64d471 as ::core::ffi::c_ulonglong, - 0x794524fc0f15c766 as ::core::ffi::c_ulonglong, - 0x2dac5d6e53c5366b as ::core::ffi::c_ulonglong, - 0x1c8a3547d6c542a as ::core::ffi::c_ulonglong, - 0x5521dac621bca527 as ::core::ffi::c_ulonglong, - 0xa81a5070c4cdb630 as ::core::ffi::c_ulonglong, - 0xfcf329e2981d473d as ::core::ffi::c_ulonglong, - 0xc0b5ea36a1218e9b as ::core::ffi::c_ulonglong, - 0x945c93a4fdf17f96 as ::core::ffi::c_ulonglong, - 0x6967191218806c81 as ::core::ffi::c_ulonglong, - 0x3d8e608044509d8c as ::core::ffi::c_ulonglong, - 0x31aee56645d2a803 as ::core::ffi::c_ulonglong, - 0x65479cf41902590e as ::core::ffi::c_ulonglong, - 0x987c1642fc734a19 as ::core::ffi::c_ulonglong, - 0xcc956fd0a0a3bb14 as ::core::ffi::c_ulonglong, - 0xf0d3ac04999f72b2 as ::core::ffi::c_ulonglong, - 0xa43ad596c54f83bf as ::core::ffi::c_ulonglong, - 0x59015f20203e90a8 as ::core::ffi::c_ulonglong, - 0xde826b27cee61a5 as ::core::ffi::c_ulonglong, - 0x218cd888524703e4 as ::core::ffi::c_ulonglong, - 0x7565a11a0e97f2e9 as ::core::ffi::c_ulonglong, - 0x885e2bacebe6e1fe as ::core::ffi::c_ulonglong, - 0xdcb7523eb73610f3 as ::core::ffi::c_ulonglong, - 0xe0f191ea8e0ad955 as ::core::ffi::c_ulonglong, - 0xb418e878d2da2858 as ::core::ffi::c_ulonglong, - 0x492362ce37ab3b4f as ::core::ffi::c_ulonglong, - 0x1dca1b5c6b7bca42 as ::core::ffi::c_ulonglong, - 0x5162690234af5051 as ::core::ffi::c_ulonglong, - 0x58b1090687fa15c as ::core::ffi::c_ulonglong, - 0xf8b09a268d0eb24b as ::core::ffi::c_ulonglong, - 0xac59e3b4d1de4346 as ::core::ffi::c_ulonglong, - 0x901f2060e8e28ae0 as ::core::ffi::c_ulonglong, - 0xc4f659f2b4327bed as ::core::ffi::c_ulonglong, - 0x39cdd344514368fa as ::core::ffi::c_ulonglong, - 0x6d24aad60d9399f7 as ::core::ffi::c_ulonglong, - 0x414054ec233afbb6 as ::core::ffi::c_ulonglong, - 0x15a92d7e7fea0abb as ::core::ffi::c_ulonglong, - 0xe892a7c89a9b19ac as ::core::ffi::c_ulonglong, - 0xbc7bde5ac64be8a1 as ::core::ffi::c_ulonglong, - 0x803d1d8eff772107 as ::core::ffi::c_ulonglong, - 0xd4d4641ca3a7d00a as ::core::ffi::c_ulonglong, - 0x29efeeaa46d6c31d as ::core::ffi::c_ulonglong, - 0x7d0697381a063210 as ::core::ffi::c_ulonglong, - 0x712612de1b84079f as ::core::ffi::c_ulonglong, - 0x25cf6b4c4754f692 as ::core::ffi::c_ulonglong, - 0xd8f4e1faa225e585 as ::core::ffi::c_ulonglong, - 0x8c1d9868fef51488 as ::core::ffi::c_ulonglong, - 0xb05b5bbcc7c9dd2e as ::core::ffi::c_ulonglong, - 0xe4b2222e9b192c23 as ::core::ffi::c_ulonglong, - 0x1989a8987e683f34 as ::core::ffi::c_ulonglong, - 0x4d60d10a22b8ce39 as ::core::ffi::c_ulonglong, - 0x61042f300c11ac78 as ::core::ffi::c_ulonglong, - 0x35ed56a250c15d75 as ::core::ffi::c_ulonglong, - 0xc8d6dc14b5b04e62 as ::core::ffi::c_ulonglong, - 0x9c3fa586e960bf6f as ::core::ffi::c_ulonglong, - 0xa0796652d05c76c9 as ::core::ffi::c_ulonglong, - 0xf4901fc08c8c87c4 as ::core::ffi::c_ulonglong, - 0x9ab957669fd94d3 as ::core::ffi::c_ulonglong, - 0x5d42ece4352d65de as ::core::ffi::c_ulonglong, + 0, + 0x54e979925cd0f10d, + 0xa9d2f324b9a1e21a, + 0xfd3b8ab6e5711317, + 0xc17d4962dc4ddab1, + 0x959430f0809d2bbc, + 0x68afba4665ec38ab, + 0x3c46c3d4393cc9a6, + 0x10223dee1795abe7, + 0x44cb447c4b455aea, + 0xb9f0cecaae3449fd, + 0xed19b758f2e4b8f0, + 0xd15f748ccbd87156, + 0x85b60d1e9708805b, + 0x788d87a87279934c, + 0x2c64fe3a2ea96241, + 0x20447bdc2f2b57ce, + 0x74ad024e73fba6c3, + 0x899688f8968ab5d4, + 0xdd7ff16aca5a44d9, + 0xe13932bef3668d7f, + 0xb5d04b2cafb67c72, + 0x48ebc19a4ac76f65, + 0x1c02b80816179e68, + 0x3066463238befc29, + 0x648f3fa0646e0d24, + 0x99b4b516811f1e33, + 0xcd5dcc84ddcfef3e, + 0xf11b0f50e4f32698, + 0xa5f276c2b823d795, + 0x58c9fc745d52c482, + 0xc2085e60182358f, + 0x4088f7b85e56af9c, + 0x14618e2a02865e91, + 0xe95a049ce7f74d86, + 0xbdb37d0ebb27bc8b, + 0x81f5beda821b752d, + 0xd51cc748decb8420, + 0x28274dfe3bba9737, + 0x7cce346c676a663a, + 0x50aaca5649c3047b, + 0x443b3c41513f576, + 0xf9783972f062e661, + 0xad9140e0acb2176c, + 0x91d78334958edeca, + 0xc53efaa6c95e2fc7, + 0x380570102c2f3cd0, + 0x6cec098270ffcddd, + 0x60cc8c64717df852, + 0x3425f5f62dad095f, + 0xc91e7f40c8dc1a48, + 0x9df706d2940ceb45, + 0xa1b1c506ad3022e3, + 0xf558bc94f1e0d3ee, + 0x86336221491c0f9, + 0x5c8a4fb0484131f4, + 0x70eeb18a66e853b5, + 0x2407c8183a38a2b8, + 0xd93c42aedf49b1af, + 0x8dd53b3c839940a2, + 0xb193f8e8baa58904, + 0xe57a817ae6757809, + 0x18410bcc03046b1e, + 0x4ca8725e5fd49a13, + 0x8111ef70bcad5f38, + 0xd5f896e2e07dae35, + 0x28c31c54050cbd22, + 0x7c2a65c659dc4c2f, + 0x406ca61260e08589, + 0x1485df803c307484, + 0xe9be5536d9416793, + 0xbd572ca48591969e, + 0x9133d29eab38f4df, + 0xc5daab0cf7e805d2, + 0x38e121ba129916c5, + 0x6c0858284e49e7c8, + 0x504e9bfc77752e6e, + 0x4a7e26e2ba5df63, + 0xf99c68d8ced4cc74, + 0xad75114a92043d79, + 0xa15594ac938608f6, + 0xf5bced3ecf56f9fb, + 0x88767882a27eaec, + 0x5c6e1e1a76f71be1, + 0x6028ddce4fcbd247, + 0x34c1a45c131b234a, + 0xc9fa2eeaf66a305d, + 0x9d135778aabac150, + 0xb177a9428413a311, + 0xe59ed0d0d8c3521c, + 0x18a55a663db2410b, + 0x4c4c23f46162b006, + 0x700ae020585e79a0, + 0x24e399b2048e88ad, + 0xd9d81304e1ff9bba, + 0x8d316a96bd2f6ab7, + 0xc19918c8e2fbf0a4, + 0x9570615abe2b01a9, + 0x684bebec5b5a12be, + 0x3ca2927e078ae3b3, + 0xe451aa3eb62a15, + 0x540d28386266db18, + 0xa936a28e8717c80f, + 0xfddfdb1cdbc73902, + 0xd1bb2526f56e5b43, + 0x85525cb4a9beaa4e, + 0x7869d6024ccfb959, + 0x2c80af90101f4854, + 0x10c66c44292381f2, + 0x442f15d675f370ff, + 0xb9149f60908263e8, + 0xedfde6f2cc5292e5, + 0xe1dd6314cdd0a76a, + 0xb5341a8691005667, + 0x480f903074714570, + 0x1ce6e9a228a1b47d, + 0x20a02a76119d7ddb, + 0x744953e44d4d8cd6, + 0x8972d952a83c9fc1, + 0xdd9ba0c0f4ec6ecc, + 0xf1ff5efada450c8d, + 0xa51627688695fd80, + 0x582dadde63e4ee97, + 0xcc4d44c3f341f9a, + 0x308217980608d63c, + 0x646b6e0a5ad82731, + 0x9950e4bcbfa93426, + 0xcdb99d2ee379c52b, + 0x90fb71cad654a0f5, + 0xc41208588a8451f8, + 0x392982ee6ff542ef, + 0x6dc0fb7c3325b3e2, + 0x518638a80a197a44, + 0x56f413a56c98b49, + 0xf854cb8cb3b8985e, + 0xacbdb21eef686953, + 0x80d94c24c1c10b12, + 0xd43035b69d11fa1f, + 0x290bbf007860e908, + 0x7de2c69224b01805, + 0x41a405461d8cd1a3, + 0x154d7cd4415c20ae, + 0xe876f662a42d33b9, + 0xbc9f8ff0f8fdc2b4, + 0xb0bf0a16f97ff73b, + 0xe4567384a5af0636, + 0x196df93240de1521, + 0x4d8480a01c0ee42c, + 0x71c2437425322d8a, + 0x252b3ae679e2dc87, + 0xd810b0509c93cf90, + 0x8cf9c9c2c0433e9d, + 0xa09d37f8eeea5cdc, + 0xf4744e6ab23aadd1, + 0x94fc4dc574bbec6, + 0x5da6bd4e0b9b4fcb, + 0x61e07e9a32a7866d, + 0x350907086e777760, + 0xc8328dbe8b066477, + 0x9cdbf42cd7d6957a, + 0xd073867288020f69, + 0x849affe0d4d2fe64, + 0x79a1755631a3ed73, + 0x2d480cc46d731c7e, + 0x110ecf10544fd5d8, + 0x45e7b682089f24d5, + 0xb8dc3c34edee37c2, + 0xec3545a6b13ec6cf, + 0xc051bb9c9f97a48e, + 0x94b8c20ec3475583, + 0x698348b826364694, + 0x3d6a312a7ae6b799, + 0x12cf2fe43da7e3f, + 0x55c58b6c1f0a8f32, + 0xa8fe01dafa7b9c25, + 0xfc177848a6ab6d28, + 0xf037fdaea72958a7, + 0xa4de843cfbf9a9aa, + 0x59e50e8a1e88babd, + 0xd0c771842584bb0, + 0x314ab4cc7b648216, + 0x65a3cd5e27b4731b, + 0x989847e8c2c5600c, + 0xcc713e7a9e159101, + 0xe015c040b0bcf340, + 0xb4fcb9d2ec6c024d, + 0x49c73364091d115a, + 0x1d2e4af655cde057, + 0x216889226cf129f1, + 0x7581f0b03021d8fc, + 0x88ba7a06d550cbeb, + 0xdc53039489803ae6, + 0x11ea9eba6af9ffcd, + 0x4503e72836290ec0, + 0xb8386d9ed3581dd7, + 0xecd1140c8f88ecda, + 0xd097d7d8b6b4257c, + 0x847eae4aea64d471, + 0x794524fc0f15c766, + 0x2dac5d6e53c5366b, + 0x1c8a3547d6c542a, + 0x5521dac621bca527, + 0xa81a5070c4cdb630, + 0xfcf329e2981d473d, + 0xc0b5ea36a1218e9b, + 0x945c93a4fdf17f96, + 0x6967191218806c81, + 0x3d8e608044509d8c, + 0x31aee56645d2a803, + 0x65479cf41902590e, + 0x987c1642fc734a19, + 0xcc956fd0a0a3bb14, + 0xf0d3ac04999f72b2, + 0xa43ad596c54f83bf, + 0x59015f20203e90a8, + 0xde826b27cee61a5, + 0x218cd888524703e4, + 0x7565a11a0e97f2e9, + 0x885e2bacebe6e1fe, + 0xdcb7523eb73610f3, + 0xe0f191ea8e0ad955, + 0xb418e878d2da2858, + 0x492362ce37ab3b4f, + 0x1dca1b5c6b7bca42, + 0x5162690234af5051, + 0x58b1090687fa15c, + 0xf8b09a268d0eb24b, + 0xac59e3b4d1de4346, + 0x901f2060e8e28ae0, + 0xc4f659f2b4327bed, + 0x39cdd344514368fa, + 0x6d24aad60d9399f7, + 0x414054ec233afbb6, + 0x15a92d7e7fea0abb, + 0xe892a7c89a9b19ac, + 0xbc7bde5ac64be8a1, + 0x803d1d8eff772107, + 0xd4d4641ca3a7d00a, + 0x29efeeaa46d6c31d, + 0x7d0697381a063210, + 0x712612de1b84079f, + 0x25cf6b4c4754f692, + 0xd8f4e1faa225e585, + 0x8c1d9868fef51488, + 0xb05b5bbcc7c9dd2e, + 0xe4b2222e9b192c23, + 0x1989a8987e683f34, + 0x4d60d10a22b8ce39, + 0x61042f300c11ac78, + 0x35ed56a250c15d75, + 0xc8d6dc14b5b04e62, + 0x9c3fa586e960bf6f, + 0xa0796652d05c76c9, + 0xf4901fc08c8c87c4, + 0x9ab957669fd94d3, + 0x5d42ece4352d65de, ], [ - 0 as ::core::ffi::c_ulonglong, - 0x3f0be14a916a6dcb as ::core::ffi::c_ulonglong, - 0x7e17c29522d4db96 as ::core::ffi::c_ulonglong, - 0x411c23dfb3beb65d as ::core::ffi::c_ulonglong, - 0xfc2f852a45a9b72c as ::core::ffi::c_ulonglong, - 0xc3246460d4c3dae7 as ::core::ffi::c_ulonglong, - 0x823847bf677d6cba as ::core::ffi::c_ulonglong, - 0xbd33a6f5f6170171 as ::core::ffi::c_ulonglong, - 0x6a87a57f245d70dd as ::core::ffi::c_ulonglong, - 0x558c4435b5371d16 as ::core::ffi::c_ulonglong, - 0x149067ea0689ab4b as ::core::ffi::c_ulonglong, - 0x2b9b86a097e3c680 as ::core::ffi::c_ulonglong, - 0x96a8205561f4c7f1 as ::core::ffi::c_ulonglong, - 0xa9a3c11ff09eaa3a as ::core::ffi::c_ulonglong, - 0xe8bfe2c043201c67 as ::core::ffi::c_ulonglong, - 0xd7b4038ad24a71ac as ::core::ffi::c_ulonglong, - 0xd50f4afe48bae1ba as ::core::ffi::c_ulonglong, - 0xea04abb4d9d08c71 as ::core::ffi::c_ulonglong, - 0xab18886b6a6e3a2c as ::core::ffi::c_ulonglong, - 0x94136921fb0457e7 as ::core::ffi::c_ulonglong, - 0x2920cfd40d135696 as ::core::ffi::c_ulonglong, - 0x162b2e9e9c793b5d as ::core::ffi::c_ulonglong, - 0x57370d412fc78d00 as ::core::ffi::c_ulonglong, - 0x683cec0bbeade0cb as ::core::ffi::c_ulonglong, - 0xbf88ef816ce79167 as ::core::ffi::c_ulonglong, - 0x80830ecbfd8dfcac as ::core::ffi::c_ulonglong, - 0xc19f2d144e334af1 as ::core::ffi::c_ulonglong, - 0xfe94cc5edf59273a as ::core::ffi::c_ulonglong, - 0x43a76aab294e264b as ::core::ffi::c_ulonglong, - 0x7cac8be1b8244b80 as ::core::ffi::c_ulonglong, - 0x3db0a83e0b9afddd as ::core::ffi::c_ulonglong, - 0x2bb49749af09016 as ::core::ffi::c_ulonglong, - 0x38c63ad73e7bddf1 as ::core::ffi::c_ulonglong, - 0x7cddb9daf11b03a as ::core::ffi::c_ulonglong, - 0x46d1f8421caf0667 as ::core::ffi::c_ulonglong, - 0x79da19088dc56bac as ::core::ffi::c_ulonglong, - 0xc4e9bffd7bd26add as ::core::ffi::c_ulonglong, - 0xfbe25eb7eab80716 as ::core::ffi::c_ulonglong, - 0xbafe7d685906b14b as ::core::ffi::c_ulonglong, - 0x85f59c22c86cdc80 as ::core::ffi::c_ulonglong, - 0x52419fa81a26ad2c as ::core::ffi::c_ulonglong, - 0x6d4a7ee28b4cc0e7 as ::core::ffi::c_ulonglong, - 0x2c565d3d38f276ba as ::core::ffi::c_ulonglong, - 0x135dbc77a9981b71 as ::core::ffi::c_ulonglong, - 0xae6e1a825f8f1a00 as ::core::ffi::c_ulonglong, - 0x9165fbc8cee577cb as ::core::ffi::c_ulonglong, - 0xd079d8177d5bc196 as ::core::ffi::c_ulonglong, - 0xef72395dec31ac5d as ::core::ffi::c_ulonglong, - 0xedc9702976c13c4b as ::core::ffi::c_ulonglong, - 0xd2c29163e7ab5180 as ::core::ffi::c_ulonglong, - 0x93deb2bc5415e7dd as ::core::ffi::c_ulonglong, - 0xacd553f6c57f8a16 as ::core::ffi::c_ulonglong, - 0x11e6f50333688b67 as ::core::ffi::c_ulonglong, - 0x2eed1449a202e6ac as ::core::ffi::c_ulonglong, - 0x6ff1379611bc50f1 as ::core::ffi::c_ulonglong, - 0x50fad6dc80d63d3a as ::core::ffi::c_ulonglong, - 0x874ed556529c4c96 as ::core::ffi::c_ulonglong, - 0xb845341cc3f6215d as ::core::ffi::c_ulonglong, - 0xf95917c370489700 as ::core::ffi::c_ulonglong, - 0xc652f689e122facb as ::core::ffi::c_ulonglong, - 0x7b61507c1735fbba as ::core::ffi::c_ulonglong, - 0x446ab136865f9671 as ::core::ffi::c_ulonglong, - 0x57692e935e1202c as ::core::ffi::c_ulonglong, - 0x3a7d73a3a48b4de7 as ::core::ffi::c_ulonglong, - 0x718c75ae7cf7bbe2 as ::core::ffi::c_ulonglong, - 0x4e8794e4ed9dd629 as ::core::ffi::c_ulonglong, - 0xf9bb73b5e236074 as ::core::ffi::c_ulonglong, - 0x30905671cf490dbf as ::core::ffi::c_ulonglong, - 0x8da3f084395e0cce as ::core::ffi::c_ulonglong, - 0xb2a811cea8346105 as ::core::ffi::c_ulonglong, - 0xf3b432111b8ad758 as ::core::ffi::c_ulonglong, - 0xccbfd35b8ae0ba93 as ::core::ffi::c_ulonglong, - 0x1b0bd0d158aacb3f as ::core::ffi::c_ulonglong, - 0x2400319bc9c0a6f4 as ::core::ffi::c_ulonglong, - 0x651c12447a7e10a9 as ::core::ffi::c_ulonglong, - 0x5a17f30eeb147d62 as ::core::ffi::c_ulonglong, - 0xe72455fb1d037c13 as ::core::ffi::c_ulonglong, - 0xd82fb4b18c6911d8 as ::core::ffi::c_ulonglong, - 0x9933976e3fd7a785 as ::core::ffi::c_ulonglong, - 0xa6387624aebdca4e as ::core::ffi::c_ulonglong, - 0xa4833f50344d5a58 as ::core::ffi::c_ulonglong, - 0x9b88de1aa5273793 as ::core::ffi::c_ulonglong, - 0xda94fdc5169981ce as ::core::ffi::c_ulonglong, - 0xe59f1c8f87f3ec05 as ::core::ffi::c_ulonglong, - 0x58acba7a71e4ed74 as ::core::ffi::c_ulonglong, - 0x67a75b30e08e80bf as ::core::ffi::c_ulonglong, - 0x26bb78ef533036e2 as ::core::ffi::c_ulonglong, - 0x19b099a5c25a5b29 as ::core::ffi::c_ulonglong, - 0xce049a2f10102a85 as ::core::ffi::c_ulonglong, - 0xf10f7b65817a474e as ::core::ffi::c_ulonglong, - 0xb01358ba32c4f113 as ::core::ffi::c_ulonglong, - 0x8f18b9f0a3ae9cd8 as ::core::ffi::c_ulonglong, - 0x322b1f0555b99da9 as ::core::ffi::c_ulonglong, - 0xd20fe4fc4d3f062 as ::core::ffi::c_ulonglong, - 0x4c3cdd90776d463f as ::core::ffi::c_ulonglong, - 0x73373cdae6072bf4 as ::core::ffi::c_ulonglong, - 0x494a4f79428c6613 as ::core::ffi::c_ulonglong, - 0x7641ae33d3e60bd8 as ::core::ffi::c_ulonglong, - 0x375d8dec6058bd85 as ::core::ffi::c_ulonglong, - 0x8566ca6f132d04e as ::core::ffi::c_ulonglong, - 0xb565ca530725d13f as ::core::ffi::c_ulonglong, - 0x8a6e2b19964fbcf4 as ::core::ffi::c_ulonglong, - 0xcb7208c625f10aa9 as ::core::ffi::c_ulonglong, - 0xf479e98cb49b6762 as ::core::ffi::c_ulonglong, - 0x23cdea0666d116ce as ::core::ffi::c_ulonglong, - 0x1cc60b4cf7bb7b05 as ::core::ffi::c_ulonglong, - 0x5dda28934405cd58 as ::core::ffi::c_ulonglong, - 0x62d1c9d9d56fa093 as ::core::ffi::c_ulonglong, - 0xdfe26f2c2378a1e2 as ::core::ffi::c_ulonglong, - 0xe0e98e66b212cc29 as ::core::ffi::c_ulonglong, - 0xa1f5adb901ac7a74 as ::core::ffi::c_ulonglong, - 0x9efe4cf390c617bf as ::core::ffi::c_ulonglong, - 0x9c4505870a3687a9 as ::core::ffi::c_ulonglong, - 0xa34ee4cd9b5cea62 as ::core::ffi::c_ulonglong, - 0xe252c71228e25c3f as ::core::ffi::c_ulonglong, - 0xdd592658b98831f4 as ::core::ffi::c_ulonglong, - 0x606a80ad4f9f3085 as ::core::ffi::c_ulonglong, - 0x5f6161e7def55d4e as ::core::ffi::c_ulonglong, - 0x1e7d42386d4beb13 as ::core::ffi::c_ulonglong, - 0x2176a372fc2186d8 as ::core::ffi::c_ulonglong, - 0xf6c2a0f82e6bf774 as ::core::ffi::c_ulonglong, - 0xc9c941b2bf019abf as ::core::ffi::c_ulonglong, - 0x88d5626d0cbf2ce2 as ::core::ffi::c_ulonglong, - 0xb7de83279dd54129 as ::core::ffi::c_ulonglong, - 0xaed25d26bc24058 as ::core::ffi::c_ulonglong, - 0x35e6c498faa82d93 as ::core::ffi::c_ulonglong, - 0x74fae74749169bce as ::core::ffi::c_ulonglong, - 0x4bf1060dd87cf605 as ::core::ffi::c_ulonglong, - 0xe318eb5cf9ef77c4 as ::core::ffi::c_ulonglong, - 0xdc130a1668851a0f as ::core::ffi::c_ulonglong, - 0x9d0f29c9db3bac52 as ::core::ffi::c_ulonglong, - 0xa204c8834a51c199 as ::core::ffi::c_ulonglong, - 0x1f376e76bc46c0e8 as ::core::ffi::c_ulonglong, - 0x203c8f3c2d2cad23 as ::core::ffi::c_ulonglong, - 0x6120ace39e921b7e as ::core::ffi::c_ulonglong, - 0x5e2b4da90ff876b5 as ::core::ffi::c_ulonglong, - 0x899f4e23ddb20719 as ::core::ffi::c_ulonglong, - 0xb694af694cd86ad2 as ::core::ffi::c_ulonglong, - 0xf7888cb6ff66dc8f as ::core::ffi::c_ulonglong, - 0xc8836dfc6e0cb144 as ::core::ffi::c_ulonglong, - 0x75b0cb09981bb035 as ::core::ffi::c_ulonglong, - 0x4abb2a430971ddfe as ::core::ffi::c_ulonglong, - 0xba7099cbacf6ba3 as ::core::ffi::c_ulonglong, - 0x34ace8d62ba50668 as ::core::ffi::c_ulonglong, - 0x3617a1a2b155967e as ::core::ffi::c_ulonglong, - 0x91c40e8203ffbb5 as ::core::ffi::c_ulonglong, - 0x4800633793814de8 as ::core::ffi::c_ulonglong, - 0x770b827d02eb2023 as ::core::ffi::c_ulonglong, - 0xca382488f4fc2152 as ::core::ffi::c_ulonglong, - 0xf533c5c265964c99 as ::core::ffi::c_ulonglong, - 0xb42fe61dd628fac4 as ::core::ffi::c_ulonglong, - 0x8b2407574742970f as ::core::ffi::c_ulonglong, - 0x5c9004dd9508e6a3 as ::core::ffi::c_ulonglong, - 0x639be59704628b68 as ::core::ffi::c_ulonglong, - 0x2287c648b7dc3d35 as ::core::ffi::c_ulonglong, - 0x1d8c270226b650fe as ::core::ffi::c_ulonglong, - 0xa0bf81f7d0a1518f as ::core::ffi::c_ulonglong, - 0x9fb460bd41cb3c44 as ::core::ffi::c_ulonglong, - 0xdea84362f2758a19 as ::core::ffi::c_ulonglong, - 0xe1a3a228631fe7d2 as ::core::ffi::c_ulonglong, - 0xdbded18bc794aa35 as ::core::ffi::c_ulonglong, - 0xe4d530c156fec7fe as ::core::ffi::c_ulonglong, - 0xa5c9131ee54071a3 as ::core::ffi::c_ulonglong, - 0x9ac2f254742a1c68 as ::core::ffi::c_ulonglong, - 0x27f154a1823d1d19 as ::core::ffi::c_ulonglong, - 0x18fab5eb135770d2 as ::core::ffi::c_ulonglong, - 0x59e69634a0e9c68f as ::core::ffi::c_ulonglong, - 0x66ed777e3183ab44 as ::core::ffi::c_ulonglong, - 0xb15974f4e3c9dae8 as ::core::ffi::c_ulonglong, - 0x8e5295be72a3b723 as ::core::ffi::c_ulonglong, - 0xcf4eb661c11d017e as ::core::ffi::c_ulonglong, - 0xf045572b50776cb5 as ::core::ffi::c_ulonglong, - 0x4d76f1dea6606dc4 as ::core::ffi::c_ulonglong, - 0x727d1094370a000f as ::core::ffi::c_ulonglong, - 0x3361334b84b4b652 as ::core::ffi::c_ulonglong, - 0xc6ad20115dedb99 as ::core::ffi::c_ulonglong, - 0xed19b758f2e4b8f as ::core::ffi::c_ulonglong, - 0x31da7a3f1e442644 as ::core::ffi::c_ulonglong, - 0x70c659e0adfa9019 as ::core::ffi::c_ulonglong, - 0x4fcdb8aa3c90fdd2 as ::core::ffi::c_ulonglong, - 0xf2fe1e5fca87fca3 as ::core::ffi::c_ulonglong, - 0xcdf5ff155bed9168 as ::core::ffi::c_ulonglong, - 0x8ce9dccae8532735 as ::core::ffi::c_ulonglong, - 0xb3e23d8079394afe as ::core::ffi::c_ulonglong, - 0x64563e0aab733b52 as ::core::ffi::c_ulonglong, - 0x5b5ddf403a195699 as ::core::ffi::c_ulonglong, - 0x1a41fc9f89a7e0c4 as ::core::ffi::c_ulonglong, - 0x254a1dd518cd8d0f as ::core::ffi::c_ulonglong, - 0x9879bb20eeda8c7e as ::core::ffi::c_ulonglong, - 0xa7725a6a7fb0e1b5 as ::core::ffi::c_ulonglong, - 0xe66e79b5cc0e57e8 as ::core::ffi::c_ulonglong, - 0xd96598ff5d643a23 as ::core::ffi::c_ulonglong, - 0x92949ef28518cc26 as ::core::ffi::c_ulonglong, - 0xad9f7fb81472a1ed as ::core::ffi::c_ulonglong, - 0xec835c67a7cc17b0 as ::core::ffi::c_ulonglong, - 0xd388bd2d36a67a7b as ::core::ffi::c_ulonglong, - 0x6ebb1bd8c0b17b0a as ::core::ffi::c_ulonglong, - 0x51b0fa9251db16c1 as ::core::ffi::c_ulonglong, - 0x10acd94de265a09c as ::core::ffi::c_ulonglong, - 0x2fa73807730fcd57 as ::core::ffi::c_ulonglong, - 0xf8133b8da145bcfb as ::core::ffi::c_ulonglong, - 0xc718dac7302fd130 as ::core::ffi::c_ulonglong, - 0x8604f9188391676d as ::core::ffi::c_ulonglong, - 0xb90f185212fb0aa6 as ::core::ffi::c_ulonglong, - 0x43cbea7e4ec0bd7 as ::core::ffi::c_ulonglong, - 0x3b375fed7586661c as ::core::ffi::c_ulonglong, - 0x7a2b7c32c638d041 as ::core::ffi::c_ulonglong, - 0x45209d785752bd8a as ::core::ffi::c_ulonglong, - 0x479bd40ccda22d9c as ::core::ffi::c_ulonglong, - 0x789035465cc84057 as ::core::ffi::c_ulonglong, - 0x398c1699ef76f60a as ::core::ffi::c_ulonglong, - 0x687f7d37e1c9bc1 as ::core::ffi::c_ulonglong, - 0xbbb45126880b9ab0 as ::core::ffi::c_ulonglong, - 0x84bfb06c1961f77b as ::core::ffi::c_ulonglong, - 0xc5a393b3aadf4126 as ::core::ffi::c_ulonglong, - 0xfaa872f93bb52ced as ::core::ffi::c_ulonglong, - 0x2d1c7173e9ff5d41 as ::core::ffi::c_ulonglong, - 0x121790397895308a as ::core::ffi::c_ulonglong, - 0x530bb3e6cb2b86d7 as ::core::ffi::c_ulonglong, - 0x6c0052ac5a41eb1c as ::core::ffi::c_ulonglong, - 0xd133f459ac56ea6d as ::core::ffi::c_ulonglong, - 0xee3815133d3c87a6 as ::core::ffi::c_ulonglong, - 0xaf2436cc8e8231fb as ::core::ffi::c_ulonglong, - 0x902fd7861fe85c30 as ::core::ffi::c_ulonglong, - 0xaa52a425bb6311d7 as ::core::ffi::c_ulonglong, - 0x9559456f2a097c1c as ::core::ffi::c_ulonglong, - 0xd44566b099b7ca41 as ::core::ffi::c_ulonglong, - 0xeb4e87fa08dda78a as ::core::ffi::c_ulonglong, - 0x567d210ffecaa6fb as ::core::ffi::c_ulonglong, - 0x6976c0456fa0cb30 as ::core::ffi::c_ulonglong, - 0x286ae39adc1e7d6d as ::core::ffi::c_ulonglong, - 0x176102d04d7410a6 as ::core::ffi::c_ulonglong, - 0xc0d5015a9f3e610a as ::core::ffi::c_ulonglong, - 0xffdee0100e540cc1 as ::core::ffi::c_ulonglong, - 0xbec2c3cfbdeaba9c as ::core::ffi::c_ulonglong, - 0x81c922852c80d757 as ::core::ffi::c_ulonglong, - 0x3cfa8470da97d626 as ::core::ffi::c_ulonglong, - 0x3f1653a4bfdbbed as ::core::ffi::c_ulonglong, - 0x42ed46e5f8430db0 as ::core::ffi::c_ulonglong, - 0x7de6a7af6929607b as ::core::ffi::c_ulonglong, - 0x7f5deedbf3d9f06d as ::core::ffi::c_ulonglong, - 0x40560f9162b39da6 as ::core::ffi::c_ulonglong, - 0x14a2c4ed10d2bfb as ::core::ffi::c_ulonglong, - 0x3e41cd0440674630 as ::core::ffi::c_ulonglong, - 0x83726bf1b6704741 as ::core::ffi::c_ulonglong, - 0xbc798abb271a2a8a as ::core::ffi::c_ulonglong, - 0xfd65a96494a49cd7 as ::core::ffi::c_ulonglong, - 0xc26e482e05cef11c as ::core::ffi::c_ulonglong, - 0x15da4ba4d78480b0 as ::core::ffi::c_ulonglong, - 0x2ad1aaee46eeed7b as ::core::ffi::c_ulonglong, - 0x6bcd8931f5505b26 as ::core::ffi::c_ulonglong, - 0x54c6687b643a36ed as ::core::ffi::c_ulonglong, - 0xe9f5ce8e922d379c as ::core::ffi::c_ulonglong, - 0xd6fe2fc403475a57 as ::core::ffi::c_ulonglong, - 0x97e20c1bb0f9ec0a as ::core::ffi::c_ulonglong, - 0xa8e9ed51219381c1 as ::core::ffi::c_ulonglong, + 0, + 0x3f0be14a916a6dcb, + 0x7e17c29522d4db96, + 0x411c23dfb3beb65d, + 0xfc2f852a45a9b72c, + 0xc3246460d4c3dae7, + 0x823847bf677d6cba, + 0xbd33a6f5f6170171, + 0x6a87a57f245d70dd, + 0x558c4435b5371d16, + 0x149067ea0689ab4b, + 0x2b9b86a097e3c680, + 0x96a8205561f4c7f1, + 0xa9a3c11ff09eaa3a, + 0xe8bfe2c043201c67, + 0xd7b4038ad24a71ac, + 0xd50f4afe48bae1ba, + 0xea04abb4d9d08c71, + 0xab18886b6a6e3a2c, + 0x94136921fb0457e7, + 0x2920cfd40d135696, + 0x162b2e9e9c793b5d, + 0x57370d412fc78d00, + 0x683cec0bbeade0cb, + 0xbf88ef816ce79167, + 0x80830ecbfd8dfcac, + 0xc19f2d144e334af1, + 0xfe94cc5edf59273a, + 0x43a76aab294e264b, + 0x7cac8be1b8244b80, + 0x3db0a83e0b9afddd, + 0x2bb49749af09016, + 0x38c63ad73e7bddf1, + 0x7cddb9daf11b03a, + 0x46d1f8421caf0667, + 0x79da19088dc56bac, + 0xc4e9bffd7bd26add, + 0xfbe25eb7eab80716, + 0xbafe7d685906b14b, + 0x85f59c22c86cdc80, + 0x52419fa81a26ad2c, + 0x6d4a7ee28b4cc0e7, + 0x2c565d3d38f276ba, + 0x135dbc77a9981b71, + 0xae6e1a825f8f1a00, + 0x9165fbc8cee577cb, + 0xd079d8177d5bc196, + 0xef72395dec31ac5d, + 0xedc9702976c13c4b, + 0xd2c29163e7ab5180, + 0x93deb2bc5415e7dd, + 0xacd553f6c57f8a16, + 0x11e6f50333688b67, + 0x2eed1449a202e6ac, + 0x6ff1379611bc50f1, + 0x50fad6dc80d63d3a, + 0x874ed556529c4c96, + 0xb845341cc3f6215d, + 0xf95917c370489700, + 0xc652f689e122facb, + 0x7b61507c1735fbba, + 0x446ab136865f9671, + 0x57692e935e1202c, + 0x3a7d73a3a48b4de7, + 0x718c75ae7cf7bbe2, + 0x4e8794e4ed9dd629, + 0xf9bb73b5e236074, + 0x30905671cf490dbf, + 0x8da3f084395e0cce, + 0xb2a811cea8346105, + 0xf3b432111b8ad758, + 0xccbfd35b8ae0ba93, + 0x1b0bd0d158aacb3f, + 0x2400319bc9c0a6f4, + 0x651c12447a7e10a9, + 0x5a17f30eeb147d62, + 0xe72455fb1d037c13, + 0xd82fb4b18c6911d8, + 0x9933976e3fd7a785, + 0xa6387624aebdca4e, + 0xa4833f50344d5a58, + 0x9b88de1aa5273793, + 0xda94fdc5169981ce, + 0xe59f1c8f87f3ec05, + 0x58acba7a71e4ed74, + 0x67a75b30e08e80bf, + 0x26bb78ef533036e2, + 0x19b099a5c25a5b29, + 0xce049a2f10102a85, + 0xf10f7b65817a474e, + 0xb01358ba32c4f113, + 0x8f18b9f0a3ae9cd8, + 0x322b1f0555b99da9, + 0xd20fe4fc4d3f062, + 0x4c3cdd90776d463f, + 0x73373cdae6072bf4, + 0x494a4f79428c6613, + 0x7641ae33d3e60bd8, + 0x375d8dec6058bd85, + 0x8566ca6f132d04e, + 0xb565ca530725d13f, + 0x8a6e2b19964fbcf4, + 0xcb7208c625f10aa9, + 0xf479e98cb49b6762, + 0x23cdea0666d116ce, + 0x1cc60b4cf7bb7b05, + 0x5dda28934405cd58, + 0x62d1c9d9d56fa093, + 0xdfe26f2c2378a1e2, + 0xe0e98e66b212cc29, + 0xa1f5adb901ac7a74, + 0x9efe4cf390c617bf, + 0x9c4505870a3687a9, + 0xa34ee4cd9b5cea62, + 0xe252c71228e25c3f, + 0xdd592658b98831f4, + 0x606a80ad4f9f3085, + 0x5f6161e7def55d4e, + 0x1e7d42386d4beb13, + 0x2176a372fc2186d8, + 0xf6c2a0f82e6bf774, + 0xc9c941b2bf019abf, + 0x88d5626d0cbf2ce2, + 0xb7de83279dd54129, + 0xaed25d26bc24058, + 0x35e6c498faa82d93, + 0x74fae74749169bce, + 0x4bf1060dd87cf605, + 0xe318eb5cf9ef77c4, + 0xdc130a1668851a0f, + 0x9d0f29c9db3bac52, + 0xa204c8834a51c199, + 0x1f376e76bc46c0e8, + 0x203c8f3c2d2cad23, + 0x6120ace39e921b7e, + 0x5e2b4da90ff876b5, + 0x899f4e23ddb20719, + 0xb694af694cd86ad2, + 0xf7888cb6ff66dc8f, + 0xc8836dfc6e0cb144, + 0x75b0cb09981bb035, + 0x4abb2a430971ddfe, + 0xba7099cbacf6ba3, + 0x34ace8d62ba50668, + 0x3617a1a2b155967e, + 0x91c40e8203ffbb5, + 0x4800633793814de8, + 0x770b827d02eb2023, + 0xca382488f4fc2152, + 0xf533c5c265964c99, + 0xb42fe61dd628fac4, + 0x8b2407574742970f, + 0x5c9004dd9508e6a3, + 0x639be59704628b68, + 0x2287c648b7dc3d35, + 0x1d8c270226b650fe, + 0xa0bf81f7d0a1518f, + 0x9fb460bd41cb3c44, + 0xdea84362f2758a19, + 0xe1a3a228631fe7d2, + 0xdbded18bc794aa35, + 0xe4d530c156fec7fe, + 0xa5c9131ee54071a3, + 0x9ac2f254742a1c68, + 0x27f154a1823d1d19, + 0x18fab5eb135770d2, + 0x59e69634a0e9c68f, + 0x66ed777e3183ab44, + 0xb15974f4e3c9dae8, + 0x8e5295be72a3b723, + 0xcf4eb661c11d017e, + 0xf045572b50776cb5, + 0x4d76f1dea6606dc4, + 0x727d1094370a000f, + 0x3361334b84b4b652, + 0xc6ad20115dedb99, + 0xed19b758f2e4b8f, + 0x31da7a3f1e442644, + 0x70c659e0adfa9019, + 0x4fcdb8aa3c90fdd2, + 0xf2fe1e5fca87fca3, + 0xcdf5ff155bed9168, + 0x8ce9dccae8532735, + 0xb3e23d8079394afe, + 0x64563e0aab733b52, + 0x5b5ddf403a195699, + 0x1a41fc9f89a7e0c4, + 0x254a1dd518cd8d0f, + 0x9879bb20eeda8c7e, + 0xa7725a6a7fb0e1b5, + 0xe66e79b5cc0e57e8, + 0xd96598ff5d643a23, + 0x92949ef28518cc26, + 0xad9f7fb81472a1ed, + 0xec835c67a7cc17b0, + 0xd388bd2d36a67a7b, + 0x6ebb1bd8c0b17b0a, + 0x51b0fa9251db16c1, + 0x10acd94de265a09c, + 0x2fa73807730fcd57, + 0xf8133b8da145bcfb, + 0xc718dac7302fd130, + 0x8604f9188391676d, + 0xb90f185212fb0aa6, + 0x43cbea7e4ec0bd7, + 0x3b375fed7586661c, + 0x7a2b7c32c638d041, + 0x45209d785752bd8a, + 0x479bd40ccda22d9c, + 0x789035465cc84057, + 0x398c1699ef76f60a, + 0x687f7d37e1c9bc1, + 0xbbb45126880b9ab0, + 0x84bfb06c1961f77b, + 0xc5a393b3aadf4126, + 0xfaa872f93bb52ced, + 0x2d1c7173e9ff5d41, + 0x121790397895308a, + 0x530bb3e6cb2b86d7, + 0x6c0052ac5a41eb1c, + 0xd133f459ac56ea6d, + 0xee3815133d3c87a6, + 0xaf2436cc8e8231fb, + 0x902fd7861fe85c30, + 0xaa52a425bb6311d7, + 0x9559456f2a097c1c, + 0xd44566b099b7ca41, + 0xeb4e87fa08dda78a, + 0x567d210ffecaa6fb, + 0x6976c0456fa0cb30, + 0x286ae39adc1e7d6d, + 0x176102d04d7410a6, + 0xc0d5015a9f3e610a, + 0xffdee0100e540cc1, + 0xbec2c3cfbdeaba9c, + 0x81c922852c80d757, + 0x3cfa8470da97d626, + 0x3f1653a4bfdbbed, + 0x42ed46e5f8430db0, + 0x7de6a7af6929607b, + 0x7f5deedbf3d9f06d, + 0x40560f9162b39da6, + 0x14a2c4ed10d2bfb, + 0x3e41cd0440674630, + 0x83726bf1b6704741, + 0xbc798abb271a2a8a, + 0xfd65a96494a49cd7, + 0xc26e482e05cef11c, + 0x15da4ba4d78480b0, + 0x2ad1aaee46eeed7b, + 0x6bcd8931f5505b26, + 0x54c6687b643a36ed, + 0xe9f5ce8e922d379c, + 0xd6fe2fc403475a57, + 0x97e20c1bb0f9ec0a, + 0xa8e9ed51219381c1, ], [ - 0 as ::core::ffi::c_ulonglong, - 0x1dee8a5e222ca1dc as ::core::ffi::c_ulonglong, - 0x3bdd14bc445943b8 as ::core::ffi::c_ulonglong, - 0x26339ee26675e264 as ::core::ffi::c_ulonglong, - 0x77ba297888b28770 as ::core::ffi::c_ulonglong, - 0x6a54a326aa9e26ac as ::core::ffi::c_ulonglong, - 0x4c673dc4ccebc4c8 as ::core::ffi::c_ulonglong, - 0x5189b79aeec76514 as ::core::ffi::c_ulonglong, - 0xef7452f111650ee0 as ::core::ffi::c_ulonglong, - 0xf29ad8af3349af3c as ::core::ffi::c_ulonglong, - 0xd4a9464d553c4d58 as ::core::ffi::c_ulonglong, - 0xc947cc137710ec84 as ::core::ffi::c_ulonglong, - 0x98ce7b8999d78990 as ::core::ffi::c_ulonglong, - 0x8520f1d7bbfb284c as ::core::ffi::c_ulonglong, - 0xa3136f35dd8eca28 as ::core::ffi::c_ulonglong, - 0xbefde56bffa26bf4 as ::core::ffi::c_ulonglong, - 0x4c300ac98dc40345 as ::core::ffi::c_ulonglong, - 0x51de8097afe8a299 as ::core::ffi::c_ulonglong, - 0x77ed1e75c99d40fd as ::core::ffi::c_ulonglong, - 0x6a03942bebb1e121 as ::core::ffi::c_ulonglong, - 0x3b8a23b105768435 as ::core::ffi::c_ulonglong, - 0x2664a9ef275a25e9 as ::core::ffi::c_ulonglong, - 0x57370d412fc78d as ::core::ffi::c_ulonglong, - 0x1db9bd5363036651 as ::core::ffi::c_ulonglong, - 0xa34458389ca10da5 as ::core::ffi::c_ulonglong, - 0xbeaad266be8dac79 as ::core::ffi::c_ulonglong, - 0x98994c84d8f84e1d as ::core::ffi::c_ulonglong, - 0x8577c6dafad4efc1 as ::core::ffi::c_ulonglong, - 0xd4fe714014138ad5 as ::core::ffi::c_ulonglong, - 0xc910fb1e363f2b09 as ::core::ffi::c_ulonglong, - 0xef2365fc504ac96d as ::core::ffi::c_ulonglong, - 0xf2cdefa2726668b1 as ::core::ffi::c_ulonglong, - 0x986015931b88068a as ::core::ffi::c_ulonglong, - 0x858e9fcd39a4a756 as ::core::ffi::c_ulonglong, - 0xa3bd012f5fd14532 as ::core::ffi::c_ulonglong, - 0xbe538b717dfde4ee as ::core::ffi::c_ulonglong, - 0xefda3ceb933a81fa as ::core::ffi::c_ulonglong, - 0xf234b6b5b1162026 as ::core::ffi::c_ulonglong, - 0xd4072857d763c242 as ::core::ffi::c_ulonglong, - 0xc9e9a209f54f639e as ::core::ffi::c_ulonglong, - 0x771447620aed086a as ::core::ffi::c_ulonglong, - 0x6afacd3c28c1a9b6 as ::core::ffi::c_ulonglong, - 0x4cc953de4eb44bd2 as ::core::ffi::c_ulonglong, - 0x5127d9806c98ea0e as ::core::ffi::c_ulonglong, - 0xae6e1a825f8f1a as ::core::ffi::c_ulonglong, - 0x1d40e444a0732ec6 as ::core::ffi::c_ulonglong, - 0x3b737aa6c606cca2 as ::core::ffi::c_ulonglong, - 0x269df0f8e42a6d7e as ::core::ffi::c_ulonglong, - 0xd4501f5a964c05cf as ::core::ffi::c_ulonglong, - 0xc9be9504b460a413 as ::core::ffi::c_ulonglong, - 0xef8d0be6d2154677 as ::core::ffi::c_ulonglong, - 0xf26381b8f039e7ab as ::core::ffi::c_ulonglong, - 0xa3ea36221efe82bf as ::core::ffi::c_ulonglong, - 0xbe04bc7c3cd22363 as ::core::ffi::c_ulonglong, - 0x9837229e5aa7c107 as ::core::ffi::c_ulonglong, - 0x85d9a8c0788b60db as ::core::ffi::c_ulonglong, - 0x3b244dab87290b2f as ::core::ffi::c_ulonglong, - 0x26cac7f5a505aaf3 as ::core::ffi::c_ulonglong, - 0xf95917c3704897 as ::core::ffi::c_ulonglong, - 0x1d17d349e15ce94b as ::core::ffi::c_ulonglong, - 0x4c9e64d30f9b8c5f as ::core::ffi::c_ulonglong, - 0x5170ee8d2db72d83 as ::core::ffi::c_ulonglong, - 0x7743706f4bc2cfe7 as ::core::ffi::c_ulonglong, - 0x6aadfa3169ee6e3b as ::core::ffi::c_ulonglong, - 0xa218840d981e1391 as ::core::ffi::c_ulonglong, - 0xbff60e53ba32b24d as ::core::ffi::c_ulonglong, - 0x99c590b1dc475029 as ::core::ffi::c_ulonglong, - 0x842b1aeffe6bf1f5 as ::core::ffi::c_ulonglong, - 0xd5a2ad7510ac94e1 as ::core::ffi::c_ulonglong, - 0xc84c272b3280353d as ::core::ffi::c_ulonglong, - 0xee7fb9c954f5d759 as ::core::ffi::c_ulonglong, - 0xf391339776d97685 as ::core::ffi::c_ulonglong, - 0x4d6cd6fc897b1d71 as ::core::ffi::c_ulonglong, - 0x50825ca2ab57bcad as ::core::ffi::c_ulonglong, - 0x76b1c240cd225ec9 as ::core::ffi::c_ulonglong, - 0x6b5f481eef0eff15 as ::core::ffi::c_ulonglong, - 0x3ad6ff8401c99a01 as ::core::ffi::c_ulonglong, - 0x273875da23e53bdd as ::core::ffi::c_ulonglong, - 0x10beb384590d9b9 as ::core::ffi::c_ulonglong, - 0x1ce5616667bc7865 as ::core::ffi::c_ulonglong, - 0xee288ec415da10d4 as ::core::ffi::c_ulonglong, - 0xf3c6049a37f6b108 as ::core::ffi::c_ulonglong, - 0xd5f59a785183536c as ::core::ffi::c_ulonglong, - 0xc81b102673aff2b0 as ::core::ffi::c_ulonglong, - 0x9992a7bc9d6897a4 as ::core::ffi::c_ulonglong, - 0x847c2de2bf443678 as ::core::ffi::c_ulonglong, - 0xa24fb300d931d41c as ::core::ffi::c_ulonglong, - 0xbfa1395efb1d75c0 as ::core::ffi::c_ulonglong, - 0x15cdc3504bf1e34 as ::core::ffi::c_ulonglong, - 0x1cb2566b2693bfe8 as ::core::ffi::c_ulonglong, - 0x3a81c88940e65d8c as ::core::ffi::c_ulonglong, - 0x276f42d762cafc50 as ::core::ffi::c_ulonglong, - 0x76e6f54d8c0d9944 as ::core::ffi::c_ulonglong, - 0x6b087f13ae213898 as ::core::ffi::c_ulonglong, - 0x4d3be1f1c854dafc as ::core::ffi::c_ulonglong, - 0x50d56bafea787b20 as ::core::ffi::c_ulonglong, - 0x3a78919e8396151b as ::core::ffi::c_ulonglong, - 0x27961bc0a1bab4c7 as ::core::ffi::c_ulonglong, - 0x1a58522c7cf56a3 as ::core::ffi::c_ulonglong, - 0x1c4b0f7ce5e3f77f as ::core::ffi::c_ulonglong, - 0x4dc2b8e60b24926b as ::core::ffi::c_ulonglong, - 0x502c32b8290833b7 as ::core::ffi::c_ulonglong, - 0x761fac5a4f7dd1d3 as ::core::ffi::c_ulonglong, - 0x6bf126046d51700f as ::core::ffi::c_ulonglong, - 0xd50cc36f92f31bfb as ::core::ffi::c_ulonglong, - 0xc8e24931b0dfba27 as ::core::ffi::c_ulonglong, - 0xeed1d7d3d6aa5843 as ::core::ffi::c_ulonglong, - 0xf33f5d8df486f99f as ::core::ffi::c_ulonglong, - 0xa2b6ea171a419c8b as ::core::ffi::c_ulonglong, - 0xbf586049386d3d57 as ::core::ffi::c_ulonglong, - 0x996bfeab5e18df33 as ::core::ffi::c_ulonglong, - 0x848574f57c347eef as ::core::ffi::c_ulonglong, - 0x76489b570e52165e as ::core::ffi::c_ulonglong, - 0x6ba611092c7eb782 as ::core::ffi::c_ulonglong, - 0x4d958feb4a0b55e6 as ::core::ffi::c_ulonglong, - 0x507b05b56827f43a as ::core::ffi::c_ulonglong, - 0x1f2b22f86e0912e as ::core::ffi::c_ulonglong, - 0x1c1c3871a4cc30f2 as ::core::ffi::c_ulonglong, - 0x3a2fa693c2b9d296 as ::core::ffi::c_ulonglong, - 0x27c12ccde095734a as ::core::ffi::c_ulonglong, - 0x993cc9a61f3718be as ::core::ffi::c_ulonglong, - 0x84d243f83d1bb962 as ::core::ffi::c_ulonglong, - 0xa2e1dd1a5b6e5b06 as ::core::ffi::c_ulonglong, - 0xbf0f57447942fada as ::core::ffi::c_ulonglong, - 0xee86e0de97859fce as ::core::ffi::c_ulonglong, - 0xf3686a80b5a93e12 as ::core::ffi::c_ulonglong, - 0xd55bf462d3dcdc76 as ::core::ffi::c_ulonglong, - 0xc8b57e3cf1f07daa as ::core::ffi::c_ulonglong, - 0xd6e9a7309f3239a7 as ::core::ffi::c_ulonglong, - 0xcb072d6ebd1e987b as ::core::ffi::c_ulonglong, - 0xed34b38cdb6b7a1f as ::core::ffi::c_ulonglong, - 0xf0da39d2f947dbc3 as ::core::ffi::c_ulonglong, - 0xa1538e481780bed7 as ::core::ffi::c_ulonglong, - 0xbcbd041635ac1f0b as ::core::ffi::c_ulonglong, - 0x9a8e9af453d9fd6f as ::core::ffi::c_ulonglong, - 0x876010aa71f55cb3 as ::core::ffi::c_ulonglong, - 0x399df5c18e573747 as ::core::ffi::c_ulonglong, - 0x24737f9fac7b969b as ::core::ffi::c_ulonglong, - 0x240e17dca0e74ff as ::core::ffi::c_ulonglong, - 0x1fae6b23e822d523 as ::core::ffi::c_ulonglong, - 0x4e27dcb906e5b037 as ::core::ffi::c_ulonglong, - 0x53c956e724c911eb as ::core::ffi::c_ulonglong, - 0x75fac80542bcf38f as ::core::ffi::c_ulonglong, - 0x6814425b60905253 as ::core::ffi::c_ulonglong, - 0x9ad9adf912f63ae2 as ::core::ffi::c_ulonglong, - 0x873727a730da9b3e as ::core::ffi::c_ulonglong, - 0xa104b94556af795a as ::core::ffi::c_ulonglong, - 0xbcea331b7483d886 as ::core::ffi::c_ulonglong, - 0xed6384819a44bd92 as ::core::ffi::c_ulonglong, - 0xf08d0edfb8681c4e as ::core::ffi::c_ulonglong, - 0xd6be903dde1dfe2a as ::core::ffi::c_ulonglong, - 0xcb501a63fc315ff6 as ::core::ffi::c_ulonglong, - 0x75adff0803933402 as ::core::ffi::c_ulonglong, - 0x6843755621bf95de as ::core::ffi::c_ulonglong, - 0x4e70ebb447ca77ba as ::core::ffi::c_ulonglong, - 0x539e61ea65e6d666 as ::core::ffi::c_ulonglong, - 0x217d6708b21b372 as ::core::ffi::c_ulonglong, - 0x1ff95c2ea90d12ae as ::core::ffi::c_ulonglong, - 0x39cac2cccf78f0ca as ::core::ffi::c_ulonglong, - 0x24244892ed545116 as ::core::ffi::c_ulonglong, - 0x4e89b2a384ba3f2d as ::core::ffi::c_ulonglong, - 0x536738fda6969ef1 as ::core::ffi::c_ulonglong, - 0x7554a61fc0e37c95 as ::core::ffi::c_ulonglong, - 0x68ba2c41e2cfdd49 as ::core::ffi::c_ulonglong, - 0x39339bdb0c08b85d as ::core::ffi::c_ulonglong, - 0x24dd11852e241981 as ::core::ffi::c_ulonglong, - 0x2ee8f674851fbe5 as ::core::ffi::c_ulonglong, - 0x1f0005396a7d5a39 as ::core::ffi::c_ulonglong, - 0xa1fde05295df31cd as ::core::ffi::c_ulonglong, - 0xbc136a0cb7f39011 as ::core::ffi::c_ulonglong, - 0x9a20f4eed1867275 as ::core::ffi::c_ulonglong, - 0x87ce7eb0f3aad3a9 as ::core::ffi::c_ulonglong, - 0xd647c92a1d6db6bd as ::core::ffi::c_ulonglong, - 0xcba943743f411761 as ::core::ffi::c_ulonglong, - 0xed9add965934f505 as ::core::ffi::c_ulonglong, - 0xf07457c87b1854d9 as ::core::ffi::c_ulonglong, - 0x2b9b86a097e3c68 as ::core::ffi::c_ulonglong, - 0x1f5732342b529db4 as ::core::ffi::c_ulonglong, - 0x3964acd64d277fd0 as ::core::ffi::c_ulonglong, - 0x248a26886f0bde0c as ::core::ffi::c_ulonglong, - 0x7503911281ccbb18 as ::core::ffi::c_ulonglong, - 0x68ed1b4ca3e01ac4 as ::core::ffi::c_ulonglong, - 0x4ede85aec595f8a0 as ::core::ffi::c_ulonglong, - 0x53300ff0e7b9597c as ::core::ffi::c_ulonglong, - 0xedcdea9b181b3288 as ::core::ffi::c_ulonglong, - 0xf02360c53a379354 as ::core::ffi::c_ulonglong, - 0xd610fe275c427130 as ::core::ffi::c_ulonglong, - 0xcbfe74797e6ed0ec as ::core::ffi::c_ulonglong, - 0x9a77c3e390a9b5f8 as ::core::ffi::c_ulonglong, - 0x879949bdb2851424 as ::core::ffi::c_ulonglong, - 0xa1aad75fd4f0f640 as ::core::ffi::c_ulonglong, - 0xbc445d01f6dc579c as ::core::ffi::c_ulonglong, - 0x74f1233d072c2a36 as ::core::ffi::c_ulonglong, - 0x691fa96325008bea as ::core::ffi::c_ulonglong, - 0x4f2c37814375698e as ::core::ffi::c_ulonglong, - 0x52c2bddf6159c852 as ::core::ffi::c_ulonglong, - 0x34b0a458f9ead46 as ::core::ffi::c_ulonglong, - 0x1ea5801badb20c9a as ::core::ffi::c_ulonglong, - 0x38961ef9cbc7eefe as ::core::ffi::c_ulonglong, - 0x257894a7e9eb4f22 as ::core::ffi::c_ulonglong, - 0x9b8571cc164924d6 as ::core::ffi::c_ulonglong, - 0x866bfb923465850a as ::core::ffi::c_ulonglong, - 0xa05865705210676e as ::core::ffi::c_ulonglong, - 0xbdb6ef2e703cc6b2 as ::core::ffi::c_ulonglong, - 0xec3f58b49efba3a6 as ::core::ffi::c_ulonglong, - 0xf1d1d2eabcd7027a as ::core::ffi::c_ulonglong, - 0xd7e24c08daa2e01e as ::core::ffi::c_ulonglong, - 0xca0cc656f88e41c2 as ::core::ffi::c_ulonglong, - 0x38c129f48ae82973 as ::core::ffi::c_ulonglong, - 0x252fa3aaa8c488af as ::core::ffi::c_ulonglong, - 0x31c3d48ceb16acb as ::core::ffi::c_ulonglong, - 0x1ef2b716ec9dcb17 as ::core::ffi::c_ulonglong, - 0x4f7b008c025aae03 as ::core::ffi::c_ulonglong, - 0x52958ad220760fdf as ::core::ffi::c_ulonglong, - 0x74a614304603edbb as ::core::ffi::c_ulonglong, - 0x69489e6e642f4c67 as ::core::ffi::c_ulonglong, - 0xd7b57b059b8d2793 as ::core::ffi::c_ulonglong, - 0xca5bf15bb9a1864f as ::core::ffi::c_ulonglong, - 0xec686fb9dfd4642b as ::core::ffi::c_ulonglong, - 0xf186e5e7fdf8c5f7 as ::core::ffi::c_ulonglong, - 0xa00f527d133fa0e3 as ::core::ffi::c_ulonglong, - 0xbde1d8233113013f as ::core::ffi::c_ulonglong, - 0x9bd246c15766e35b as ::core::ffi::c_ulonglong, - 0x863ccc9f754a4287 as ::core::ffi::c_ulonglong, - 0xec9136ae1ca42cbc as ::core::ffi::c_ulonglong, - 0xf17fbcf03e888d60 as ::core::ffi::c_ulonglong, - 0xd74c221258fd6f04 as ::core::ffi::c_ulonglong, - 0xcaa2a84c7ad1ced8 as ::core::ffi::c_ulonglong, - 0x9b2b1fd69416abcc as ::core::ffi::c_ulonglong, - 0x86c59588b63a0a10 as ::core::ffi::c_ulonglong, - 0xa0f60b6ad04fe874 as ::core::ffi::c_ulonglong, - 0xbd188134f26349a8 as ::core::ffi::c_ulonglong, - 0x3e5645f0dc1225c as ::core::ffi::c_ulonglong, - 0x1e0bee012fed8380 as ::core::ffi::c_ulonglong, - 0x383870e3499861e4 as ::core::ffi::c_ulonglong, - 0x25d6fabd6bb4c038 as ::core::ffi::c_ulonglong, - 0x745f4d278573a52c as ::core::ffi::c_ulonglong, - 0x69b1c779a75f04f0 as ::core::ffi::c_ulonglong, - 0x4f82599bc12ae694 as ::core::ffi::c_ulonglong, - 0x526cd3c5e3064748 as ::core::ffi::c_ulonglong, - 0xa0a13c6791602ff9 as ::core::ffi::c_ulonglong, - 0xbd4fb639b34c8e25 as ::core::ffi::c_ulonglong, - 0x9b7c28dbd5396c41 as ::core::ffi::c_ulonglong, - 0x8692a285f715cd9d as ::core::ffi::c_ulonglong, - 0xd71b151f19d2a889 as ::core::ffi::c_ulonglong, - 0xcaf59f413bfe0955 as ::core::ffi::c_ulonglong, - 0xecc601a35d8beb31 as ::core::ffi::c_ulonglong, - 0xf1288bfd7fa74aed as ::core::ffi::c_ulonglong, - 0x4fd56e9680052119 as ::core::ffi::c_ulonglong, - 0x523be4c8a22980c5 as ::core::ffi::c_ulonglong, - 0x74087a2ac45c62a1 as ::core::ffi::c_ulonglong, - 0x69e6f074e670c37d as ::core::ffi::c_ulonglong, - 0x386f47ee08b7a669 as ::core::ffi::c_ulonglong, - 0x2581cdb02a9b07b5 as ::core::ffi::c_ulonglong, - 0x3b253524ceee5d1 as ::core::ffi::c_ulonglong, - 0x1e5cd90c6ec2440d as ::core::ffi::c_ulonglong, + 0, + 0x1dee8a5e222ca1dc, + 0x3bdd14bc445943b8, + 0x26339ee26675e264, + 0x77ba297888b28770, + 0x6a54a326aa9e26ac, + 0x4c673dc4ccebc4c8, + 0x5189b79aeec76514, + 0xef7452f111650ee0, + 0xf29ad8af3349af3c, + 0xd4a9464d553c4d58, + 0xc947cc137710ec84, + 0x98ce7b8999d78990, + 0x8520f1d7bbfb284c, + 0xa3136f35dd8eca28, + 0xbefde56bffa26bf4, + 0x4c300ac98dc40345, + 0x51de8097afe8a299, + 0x77ed1e75c99d40fd, + 0x6a03942bebb1e121, + 0x3b8a23b105768435, + 0x2664a9ef275a25e9, + 0x57370d412fc78d, + 0x1db9bd5363036651, + 0xa34458389ca10da5, + 0xbeaad266be8dac79, + 0x98994c84d8f84e1d, + 0x8577c6dafad4efc1, + 0xd4fe714014138ad5, + 0xc910fb1e363f2b09, + 0xef2365fc504ac96d, + 0xf2cdefa2726668b1, + 0x986015931b88068a, + 0x858e9fcd39a4a756, + 0xa3bd012f5fd14532, + 0xbe538b717dfde4ee, + 0xefda3ceb933a81fa, + 0xf234b6b5b1162026, + 0xd4072857d763c242, + 0xc9e9a209f54f639e, + 0x771447620aed086a, + 0x6afacd3c28c1a9b6, + 0x4cc953de4eb44bd2, + 0x5127d9806c98ea0e, + 0xae6e1a825f8f1a, + 0x1d40e444a0732ec6, + 0x3b737aa6c606cca2, + 0x269df0f8e42a6d7e, + 0xd4501f5a964c05cf, + 0xc9be9504b460a413, + 0xef8d0be6d2154677, + 0xf26381b8f039e7ab, + 0xa3ea36221efe82bf, + 0xbe04bc7c3cd22363, + 0x9837229e5aa7c107, + 0x85d9a8c0788b60db, + 0x3b244dab87290b2f, + 0x26cac7f5a505aaf3, + 0xf95917c3704897, + 0x1d17d349e15ce94b, + 0x4c9e64d30f9b8c5f, + 0x5170ee8d2db72d83, + 0x7743706f4bc2cfe7, + 0x6aadfa3169ee6e3b, + 0xa218840d981e1391, + 0xbff60e53ba32b24d, + 0x99c590b1dc475029, + 0x842b1aeffe6bf1f5, + 0xd5a2ad7510ac94e1, + 0xc84c272b3280353d, + 0xee7fb9c954f5d759, + 0xf391339776d97685, + 0x4d6cd6fc897b1d71, + 0x50825ca2ab57bcad, + 0x76b1c240cd225ec9, + 0x6b5f481eef0eff15, + 0x3ad6ff8401c99a01, + 0x273875da23e53bdd, + 0x10beb384590d9b9, + 0x1ce5616667bc7865, + 0xee288ec415da10d4, + 0xf3c6049a37f6b108, + 0xd5f59a785183536c, + 0xc81b102673aff2b0, + 0x9992a7bc9d6897a4, + 0x847c2de2bf443678, + 0xa24fb300d931d41c, + 0xbfa1395efb1d75c0, + 0x15cdc3504bf1e34, + 0x1cb2566b2693bfe8, + 0x3a81c88940e65d8c, + 0x276f42d762cafc50, + 0x76e6f54d8c0d9944, + 0x6b087f13ae213898, + 0x4d3be1f1c854dafc, + 0x50d56bafea787b20, + 0x3a78919e8396151b, + 0x27961bc0a1bab4c7, + 0x1a58522c7cf56a3, + 0x1c4b0f7ce5e3f77f, + 0x4dc2b8e60b24926b, + 0x502c32b8290833b7, + 0x761fac5a4f7dd1d3, + 0x6bf126046d51700f, + 0xd50cc36f92f31bfb, + 0xc8e24931b0dfba27, + 0xeed1d7d3d6aa5843, + 0xf33f5d8df486f99f, + 0xa2b6ea171a419c8b, + 0xbf586049386d3d57, + 0x996bfeab5e18df33, + 0x848574f57c347eef, + 0x76489b570e52165e, + 0x6ba611092c7eb782, + 0x4d958feb4a0b55e6, + 0x507b05b56827f43a, + 0x1f2b22f86e0912e, + 0x1c1c3871a4cc30f2, + 0x3a2fa693c2b9d296, + 0x27c12ccde095734a, + 0x993cc9a61f3718be, + 0x84d243f83d1bb962, + 0xa2e1dd1a5b6e5b06, + 0xbf0f57447942fada, + 0xee86e0de97859fce, + 0xf3686a80b5a93e12, + 0xd55bf462d3dcdc76, + 0xc8b57e3cf1f07daa, + 0xd6e9a7309f3239a7, + 0xcb072d6ebd1e987b, + 0xed34b38cdb6b7a1f, + 0xf0da39d2f947dbc3, + 0xa1538e481780bed7, + 0xbcbd041635ac1f0b, + 0x9a8e9af453d9fd6f, + 0x876010aa71f55cb3, + 0x399df5c18e573747, + 0x24737f9fac7b969b, + 0x240e17dca0e74ff, + 0x1fae6b23e822d523, + 0x4e27dcb906e5b037, + 0x53c956e724c911eb, + 0x75fac80542bcf38f, + 0x6814425b60905253, + 0x9ad9adf912f63ae2, + 0x873727a730da9b3e, + 0xa104b94556af795a, + 0xbcea331b7483d886, + 0xed6384819a44bd92, + 0xf08d0edfb8681c4e, + 0xd6be903dde1dfe2a, + 0xcb501a63fc315ff6, + 0x75adff0803933402, + 0x6843755621bf95de, + 0x4e70ebb447ca77ba, + 0x539e61ea65e6d666, + 0x217d6708b21b372, + 0x1ff95c2ea90d12ae, + 0x39cac2cccf78f0ca, + 0x24244892ed545116, + 0x4e89b2a384ba3f2d, + 0x536738fda6969ef1, + 0x7554a61fc0e37c95, + 0x68ba2c41e2cfdd49, + 0x39339bdb0c08b85d, + 0x24dd11852e241981, + 0x2ee8f674851fbe5, + 0x1f0005396a7d5a39, + 0xa1fde05295df31cd, + 0xbc136a0cb7f39011, + 0x9a20f4eed1867275, + 0x87ce7eb0f3aad3a9, + 0xd647c92a1d6db6bd, + 0xcba943743f411761, + 0xed9add965934f505, + 0xf07457c87b1854d9, + 0x2b9b86a097e3c68, + 0x1f5732342b529db4, + 0x3964acd64d277fd0, + 0x248a26886f0bde0c, + 0x7503911281ccbb18, + 0x68ed1b4ca3e01ac4, + 0x4ede85aec595f8a0, + 0x53300ff0e7b9597c, + 0xedcdea9b181b3288, + 0xf02360c53a379354, + 0xd610fe275c427130, + 0xcbfe74797e6ed0ec, + 0x9a77c3e390a9b5f8, + 0x879949bdb2851424, + 0xa1aad75fd4f0f640, + 0xbc445d01f6dc579c, + 0x74f1233d072c2a36, + 0x691fa96325008bea, + 0x4f2c37814375698e, + 0x52c2bddf6159c852, + 0x34b0a458f9ead46, + 0x1ea5801badb20c9a, + 0x38961ef9cbc7eefe, + 0x257894a7e9eb4f22, + 0x9b8571cc164924d6, + 0x866bfb923465850a, + 0xa05865705210676e, + 0xbdb6ef2e703cc6b2, + 0xec3f58b49efba3a6, + 0xf1d1d2eabcd7027a, + 0xd7e24c08daa2e01e, + 0xca0cc656f88e41c2, + 0x38c129f48ae82973, + 0x252fa3aaa8c488af, + 0x31c3d48ceb16acb, + 0x1ef2b716ec9dcb17, + 0x4f7b008c025aae03, + 0x52958ad220760fdf, + 0x74a614304603edbb, + 0x69489e6e642f4c67, + 0xd7b57b059b8d2793, + 0xca5bf15bb9a1864f, + 0xec686fb9dfd4642b, + 0xf186e5e7fdf8c5f7, + 0xa00f527d133fa0e3, + 0xbde1d8233113013f, + 0x9bd246c15766e35b, + 0x863ccc9f754a4287, + 0xec9136ae1ca42cbc, + 0xf17fbcf03e888d60, + 0xd74c221258fd6f04, + 0xcaa2a84c7ad1ced8, + 0x9b2b1fd69416abcc, + 0x86c59588b63a0a10, + 0xa0f60b6ad04fe874, + 0xbd188134f26349a8, + 0x3e5645f0dc1225c, + 0x1e0bee012fed8380, + 0x383870e3499861e4, + 0x25d6fabd6bb4c038, + 0x745f4d278573a52c, + 0x69b1c779a75f04f0, + 0x4f82599bc12ae694, + 0x526cd3c5e3064748, + 0xa0a13c6791602ff9, + 0xbd4fb639b34c8e25, + 0x9b7c28dbd5396c41, + 0x8692a285f715cd9d, + 0xd71b151f19d2a889, + 0xcaf59f413bfe0955, + 0xecc601a35d8beb31, + 0xf1288bfd7fa74aed, + 0x4fd56e9680052119, + 0x523be4c8a22980c5, + 0x74087a2ac45c62a1, + 0x69e6f074e670c37d, + 0x386f47ee08b7a669, + 0x2581cdb02a9b07b5, + 0x3b253524ceee5d1, + 0x1e5cd90c6ec2440d, ], ]; -unsafe extern "C" fn lzma_crc64_generic( - mut buf: *const uint8_t, - mut size: size_t, - mut crc: uint64_t, -) -> uint64_t { +unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mut crc: u64) -> u64 { crc = !crc; if size > 4 as size_t { - while buf as uintptr_t & 3 as ::core::ffi::c_int as uintptr_t != 0 { + while buf as uintptr_t & 3 as uintptr_t != 0 { let fresh0 = buf; buf = buf.offset(1); - crc = lzma_crc64_table[0 as ::core::ffi::c_int - as usize][(*fresh0 as uint64_t ^ crc & 0xff as uint64_t) as usize] - ^ crc >> 8 as ::core::ffi::c_int; + crc = lzma_crc64_table[0 as usize][(*fresh0 as u64 ^ crc & 0xff as u64) as usize] + ^ crc >> 8 as c_int; size = size.wrapping_sub(1); } - let limit: *const uint8_t = buf - .offset((size & !(3 as ::core::ffi::c_int as size_t)) as isize); - size &= 3 as ::core::ffi::c_int as size_t; + let limit: *const u8 = buf.offset((size & !(3 as size_t)) as isize); + size &= 3 as size_t; while buf < limit { - let tmp: uint32_t = crc as uint32_t ^ aligned_read32ne(buf) as uint32_t; - buf = buf.offset(4 as ::core::ffi::c_int as isize); - crc = lzma_crc64_table[3 as ::core::ffi::c_int - as usize][(tmp & 0xff as uint32_t) as usize] - ^ lzma_crc64_table[2 as ::core::ffi::c_int - as usize][(tmp >> 8 as ::core::ffi::c_int & 0xff as uint32_t) - as usize] ^ crc >> 32 as ::core::ffi::c_int - ^ lzma_crc64_table[1 as ::core::ffi::c_int - as usize][(tmp >> 16 as ::core::ffi::c_int & 0xff as uint32_t) - as usize] - ^ lzma_crc64_table[0 as ::core::ffi::c_int - as usize][(tmp >> 24 as ::core::ffi::c_int) as usize]; + let tmp: u32 = crc as u32 ^ aligned_read32ne(buf) as u32; + buf = buf.offset(4 as isize); + crc = lzma_crc64_table[3 as usize][(tmp & 0xff as u32) as usize] + ^ lzma_crc64_table[2 as usize][(tmp >> 8 as c_int & 0xff as u32) as usize] + ^ crc >> 32 as c_int + ^ lzma_crc64_table[1 as usize][(tmp >> 16 as c_int & 0xff as u32) as usize] + ^ lzma_crc64_table[0 as usize][(tmp >> 24 as c_int) as usize]; } } loop { @@ -1084,17 +1069,12 @@ unsafe extern "C" fn lzma_crc64_generic( } let fresh2 = buf; buf = buf.offset(1); - crc = lzma_crc64_table[0 as ::core::ffi::c_int - as usize][(*fresh2 as uint64_t ^ crc & 0xff as uint64_t) as usize] - ^ crc >> 8 as ::core::ffi::c_int; + crc = lzma_crc64_table[0 as usize][(*fresh2 as u64 ^ crc & 0xff as u64) as usize] + ^ crc >> 8 as c_int; } return !crc; } #[no_mangle] -pub unsafe extern "C" fn lzma_crc64( - mut buf: *const uint8_t, - mut size: size_t, - mut crc: uint64_t, -) -> uint64_t { +pub unsafe extern "C" fn lzma_crc64(mut buf: *const u8, mut size: size_t, mut crc: u64) -> u64 { return lzma_crc64_generic(buf, size, crc); } diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index 7bc296a4..e22b8d69 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -1,20 +1,13 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_sha256_state { - pub state: [uint32_t; 8], - pub size: uint64_t, + pub state: [u32; 8], + pub size: u64, } #[derive(Copy, Clone)] #[repr(C)] @@ -25,3410 +18,2153 @@ pub struct lzma_check_state { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed { - pub crc32: uint32_t, - pub crc64: uint64_t, + pub crc32: u32, + pub crc64: u64, pub sha256: lzma_sha256_state, } #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_0 { - pub u8_0: [uint8_t; 64], - pub u32_0: [uint32_t; 16], - pub u64_0: [uint64_t; 8], + pub u8_0: [u8; 64], + pub u32_0: [u32; 16], + pub u64_0: [u64; 8], } #[inline] -unsafe extern "C" fn rotr_32( - mut num: uint32_t, - mut amount: ::core::ffi::c_uint, -) -> uint32_t { - return num >> amount | num << (32 as ::core::ffi::c_uint).wrapping_sub(amount); +unsafe extern "C" fn rotr_32(mut num: u32, mut amount: c_uint) -> u32 { + return num >> amount | num << (32 as c_uint).wrapping_sub(amount); } -static mut SHA256_K: [uint32_t; 64] = [ - 0x428a2f98 as ::core::ffi::c_int as uint32_t, - 0x71374491 as ::core::ffi::c_int as uint32_t, - 0xb5c0fbcf as ::core::ffi::c_uint, - 0xe9b5dba5 as ::core::ffi::c_uint, - 0x3956c25b as ::core::ffi::c_int as uint32_t, - 0x59f111f1 as ::core::ffi::c_int as uint32_t, - 0x923f82a4 as ::core::ffi::c_uint, - 0xab1c5ed5 as ::core::ffi::c_uint, - 0xd807aa98 as ::core::ffi::c_uint, - 0x12835b01 as ::core::ffi::c_int as uint32_t, - 0x243185be as ::core::ffi::c_int as uint32_t, - 0x550c7dc3 as ::core::ffi::c_int as uint32_t, - 0x72be5d74 as ::core::ffi::c_int as uint32_t, - 0x80deb1fe as ::core::ffi::c_uint, - 0x9bdc06a7 as ::core::ffi::c_uint, - 0xc19bf174 as ::core::ffi::c_uint, - 0xe49b69c1 as ::core::ffi::c_uint, - 0xefbe4786 as ::core::ffi::c_uint, - 0xfc19dc6 as ::core::ffi::c_int as uint32_t, - 0x240ca1cc as ::core::ffi::c_int as uint32_t, - 0x2de92c6f as ::core::ffi::c_int as uint32_t, - 0x4a7484aa as ::core::ffi::c_int as uint32_t, - 0x5cb0a9dc as ::core::ffi::c_int as uint32_t, - 0x76f988da as ::core::ffi::c_int as uint32_t, - 0x983e5152 as ::core::ffi::c_uint, - 0xa831c66d as ::core::ffi::c_uint, - 0xb00327c8 as ::core::ffi::c_uint, - 0xbf597fc7 as ::core::ffi::c_uint, - 0xc6e00bf3 as ::core::ffi::c_uint, - 0xd5a79147 as ::core::ffi::c_uint, - 0x6ca6351 as ::core::ffi::c_int as uint32_t, - 0x14292967 as ::core::ffi::c_int as uint32_t, - 0x27b70a85 as ::core::ffi::c_int as uint32_t, - 0x2e1b2138 as ::core::ffi::c_int as uint32_t, - 0x4d2c6dfc as ::core::ffi::c_int as uint32_t, - 0x53380d13 as ::core::ffi::c_int as uint32_t, - 0x650a7354 as ::core::ffi::c_int as uint32_t, - 0x766a0abb as ::core::ffi::c_int as uint32_t, - 0x81c2c92e as ::core::ffi::c_uint, - 0x92722c85 as ::core::ffi::c_uint, - 0xa2bfe8a1 as ::core::ffi::c_uint, - 0xa81a664b as ::core::ffi::c_uint, - 0xc24b8b70 as ::core::ffi::c_uint, - 0xc76c51a3 as ::core::ffi::c_uint, - 0xd192e819 as ::core::ffi::c_uint, - 0xd6990624 as ::core::ffi::c_uint, - 0xf40e3585 as ::core::ffi::c_uint, - 0x106aa070 as ::core::ffi::c_int as uint32_t, - 0x19a4c116 as ::core::ffi::c_int as uint32_t, - 0x1e376c08 as ::core::ffi::c_int as uint32_t, - 0x2748774c as ::core::ffi::c_int as uint32_t, - 0x34b0bcb5 as ::core::ffi::c_int as uint32_t, - 0x391c0cb3 as ::core::ffi::c_int as uint32_t, - 0x4ed8aa4a as ::core::ffi::c_int as uint32_t, - 0x5b9cca4f as ::core::ffi::c_int as uint32_t, - 0x682e6ff3 as ::core::ffi::c_int as uint32_t, - 0x748f82ee as ::core::ffi::c_int as uint32_t, - 0x78a5636f as ::core::ffi::c_int as uint32_t, - 0x84c87814 as ::core::ffi::c_uint, - 0x8cc70208 as ::core::ffi::c_uint, - 0x90befffa as ::core::ffi::c_uint, - 0xa4506ceb as ::core::ffi::c_uint, - 0xbef9a3f7 as ::core::ffi::c_uint, - 0xc67178f2 as ::core::ffi::c_uint, +static mut SHA256_K: [u32; 64] = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0xfc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x6ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, ]; -unsafe extern "C" fn transform(mut state: *mut uint32_t, mut data: *const uint32_t) { - let mut W: [uint32_t; 16] = [0; 16]; - let mut T: [uint32_t; 8] = [0; 8]; +unsafe extern "C" fn transform(mut state: *mut u32, mut data: *const u32) { + let mut W: [u32; 16] = [0; 16]; + let mut T: [u32; 8] = [0; 8]; memcpy( - &raw mut T as *mut uint32_t as *mut ::core::ffi::c_void, - state as *const ::core::ffi::c_void, - ::core::mem::size_of::<[uint32_t; 8]>() as size_t, + &raw mut T as *mut u32 as *mut c_void, + state as *const c_void, + ::core::mem::size_of::<[u32; 8]>() as size_t, ); - W[0 as ::core::ffi::c_int as usize] = (*data.offset(0 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(0 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(0 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(0 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[0 as usize] = (*data.offset(0 as isize) & 0xff) << 24 as c_int + | (*data.offset(0 as isize) & 0xff00) << 8 as c_int + | (*data.offset(0 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(0 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 0 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 0 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(0 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[0 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 0 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 0 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(0 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[0 as usize]), ); - T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 0 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 0 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 0 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 0 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 0 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 0 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 0 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 0 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 0 as c_int & 7 as c_int) as usize], + ), + ), ); - W[1 as ::core::ffi::c_int as usize] = (*data.offset(1 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(1 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(1 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(1 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[1 as usize] = (*data.offset(1 as isize) & 0xff) << 24 as c_int + | (*data.offset(1 as isize) & 0xff00) << 8 as c_int + | (*data.offset(1 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(1 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 1 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 1 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(1 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[1 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 1 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 1 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(1 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[1 as usize]), ); - T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 1 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 1 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 1 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 1 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 1 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 1 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 1 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 1 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 1 as c_int & 7 as c_int) as usize], + ), + ), ); - W[2 as ::core::ffi::c_int as usize] = (*data.offset(2 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(2 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(2 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(2 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[2 as usize] = (*data.offset(2 as isize) & 0xff) << 24 as c_int + | (*data.offset(2 as isize) & 0xff00) << 8 as c_int + | (*data.offset(2 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(2 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 2 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 2 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(2 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[2 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 2 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 2 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(2 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[2 as usize]), ); - T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 2 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 2 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 2 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 2 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 2 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 2 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 2 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 2 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 2 as c_int & 7 as c_int) as usize], + ), + ), ); - W[3 as ::core::ffi::c_int as usize] = (*data.offset(3 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(3 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(3 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(3 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[3 as usize] = (*data.offset(3 as isize) & 0xff) << 24 as c_int + | (*data.offset(3 as isize) & 0xff00) << 8 as c_int + | (*data.offset(3 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(3 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 3 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 3 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(3 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[3 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 3 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 3 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(3 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[3 as usize]), ); - T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 3 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 3 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 3 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 3 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 3 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 3 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 3 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 3 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 3 as c_int & 7 as c_int) as usize], + ), + ), ); - W[4 as ::core::ffi::c_int as usize] = (*data.offset(4 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(4 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(4 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(4 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[4 as usize] = (*data.offset(4 as isize) & 0xff) << 24 as c_int + | (*data.offset(4 as isize) & 0xff00) << 8 as c_int + | (*data.offset(4 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(4 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 4 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 4 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(4 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[4 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 4 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 4 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(4 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[4 as usize]), ); - T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 4 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 4 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 4 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 4 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 4 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 4 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 4 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 4 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 4 as c_int & 7 as c_int) as usize], + ), + ), ); - W[5 as ::core::ffi::c_int as usize] = (*data.offset(5 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(5 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(5 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(5 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[5 as usize] = (*data.offset(5 as isize) & 0xff) << 24 as c_int + | (*data.offset(5 as isize) & 0xff00) << 8 as c_int + | (*data.offset(5 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(5 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 5 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 5 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(5 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[5 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 5 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 5 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(5 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[5 as usize]), ); - T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 5 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 5 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 5 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 5 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 5 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 5 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 5 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 5 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 5 as c_int & 7 as c_int) as usize], + ), + ), ); - W[6 as ::core::ffi::c_int as usize] = (*data.offset(6 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(6 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(6 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(6 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[6 as usize] = (*data.offset(6 as isize) & 0xff) << 24 as c_int + | (*data.offset(6 as isize) & 0xff00) << 8 as c_int + | (*data.offset(6 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(6 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 6 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 6 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(6 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[6 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 6 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 6 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(6 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[6 as usize]), ); - T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 6 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 6 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 6 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 6 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 6 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 6 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 6 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 6 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 6 as c_int & 7 as c_int) as usize], + ), + ), ); - W[7 as ::core::ffi::c_int as usize] = (*data.offset(7 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(7 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(7 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(7 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[7 as usize] = (*data.offset(7 as isize) & 0xff) << 24 as c_int + | (*data.offset(7 as isize) & 0xff00) << 8 as c_int + | (*data.offset(7 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(7 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 7 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 7 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(7 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[7 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 7 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 7 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(7 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[7 as usize]), ); - T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 7 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 7 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 7 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 7 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 7 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 7 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 7 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 7 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 7 as c_int & 7 as c_int) as usize], + ), + ), ); - W[8 as ::core::ffi::c_int as usize] = (*data.offset(8 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(8 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(8 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(8 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[8 as usize] = (*data.offset(8 as isize) & 0xff) << 24 as c_int + | (*data.offset(8 as isize) & 0xff00) << 8 as c_int + | (*data.offset(8 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(8 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 8 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 8 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(8 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[8 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 8 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 8 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(8 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[8 as usize]), ); - T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 8 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 8 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 8 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 8 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 8 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 8 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 8 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 8 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 8 as c_int & 7 as c_int) as usize], + ), + ), ); - W[9 as ::core::ffi::c_int as usize] = (*data.offset(9 as ::core::ffi::c_int as isize) - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | (*data.offset(9 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(9 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(9 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[9 as usize] = (*data.offset(9 as isize) & 0xff) << 24 as c_int + | (*data.offset(9 as isize) & 0xff00) << 8 as c_int + | (*data.offset(9 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(9 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 9 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 9 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(9 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[9 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 9 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 9 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(9 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[9 as usize]), ); - T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 9 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 9 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 9 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 9 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 9 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 9 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 9 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 9 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 9 as c_int & 7 as c_int) as usize], + ), + ), ); - W[10 as ::core::ffi::c_int as usize] = (*data - .offset(10 as ::core::ffi::c_int as isize) & 0xff as uint32_t) - << 24 as ::core::ffi::c_int - | (*data.offset(10 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(10 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(10 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[10 as usize] = (*data.offset(10 as isize) & 0xff) << 24 as c_int + | (*data.offset(10 as isize) & 0xff00) << 8 as c_int + | (*data.offset(10 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(10 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 10 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 10 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(10 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[10 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 10 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 10 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(10 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[10 as usize]), ); - T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 10 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 10 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 10 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 10 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 10 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 10 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 10 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 10 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 10 as c_int & 7 as c_int) as usize], + ), + ), ); - W[11 as ::core::ffi::c_int as usize] = (*data - .offset(11 as ::core::ffi::c_int as isize) & 0xff as uint32_t) - << 24 as ::core::ffi::c_int - | (*data.offset(11 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(11 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(11 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[11 as usize] = (*data.offset(11 as isize) & 0xff) << 24 as c_int + | (*data.offset(11 as isize) & 0xff00) << 8 as c_int + | (*data.offset(11 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(11 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 11 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 11 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(11 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[11 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 11 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 11 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(11 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[11 as usize]), ); - T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 11 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 11 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 11 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 11 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 11 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 11 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 11 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 11 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 11 as c_int & 7 as c_int) as usize], + ), + ), ); - W[12 as ::core::ffi::c_int as usize] = (*data - .offset(12 as ::core::ffi::c_int as isize) & 0xff as uint32_t) - << 24 as ::core::ffi::c_int - | (*data.offset(12 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(12 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(12 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[12 as usize] = (*data.offset(12 as isize) & 0xff) << 24 as c_int + | (*data.offset(12 as isize) & 0xff00) << 8 as c_int + | (*data.offset(12 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(12 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 12 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 12 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(12 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[12 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 12 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 12 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(12 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[12 as usize]), ); - T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 12 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 12 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 12 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 12 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 12 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 12 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 12 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 12 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 12 as c_int & 7 as c_int) as usize], + ), + ), ); - W[13 as ::core::ffi::c_int as usize] = (*data - .offset(13 as ::core::ffi::c_int as isize) & 0xff as uint32_t) - << 24 as ::core::ffi::c_int - | (*data.offset(13 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(13 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(13 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[13 as usize] = (*data.offset(13 as isize) & 0xff) << 24 as c_int + | (*data.offset(13 as isize) & 0xff00) << 8 as c_int + | (*data.offset(13 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(13 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 13 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 13 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(13 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[13 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 13 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 13 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(13 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[13 as usize]), ); - T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 13 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 13 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 13 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 13 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 13 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 13 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 13 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 13 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 13 as c_int & 7 as c_int) as usize], + ), + ), ); - W[14 as ::core::ffi::c_int as usize] = (*data - .offset(14 as ::core::ffi::c_int as isize) & 0xff as uint32_t) - << 24 as ::core::ffi::c_int - | (*data.offset(14 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(14 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(14 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[14 as usize] = (*data.offset(14 as isize) & 0xff) << 24 as c_int + | (*data.offset(14 as isize) & 0xff00) << 8 as c_int + | (*data.offset(14 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(14 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 14 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 14 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(14 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[14 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 14 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 14 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(14 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[14 as usize]), ); - T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 14 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 14 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 14 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 14 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 14 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 14 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 14 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 14 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 14 as c_int & 7 as c_int) as usize], + ), + ), ); - W[15 as ::core::ffi::c_int as usize] = (*data - .offset(15 as ::core::ffi::c_int as isize) & 0xff as uint32_t) - << 24 as ::core::ffi::c_int - | (*data.offset(15 as ::core::ffi::c_int as isize) & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | (*data.offset(15 as ::core::ffi::c_int as isize) & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | (*data.offset(15 as ::core::ffi::c_int as isize) & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; - T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + W[15 as usize] = (*data.offset(15 as isize) & 0xff) << 24 as c_int + | (*data.offset(15 as isize) & 0xff00) << 8 as c_int + | (*data.offset(15 as isize) & 0xff0000) >> 8 as c_int + | (*data.offset(15 as isize) & 0xff000000) >> 24 as c_int; + T[(7 as c_int - 15 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 15 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(15 as ::core::ffi::c_int + 0 as ::core::ffi::c_int) - as usize], - ) - .wrapping_add(W[15 as ::core::ffi::c_int as usize]), - ); - T[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], + T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 15 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 15 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(15 as c_int + 0 as c_int) as usize]) + .wrapping_add(W[15 as usize]), ); - T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(3 as c_int - 15 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 15 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 15 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 15 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 15 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 15 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 15 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 15 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 15 as c_int & 7 as c_int) as usize], + ), + ), ); - let mut j: ::core::ffi::c_uint = 16 as ::core::ffi::c_uint; - while j < 64 as ::core::ffi::c_uint { - W[(0 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(0 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + let mut j: c_uint = 16 as c_uint; + while j < 64 as c_uint { + W[(0 as c_int & 15 as c_int) as usize] = W[(0 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(0 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(0 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(0 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(0 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(0 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(0 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(0 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 0 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 0 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(0 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(0 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 0 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 0 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(0 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(0 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 0 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 0 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 0 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 0 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 0 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 0 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 0 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 0 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 0 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 0 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(1 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(1 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(1 as c_int & 15 as c_int) as usize] = W[(1 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(1 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(1 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(1 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(1 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(1 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(1 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(1 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 1 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 1 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(1 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(1 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 1 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 1 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(1 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(1 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 1 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 1 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 1 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 1 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 1 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 1 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 1 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 1 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 1 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 1 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(2 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(2 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(2 as c_int & 15 as c_int) as usize] = W[(2 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(2 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(2 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(2 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(2 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(2 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(2 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(2 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 2 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 2 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(2 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(2 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 2 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 2 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(2 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(2 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 2 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 2 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 2 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 2 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 2 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 2 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 2 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 2 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 2 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 2 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(3 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(3 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(3 as c_int & 15 as c_int) as usize] = W[(3 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(3 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(3 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(3 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(3 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(3 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(3 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(3 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(3 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 3 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 3 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(3 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(3 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 3 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 3 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(3 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(3 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 3 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 3 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 3 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 3 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 3 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 3 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 3 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 3 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 3 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 3 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 3 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(4 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(4 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(4 as c_int & 15 as c_int) as usize] = W[(4 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(4 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(4 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(4 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(4 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(4 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(4 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(4 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 4 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 4 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(4 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(4 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 4 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 4 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(4 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(4 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 4 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 4 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 4 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 4 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 4 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 4 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 4 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 4 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 4 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 4 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 4 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(5 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(5 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(5 as c_int & 15 as c_int) as usize] = W[(5 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(5 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(5 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(5 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(5 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(5 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(5 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(5 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(5 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(5 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 5 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 5 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(5 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(5 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 5 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 5 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(5 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(5 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 5 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 5 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 5 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 5 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 5 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 5 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 5 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 5 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 5 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 5 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 5 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(6 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(6 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(6 as c_int & 15 as c_int) as usize] = W[(6 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(6 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(6 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(6 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(6 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(6 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(6 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(6 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 6 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 6 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(6 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(6 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 6 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 6 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(6 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(6 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 6 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 6 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 6 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 6 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 6 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 6 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 6 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 6 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 6 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 6 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 6 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(7 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(7 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(7 as c_int & 15 as c_int) as usize] = W[(7 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(7 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(7 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(7 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(7 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(7 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(7 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(7 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(7 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 7 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 7 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(7 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(7 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 7 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 7 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(7 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(7 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 7 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 7 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 7 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 7 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 7 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 7 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 7 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 7 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 7 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 7 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(8 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(8 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(8 as c_int & 15 as c_int) as usize] = W[(8 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(8 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(8 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(8 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(8 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(8 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(8 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(8 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(8 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(8 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(8 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(8 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 8 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 8 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(8 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(8 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 8 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 8 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(8 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(8 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 8 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 8 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 8 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 8 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 8 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 8 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 8 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 8 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 8 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 8 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 8 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(9 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(9 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(9 as c_int & 15 as c_int) as usize] = W[(9 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(9 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(9 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(9 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(9 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(9 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(9 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(9 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(9 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(9 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(9 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(9 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(9 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(9 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(9 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 9 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 9 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(9 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(9 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 9 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 9 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(9 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(9 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 9 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 9 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 9 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 9 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 9 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 9 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 9 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 9 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 9 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 9 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 9 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(10 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(10 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(10 as c_int & 15 as c_int) as usize] = W[(10 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(10 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(10 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(10 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(10 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(10 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(10 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(10 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(10 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(10 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(10 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(10 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(10 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(10 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(10 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 10 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 10 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(10 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(10 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 10 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 10 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(10 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(10 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 10 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 10 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 10 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 10 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 10 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 10 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 10 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 10 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 10 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 10 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 10 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(11 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(11 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(11 as c_int & 15 as c_int) as usize] = W[(11 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(11 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(11 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(11 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(11 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(11 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(11 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(11 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(11 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(11 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(11 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(11 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(11 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(11 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(11 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 11 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 11 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(11 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(11 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 11 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 11 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(11 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(11 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 11 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 11 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 11 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 11 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 11 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 11 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 11 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 11 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 11 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 11 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 11 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(12 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(12 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(12 as c_int & 15 as c_int) as usize] = W[(12 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(12 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(12 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(12 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(12 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(12 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(12 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(12 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(12 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(12 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(12 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(12 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(12 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(12 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(12 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 12 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 12 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(12 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(12 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 12 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 12 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(12 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(12 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 12 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 12 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 12 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 12 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 12 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 12 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 12 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 12 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 12 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 12 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 12 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(13 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(13 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(13 as c_int & 15 as c_int) as usize] = W[(13 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(13 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(13 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(13 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(13 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(13 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(13 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(13 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(13 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(13 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(13 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(13 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(13 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(13 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(13 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 13 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 13 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(13 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(13 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 13 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 13 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(13 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(13 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 13 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 13 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 13 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 13 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 13 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 13 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 13 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 13 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 13 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 13 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 13 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(14 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(14 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(14 as c_int & 15 as c_int) as usize] = W[(14 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(14 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(14 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(14 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(14 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(14 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(14 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(14 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(14 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(14 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(14 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(14 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(14 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(14 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(14 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 14 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 14 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(14 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(14 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 14 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 14 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(14 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(14 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 14 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 14 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 14 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 14 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 14 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 14 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 14 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 14 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 14 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 14 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 14 as c_int & 7 as c_int) as usize], + ), + ), ); - W[(15 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] = W[(15 - as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize] + W[(15 as c_int & 15 as c_int) as usize] = W[(15 as c_int & 15 as c_int) as usize] .wrapping_add( (rotr_32( - W[(15 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(15 as c_int - 2 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(15 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 2 as ::core::ffi::c_uint, + W[(15 as c_int - 2 as c_int & 15 as c_int) as usize], + 2 as c_uint, ), - 17 as ::core::ffi::c_uint, - ) - ^ W[(15 as ::core::ffi::c_int - 2 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 10 as ::core::ffi::c_int) - .wrapping_add( - W[(15 as ::core::ffi::c_int - 7 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - ) + 17 as c_uint, + ) ^ W[(15 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) + .wrapping_add(W[(15 as c_int - 7 as c_int & 15 as c_int) as usize]) .wrapping_add( rotr_32( - W[(15 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] + W[(15 as c_int - 15 as c_int & 15 as c_int) as usize] ^ rotr_32( - W[(15 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize], - 11 as ::core::ffi::c_uint, + W[(15 as c_int - 15 as c_int & 15 as c_int) as usize], + 11 as c_uint, ), - 7 as ::core::ffi::c_uint, - ) - ^ W[(15 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 15 as ::core::ffi::c_int) as usize] - >> 3 as ::core::ffi::c_int, + 7 as c_uint, + ) ^ W[(15 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, ), ); - T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(7 as c_int - 15 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 15 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 14 as ::core::ffi::c_uint, - ), - 5 as ::core::ffi::c_uint, - ), - 6 as ::core::ffi::c_uint, - ) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(4 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(5 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(6 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize]), - ) - .wrapping_add( - SHA256_K[(15 as ::core::ffi::c_uint).wrapping_add(j) as usize], - ) - .wrapping_add( - W[(15 as ::core::ffi::c_int & 15 as ::core::ffi::c_int) as usize], - ), - ); - T[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(3 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( - T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int & 7 as ::core::ffi::c_int) - as usize] = T[(7 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - .wrapping_add( + T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(4 as c_int - 15 as c_int & 7 as c_int) as usize], + 14 as c_uint, + ), + 5 as c_uint, + ), + 6 as c_uint, + ) + .wrapping_add( + T[(6 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] + & (T[(5 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ T[(6 as c_int - 15 as c_int & 7 as c_int) as usize]), + ) + .wrapping_add(SHA256_K[(15 as c_uint).wrapping_add(j) as usize]) + .wrapping_add(W[(15 as c_int & 15 as c_int) as usize]), + ); + T[(3 as c_int - 15 as c_int & 7 as c_int) as usize] = T + [(3 as c_int - 15 as c_int & 7 as c_int) as usize] + .wrapping_add(T[(7 as c_int - 15 as c_int & 7 as c_int) as usize]); + T[(7 as c_int - 15 as c_int & 7 as c_int) as usize] = + T[(7 as c_int - 15 as c_int & 7 as c_int) as usize].wrapping_add( rotr_32( - T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ rotr_32( - T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - 9 as ::core::ffi::c_uint, - ), - 11 as ::core::ffi::c_uint, - ), - 2 as ::core::ffi::c_uint, - ) - .wrapping_add( - (T[(0 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & (T[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - ^ T[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize])) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize] - & T[(2 as ::core::ffi::c_int - 15 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ), - ), + T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ rotr_32( + T[(0 as c_int - 15 as c_int & 7 as c_int) as usize], + 9 as c_uint, + ), + 11 as c_uint, + ), + 2 as c_uint, + ) + .wrapping_add( + (T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] + & (T[(1 as c_int - 15 as c_int & 7 as c_int) as usize] + ^ T[(2 as c_int - 15 as c_int & 7 as c_int) as usize])) + .wrapping_add( + T[(1 as c_int - 15 as c_int & 7 as c_int) as usize] + & T[(2 as c_int - 15 as c_int & 7 as c_int) as usize], + ), + ), ); - j = j.wrapping_add(16 as ::core::ffi::c_uint); + j = j.wrapping_add(16 as c_uint); } - let ref mut fresh0 = *state.offset(0 as ::core::ffi::c_int as isize); - *fresh0 = (*fresh0) - .wrapping_add( - T[(0 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - let ref mut fresh1 = *state.offset(1 as ::core::ffi::c_int as isize); - *fresh1 = (*fresh1) - .wrapping_add( - T[(1 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - let ref mut fresh2 = *state.offset(2 as ::core::ffi::c_int as isize); - *fresh2 = (*fresh2) - .wrapping_add( - T[(2 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - let ref mut fresh3 = *state.offset(3 as ::core::ffi::c_int as isize); - *fresh3 = (*fresh3) - .wrapping_add( - T[(3 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - let ref mut fresh4 = *state.offset(4 as ::core::ffi::c_int as isize); - *fresh4 = (*fresh4) - .wrapping_add( - T[(4 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - let ref mut fresh5 = *state.offset(5 as ::core::ffi::c_int as isize); - *fresh5 = (*fresh5) - .wrapping_add( - T[(5 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - let ref mut fresh6 = *state.offset(6 as ::core::ffi::c_int as isize); - *fresh6 = (*fresh6) - .wrapping_add( - T[(6 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); - let ref mut fresh7 = *state.offset(7 as ::core::ffi::c_int as isize); - *fresh7 = (*fresh7) - .wrapping_add( - T[(7 as ::core::ffi::c_int - 0 as ::core::ffi::c_int - & 7 as ::core::ffi::c_int) as usize], - ); + let ref mut fresh0 = *state.offset(0 as isize); + *fresh0 = (*fresh0).wrapping_add(T[(0 as c_int - 0 as c_int & 7 as c_int) as usize]); + let ref mut fresh1 = *state.offset(1 as isize); + *fresh1 = (*fresh1).wrapping_add(T[(1 as c_int - 0 as c_int & 7 as c_int) as usize]); + let ref mut fresh2 = *state.offset(2 as isize); + *fresh2 = (*fresh2).wrapping_add(T[(2 as c_int - 0 as c_int & 7 as c_int) as usize]); + let ref mut fresh3 = *state.offset(3 as isize); + *fresh3 = (*fresh3).wrapping_add(T[(3 as c_int - 0 as c_int & 7 as c_int) as usize]); + let ref mut fresh4 = *state.offset(4 as isize); + *fresh4 = (*fresh4).wrapping_add(T[(4 as c_int - 0 as c_int & 7 as c_int) as usize]); + let ref mut fresh5 = *state.offset(5 as isize); + *fresh5 = (*fresh5).wrapping_add(T[(5 as c_int - 0 as c_int & 7 as c_int) as usize]); + let ref mut fresh6 = *state.offset(6 as isize); + *fresh6 = (*fresh6).wrapping_add(T[(6 as c_int - 0 as c_int & 7 as c_int) as usize]); + let ref mut fresh7 = *state.offset(7 as isize); + *fresh7 = (*fresh7).wrapping_add(T[(7 as c_int - 0 as c_int & 7 as c_int) as usize]); } unsafe extern "C" fn process(mut check: *mut lzma_check_state) { transform( - &raw mut (*check).state.sha256.state as *mut uint32_t, - &raw mut (*check).buffer.u32_0 as *mut uint32_t as *const uint32_t, + &raw mut (*check).state.sha256.state as *mut u32, + &raw mut (*check).buffer.u32_0 as *mut u32 as *const u32, ); } #[no_mangle] pub unsafe extern "C" fn lzma_sha256_init(mut check: *mut lzma_check_state) { - static mut s: [uint32_t; 8] = [ - 0x6a09e667 as ::core::ffi::c_int as uint32_t, - 0xbb67ae85 as ::core::ffi::c_uint, - 0x3c6ef372 as ::core::ffi::c_int as uint32_t, - 0xa54ff53a as ::core::ffi::c_uint, - 0x510e527f as ::core::ffi::c_int as uint32_t, - 0x9b05688c as ::core::ffi::c_uint, - 0x1f83d9ab as ::core::ffi::c_int as uint32_t, - 0x5be0cd19 as ::core::ffi::c_int as uint32_t, + static mut s: [u32; 8] = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, + 0x5be0cd19, ]; memcpy( - &raw mut (*check).state.sha256.state as *mut uint32_t - as *mut ::core::ffi::c_void, - &raw const s as *const uint32_t as *const ::core::ffi::c_void, - ::core::mem::size_of::<[uint32_t; 8]>() as size_t, + &raw mut (*check).state.sha256.state as *mut u32 as *mut c_void, + &raw const s as *const u32 as *const c_void, + ::core::mem::size_of::<[u32; 8]>() as size_t, ); - (*check).state.sha256.size = 0 as uint64_t; + (*check).state.sha256.size = 0 as u64; } #[no_mangle] pub unsafe extern "C" fn lzma_sha256_update( - mut buf: *const uint8_t, + mut buf: *const u8, mut size: size_t, mut check: *mut lzma_check_state, ) { while size > 0 as size_t { - let copy_start: size_t = ((*check).state.sha256.size & 0x3f as uint64_t) - as size_t; + let copy_start: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; let mut copy_size: size_t = (64 as size_t).wrapping_sub(copy_start); if copy_size > size { copy_size = size; } memcpy( - (&raw mut (*check).buffer.u8_0 as *mut uint8_t).offset(copy_start as isize) - as *mut ::core::ffi::c_void, - buf as *const ::core::ffi::c_void, + (&raw mut (*check).buffer.u8_0 as *mut u8).offset(copy_start as isize) as *mut c_void, + buf as *const c_void, copy_size, ); buf = buf.offset(copy_size as isize); size = size.wrapping_sub(copy_size); - (*check).state.sha256.size = (*check) - .state - .sha256 - .size - .wrapping_add(copy_size as uint64_t); - if (*check).state.sha256.size & 0x3f as uint64_t == 0 as uint64_t { + (*check).state.sha256.size = (*check).state.sha256.size.wrapping_add(copy_size as u64); + if (*check).state.sha256.size & 0x3f as u64 == 0 as u64 { process(check); } } } #[no_mangle] pub unsafe extern "C" fn lzma_sha256_finish(mut check: *mut lzma_check_state) { - let mut pos: size_t = ((*check).state.sha256.size & 0x3f as uint64_t) as size_t; + let mut pos: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; let fresh8 = pos; pos = pos.wrapping_add(1); - (*check).buffer.u8_0[fresh8 as usize] = 0x80 as uint8_t; - while pos != (64 as ::core::ffi::c_int - 8 as ::core::ffi::c_int) as size_t { + (*check).buffer.u8_0[fresh8 as usize] = 0x80 as u8; + while pos != (64 as c_int - 8 as c_int) as size_t { if pos == 64 as size_t { process(check); pos = 0 as size_t; } let fresh9 = pos; pos = pos.wrapping_add(1); - (*check).buffer.u8_0[fresh9 as usize] = 0 as uint8_t; + (*check).buffer.u8_0[fresh9 as usize] = 0 as u8; } - (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8 as uint64_t); - (*check) - .buffer - .u64_0[((64 as ::core::ffi::c_int - 8 as ::core::ffi::c_int) - / 8 as ::core::ffi::c_int) as usize] = ((*check).state.sha256.size - & 0xff as uint64_t) << 56 as ::core::ffi::c_int - | ((*check).state.sha256.size & 0xff00 as uint64_t) << 40 as ::core::ffi::c_int - | ((*check).state.sha256.size & 0xff0000 as uint64_t) << 24 as ::core::ffi::c_int - | ((*check).state.sha256.size & 0xff000000 as uint64_t) - << 8 as ::core::ffi::c_int - | ((*check).state.sha256.size & 0xff00000000 as uint64_t) - >> 8 as ::core::ffi::c_int - | ((*check).state.sha256.size & 0xff0000000000 as uint64_t) - >> 24 as ::core::ffi::c_int - | ((*check).state.sha256.size & 0xff000000000000 as uint64_t) - >> 40 as ::core::ffi::c_int - | ((*check).state.sha256.size & 0xff00000000000000 as uint64_t) - >> 56 as ::core::ffi::c_int; + (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8 as u64); + (*check).buffer.u64_0[((64 as c_int - 8 as c_int) / 8 as c_int) as usize] = + ((*check).state.sha256.size & 0xff as u64) << 56 as c_int + | ((*check).state.sha256.size & 0xff00 as u64) << 40 as c_int + | ((*check).state.sha256.size & 0xff0000 as u64) << 24 as c_int + | ((*check).state.sha256.size & 0xff000000 as u64) << 8 as c_int + | ((*check).state.sha256.size & 0xff00000000 as u64) >> 8 as c_int + | ((*check).state.sha256.size & 0xff0000000000 as u64) >> 24 as c_int + | ((*check).state.sha256.size & 0xff000000000000 as u64) >> 40 as c_int + | ((*check).state.sha256.size & 0xff00000000000000 as u64) >> 56 as c_int; process(check); let mut i: size_t = 0 as size_t; while i < 8 as size_t { - (*check).buffer.u32_0[i as usize] = ((*check).state.sha256.state[i as usize] - & 0xff as uint32_t) << 24 as ::core::ffi::c_int - | ((*check).state.sha256.state[i as usize] & 0xff00 as uint32_t) - << 8 as ::core::ffi::c_int - | ((*check).state.sha256.state[i as usize] & 0xff0000 as uint32_t) - >> 8 as ::core::ffi::c_int - | ((*check).state.sha256.state[i as usize] & 0xff000000 as uint32_t) - >> 24 as ::core::ffi::c_int; + (*check).buffer.u32_0[i as usize] = ((*check).state.sha256.state[i as usize] & 0xff) + << 24 as c_int + | ((*check).state.sha256.state[i as usize] & 0xff00) << 8 as c_int + | ((*check).state.sha256.state[i as usize] & 0xff0000) >> 8 as c_int + | ((*check).state.sha256.state[i as usize] & 0xff000000) >> 24 as c_int; i = i.wrapping_add(1); } } diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 21384166..e0825154 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -1,10 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -17,20 +16,10 @@ extern "C" { allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma_decoder_memusage_nocheck( - options: *const ::core::ffi::c_void, - ) -> uint64_t; - fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: uint8_t) -> bool; + fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; + fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -52,7 +41,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -61,17 +49,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -82,7 +62,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -94,68 +74,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -165,61 +120,59 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, } -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -229,11 +182,11 @@ pub struct lzma_alone_coder { pub picky: bool, pub pos: size_t, pub uncompressed_size: lzma_vli, - pub memlimit: uint64_t, - pub memusage: uint64_t, + pub memlimit: u64, + pub memusage: u64, pub options: lzma_options_lzma, } -pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub type C2RustUnnamed_0 = c_uint; pub const SEQ_CODE: C2RustUnnamed_0 = 4; pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; pub const SEQ_UNCOMPRESSED_SIZE: C2RustUnnamed_0 = 2; @@ -245,7 +198,7 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -254,39 +207,32 @@ pub type lzma_init_function = Option< *const lzma_filter_info, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 - as ::core::ffi::c_ulonglong; -pub const LZMA_LZMA1EXT_ALLOW_EOPM: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; -pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) - << 15 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1 as c_uint; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; unsafe extern "C" fn alone_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; while *out_pos < out_size - && ((*coder).sequence as ::core::ffi::c_uint - == SEQ_CODE as ::core::ffi::c_int as ::core::ffi::c_uint - || *in_pos < in_size) + && ((*coder).sequence as c_uint == SEQ_CODE as c_uint || *in_pos < in_size) { let mut current_block_42: u64; - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { if lzma_lzma_lclppb_decode( &raw mut (*coder).options, @@ -301,21 +247,19 @@ unsafe extern "C" fn alone_decode( 1 => { (*coder).options.dict_size = ((*coder).options.dict_size as size_t | (*in_0.offset(*in_pos as isize) as size_t) - << (*coder).pos.wrapping_mul(8 as size_t)) as uint32_t; + << (*coder).pos.wrapping_mul(8 as size_t)) + as u32; (*coder).pos = (*coder).pos.wrapping_add(1); if (*coder).pos == 4 as size_t { - if (*coder).picky as ::core::ffi::c_int != 0 - && (*coder).options.dict_size != UINT32_MAX as uint32_t + if (*coder).picky as c_int != 0 + && (*coder).options.dict_size != UINT32_MAX as u32 { - let mut d: uint32_t = (*coder) - .options - .dict_size - .wrapping_sub(1 as uint32_t); - d |= d >> 2 as ::core::ffi::c_int; - d |= d >> 3 as ::core::ffi::c_int; - d |= d >> 4 as ::core::ffi::c_int; - d |= d >> 8 as ::core::ffi::c_int; - d |= d >> 16 as ::core::ffi::c_int; + let mut d: u32 = (*coder).options.dict_size.wrapping_sub(1 as u32); + d |= d >> 2 as c_int; + d |= d >> 3 as c_int; + d |= d >> 4 as c_int; + d |= d >> 8 as c_int; + d |= d >> 16 as c_int; d = d.wrapping_add(1); if d != (*coder).options.dict_size { return LZMA_FORMAT_ERROR; @@ -328,30 +272,27 @@ unsafe extern "C" fn alone_decode( current_block_42 = 11048769245176032998; } 2 => { - (*coder).uncompressed_size - |= (*in_0.offset(*in_pos as isize) as lzma_vli) - << (*coder).pos.wrapping_mul(8 as size_t); + (*coder).uncompressed_size |= (*in_0.offset(*in_pos as isize) as lzma_vli) + << (*coder).pos.wrapping_mul(8 as size_t); *in_pos = (*in_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); if (*coder).pos < 8 as size_t { current_block_42 = 11048769245176032998; } else { - if (*coder).picky as ::core::ffi::c_int != 0 + if (*coder).picky as c_int != 0 && (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli - && (*coder).uncompressed_size - >= (1 as lzma_vli) << 38 as ::core::ffi::c_int + && (*coder).uncompressed_size >= (1 as lzma_vli) << 38 as c_int { return LZMA_FORMAT_ERROR; } - (*coder).options.ext_flags = LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t; - (*coder).options.ext_size_low = (*coder).uncompressed_size - as uint32_t; - (*coder).options.ext_size_high = ((*coder).uncompressed_size - >> 32 as ::core::ffi::c_int) as uint32_t; + (*coder).options.ext_flags = LZMA_LZMA1EXT_ALLOW_EOPM as u32; + (*coder).options.ext_size_low = (*coder).uncompressed_size as u32; + (*coder).options.ext_size_high = + ((*coder).uncompressed_size >> 32 as c_int) as u32; (*coder).memusage = lzma_lzma_decoder_memusage_nocheck( - &raw mut (*coder).options as *const ::core::ffi::c_void, - ) - .wrapping_add(LZMA_MEMUSAGE_BASE as uint64_t); + &raw mut (*coder).options as *const c_void, + ) + .wrapping_add(LZMA_MEMUSAGE_BASE as u64); (*coder).pos = 0 as size_t; (*coder).sequence = SEQ_CODER_INIT; current_block_42 = 14763689060501151050; @@ -361,12 +302,7 @@ unsafe extern "C" fn alone_decode( current_block_42 = 14763689060501151050; } 4 => { - return (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + return (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -394,14 +330,15 @@ unsafe extern "C" fn alone_decode( *mut lzma_next_coder, *const lzma_allocator, *const lzma_filter_info, - ) -> lzma_ret, + ) + -> lzma_ret, ), - options: &raw mut (*coder).options as *mut ::core::ffi::c_void, + options: &raw mut (*coder).options as *mut c_void, }, lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }, ]; let ret_: lzma_ret = lzma_next_filter_init( @@ -409,9 +346,7 @@ unsafe extern "C" fn alone_decode( allocator, &raw mut filters as *mut lzma_filter_info, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } (*coder).sequence = SEQ_CODE; @@ -422,23 +357,23 @@ unsafe extern "C" fn alone_decode( return LZMA_OK; } unsafe extern "C" fn alone_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; lzma_next_end(&raw mut (*coder).next, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn alone_decoder_memconfig( - mut coder_ptr: *mut ::core::ffi::c_void, - mut memusage: *mut uint64_t, - mut old_memlimit: *mut uint64_t, - mut new_memlimit: uint64_t, + mut coder_ptr: *mut c_void, + mut memusage: *mut u64, + mut old_memlimit: *mut u64, + mut new_memlimit: u64, ) -> lzma_ret { let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; *memusage = (*coder).memusage; *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as uint64_t { + if new_memlimit != 0 as u64 { if new_memlimit < (*coder).memusage { return LZMA_MEMLIMIT_ERROR; } @@ -450,7 +385,7 @@ unsafe extern "C" fn alone_decoder_memconfig( pub unsafe extern "C" fn lzma_alone_decoder_init( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, - mut memlimit: uint64_t, + mut memlimit: u64, mut picky: bool, ) -> lzma_ret { if ::core::mem::transmute::< @@ -458,22 +393,20 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, + u64, bool, ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_alone_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - bool, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + lzma_alone_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + u64, + bool, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -482,22 +415,20 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, + u64, bool, ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_alone_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - bool, - ) -> lzma_ret, - ), - ); + >(Some( + lzma_alone_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + u64, + bool, + ) -> lzma_ret, + )); let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; if coder.is_null() { coder = lzma_alloc( @@ -507,49 +438,33 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( alone_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - alone_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + alone_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*next).memconfig = Some( alone_decoder_memconfig - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >; + as Option lzma_ret>; (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -562,40 +477,38 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( (*coder).sequence = SEQ_PROPERTIES; (*coder).picky = picky; (*coder).pos = 0 as size_t; - (*coder).options.dict_size = 0 as uint32_t; - (*coder).options.preset_dict = ::core::ptr::null::(); - (*coder).options.preset_dict_size = 0 as uint32_t; + (*coder).options.dict_size = 0 as u32; + (*coder).options.preset_dict = ::core::ptr::null::(); + (*coder).options.preset_dict_size = 0 as u32; (*coder).uncompressed_size = 0 as lzma_vli; - (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; - (*coder).memusage = LZMA_MEMUSAGE_BASE as uint64_t; + (*coder).memlimit = if 1 as u64 > memlimit { + 1 as u64 + } else { + memlimit + }; + (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_alone_decoder( mut strm: *mut lzma_stream, - mut memlimit: uint64_t, + mut memlimit: u64, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = lzma_alone_decoder_init( &raw mut (*(*strm).internal).next, (*strm).allocator, memlimit, - 0 as ::core::ffi::c_int != 0, + 0 as c_int != 0, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index 4de5826f..c09b5b55 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -1,15 +1,10 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn memset( - __b: *mut ::core::ffi::c_void, - __c: ::core::ffi::c_int, - __len: size_t, - ) -> *mut ::core::ffi::c_void; + fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -18,10 +13,10 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -30,20 +25,9 @@ extern "C" { allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma_lclppb_encode( - options: *const lzma_options_lzma, - byte: *mut uint8_t, - ) -> bool; + fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -65,7 +49,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -74,17 +57,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -95,7 +70,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -107,68 +82,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -178,61 +128,59 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, } -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } pub type lzma_filter_info = lzma_filter_info_s; #[derive(Copy, Clone)] @@ -240,7 +188,7 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -255,52 +203,44 @@ pub struct lzma_alone_coder { pub next: lzma_next_coder, pub sequence: C2RustUnnamed_0, pub header_pos: size_t, - pub header: [uint8_t; 13], + pub header: [u8; 13], } -pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub type C2RustUnnamed_0 = c_uint; pub const SEQ_CODE: C2RustUnnamed_0 = 1; pub const SEQ_HEADER: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { - *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; - *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) - as uint8_t; +unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { + *buf.offset(0 as isize) = num as u8; + *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; + *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; + *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; } -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 - as ::core::ffi::c_ulonglong; -pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; -pub const ALONE_HEADER_SIZE: ::core::ffi::c_int = 1 as ::core::ffi::c_int - + 4 as ::core::ffi::c_int + 8 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; +pub const ALONE_HEADER_SIZE: c_int = 1 as c_int + 4 as c_int + 8 as c_int; unsafe extern "C" fn alone_encode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; while *out_pos < out_size { - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { lzma_bufcpy( - &raw mut (*coder).header as *mut uint8_t, + &raw mut (*coder).header as *mut u8, &raw mut (*coder).header_pos, ALONE_HEADER_SIZE as size_t, out, @@ -313,12 +253,7 @@ unsafe extern "C" fn alone_encode( (*coder).sequence = SEQ_CODE; } 1 => { - return (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + return (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -336,12 +271,12 @@ unsafe extern "C" fn alone_encode( return LZMA_OK; } unsafe extern "C" fn alone_encoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; lzma_next_end(&raw mut (*coder).next, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn alone_encoder_init( mut next: *mut lzma_next_coder, @@ -357,16 +292,14 @@ unsafe extern "C" fn alone_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - alone_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_options_lzma, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + alone_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -379,16 +312,14 @@ unsafe extern "C" fn alone_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - alone_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_options_lzma, - ) -> lzma_ret, - ), - ); + >(Some( + alone_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + )); let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; if coder.is_null() { coder = lzma_alloc( @@ -398,32 +329,28 @@ unsafe extern "C" fn alone_encoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( alone_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - alone_encoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + alone_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -435,31 +362,27 @@ unsafe extern "C" fn alone_encoder_init( } (*coder).sequence = SEQ_HEADER; (*coder).header_pos = 0 as size_t; - if lzma_lzma_lclppb_encode(options, &raw mut (*coder).header as *mut uint8_t) { + if lzma_lzma_lclppb_encode(options, &raw mut (*coder).header as *mut u8) { return LZMA_OPTIONS_ERROR; } - if (*options).dict_size < LZMA_DICT_SIZE_MIN as uint32_t { + if (*options).dict_size < LZMA_DICT_SIZE_MIN as u32 { return LZMA_OPTIONS_ERROR; } - let mut d: uint32_t = (*options).dict_size.wrapping_sub(1 as uint32_t); - d |= d >> 2 as ::core::ffi::c_int; - d |= d >> 3 as ::core::ffi::c_int; - d |= d >> 4 as ::core::ffi::c_int; - d |= d >> 8 as ::core::ffi::c_int; - d |= d >> 16 as ::core::ffi::c_int; - if d != UINT32_MAX as uint32_t { + let mut d: u32 = (*options).dict_size.wrapping_sub(1 as u32); + d |= d >> 2 as c_int; + d |= d >> 3 as c_int; + d |= d >> 4 as c_int; + d |= d >> 8 as c_int; + d |= d >> 16 as c_int; + if d != UINT32_MAX as u32 { d = d.wrapping_add(1); } - write32le( - (&raw mut (*coder).header as *mut uint8_t) - .offset(1 as ::core::ffi::c_int as isize), - d, - ); + write32le((&raw mut (*coder).header as *mut u8).offset(1 as isize), d); memset( - (&raw mut (*coder).header as *mut uint8_t) - .offset(1 as ::core::ffi::c_int as isize) - .offset(4 as ::core::ffi::c_int as isize) as *mut ::core::ffi::c_void, - 0xff as ::core::ffi::c_int, + (&raw mut (*coder).header as *mut u8) + .offset(1 as isize) + .offset(4 as isize) as *mut c_void, + 0xff as c_int, 8 as size_t, ); let filters: [lzma_filter_info; 2] = [ @@ -473,12 +396,12 @@ unsafe extern "C" fn alone_encoder_init( *const lzma_filter_info, ) -> lzma_ret, ), - options: options as *mut ::core::ffi::c_void, + options: options as *mut c_void, }, lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }, ]; return lzma_next_filter_init( @@ -493,9 +416,7 @@ pub unsafe extern "C" fn lzma_alone_encoder( mut options: *const lzma_options_lzma, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = alone_encoder_init( @@ -503,15 +424,11 @@ pub unsafe extern "C" fn lzma_alone_encoder( (*strm).allocator, options, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index d729d076..d869ccd1 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -1,34 +1,25 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_stream_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, - memlimit: uint64_t, - flags: uint32_t, + memlimit: u64, + flags: u32, ) -> lzma_ret; fn lzma_alone_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, - memlimit: uint64_t, + memlimit: u64, picky: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -50,7 +41,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -59,17 +49,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -80,7 +62,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -92,68 +74,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -163,26 +120,26 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, } -pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub type C2RustUnnamed_0 = c_uint; pub const SEQ_FINISH: C2RustUnnamed_0 = 2; pub const SEQ_CODE: C2RustUnnamed_0 = 1; pub const SEQ_INIT: C2RustUnnamed_0 = 0; @@ -190,60 +147,55 @@ pub const SEQ_INIT: C2RustUnnamed_0 = 0; #[repr(C)] pub struct lzma_auto_coder { pub next: lzma_next_coder, - pub memlimit: uint64_t, - pub flags: uint32_t, + pub memlimit: u64, + pub flags: u32, pub sequence: C2RustUnnamed_0, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_NO_CHECK: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; -pub const LZMA_TELL_UNSUPPORTED_CHECK: ::core::ffi::c_uint = 0x2 as ::core::ffi::c_uint; -pub const LZMA_TELL_ANY_CHECK: ::core::ffi::c_uint = 0x4 as ::core::ffi::c_uint; -pub const LZMA_IGNORE_CHECK: ::core::ffi::c_uint = 0x10 as ::core::ffi::c_uint; -pub const LZMA_CONCATENATED: ::core::ffi::c_uint = 0x8 as ::core::ffi::c_uint; -pub const LZMA_FAIL_FAST: ::core::ffi::c_uint = 0x20 as ::core::ffi::c_uint; -pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) - << 15 as ::core::ffi::c_int; -pub const LZMA_SUPPORTED_FLAGS: ::core::ffi::c_uint = LZMA_TELL_NO_CHECK - | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK | LZMA_IGNORE_CHECK - | LZMA_CONCATENATED | LZMA_FAIL_FAST; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1 as c_uint; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2 as c_uint; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10 as c_uint; +pub const LZMA_CONCATENATED: c_uint = 0x8 as c_uint; +pub const LZMA_FAIL_FAST: c_uint = 0x20 as c_uint; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK + | LZMA_TELL_UNSUPPORTED_CHECK + | LZMA_TELL_ANY_CHECK + | LZMA_IGNORE_CHECK + | LZMA_CONCATENATED + | LZMA_FAIL_FAST; unsafe extern "C" fn auto_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; let mut current_block_28: u64; - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { if *in_pos >= in_size { return LZMA_OK; } (*coder).sequence = SEQ_CODE; - if *in_0.offset(*in_pos as isize) as ::core::ffi::c_int - == 0xfd as ::core::ffi::c_int - { + if *in_0.offset(*in_pos as isize) as c_int == 0xfd as c_int { let ret_: lzma_ret = lzma_stream_decoder_init( &raw mut (*coder).next, allocator, (*coder).memlimit, (*coder).flags, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } } else { @@ -251,17 +203,15 @@ unsafe extern "C" fn auto_decode( &raw mut (*coder).next, allocator, (*coder).memlimit, - 1 as ::core::ffi::c_int != 0, + 1 as c_int != 0, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { return ret__0; } - if (*coder).flags & LZMA_TELL_NO_CHECK as uint32_t != 0 { + if (*coder).flags & LZMA_TELL_NO_CHECK as u32 != 0 { return LZMA_NO_CHECK; } - if (*coder).flags & LZMA_TELL_ANY_CHECK as uint32_t != 0 { + if (*coder).flags & LZMA_TELL_ANY_CHECK as u32 != 0 { return LZMA_GET_CHECK; } } @@ -277,12 +227,7 @@ unsafe extern "C" fn auto_decode( } match current_block_28 { 13935781298497728377 => { - let ret: lzma_ret = (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -293,9 +238,8 @@ unsafe extern "C" fn auto_decode( out_size, action, ) as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - || (*coder).flags & LZMA_CONCATENATED as uint32_t == 0 as uint32_t + if ret as c_uint != LZMA_STREAM_END as c_uint + || (*coder).flags & LZMA_CONCATENATED as u32 == 0 as u32 { return ret; } @@ -306,59 +250,52 @@ unsafe extern "C" fn auto_decode( if *in_pos < in_size { return LZMA_DATA_ERROR; } - return (if action as ::core::ffi::c_uint - == LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint - { - LZMA_STREAM_END as ::core::ffi::c_int + return (if action as c_uint == LZMA_FINISH as c_uint { + LZMA_STREAM_END as c_int } else { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int }) as lzma_ret; } unsafe extern "C" fn auto_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; lzma_next_end(&raw mut (*coder).next, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } -unsafe extern "C" fn auto_decoder_get_check( - mut coder_ptr: *const ::core::ffi::c_void, -) -> lzma_check { +unsafe extern "C" fn auto_decoder_get_check(mut coder_ptr: *const c_void) -> lzma_check { let mut coder: *const lzma_auto_coder = coder_ptr as *const lzma_auto_coder; return (if (*coder).next.get_check.is_none() { - LZMA_CHECK_NONE as ::core::ffi::c_int as ::core::ffi::c_uint + LZMA_CHECK_NONE as c_uint } else { - (*coder).next.get_check.expect("non-null function pointer")((*coder).next.coder) - as ::core::ffi::c_uint + (*coder).next.get_check.expect("non-null function pointer")((*coder).next.coder) as c_uint }) as lzma_check; } unsafe extern "C" fn auto_decoder_memconfig( - mut coder_ptr: *mut ::core::ffi::c_void, - mut memusage: *mut uint64_t, - mut old_memlimit: *mut uint64_t, - mut new_memlimit: uint64_t, + mut coder_ptr: *mut c_void, + mut memusage: *mut u64, + mut old_memlimit: *mut u64, + mut new_memlimit: u64, ) -> lzma_ret { let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; let mut ret: lzma_ret = LZMA_OK; if (*coder).next.memconfig.is_some() { - ret = (*coder) - .next - .memconfig - .expect( - "non-null function pointer", - )((*coder).next.coder, memusage, old_memlimit, new_memlimit); + ret = (*coder).next.memconfig.expect("non-null function pointer")( + (*coder).next.coder, + memusage, + old_memlimit, + new_memlimit, + ); } else { - *memusage = LZMA_MEMUSAGE_BASE as uint64_t; + *memusage = LZMA_MEMUSAGE_BASE as u64; *old_memlimit = (*coder).memlimit; ret = LZMA_OK; - if new_memlimit != 0 as uint64_t && new_memlimit < *memusage { + if new_memlimit != 0 as u64 && new_memlimit < *memusage { ret = LZMA_MEMLIMIT_ERROR; } } - if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - && new_memlimit != 0 as uint64_t - { + if ret as c_uint == LZMA_OK as c_uint && new_memlimit != 0 as u64 { (*coder).memlimit = new_memlimit; } return ret; @@ -366,55 +303,41 @@ unsafe extern "C" fn auto_decoder_memconfig( unsafe extern "C" fn auto_decoder_init( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, - mut memlimit: uint64_t, - mut flags: uint32_t, + mut memlimit: u64, + mut flags: u32, ) -> lzma_ret { if ::core::mem::transmute::< Option< - unsafe extern "C" fn( + unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, + >, + uintptr_t, + >(Some( + auto_decoder_init + as unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, - uint32_t, + u64, + u32, ) -> lzma_ret, - >, - uintptr_t, - >( - Some( - auto_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - uint32_t, - ) -> lzma_ret, - ), - ) != (*next).init + )) != (*next).init { lzma_next_end(next, allocator); } (*next).init = ::core::mem::transmute::< Option< - unsafe extern "C" fn( + unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, + >, + uintptr_t, + >(Some( + auto_decoder_init + as unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, - uint32_t, + u64, + u32, ) -> lzma_ret, - >, - uintptr_t, - >( - Some( - auto_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - uint32_t, - ) -> lzma_ret, - ), - ); - if flags & !(LZMA_SUPPORTED_FLAGS as uint32_t) != 0 { + )); + if flags & !(LZMA_SUPPORTED_FLAGS as u32) != 0 { return LZMA_OPTIONS_ERROR; } let mut coder: *mut lzma_auto_coder = (*next).coder as *mut lzma_auto_coder; @@ -426,53 +349,36 @@ unsafe extern "C" fn auto_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( auto_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - auto_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + auto_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; - (*next).get_check = Some( - auto_decoder_get_check - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - ) as Option lzma_check>; + (*next).get_check = + Some(auto_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check) + as Option lzma_check>; (*next).memconfig = Some( auto_decoder_memconfig - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >; + as Option lzma_ret>; (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -482,7 +388,11 @@ unsafe extern "C" fn auto_decoder_init( set_out_limit: None, }; } - (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).memlimit = if 1 as u64 > memlimit { + 1 as u64 + } else { + memlimit + }; (*coder).flags = flags; (*coder).sequence = SEQ_INIT; return LZMA_OK; @@ -490,13 +400,11 @@ unsafe extern "C" fn auto_decoder_init( #[no_mangle] pub unsafe extern "C" fn lzma_auto_decoder( mut strm: *mut lzma_stream, - mut memlimit: uint64_t, - mut flags: uint32_t, + mut memlimit: u64, + mut flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = auto_decoder_init( @@ -505,15 +413,11 @@ pub unsafe extern "C" fn lzma_auto_decoder( memlimit, flags, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index b9dc6136..0df0eb1b 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -1,3 +1,5 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_block_decoder_init( @@ -6,16 +8,7 @@ extern "C" { block: *mut lzma_block, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -37,7 +30,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -46,84 +38,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -132,18 +91,18 @@ pub type lzma_code_function = Option< #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -163,26 +122,26 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_decode( mut block: *mut lzma_block, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { - if in_pos.is_null() || in_0.is_null() && *in_pos != in_size || *in_pos > in_size - || out_pos.is_null() || out.is_null() && *out_pos != out_size + if in_pos.is_null() + || in_0.is_null() && *in_pos != in_size + || *in_pos > in_size + || out_pos.is_null() + || out.is_null() && *out_pos != out_size || *out_pos > out_size { return LZMA_PROG_ERROR; @@ -190,7 +149,7 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( let mut block_decoder: lzma_next_coder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -199,20 +158,11 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( update: None, set_out_limit: None, }; - let mut ret: lzma_ret = lzma_block_decoder_init( - &raw mut block_decoder, - allocator, - block, - ); - if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let mut ret: lzma_ret = lzma_block_decoder_init(&raw mut block_decoder, allocator, block); + if ret as c_uint == LZMA_OK as c_uint { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - ret = block_decoder - .code - .expect( - "non-null function pointer", - )( + ret = block_decoder.code.expect("non-null function pointer")( block_decoder.coder, allocator, in_0, @@ -223,14 +173,10 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( out_size, LZMA_FINISH, ); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { ret = LZMA_OK; } else { - if ret as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_OK as c_uint { if *in_pos == in_size { ret = LZMA_DATA_ERROR; } else { diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 35e53aee..a034646a 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -1,13 +1,11 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_check_size(check: lzma_check) -> uint32_t; + fn lzma_check_size(check: lzma_check) -> u32; fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; - fn lzma_block_header_encode(block: *const lzma_block, out: *mut uint8_t) -> lzma_ret; + fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_raw_encoder_init( next: *mut lzma_next_coder, @@ -18,21 +16,12 @@ extern "C" { fn lzma_check_update( check: *mut lzma_check_state, type_0: lzma_check, - buf: *const uint8_t, + buf: *const u8, size: size_t, ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -54,7 +43,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -63,141 +51,106 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -220,9 +173,9 @@ pub struct lzma_block { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed { - pub u8_0: [uint8_t; 64], - pub u32_0: [uint32_t; 16], - pub u64_0: [uint64_t; 8], + pub u8_0: [u8; 64], + pub u32_0: [u32; 16], + pub u64_0: [u64; 8], } #[derive(Copy, Clone)] #[repr(C)] @@ -233,88 +186,83 @@ pub struct lzma_check_state { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_0 { - pub crc32: uint32_t, - pub crc64: uint64_t, + pub crc32: u32, + pub crc64: u64, pub sha256: lzma_sha256_state, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_sha256_state { - pub state: [uint32_t; 8], - pub size: uint64_t, + pub state: [u32; 8], + pub size: u64, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_VLI_BYTES_MAX: ::core::ffi::c_int = 9 as ::core::ffi::c_int; -pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; -pub const LZMA_CHECK_SIZE_MAX: ::core::ffi::c_int = 64 as ::core::ffi::c_int; -pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; -pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: ::core::ffi::c_int = 1024 as ::core::ffi::c_int; -pub const COMPRESSED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX - .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as ::core::ffi::c_ulonglong) - .wrapping_sub(LZMA_CHECK_SIZE_MAX as ::core::ffi::c_ulonglong) - & !(3 as ::core::ffi::c_ulonglong); -pub const LZMA2_CHUNK_MAX: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 16 as ::core::ffi::c_int; -pub const LZMA2_HEADER_UNCOMPRESSED: ::core::ffi::c_int = 3 as ::core::ffi::c_int; -pub const HEADERS_BOUND: ::core::ffi::c_int = 1 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int + 2 as ::core::ffi::c_int * LZMA_VLI_BYTES_MAX - + 3 as ::core::ffi::c_int + 4 as ::core::ffi::c_int + LZMA_CHECK_SIZE_MAX - + 3 as ::core::ffi::c_int & !(3 as ::core::ffi::c_int); -unsafe extern "C" fn lzma2_bound(mut uncompressed_size: uint64_t) -> uint64_t { - if uncompressed_size > COMPRESSED_SIZE_MAX as uint64_t { - return 0 as uint64_t; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_SIZE_MAX: c_int = 64 as c_int; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX + .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as c_ulonglong) + .wrapping_sub(LZMA_CHECK_SIZE_MAX as c_ulonglong) + & !(3 as c_ulonglong); +pub const LZMA2_CHUNK_MAX: c_uint = (1 as c_uint) << 16 as c_int; +pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3 as c_int; +pub const HEADERS_BOUND: c_int = 1 as c_int + + 1 as c_int + + 2 as c_int * LZMA_VLI_BYTES_MAX + + 3 as c_int + + 4 as c_int + + LZMA_CHECK_SIZE_MAX + + 3 as c_int + & !(3 as c_int); +unsafe extern "C" fn lzma2_bound(mut uncompressed_size: u64) -> u64 { + if uncompressed_size > COMPRESSED_SIZE_MAX as u64 { + return 0 as u64; } - let overhead: uint64_t = uncompressed_size - .wrapping_add(LZMA2_CHUNK_MAX as uint64_t) - .wrapping_sub(1 as uint64_t) - .wrapping_div(LZMA2_CHUNK_MAX as uint64_t) - .wrapping_mul(LZMA2_HEADER_UNCOMPRESSED as uint64_t) - .wrapping_add(1 as uint64_t); - if (COMPRESSED_SIZE_MAX as uint64_t).wrapping_sub(overhead) < uncompressed_size { - return 0 as uint64_t; + let overhead: u64 = uncompressed_size + .wrapping_add(LZMA2_CHUNK_MAX as u64) + .wrapping_sub(1 as u64) + .wrapping_div(LZMA2_CHUNK_MAX as u64) + .wrapping_mul(LZMA2_HEADER_UNCOMPRESSED as u64) + .wrapping_add(1 as u64); + if (COMPRESSED_SIZE_MAX as u64).wrapping_sub(overhead) < uncompressed_size { + return 0 as u64; } return uncompressed_size.wrapping_add(overhead); } #[no_mangle] -pub unsafe extern "C" fn lzma_block_buffer_bound64( - mut uncompressed_size: uint64_t, -) -> uint64_t { - let mut lzma2_size: uint64_t = lzma2_bound(uncompressed_size); - if lzma2_size == 0 as uint64_t { - return 0 as uint64_t; +pub unsafe extern "C" fn lzma_block_buffer_bound64(mut uncompressed_size: u64) -> u64 { + let mut lzma2_size: u64 = lzma2_bound(uncompressed_size); + if lzma2_size == 0 as u64 { + return 0 as u64; } - lzma2_size = lzma2_size.wrapping_add(3 as uint64_t) & !(3 as uint64_t); - return (HEADERS_BOUND as uint64_t).wrapping_add(lzma2_size); + lzma2_size = lzma2_size.wrapping_add(3 as u64) & !(3 as u64); + return (HEADERS_BOUND as u64).wrapping_add(lzma2_size); } #[no_mangle] -pub unsafe extern "C" fn lzma_block_buffer_bound( - mut uncompressed_size: size_t, -) -> size_t { - let mut ret: uint64_t = lzma_block_buffer_bound64(uncompressed_size as uint64_t); +pub unsafe extern "C" fn lzma_block_buffer_bound(mut uncompressed_size: size_t) -> size_t { + let mut ret: u64 = lzma_block_buffer_bound64(uncompressed_size as u64); return ret as size_t; } unsafe extern "C" fn block_encode_uncompressed( mut block: *mut lzma_block, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { let mut lzma2: lzma_options_lzma = lzma_options_lzma { - dict_size: LZMA_DICT_SIZE_MIN as uint32_t, - preset_dict: ::core::ptr::null::(), + dict_size: LZMA_DICT_SIZE_MIN as u32, + preset_dict: ::core::ptr::null::(), preset_dict_size: 0, lc: 0, lp: 0, @@ -335,22 +283,19 @@ unsafe extern "C" fn block_encode_uncompressed( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), }; let mut filters: [lzma_filter; 2] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 2]; - filters[0 as ::core::ffi::c_int as usize].id = LZMA_FILTER_LZMA2 as lzma_vli; - filters[0 as ::core::ffi::c_int as usize].options = &raw mut lzma2 - as *mut ::core::ffi::c_void; - filters[1 as ::core::ffi::c_int as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + filters[0 as usize].id = LZMA_FILTER_LZMA2 as lzma_vli; + filters[0 as usize].options = &raw mut lzma2 as *mut c_void; + filters[1 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; let mut filters_orig: *mut lzma_filter = (*block).filters; (*block).filters = &raw mut filters as *mut lzma_filter; - if lzma_block_header_size(block) as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if lzma_block_header_size(block) as c_uint != LZMA_OK as c_uint { (*block).filters = filters_orig; return LZMA_PROG_ERROR; } @@ -360,8 +305,7 @@ unsafe extern "C" fn block_encode_uncompressed( (*block).filters = filters_orig; return LZMA_BUF_ERROR; } - if lzma_block_header_encode(block, out.offset(*out_pos as isize)) - as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + if lzma_block_header_encode(block, out.offset(*out_pos as isize)) as c_uint != LZMA_OK as c_uint { (*block).filters = filters_orig; return LZMA_PROG_ERROR; @@ -369,30 +313,27 @@ unsafe extern "C" fn block_encode_uncompressed( (*block).filters = filters_orig; *out_pos = (*out_pos).wrapping_add((*block).header_size as size_t); let mut in_pos: size_t = 0 as size_t; - let mut control: uint8_t = 0x1 as uint8_t; + let mut control: u8 = 0x1 as u8; while in_pos < in_size { let fresh1 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); *out.offset(fresh1 as isize) = control; - control = 0x2 as uint8_t; - let copy_size: size_t = if in_size.wrapping_sub(in_pos) - < ((1 as ::core::ffi::c_uint) << 16 as ::core::ffi::c_int) as size_t - { - in_size.wrapping_sub(in_pos) - } else { - ((1 as ::core::ffi::c_uint) << 16 as ::core::ffi::c_int) as size_t - }; + control = 0x2 as u8; + let copy_size: size_t = + if in_size.wrapping_sub(in_pos) < ((1 as c_uint) << 16 as c_int) as size_t { + in_size.wrapping_sub(in_pos) + } else { + ((1 as c_uint) << 16 as c_int) as size_t + }; let fresh2 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1 as size_t) - >> 8 as ::core::ffi::c_int) as uint8_t; + *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1 as size_t) >> 8 as c_int) as u8; let fresh3 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1 as size_t) - & 0xff as size_t) as uint8_t; + *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1 as size_t) & 0xff as size_t) as u8; memcpy( - out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, - in_0.offset(in_pos as isize) as *const ::core::ffi::c_void, + out.offset(*out_pos as isize) as *mut c_void, + in_0.offset(in_pos as isize) as *const c_void, copy_size, ); in_pos = in_pos.wrapping_add(copy_size); @@ -400,22 +341,20 @@ unsafe extern "C" fn block_encode_uncompressed( } let fresh4 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh4 as isize) = 0 as uint8_t; + *out.offset(fresh4 as isize) = 0 as u8; return LZMA_OK; } unsafe extern "C" fn block_encode_normal( mut block: *mut lzma_block, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { let ret_: lzma_ret = lzma_block_header_size(block) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } if out_size.wrapping_sub(*out_pos) <= (*block).header_size as size_t { @@ -424,13 +363,12 @@ unsafe extern "C" fn block_encode_normal( let out_start: size_t = *out_pos; *out_pos = (*out_pos).wrapping_add((*block).header_size as size_t); if out_size.wrapping_sub(*out_pos) as lzma_vli > (*block).compressed_size { - out_size = (*out_pos as lzma_vli).wrapping_add((*block).compressed_size) - as size_t; + out_size = (*out_pos as lzma_vli).wrapping_add((*block).compressed_size) as size_t; } let mut raw_encoder: lzma_next_coder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -439,19 +377,11 @@ unsafe extern "C" fn block_encode_normal( update: None, set_out_limit: None, }; - let mut ret: lzma_ret = lzma_raw_encoder_init( - &raw mut raw_encoder, - allocator, - (*block).filters, - ); - if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let mut ret: lzma_ret = + lzma_raw_encoder_init(&raw mut raw_encoder, allocator, (*block).filters); + if ret as c_uint == LZMA_OK as c_uint { let mut in_pos: size_t = 0 as size_t; - ret = raw_encoder - .code - .expect( - "non-null function pointer", - )( + ret = raw_encoder.code.expect("non-null function pointer")( raw_encoder.coder, allocator, in_0, @@ -464,25 +394,18 @@ unsafe extern "C" fn block_encode_normal( ); } lzma_next_end(&raw mut raw_encoder, allocator); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { (*block).compressed_size = (*out_pos) .wrapping_sub(out_start.wrapping_add((*block).header_size as size_t)) as lzma_vli; ret = lzma_block_header_encode(block, out.offset(out_start as isize)); - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_OK as c_uint { ret = LZMA_PROG_ERROR; } - } else if ret as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + } else if ret as c_uint == LZMA_OK as c_uint { ret = LZMA_BUF_ERROR; } - if ret as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_OK as c_uint { *out_pos = out_start; } return ret; @@ -490,23 +413,26 @@ unsafe extern "C" fn block_encode_normal( unsafe extern "C" fn block_buffer_encode( mut block: *mut lzma_block, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut try_to_compress: bool, ) -> lzma_ret { - if block.is_null() || in_0.is_null() && in_size != 0 as size_t || out.is_null() - || out_pos.is_null() || *out_pos > out_size + if block.is_null() + || in_0.is_null() && in_size != 0 as size_t + || out.is_null() + || out_pos.is_null() + || *out_pos > out_size { return LZMA_PROG_ERROR; } - if (*block).version > 1 as uint32_t { + if (*block).version > 1 as u32 { return LZMA_OPTIONS_ERROR; } - if (*block).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint - || try_to_compress as ::core::ffi::c_int != 0 && (*block).filters.is_null() + if (*block).check as c_uint > LZMA_CHECK_ID_MAX as c_uint + || try_to_compress as c_int != 0 && (*block).filters.is_null() { return LZMA_PROG_ERROR; } @@ -520,40 +446,21 @@ unsafe extern "C" fn block_buffer_encode( } out_size = out_size.wrapping_sub(check_size); (*block).uncompressed_size = in_size as lzma_vli; - (*block).compressed_size = lzma2_bound(in_size as uint64_t) as lzma_vli; + (*block).compressed_size = lzma2_bound(in_size as u64) as lzma_vli; if (*block).compressed_size == 0 as lzma_vli { return LZMA_DATA_ERROR; } let mut ret: lzma_ret = LZMA_BUF_ERROR; if try_to_compress { - ret = block_encode_normal( - block, - allocator, - in_0, - in_size, - out, - out_pos, - out_size, - ); + ret = block_encode_normal(block, allocator, in_0, in_size, out, out_pos, out_size); } - if ret as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { - if ret as ::core::ffi::c_uint - != LZMA_BUF_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_OK as c_uint { + if ret as c_uint != LZMA_BUF_ERROR as c_uint { return ret; } - let ret_: lzma_ret = block_encode_uncompressed( - block, - in_0, - in_size, - out, - out_pos, - out_size, - ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = + block_encode_uncompressed(block, in_0, in_size, out, out_pos, out_size) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } } @@ -561,7 +468,7 @@ unsafe extern "C" fn block_buffer_encode( while i & 3 as size_t != 0 { let fresh0 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0 as uint8_t; + *out.offset(fresh0 as isize) = 0 as u8; i = i.wrapping_add(1); } if check_size > 0 as size_t { @@ -573,13 +480,13 @@ unsafe extern "C" fn block_buffer_encode( lzma_check_update(&raw mut check, (*block).check, in_0, in_size); lzma_check_finish(&raw mut check, (*block).check); memcpy( - &raw mut (*block).raw_check as *mut uint8_t as *mut ::core::ffi::c_void, - &raw mut check.buffer.u8_0 as *mut uint8_t as *const ::core::ffi::c_void, + &raw mut (*block).raw_check as *mut u8 as *mut c_void, + &raw mut check.buffer.u8_0 as *mut u8 as *const c_void, check_size, ); memcpy( - out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, - &raw mut check.buffer.u8_0 as *mut uint8_t as *const ::core::ffi::c_void, + out.offset(*out_pos as isize) as *mut c_void, + &raw mut check.buffer.u8_0 as *mut u8 as *const c_void, check_size, ); *out_pos = (*out_pos).wrapping_add(check_size); @@ -590,9 +497,9 @@ unsafe extern "C" fn block_buffer_encode( pub unsafe extern "C" fn lzma_block_buffer_encode( mut block: *mut lzma_block, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { @@ -610,9 +517,9 @@ pub unsafe extern "C" fn lzma_block_buffer_encode( #[no_mangle] pub unsafe extern "C" fn lzma_block_uncomp_encode( mut block: *mut lzma_block, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 3aca231d..62f73da7 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -1,25 +1,20 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcmp( - __s1: *const ::core::ffi::c_void, - __s2: *const ::core::ffi::c_void, - __n: size_t, - ) -> ::core::ffi::c_int; + fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; fn lzma_end(strm: *mut lzma_stream); fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_check_size(check: lzma_check) -> uint32_t; + fn lzma_check_size(check: lzma_check) -> u32; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -32,21 +27,12 @@ extern "C" { fn lzma_check_update( check: *mut lzma_check_state, type_0: lzma_check, - buf: *const uint8_t, + buf: *const u8, size: size_t, ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -68,7 +54,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -77,17 +62,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -98,7 +75,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -110,68 +87,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -181,20 +133,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -203,18 +155,18 @@ pub struct lzma_stream { #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -257,49 +209,45 @@ pub struct lzma_check_state { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_0 { - pub crc32: uint32_t, - pub crc64: uint64_t, + pub crc32: u32, + pub crc64: u64, pub sha256: lzma_sha256_state, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_sha256_state { - pub state: [uint32_t; 8], - pub size: uint64_t, + pub state: [u32; 8], + pub size: u64, } #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_1 { - pub u8_0: [uint8_t; 64], - pub u32_0: [uint32_t; 16], - pub u64_0: [uint64_t; 8], + pub u8_0: [u8; 64], + pub u32_0: [u32; 16], + pub u64_0: [u64; 8], } -pub type C2RustUnnamed_2 = ::core::ffi::c_uint; +pub type C2RustUnnamed_2 = c_uint; pub const SEQ_CHECK: C2RustUnnamed_2 = 2; pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[inline] unsafe extern "C" fn is_size_valid(mut size: lzma_vli, mut reference: lzma_vli) -> bool { return reference == LZMA_VLI_UNKNOWN as lzma_vli || reference == size; } unsafe extern "C" fn block_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -307,44 +255,37 @@ unsafe extern "C" fn block_decode( let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; 's_177: { let mut current_block_40: u64; - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - let in_stop: size_t = (*in_pos) - .wrapping_add( - (if (in_size.wrapping_sub(*in_pos) as lzma_vli) - < (*coder) - .compressed_limit - .wrapping_sub((*coder).compressed_size) - { - in_size.wrapping_sub(*in_pos) as lzma_vli - } else { - (*coder) - .compressed_limit - .wrapping_sub((*coder).compressed_size) - }) as size_t, - ); - let out_stop: size_t = (*out_pos) - .wrapping_add( - (if (out_size.wrapping_sub(*out_pos) as lzma_vli) - < (*coder) - .uncompressed_limit - .wrapping_sub((*coder).uncompressed_size) - { - out_size.wrapping_sub(*out_pos) as lzma_vli - } else { - (*coder) - .uncompressed_limit - .wrapping_sub((*coder).uncompressed_size) - }) as size_t, - ); - let ret: lzma_ret = (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + let in_stop: size_t = (*in_pos).wrapping_add( + (if (in_size.wrapping_sub(*in_pos) as lzma_vli) + < (*coder) + .compressed_limit + .wrapping_sub((*coder).compressed_size) + { + in_size.wrapping_sub(*in_pos) as lzma_vli + } else { + (*coder) + .compressed_limit + .wrapping_sub((*coder).compressed_size) + }) as size_t, + ); + let out_stop: size_t = (*out_pos).wrapping_add( + (if (out_size.wrapping_sub(*out_pos) as lzma_vli) + < (*coder) + .uncompressed_limit + .wrapping_sub((*coder).uncompressed_size) + { + out_size.wrapping_sub(*out_pos) as lzma_vli + } else { + (*coder) + .uncompressed_limit + .wrapping_sub((*coder).uncompressed_size) + }) as size_t, + ); + let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -357,28 +298,23 @@ unsafe extern "C" fn block_decode( ) as lzma_ret; let in_used: size_t = (*in_pos).wrapping_sub(in_start); let out_used: size_t = (*out_pos).wrapping_sub(out_start); - (*coder).compressed_size = (*coder) - .compressed_size - .wrapping_add(in_used as lzma_vli); + (*coder).compressed_size = + (*coder).compressed_size.wrapping_add(in_used as lzma_vli); (*coder).uncompressed_size = (*coder) .uncompressed_size .wrapping_add(out_used as lzma_vli); - if ret as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { - let comp_done: bool = (*coder).compressed_size - == (*(*coder).block).compressed_size; - let uncomp_done: bool = (*coder).uncompressed_size - == (*(*coder).block).uncompressed_size; - if comp_done as ::core::ffi::c_int != 0 - && uncomp_done as ::core::ffi::c_int != 0 - { + if ret as c_uint == LZMA_OK as c_uint { + let comp_done: bool = + (*coder).compressed_size == (*(*coder).block).compressed_size; + let uncomp_done: bool = + (*coder).uncompressed_size == (*(*coder).block).uncompressed_size; + if comp_done as c_int != 0 && uncomp_done as c_int != 0 { return LZMA_DATA_ERROR; } - if comp_done as ::core::ffi::c_int != 0 && *out_pos < out_size { + if comp_done as c_int != 0 && *out_pos < out_size { return LZMA_DATA_ERROR; } - if uncomp_done as ::core::ffi::c_int != 0 && *in_pos < in_size { + if uncomp_done as c_int != 0 && *in_pos < in_size { return LZMA_DATA_ERROR; } } @@ -390,15 +326,10 @@ unsafe extern "C" fn block_decode( out_used, ); } - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_STREAM_END as c_uint { return ret; } - if !is_size_valid( - (*coder).compressed_size, - (*(*coder).block).compressed_size, - ) + if !is_size_valid((*coder).compressed_size, (*(*coder).block).compressed_size) || !is_size_valid( (*coder).uncompressed_size, (*(*coder).block).uncompressed_size, @@ -430,15 +361,11 @@ unsafe extern "C" fn block_decode( (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) as ::core::ffi::c_int - != 0 as ::core::ffi::c_int - { + if *in_0.offset(fresh0 as isize) as c_int != 0 as c_int { return LZMA_DATA_ERROR; } } - if (*(*coder).block).check as ::core::ffi::c_uint - == LZMA_CHECK_NONE as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*(*coder).block).check as c_uint == LZMA_CHECK_NONE as c_uint { return LZMA_STREAM_END; } if !(*coder).ignore_check { @@ -453,7 +380,7 @@ unsafe extern "C" fn block_decode( in_0, in_pos, in_size, - &raw mut (*(*coder).block).raw_check as *mut uint8_t, + &raw mut (*(*coder).block).raw_check as *mut u8, &raw mut (*coder).check_pos, check_size, ); @@ -461,15 +388,12 @@ unsafe extern "C" fn block_decode( return LZMA_OK; } if !(*coder).ignore_check - && lzma_check_is_supported((*(*coder).block).check) as ::core::ffi::c_int - != 0 + && lzma_check_is_supported((*(*coder).block).check) as c_int != 0 && memcmp( - &raw mut (*(*coder).block).raw_check as *mut uint8_t - as *const ::core::ffi::c_void, - &raw mut (*coder).check.buffer.u8_0 as *mut uint8_t - as *const ::core::ffi::c_void, + &raw mut (*(*coder).block).raw_check as *mut u8 as *const c_void, + &raw mut (*coder).check.buffer.u8_0 as *mut u8 as *const c_void, check_size, - ) != 0 as ::core::ffi::c_int + ) != 0 as c_int { return LZMA_DATA_ERROR; } @@ -478,12 +402,12 @@ unsafe extern "C" fn block_decode( return LZMA_PROG_ERROR; } unsafe extern "C" fn block_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; lzma_next_end(&raw mut (*coder).next, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_block_decoder_init( @@ -500,16 +424,14 @@ pub unsafe extern "C" fn lzma_block_decoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_block_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *mut lzma_block, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + lzma_block_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -522,16 +444,14 @@ pub unsafe extern "C" fn lzma_block_decoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_block_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *mut lzma_block, - ) -> lzma_ret, - ), - ); + >(Some( + lzma_block_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + )); if lzma_block_unpadded_size(block) == 0 as lzma_vli || !((*block).uncompressed_size <= LZMA_VLI_MAX as lzma_vli || (*block).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli) @@ -547,32 +467,28 @@ pub unsafe extern "C" fn lzma_block_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( block_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - block_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + block_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -586,26 +502,22 @@ pub unsafe extern "C" fn lzma_block_decoder_init( (*coder).block = block; (*coder).compressed_size = 0 as lzma_vli; (*coder).uncompressed_size = 0 as lzma_vli; - (*coder).compressed_limit = if (*block).compressed_size - == LZMA_VLI_UNKNOWN as lzma_vli - { + (*coder).compressed_limit = if (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli { (LZMA_VLI_MAX as lzma_vli & !(3 as lzma_vli)) .wrapping_sub((*block).header_size as lzma_vli) .wrapping_sub(lzma_check_size((*block).check) as lzma_vli) } else { (*block).compressed_size }; - (*coder).uncompressed_limit = if (*block).uncompressed_size - == LZMA_VLI_UNKNOWN as lzma_vli - { + (*coder).uncompressed_limit = if (*block).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli { LZMA_VLI_MAX as lzma_vli } else { (*block).uncompressed_size }; (*coder).check_pos = 0 as size_t; lzma_check_init(&raw mut (*coder).check, (*block).check); - (*coder).ignore_check = if (*block).version >= 1 as uint32_t { - (*block).ignore_check as ::core::ffi::c_int + (*coder).ignore_check = if (*block).version >= 1 as u32 { + (*block).ignore_check as c_int } else { false_0 } != 0; @@ -617,25 +529,17 @@ pub unsafe extern "C" fn lzma_block_decoder( mut block: *mut lzma_block, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - let ret__0: lzma_ret = lzma_block_decoder_init( - &raw mut (*(*strm).internal).next, - (*strm).allocator, - block, - ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__0: lzma_ret = + lzma_block_decoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block) + as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 02d50241..992ce3db 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -1,17 +1,12 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_end(strm: *mut lzma_stream); fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_check_size(check: lzma_check) -> uint32_t; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_check_size(check: lzma_check) -> u32; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_update( next: *mut lzma_next_coder, @@ -20,10 +15,10 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -36,21 +31,12 @@ extern "C" { fn lzma_check_update( check: *mut lzma_check_state, type_0: lzma_check, - buf: *const uint8_t, + buf: *const u8, size: size_t, ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -72,7 +58,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -81,17 +66,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -102,7 +79,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -114,68 +91,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -185,20 +137,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -207,18 +159,18 @@ pub struct lzma_stream { #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -258,51 +210,47 @@ pub struct lzma_check_state { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_0 { - pub crc32: uint32_t, - pub crc64: uint64_t, + pub crc32: u32, + pub crc64: u64, pub sha256: lzma_sha256_state, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_sha256_state { - pub state: [uint32_t; 8], - pub size: uint64_t, + pub state: [u32; 8], + pub size: u64, } #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_1 { - pub u8_0: [uint8_t; 64], - pub u32_0: [uint32_t; 16], - pub u64_0: [uint64_t; 8], + pub u8_0: [u8; 64], + pub u32_0: [u32; 16], + pub u64_0: [u64; 8], } -pub type C2RustUnnamed_2 = ::core::ffi::c_uint; +pub type C2RustUnnamed_2 = c_uint; pub const SEQ_CHECK: C2RustUnnamed_2 = 2; pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; -pub const LZMA_CHECK_SIZE_MAX: ::core::ffi::c_int = 64 as ::core::ffi::c_int; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: ::core::ffi::c_int = 1024 as ::core::ffi::c_int; -pub const COMPRESSED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX - .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as ::core::ffi::c_ulonglong) - .wrapping_sub(LZMA_CHECK_SIZE_MAX as ::core::ffi::c_ulonglong) - & !(3 as ::core::ffi::c_ulonglong); +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_SIZE_MAX: c_int = 64 as c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX + .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as c_ulonglong) + .wrapping_sub(LZMA_CHECK_SIZE_MAX as c_ulonglong) + & !(3 as c_ulonglong); unsafe extern "C" fn block_encode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -315,16 +263,11 @@ unsafe extern "C" fn block_encode( } 's_142: { let mut current_block_34: u64; - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - let ret: lzma_ret = (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -337,17 +280,15 @@ unsafe extern "C" fn block_encode( ) as lzma_ret; let in_used: size_t = (*in_pos).wrapping_sub(in_start); let out_used: size_t = (*out_pos).wrapping_sub(out_start); - if (COMPRESSED_SIZE_MAX as lzma_vli) - .wrapping_sub((*coder).compressed_size) < out_used as lzma_vli + if (COMPRESSED_SIZE_MAX as lzma_vli).wrapping_sub((*coder).compressed_size) + < out_used as lzma_vli { return LZMA_DATA_ERROR; } - (*coder).compressed_size = (*coder) - .compressed_size - .wrapping_add(out_used as lzma_vli); - (*coder).uncompressed_size = (*coder) - .uncompressed_size - .wrapping_add(in_used as lzma_vli); + (*coder).compressed_size = + (*coder).compressed_size.wrapping_add(out_used as lzma_vli); + (*coder).uncompressed_size = + (*coder).uncompressed_size.wrapping_add(in_used as lzma_vli); if in_used > 0 as size_t { lzma_check_update( &raw mut (*coder).check, @@ -356,10 +297,8 @@ unsafe extern "C" fn block_encode( in_used, ); } - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - || action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + if ret as c_uint != LZMA_STREAM_END as c_uint + || action as c_uint == LZMA_SYNC_FLUSH as c_uint { return ret; } @@ -384,13 +323,11 @@ unsafe extern "C" fn block_encode( if *out_pos >= out_size { return LZMA_OK; } - *out.offset(*out_pos as isize) = 0 as uint8_t; + *out.offset(*out_pos as isize) = 0 as u8; *out_pos = (*out_pos).wrapping_add(1); (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); } - if (*(*coder).block).check as ::core::ffi::c_uint - == LZMA_CHECK_NONE as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*(*coder).block).check as c_uint == LZMA_CHECK_NONE as c_uint { return LZMA_STREAM_END; } lzma_check_finish(&raw mut (*coder).check, (*(*coder).block).check); @@ -400,7 +337,7 @@ unsafe extern "C" fn block_encode( } let check_size: size_t = lzma_check_size((*(*coder).block).check) as size_t; lzma_bufcpy( - &raw mut (*coder).check.buffer.u8_0 as *mut uint8_t, + &raw mut (*coder).check.buffer.u8_0 as *mut u8, &raw mut (*coder).pos, check_size, out, @@ -411,10 +348,8 @@ unsafe extern "C" fn block_encode( return LZMA_OK; } memcpy( - &raw mut (*(*coder).block).raw_check as *mut uint8_t - as *mut ::core::ffi::c_void, - &raw mut (*coder).check.buffer.u8_0 as *mut uint8_t - as *const ::core::ffi::c_void, + &raw mut (*(*coder).block).raw_check as *mut u8 as *mut c_void, + &raw mut (*coder).check.buffer.u8_0 as *mut u8 as *const c_void, check_size, ); return LZMA_STREAM_END; @@ -422,23 +357,21 @@ unsafe extern "C" fn block_encode( return LZMA_PROG_ERROR; } unsafe extern "C" fn block_encoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; lzma_next_end(&raw mut (*coder).next, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn block_encoder_update( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, mut filters: *const lzma_filter, mut reversed_filters: *const lzma_filter, ) -> lzma_ret { let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; - if (*coder).sequence as ::core::ffi::c_uint - != SEQ_CODE as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*coder).sequence as c_uint != SEQ_CODE as c_uint { return LZMA_PROG_ERROR; } return lzma_next_filter_update(&raw mut (*coder).next, allocator, reversed_filters); @@ -458,16 +391,14 @@ pub unsafe extern "C" fn lzma_block_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_block_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *mut lzma_block, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + lzma_block_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -480,23 +411,21 @@ pub unsafe extern "C" fn lzma_block_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_block_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *mut lzma_block, - ) -> lzma_ret, - ), - ); + >(Some( + lzma_block_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut lzma_block, + ) -> lzma_ret, + )); if block.is_null() { return LZMA_PROG_ERROR; } - if (*block).version > 1 as uint32_t { + if (*block).version > 1 as u32 { return LZMA_OPTIONS_ERROR; } - if (*block).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint { + if (*block).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { return LZMA_PROG_ERROR; } if lzma_check_is_supported((*block).check) == 0 { @@ -511,32 +440,28 @@ pub unsafe extern "C" fn lzma_block_encoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( block_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - block_encoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + block_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*next).update = Some( block_encoder_update as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -544,7 +469,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -553,7 +478,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -577,27 +502,18 @@ pub unsafe extern "C" fn lzma_block_encoder( mut block: *mut lzma_block, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - let ret__0: lzma_ret = lzma_block_encoder_init( - &raw mut (*(*strm).internal).next, - (*strm).allocator, - block, - ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__0: lzma_ret = + lzma_block_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block) + as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal) - .supported_actions[LZMA_SYNC_FLUSH as ::core::ffi::c_int as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 974608f1..90279d07 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -1,31 +1,25 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_vli_decode( vli: *mut lzma_vli, vli_pos: *mut size_t, - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, ) -> lzma_ret; - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); fn lzma_filter_flags_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, ) -> lzma_ret; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -50,26 +44,16 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -77,18 +61,18 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -108,35 +92,26 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { - let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; - num - |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - num - |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 16 as ::core::ffi::c_int; - num - |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) - << 24 as ::core::ffi::c_int; +unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { + let mut num: u32 = *buf.offset(0 as isize) as u32; + num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; + num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; + num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; return num; } -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; -pub const LZMA_FILTERS_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_block_header_decode( mut block: *mut lzma_block, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, ) -> lzma_ret { if block.is_null() || (*block).filters.is_null() || in_0.is_null() { return LZMA_PROG_ERROR; @@ -148,33 +123,27 @@ pub unsafe extern "C" fn lzma_block_header_decode( *fresh0 = NULL; i = i.wrapping_add(1); } - if (*block).version > 1 as uint32_t { - (*block).version = 1 as uint32_t; + if (*block).version > 1 as u32 { + (*block).version = 1 as u32; } (*block).ignore_check = false_0 as lzma_bool; - if (*in_0.offset(0 as ::core::ffi::c_int as isize) as uint32_t) - .wrapping_add(1 as uint32_t) - .wrapping_mul(4 as uint32_t) != (*block).header_size - || (*block).check as ::core::ffi::c_uint - > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + if (*in_0.offset(0 as isize) as u32) + .wrapping_add(1 as u32) + .wrapping_mul(4 as u32) + != (*block).header_size + || (*block).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { return LZMA_PROG_ERROR; } - let in_size: size_t = (*block).header_size.wrapping_sub(4 as uint32_t) as size_t; - if lzma_crc32(in_0, in_size, 0 as uint32_t) - != read32le(in_0.offset(in_size as isize)) - { + let in_size: size_t = (*block).header_size.wrapping_sub(4 as u32) as size_t; + if lzma_crc32(in_0, in_size, 0 as u32) != read32le(in_0.offset(in_size as isize)) { return LZMA_DATA_ERROR; } - if *in_0.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - & 0x3c as ::core::ffi::c_int != 0 - { + if *in_0.offset(1 as isize) as c_int & 0x3c as c_int != 0 { return LZMA_OPTIONS_ERROR; } let mut in_pos: size_t = 2 as size_t; - if *in_0.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - & 0x40 as ::core::ffi::c_int != 0 - { + if *in_0.offset(1 as isize) as c_int & 0x40 as c_int != 0 { let ret_: lzma_ret = lzma_vli_decode( &raw mut (*block).compressed_size, ::core::ptr::null_mut::(), @@ -182,9 +151,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( &raw mut in_pos, in_size, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } if lzma_block_unpadded_size(block) == 0 as lzma_vli { @@ -193,9 +160,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( } else { (*block).compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; } - if *in_0.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - & 0x80 as ::core::ffi::c_int != 0 - { + if *in_0.offset(1 as isize) as c_int & 0x80 as c_int != 0 { let ret__0: lzma_ret = lzma_vli_decode( &raw mut (*block).uncompressed_size, ::core::ptr::null_mut::(), @@ -203,17 +168,14 @@ pub unsafe extern "C" fn lzma_block_header_decode( &raw mut in_pos, in_size, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { return ret__0; } } else { (*block).uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; } - let filter_count: size_t = (*in_0.offset(1 as ::core::ffi::c_int as isize) - as ::core::ffi::c_uint & 3 as ::core::ffi::c_uint) - .wrapping_add(1 as ::core::ffi::c_uint) as size_t; + let filter_count: size_t = + (*in_0.offset(1 as isize) as c_uint & 3 as c_uint).wrapping_add(1 as c_uint) as size_t; let mut i_0: size_t = 0 as size_t; while i_0 < filter_count { let ret: lzma_ret = lzma_filter_flags_decode( @@ -223,9 +185,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( &raw mut in_pos, in_size, ) as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_OK as c_uint { lzma_filters_free((*block).filters, allocator); return ret; } @@ -234,8 +194,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( while in_pos < in_size { let fresh1 = in_pos; in_pos = in_pos.wrapping_add(1); - if *in_0.offset(fresh1 as isize) as ::core::ffi::c_int != 0 as ::core::ffi::c_int - { + if *in_0.offset(fresh1 as isize) as c_int != 0 as c_int { lzma_filters_free((*block).filters, allocator); return LZMA_OPTIONS_ERROR; } diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 10952de2..e9d20312 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,39 +1,26 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn memset( - __b: *mut ::core::ffi::c_void, - __c: ::core::ffi::c_int, - __len: size_t, - ) -> *mut ::core::ffi::c_void; + fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; fn lzma_vli_encode( vli: lzma_vli, vli_pos: *mut size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; - fn lzma_vli_size(vli: lzma_vli) -> uint32_t; - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; - fn lzma_filter_flags_size( - size: *mut uint32_t, - filter: *const lzma_filter, - ) -> lzma_ret; + fn lzma_vli_size(vli: lzma_vli) -> u32; + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; + fn lzma_filter_flags_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret; fn lzma_filter_flags_encode( filter: *const lzma_filter, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -59,10 +46,8 @@ pub const LZMA_OK: lzma_ret = 0; #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -70,18 +55,18 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -101,50 +86,41 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { - *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; - *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) - as uint8_t; +unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { + *buf.offset(0 as isize) = num as u8; + *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; + *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; + *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; } -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_block_header_size(mut block: *mut lzma_block) -> lzma_ret { - if (*block).version > 1 as uint32_t { + if (*block).version > 1 as u32 { return LZMA_OPTIONS_ERROR; } - let mut size: uint32_t = (1 as ::core::ffi::c_int + 1 as ::core::ffi::c_int - + 4 as ::core::ffi::c_int) as uint32_t; + let mut size: u32 = (1 as c_int + 1 as c_int + 4 as c_int) as u32; if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { - let add: uint32_t = lzma_vli_size((*block).compressed_size) as uint32_t; - if add == 0 as uint32_t || (*block).compressed_size == 0 as lzma_vli { + let add: u32 = lzma_vli_size((*block).compressed_size) as u32; + if add == 0 as u32 || (*block).compressed_size == 0 as lzma_vli { return LZMA_PROG_ERROR; } size = size.wrapping_add(add); } if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { - let add_0: uint32_t = lzma_vli_size((*block).uncompressed_size) as uint32_t; - if add_0 == 0 as uint32_t { + let add_0: u32 = lzma_vli_size((*block).uncompressed_size) as u32; + if add_0 == 0 as u32 { return LZMA_PROG_ERROR; } size = size.wrapping_add(add_0); } if (*block).filters.is_null() - || (*(*block).filters.offset(0 as ::core::ffi::c_int as isize)).id - == LZMA_VLI_UNKNOWN as lzma_vli + || (*(*block).filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_PROG_ERROR; } @@ -153,26 +129,22 @@ pub unsafe extern "C" fn lzma_block_header_size(mut block: *mut lzma_block) -> l if i == LZMA_FILTERS_MAX as size_t { return LZMA_PROG_ERROR; } - let mut add_1: uint32_t = 0; - let ret_: lzma_ret = lzma_filter_flags_size( - &raw mut add_1, - (*block).filters.offset(i as isize), - ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let mut add_1: u32 = 0; + let ret_: lzma_ret = + lzma_filter_flags_size(&raw mut add_1, (*block).filters.offset(i as isize)) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } size = size.wrapping_add(add_1); i = i.wrapping_add(1); } - (*block).header_size = size.wrapping_add(3 as uint32_t) & !(3 as uint32_t); + (*block).header_size = size.wrapping_add(3 as u32) & !(3 as u32); return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_block_header_encode( mut block: *const lzma_block, - mut out: *mut uint8_t, + mut out: *mut u8, ) -> lzma_ret { if lzma_block_unpadded_size(block) == 0 as lzma_vli || !((*block).uncompressed_size <= LZMA_VLI_MAX as lzma_vli @@ -180,10 +152,9 @@ pub unsafe extern "C" fn lzma_block_header_encode( { return LZMA_PROG_ERROR; } - let out_size: size_t = (*block).header_size.wrapping_sub(4 as uint32_t) as size_t; - *out.offset(0 as ::core::ffi::c_int as isize) = out_size.wrapping_div(4 as size_t) - as uint8_t; - *out.offset(1 as ::core::ffi::c_int as isize) = 0 as uint8_t; + let out_size: size_t = (*block).header_size.wrapping_sub(4 as u32) as size_t; + *out.offset(0 as isize) = out_size.wrapping_div(4 as size_t) as u8; + *out.offset(1 as isize) = 0 as u8; let mut out_pos: size_t = 2 as size_t; if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { let ret_: lzma_ret = lzma_vli_encode( @@ -193,14 +164,11 @@ pub unsafe extern "C" fn lzma_block_header_encode( &raw mut out_pos, out_size, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - let ref mut fresh0 = *out.offset(1 as ::core::ffi::c_int as isize); - *fresh0 = (*fresh0 as ::core::ffi::c_int | 0x40 as ::core::ffi::c_int) - as uint8_t; + let ref mut fresh0 = *out.offset(1 as isize); + *fresh0 = (*fresh0 as c_int | 0x40 as c_int) as u8; } if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { let ret__0: lzma_ret = lzma_vli_encode( @@ -210,18 +178,14 @@ pub unsafe extern "C" fn lzma_block_header_encode( &raw mut out_pos, out_size, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { return ret__0; } - let ref mut fresh1 = *out.offset(1 as ::core::ffi::c_int as isize); - *fresh1 = (*fresh1 as ::core::ffi::c_int | 0x80 as ::core::ffi::c_int) - as uint8_t; + let ref mut fresh1 = *out.offset(1 as isize); + *fresh1 = (*fresh1 as c_int | 0x80 as c_int) as u8; } if (*block).filters.is_null() - || (*(*block).filters.offset(0 as ::core::ffi::c_int as isize)).id - == LZMA_VLI_UNKNOWN as lzma_vli + || (*(*block).filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_PROG_ERROR; } @@ -236,25 +200,24 @@ pub unsafe extern "C" fn lzma_block_header_encode( &raw mut out_pos, out_size, ) as lzma_ret; - if ret__1 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__1 as c_uint != LZMA_OK as c_uint { return ret__1; } filter_count = filter_count.wrapping_add(1); - if !((*(*block).filters.offset(filter_count as isize)).id - != LZMA_VLI_UNKNOWN as lzma_vli) - { + if !((*(*block).filters.offset(filter_count as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { break; } } - let ref mut fresh2 = *out.offset(1 as ::core::ffi::c_int as isize); - *fresh2 = (*fresh2 as size_t | filter_count.wrapping_sub(1 as size_t)) as uint8_t; + let ref mut fresh2 = *out.offset(1 as isize); + *fresh2 = (*fresh2 as size_t | filter_count.wrapping_sub(1 as size_t)) as u8; memset( - out.offset(out_pos as isize) as *mut ::core::ffi::c_void, - 0 as ::core::ffi::c_int, + out.offset(out_pos as isize) as *mut c_void, + 0 as c_int, out_size.wrapping_sub(out_pos), ); - write32le(out.offset(out_size as isize), lzma_crc32(out, out_size, 0 as uint32_t)); + write32le( + out.offset(out_size as isize), + lzma_crc32(out, out_size, 0 as u32), + ); return LZMA_OK; } diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 5de1afe7..5cf6ebc1 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -1,13 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn lzma_check_size(check: lzma_check) -> uint32_t; + fn lzma_check_size(check: lzma_check) -> u32; } -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -33,10 +29,8 @@ pub const LZMA_OK: lzma_ret = 0; #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -44,18 +38,18 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -75,20 +69,15 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; -pub const LZMA_BLOCK_HEADER_SIZE_MIN: ::core::ffi::c_int = 8 as ::core::ffi::c_int; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: ::core::ffi::c_int = 1024 as ::core::ffi::c_int; -pub const UNPADDED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX - & !(3 as ::core::ffi::c_ulonglong); +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MIN: c_int = 8 as c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !(3 as c_ulonglong); #[inline] unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); @@ -101,14 +90,13 @@ pub unsafe extern "C" fn lzma_block_compressed_size( if lzma_block_unpadded_size(block) == 0 as lzma_vli { return LZMA_PROG_ERROR; } - let container_size: uint32_t = (*block) + let container_size: u32 = (*block) .header_size - .wrapping_add(lzma_check_size((*block).check) as uint32_t); + .wrapping_add(lzma_check_size((*block).check) as u32); if unpadded_size <= container_size as lzma_vli { return LZMA_DATA_ERROR; } - let compressed_size: lzma_vli = unpadded_size - .wrapping_sub(container_size as lzma_vli); + let compressed_size: lzma_vli = unpadded_size.wrapping_sub(container_size as lzma_vli); if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli && (*block).compressed_size != compressed_size { @@ -118,18 +106,16 @@ pub unsafe extern "C" fn lzma_block_compressed_size( return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_block_unpadded_size( - mut block: *const lzma_block, -) -> lzma_vli { - if block.is_null() || (*block).version > 1 as uint32_t - || (*block).header_size < LZMA_BLOCK_HEADER_SIZE_MIN as uint32_t - || (*block).header_size > LZMA_BLOCK_HEADER_SIZE_MAX as uint32_t - || (*block).header_size & 3 as uint32_t != 0 +pub unsafe extern "C" fn lzma_block_unpadded_size(mut block: *const lzma_block) -> lzma_vli { + if block.is_null() + || (*block).version > 1 as u32 + || (*block).header_size < LZMA_BLOCK_HEADER_SIZE_MIN as u32 + || (*block).header_size > LZMA_BLOCK_HEADER_SIZE_MAX as u32 + || (*block).header_size & 3 as u32 != 0 || !((*block).compressed_size <= LZMA_VLI_MAX as lzma_vli || (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli) || (*block).compressed_size == 0 as lzma_vli - || (*block).check as ::core::ffi::c_uint - > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + || (*block).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { return 0 as lzma_vli; } @@ -146,9 +132,7 @@ pub unsafe extern "C" fn lzma_block_unpadded_size( return unpadded_size; } #[no_mangle] -pub unsafe extern "C" fn lzma_block_total_size( - mut block: *const lzma_block, -) -> lzma_vli { +pub unsafe extern "C" fn lzma_block_total_size(mut block: *const lzma_block) -> lzma_vli { let mut unpadded_size: lzma_vli = lzma_block_unpadded_size(block); if unpadded_size != LZMA_VLI_UNKNOWN as lzma_vli { unpadded_size = vli_ceil4(unpadded_size); diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index 4c27d9b0..910ecee4 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -1,27 +1,13 @@ +use crate::types::*; +use core::ffi::{c_char, c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn malloc(__size: size_t) -> *mut ::core::ffi::c_void; - fn calloc(__count: size_t, __size: size_t) -> *mut ::core::ffi::c_void; - fn free(_: *mut ::core::ffi::c_void); - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn memset( - __b: *mut ::core::ffi::c_void, - __c: ::core::ffi::c_int, - __len: size_t, - ) -> *mut ::core::ffi::c_void; + fn malloc(__size: size_t) -> *mut c_void; + fn calloc(__count: size_t, __size: size_t) -> *mut c_void; + fn free(_: *mut c_void); + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -43,7 +29,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -52,17 +37,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -73,7 +50,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -85,68 +62,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -156,20 +108,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -180,7 +132,7 @@ pub struct lzma_stream { pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -190,55 +142,46 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VERSION_MAJOR: ::core::ffi::c_int = 5 as ::core::ffi::c_int; -pub const LZMA_VERSION_MINOR: ::core::ffi::c_int = 8 as ::core::ffi::c_int; -pub const LZMA_VERSION_PATCH: ::core::ffi::c_int = 2 as ::core::ffi::c_int; -pub const LZMA_VERSION_STABILITY: ::core::ffi::c_int = LZMA_VERSION_STABILITY_STABLE; -pub const LZMA_VERSION_STABILITY_STABLE: ::core::ffi::c_int = 2 as ::core::ffi::c_int; -pub const LZMA_VERSION: ::core::ffi::c_uint = (LZMA_VERSION_MAJOR as ::core::ffi::c_uint) - .wrapping_mul(10000000 as ::core::ffi::c_uint) - .wrapping_add( - (LZMA_VERSION_MINOR as ::core::ffi::c_uint) - .wrapping_mul(10000 as ::core::ffi::c_uint), - ) - .wrapping_add( - (LZMA_VERSION_PATCH as ::core::ffi::c_uint) - .wrapping_mul(10 as ::core::ffi::c_uint), - ) - .wrapping_add(LZMA_VERSION_STABILITY as ::core::ffi::c_uint); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_TIMED_OUT: ::core::ffi::c_uint = 101 as ::core::ffi::c_uint; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VERSION_MAJOR: c_int = 5 as c_int; +pub const LZMA_VERSION_MINOR: c_int = 8 as c_int; +pub const LZMA_VERSION_PATCH: c_int = 2 as c_int; +pub const LZMA_VERSION_STABILITY: c_int = LZMA_VERSION_STABILITY_STABLE; +pub const LZMA_VERSION_STABILITY_STABLE: c_int = 2 as c_int; +pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR as c_uint) + .wrapping_mul(10000000 as c_uint) + .wrapping_add((LZMA_VERSION_MINOR as c_uint).wrapping_mul(10000 as c_uint)) + .wrapping_add((LZMA_VERSION_PATCH as c_uint).wrapping_mul(10 as c_uint)) + .wrapping_add(LZMA_VERSION_STABILITY as c_uint); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_TIMED_OUT: c_uint = 101 as c_uint; #[no_mangle] -pub unsafe extern "C" fn lzma_version_number() -> uint32_t { - return LZMA_VERSION as uint32_t; +pub unsafe extern "C" fn lzma_version_number() -> u32 { + return LZMA_VERSION as u32; } #[no_mangle] -pub unsafe extern "C" fn lzma_version_string() -> *const ::core::ffi::c_char { - return b"5.8.2\0" as *const u8 as *const ::core::ffi::c_char; +pub unsafe extern "C" fn lzma_version_string() -> *const c_char { + return b"5.8.2\0" as *const u8 as *const c_char; } #[no_mangle] pub unsafe extern "C" fn lzma_alloc( mut size: size_t, mut allocator: *const lzma_allocator, -) -> *mut ::core::ffi::c_void { +) -> *mut c_void { if size == 0 as size_t { size = 1 as size_t; } - let mut ptr: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, - >(); + let mut ptr: *mut c_void = ::core::ptr::null_mut::(); if !allocator.is_null() && (*allocator).alloc.is_some() { - ptr = (*allocator) - .alloc - .expect("non-null function pointer")((*allocator).opaque, 1 as size_t, size); + ptr = (*allocator).alloc.expect("non-null function pointer")( + (*allocator).opaque, + 1 as size_t, + size, + ); } else { ptr = malloc(size); } @@ -248,19 +191,19 @@ pub unsafe extern "C" fn lzma_alloc( pub unsafe extern "C" fn lzma_alloc_zero( mut size: size_t, mut allocator: *const lzma_allocator, -) -> *mut ::core::ffi::c_void { +) -> *mut c_void { if size == 0 as size_t { size = 1 as size_t; } - let mut ptr: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, - >(); + let mut ptr: *mut c_void = ::core::ptr::null_mut::(); if !allocator.is_null() && (*allocator).alloc.is_some() { - ptr = (*allocator) - .alloc - .expect("non-null function pointer")((*allocator).opaque, 1 as size_t, size); + ptr = (*allocator).alloc.expect("non-null function pointer")( + (*allocator).opaque, + 1 as size_t, + size, + ); if !ptr.is_null() { - memset(ptr, 0 as ::core::ffi::c_int, size); + memset(ptr, 0 as c_int, size); } } else { ptr = calloc(1 as size_t, size); @@ -268,10 +211,7 @@ pub unsafe extern "C" fn lzma_alloc_zero( return ptr; } #[no_mangle] -pub unsafe extern "C" fn lzma_free( - mut ptr: *mut ::core::ffi::c_void, - mut allocator: *const lzma_allocator, -) { +pub unsafe extern "C" fn lzma_free(mut ptr: *mut c_void, mut allocator: *const lzma_allocator) { if !allocator.is_null() && (*allocator).free.is_some() { (*allocator).free.expect("non-null function pointer")((*allocator).opaque, ptr); } else { @@ -280,20 +220,24 @@ pub unsafe extern "C" fn lzma_free( } #[no_mangle] pub unsafe extern "C" fn lzma_bufcpy( - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> size_t { let in_avail: size_t = in_size.wrapping_sub(*in_pos); let out_avail: size_t = out_size.wrapping_sub(*out_pos); - let copy_size: size_t = if in_avail < out_avail { in_avail } else { out_avail }; + let copy_size: size_t = if in_avail < out_avail { + in_avail + } else { + out_avail + }; if copy_size > 0 as size_t { memcpy( - out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, - in_0.offset(*in_pos as isize) as *const ::core::ffi::c_void, + out.offset(*out_pos as isize) as *mut c_void, + in_0.offset(*in_pos as isize) as *const c_void, copy_size, ); } @@ -307,25 +251,20 @@ pub unsafe extern "C" fn lzma_next_filter_init( mut allocator: *const lzma_allocator, mut filters: *const lzma_filter_info, ) -> lzma_ret { - if ::core::mem::transmute::< - lzma_init_function, - uintptr_t, - >((*filters.offset(0 as ::core::ffi::c_int as isize)).init) != (*next).init + if ::core::mem::transmute::((*filters.offset(0 as isize)).init) + != (*next).init { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< - lzma_init_function, - uintptr_t, - >((*filters.offset(0 as ::core::ffi::c_int as isize)).init); - (*next).id = (*filters.offset(0 as ::core::ffi::c_int as isize)).id; - return (if (*filters.offset(0 as ::core::ffi::c_int as isize)).init.is_none() { - LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + (*next).init = + ::core::mem::transmute::((*filters.offset(0 as isize)).init); + (*next).id = (*filters.offset(0 as isize)).id; + return (if (*filters.offset(0 as isize)).init.is_none() { + LZMA_OK as c_uint } else { - (*filters.offset(0 as ::core::ffi::c_int as isize)) + (*filters.offset(0 as isize)) .init - .expect("non-null function pointer")(next, allocator, filters) - as ::core::ffi::c_uint + .expect("non-null function pointer")(next, allocator, filters) as c_uint }) as lzma_ret; } #[no_mangle] @@ -334,19 +273,13 @@ pub unsafe extern "C" fn lzma_next_filter_update( mut allocator: *const lzma_allocator, mut reversed_filters: *const lzma_filter, ) -> lzma_ret { - if (*reversed_filters.offset(0 as ::core::ffi::c_int as isize)).id != (*next).id { + if (*reversed_filters.offset(0 as isize)).id != (*next).id { return LZMA_PROG_ERROR; } - if (*reversed_filters.offset(0 as ::core::ffi::c_int as isize)).id - == LZMA_VLI_UNKNOWN as lzma_vli - { + if (*reversed_filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_OK; } - return (*next) - .update - .expect( - "non-null function pointer", - )( + return (*next).update.expect("non-null function pointer")( (*next).coder, allocator, ::core::ptr::null::(), @@ -358,7 +291,7 @@ pub unsafe extern "C" fn lzma_next_end( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, ) { - if (*next).init != ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t { + if (*next).init != ::core::ptr::null_mut::() as uintptr_t { if (*next).end.is_some() { (*next).end.expect("non-null function pointer")((*next).coder, allocator); } else { @@ -367,7 +300,7 @@ pub unsafe extern "C" fn lzma_next_end( *next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -394,7 +327,7 @@ pub unsafe extern "C" fn lzma_strm_init(mut strm: *mut lzma_stream) -> lzma_ret (*(*strm).internal).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -405,15 +338,14 @@ pub unsafe extern "C" fn lzma_strm_init(mut strm: *mut lzma_stream) -> lzma_ret }; } memset( - &raw mut (*(*strm).internal).supported_actions as *mut bool - as *mut ::core::ffi::c_void, - 0 as ::core::ffi::c_int, + &raw mut (*(*strm).internal).supported_actions as *mut bool as *mut c_void, + 0 as c_int, ::core::mem::size_of::<[bool; 5]>() as size_t, ); (*(*strm).internal).sequence = ISEQ_RUN; (*(*strm).internal).allow_buf_error = false_0 != 0; - (*strm).total_in = 0 as uint64_t; - (*strm).total_out = 0 as uint64_t; + (*strm).total_in = 0 as u64; + (*strm).total_out = 0 as u64; return LZMA_OK; } #[no_mangle] @@ -423,69 +355,64 @@ pub unsafe extern "C" fn lzma_code( ) -> lzma_ret { if (*strm).next_in.is_null() && (*strm).avail_in != 0 as size_t || (*strm).next_out.is_null() && (*strm).avail_out != 0 as size_t - || (*strm).internal.is_null() || (*(*strm).internal).next.code.is_none() - || action as ::core::ffi::c_uint - > LZMA_FULL_BARRIER as ::core::ffi::c_int as ::core::ffi::c_uint + || (*strm).internal.is_null() + || (*(*strm).internal).next.code.is_none() + || action as c_uint > LZMA_FULL_BARRIER as c_uint || !(*(*strm).internal).supported_actions[action as usize] { return LZMA_PROG_ERROR; } - if !(*strm).reserved_ptr1.is_null() || !(*strm).reserved_ptr2.is_null() - || !(*strm).reserved_ptr3.is_null() || !(*strm).reserved_ptr4.is_null() - || (*strm).reserved_int2 != 0 as uint64_t || (*strm).reserved_int3 != 0 as size_t + if !(*strm).reserved_ptr1.is_null() + || !(*strm).reserved_ptr2.is_null() + || !(*strm).reserved_ptr3.is_null() + || !(*strm).reserved_ptr4.is_null() + || (*strm).reserved_int2 != 0 as u64 + || (*strm).reserved_int3 != 0 as size_t || (*strm).reserved_int4 != 0 as size_t - || (*strm).reserved_enum1 as ::core::ffi::c_uint - != LZMA_RESERVED_ENUM as ::core::ffi::c_int as ::core::ffi::c_uint - || (*strm).reserved_enum2 as ::core::ffi::c_uint - != LZMA_RESERVED_ENUM as ::core::ffi::c_int as ::core::ffi::c_uint + || (*strm).reserved_enum1 as c_uint != LZMA_RESERVED_ENUM as c_uint + || (*strm).reserved_enum2 as c_uint != LZMA_RESERVED_ENUM as c_uint { return LZMA_OPTIONS_ERROR; } - match (*(*strm).internal).sequence as ::core::ffi::c_uint { - 0 => { - match action as ::core::ffi::c_uint { - 1 => { - (*(*strm).internal).sequence = ISEQ_SYNC_FLUSH; - } - 2 => { - (*(*strm).internal).sequence = ISEQ_FULL_FLUSH; - } - 3 => { - (*(*strm).internal).sequence = ISEQ_FINISH; - } - 4 => { - (*(*strm).internal).sequence = ISEQ_FULL_BARRIER; - } - 0 | _ => {} + match (*(*strm).internal).sequence as c_uint { + 0 => match action as c_uint { + 1 => { + (*(*strm).internal).sequence = ISEQ_SYNC_FLUSH; } - } + 2 => { + (*(*strm).internal).sequence = ISEQ_FULL_FLUSH; + } + 3 => { + (*(*strm).internal).sequence = ISEQ_FINISH; + } + 4 => { + (*(*strm).internal).sequence = ISEQ_FULL_BARRIER; + } + 0 | _ => {} + }, 1 => { - if action as ::core::ffi::c_uint - != LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + if action as c_uint != LZMA_SYNC_FLUSH as c_uint || (*(*strm).internal).avail_in != (*strm).avail_in { return LZMA_PROG_ERROR; } } 2 => { - if action as ::core::ffi::c_uint - != LZMA_FULL_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + if action as c_uint != LZMA_FULL_FLUSH as c_uint || (*(*strm).internal).avail_in != (*strm).avail_in { return LZMA_PROG_ERROR; } } 3 => { - if action as ::core::ffi::c_uint - != LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + if action as c_uint != LZMA_FINISH as c_uint || (*(*strm).internal).avail_in != (*strm).avail_in { return LZMA_PROG_ERROR; } } 4 => { - if action as ::core::ffi::c_uint - != LZMA_FULL_BARRIER as ::core::ffi::c_int as ::core::ffi::c_uint + if action as c_uint != LZMA_FULL_BARRIER as c_uint || (*(*strm).internal).avail_in != (*strm).avail_in { return LZMA_PROG_ERROR; @@ -499,9 +426,7 @@ pub unsafe extern "C" fn lzma_code( let mut ret: lzma_ret = (*(*strm).internal) .next .code - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*(*strm).internal).next.coder, (*strm).allocator, (*strm).next_in, @@ -515,16 +440,16 @@ pub unsafe extern "C" fn lzma_code( if in_pos > 0 as size_t { (*strm).next_in = (*strm).next_in.offset(in_pos as isize); (*strm).avail_in = (*strm).avail_in.wrapping_sub(in_pos); - (*strm).total_in = (*strm).total_in.wrapping_add(in_pos as uint64_t); + (*strm).total_in = (*strm).total_in.wrapping_add(in_pos as u64); } if out_pos > 0 as size_t { (*strm).next_out = (*strm).next_out.offset(out_pos as isize); (*strm).avail_out = (*strm).avail_out.wrapping_sub(out_pos); - (*strm).total_out = (*strm).total_out.wrapping_add(out_pos as uint64_t); + (*strm).total_out = (*strm).total_out.wrapping_add(out_pos as u64); } (*(*strm).internal).avail_in = (*strm).avail_in; let mut current_block_49: u64; - match ret as ::core::ffi::c_uint { + match ret as c_uint { 0 => { if out_pos == 0 as size_t && in_pos == 0 as size_t { if (*(*strm).internal).allow_buf_error { @@ -544,20 +469,15 @@ pub unsafe extern "C" fn lzma_code( } 12 => { (*(*strm).internal).allow_buf_error = false_0 != 0; - if (*(*strm).internal).sequence as ::core::ffi::c_uint - == ISEQ_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*(*strm).internal).sequence as c_uint == ISEQ_FINISH as c_uint { (*(*strm).internal).sequence = ISEQ_RUN; } current_block_49 = 12556861819962772176; } 1 => { - if (*(*strm).internal).sequence as ::core::ffi::c_uint - == ISEQ_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint - || (*(*strm).internal).sequence as ::core::ffi::c_uint - == ISEQ_FULL_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint - || (*(*strm).internal).sequence as ::core::ffi::c_uint - == ISEQ_FULL_BARRIER as ::core::ffi::c_int as ::core::ffi::c_uint + if (*(*strm).internal).sequence as c_uint == ISEQ_SYNC_FLUSH as c_uint + || (*(*strm).internal).sequence as c_uint == ISEQ_FULL_FLUSH as c_uint + || (*(*strm).internal).sequence as c_uint == ISEQ_FULL_BARRIER as c_uint { (*(*strm).internal).sequence = ISEQ_RUN; } else { @@ -585,23 +505,25 @@ pub unsafe extern "C" fn lzma_code( pub unsafe extern "C" fn lzma_end(mut strm: *mut lzma_stream) { if !strm.is_null() && !(*strm).internal.is_null() { lzma_next_end(&raw mut (*(*strm).internal).next, (*strm).allocator); - lzma_free((*strm).internal as *mut ::core::ffi::c_void, (*strm).allocator); + lzma_free((*strm).internal as *mut c_void, (*strm).allocator); (*strm).internal = ::core::ptr::null_mut::(); } } #[no_mangle] pub unsafe extern "C" fn lzma_get_progress( mut strm: *mut lzma_stream, - mut progress_in: *mut uint64_t, - mut progress_out: *mut uint64_t, + mut progress_in: *mut u64, + mut progress_out: *mut u64, ) { if (*(*strm).internal).next.get_progress.is_some() { (*(*strm).internal) .next .get_progress - .expect( - "non-null function pointer", - )((*(*strm).internal).next.coder, progress_in, progress_out); + .expect("non-null function pointer")( + (*(*strm).internal).next.coder, + progress_in, + progress_out, + ); } else { *progress_in = (*strm).total_in; *progress_out = (*strm).total_out; @@ -618,70 +540,67 @@ pub unsafe extern "C" fn lzma_get_check(mut strm: *const lzma_stream) -> lzma_ch .expect("non-null function pointer")((*(*strm).internal).next.coder); } #[no_mangle] -pub unsafe extern "C" fn lzma_memusage(mut strm: *const lzma_stream) -> uint64_t { - let mut memusage: uint64_t = 0; - let mut old_memlimit: uint64_t = 0; - if strm.is_null() || (*strm).internal.is_null() +pub unsafe extern "C" fn lzma_memusage(mut strm: *const lzma_stream) -> u64 { + let mut memusage: u64 = 0; + let mut old_memlimit: u64 = 0; + if strm.is_null() + || (*strm).internal.is_null() || (*(*strm).internal).next.memconfig.is_none() || (*(*strm).internal) .next .memconfig - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*(*strm).internal).next.coder, &raw mut memusage, &raw mut old_memlimit, - 0 as uint64_t, - ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + 0 as u64, + ) as c_uint + != LZMA_OK as c_uint { - return 0 as uint64_t; + return 0 as u64; } return memusage; } #[no_mangle] -pub unsafe extern "C" fn lzma_memlimit_get(mut strm: *const lzma_stream) -> uint64_t { - let mut old_memlimit: uint64_t = 0; - let mut memusage: uint64_t = 0; - if strm.is_null() || (*strm).internal.is_null() +pub unsafe extern "C" fn lzma_memlimit_get(mut strm: *const lzma_stream) -> u64 { + let mut old_memlimit: u64 = 0; + let mut memusage: u64 = 0; + if strm.is_null() + || (*strm).internal.is_null() || (*(*strm).internal).next.memconfig.is_none() || (*(*strm).internal) .next .memconfig - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*(*strm).internal).next.coder, &raw mut memusage, &raw mut old_memlimit, - 0 as uint64_t, - ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + 0 as u64, + ) as c_uint + != LZMA_OK as c_uint { - return 0 as uint64_t; + return 0 as u64; } return old_memlimit; } #[no_mangle] pub unsafe extern "C" fn lzma_memlimit_set( mut strm: *mut lzma_stream, - mut new_memlimit: uint64_t, + mut new_memlimit: u64, ) -> lzma_ret { - let mut old_memlimit: uint64_t = 0; - let mut memusage: uint64_t = 0; - if strm.is_null() || (*strm).internal.is_null() - || (*(*strm).internal).next.memconfig.is_none() + let mut old_memlimit: u64 = 0; + let mut memusage: u64 = 0; + if strm.is_null() || (*strm).internal.is_null() || (*(*strm).internal).next.memconfig.is_none() { return LZMA_PROG_ERROR; } - if new_memlimit == 0 as uint64_t { - new_memlimit = 1 as uint64_t; + if new_memlimit == 0 as u64 { + new_memlimit = 1 as u64; } return (*(*strm).internal) .next .memconfig - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*(*strm).internal).next.coder, &raw mut memusage, &raw mut old_memlimit, diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 6af32897..80d2a173 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -1,24 +1,19 @@ +use crate::types::*; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_stream_buffer_encode( filters: *mut lzma_filter, check: lzma_check, allocator: *const lzma_allocator, - in_0: *const uint8_t, + in_0: *const u8, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: uint32_t) -> bool; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -43,66 +38,54 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -112,23 +95,23 @@ pub struct lzma_options_easy { } #[no_mangle] pub unsafe extern "C" fn lzma_easy_buffer_encode( - mut preset: uint32_t, + mut preset: u32, mut check: lzma_check, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: ::core::ptr::null::(), preset_dict_size: 0, lc: 0, lp: 0, @@ -149,8 +132,8 @@ pub unsafe extern "C" fn lzma_easy_buffer_encode( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), }, }; if lzma_easy_preset(&raw mut opt_easy, preset) { diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index d77825e0..8aeffbc4 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -1,55 +1,50 @@ +use crate::types::*; +use core::ffi::{c_uint, c_void}; extern "C" { - fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> uint64_t; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: uint32_t) -> bool; + fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -57,17 +52,17 @@ pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; #[no_mangle] -pub unsafe extern "C" fn lzma_easy_decoder_memusage(mut preset: uint32_t) -> uint64_t { +pub unsafe extern "C" fn lzma_easy_decoder_memusage(mut preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: ::core::ptr::null::(), preset_dict_size: 0, lc: 0, lp: 0, @@ -88,12 +83,12 @@ pub unsafe extern "C" fn lzma_easy_decoder_memusage(mut preset: uint32_t) -> uin reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), }, }; if lzma_easy_preset(&raw mut opt_easy, preset) { - return UINT32_MAX as uint64_t; + return UINT32_MAX as u64; } return lzma_raw_decoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter); } diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index 5e1a81d0..c47e200f 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -1,20 +1,14 @@ +use crate::types::*; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_stream_encoder( strm: *mut lzma_stream, filters: *const lzma_filter, check: lzma_check, ) -> lzma_ret; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: uint32_t) -> bool; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -36,7 +30,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -45,17 +38,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -66,7 +51,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -78,68 +63,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -149,61 +109,59 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, } -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -214,17 +172,17 @@ pub struct lzma_options_easy { #[no_mangle] pub unsafe extern "C" fn lzma_easy_encoder( mut strm: *mut lzma_stream, - mut preset: uint32_t, + mut preset: u32, mut check: lzma_check, ) -> lzma_ret { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: ::core::ptr::null::(), preset_dict_size: 0, lc: 0, lp: 0, @@ -245,16 +203,12 @@ pub unsafe extern "C" fn lzma_easy_encoder( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), }, }; if lzma_easy_preset(&raw mut opt_easy, preset) { return LZMA_OPTIONS_ERROR; } - return lzma_stream_encoder( - strm, - &raw mut opt_easy.filters as *mut lzma_filter, - check, - ); + return lzma_stream_encoder(strm, &raw mut opt_easy.filters as *mut lzma_filter, check); } diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index a942c783..c56b60f2 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -1,55 +1,50 @@ +use crate::types::*; +use core::ffi::{c_uint, c_void}; extern "C" { - fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> uint64_t; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: uint32_t) -> bool; + fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -57,17 +52,17 @@ pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; #[no_mangle] -pub unsafe extern "C" fn lzma_easy_encoder_memusage(mut preset: uint32_t) -> uint64_t { +pub unsafe extern "C" fn lzma_easy_encoder_memusage(mut preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: ::core::ptr::null::(), preset_dict_size: 0, lc: 0, lp: 0, @@ -88,12 +83,12 @@ pub unsafe extern "C" fn lzma_easy_encoder_memusage(mut preset: uint32_t) -> uin reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), }, }; if lzma_easy_preset(&raw mut opt_easy, preset) { - return UINT32_MAX as uint64_t; + return UINT32_MAX as u64; } return lzma_raw_encoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter); } diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index eae4d0be..bf3c0675 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -1,55 +1,49 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: uint32_t) -> lzma_bool; + fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; } -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -57,25 +51,21 @@ pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; #[no_mangle] pub unsafe extern "C" fn lzma_easy_preset( mut opt_easy: *mut lzma_options_easy, - mut preset: uint32_t, + mut preset: u32, ) -> bool { if lzma_lzma_preset(&raw mut (*opt_easy).opt_lzma, preset) != 0 { return true_0 != 0; } - (*opt_easy).filters[0 as ::core::ffi::c_int as usize].id = LZMA_FILTER_LZMA2 - as lzma_vli; - (*opt_easy).filters[0 as ::core::ffi::c_int as usize].options = &raw mut (*opt_easy) - .opt_lzma as *mut ::core::ffi::c_void; - (*opt_easy).filters[1 as ::core::ffi::c_int as usize].id = LZMA_VLI_UNKNOWN - as lzma_vli; + (*opt_easy).filters[0 as usize].id = LZMA_FILTER_LZMA2 as lzma_vli; + (*opt_easy).filters[0 as usize].options = &raw mut (*opt_easy).opt_lzma as *mut c_void; + (*opt_easy).filters[1 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; return false_0 != 0; } diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 5b8d14d9..1d735d04 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -1,48 +1,40 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; #[repr(C)] -pub struct lzma_index_s { _opaque: [u8; 0] } +pub struct lzma_index_s { + _opaque: [u8; 0], +} extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_stream_header_decode( - options: *mut lzma_stream_flags, - in_0: *const uint8_t, - ) -> lzma_ret; - fn lzma_stream_footer_decode( - options: *mut lzma_stream_flags, - in_0: *const uint8_t, - ) -> lzma_ret; + fn lzma_stream_header_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; + fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; fn lzma_stream_flags_compare( a: *const lzma_stream_flags, b: *const lzma_stream_flags, ) -> lzma_ret; - fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> uint64_t; - fn lzma_index_memused(i: *const lzma_index) -> uint64_t; + fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64; + fn lzma_index_memused(i: *const lzma_index) -> u64; fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); fn lzma_index_stream_flags( i: *mut lzma_index, stream_flags: *const lzma_stream_flags, ) -> lzma_ret; - fn lzma_index_stream_padding( - i: *mut lzma_index, - stream_padding: lzma_vli, - ) -> lzma_ret; + fn lzma_index_stream_padding(i: *mut lzma_index, stream_padding: lzma_vli) -> lzma_ret; fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli; fn lzma_index_cat( dest: *mut lzma_index, src: *mut lzma_index, allocator: *const lzma_allocator, ) -> lzma_ret; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -50,19 +42,10 @@ extern "C" { next: *mut lzma_next_coder, allocator: *const lzma_allocator, i: *mut *mut lzma_index, - memlimit: uint64_t, + memlimit: u64, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -84,7 +67,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -93,17 +75,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -114,7 +88,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -126,68 +100,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -197,20 +146,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -219,7 +168,7 @@ pub struct lzma_stream { #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -234,33 +183,33 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_file_info_coder { pub sequence: C2RustUnnamed_0, - pub file_cur_pos: uint64_t, - pub file_target_pos: uint64_t, - pub file_size: uint64_t, + pub file_cur_pos: u64, + pub file_target_pos: u64, + pub file_size: u64, pub index_decoder: lzma_next_coder, pub index_remaining: lzma_vli, pub this_index: *mut lzma_index, pub stream_padding: lzma_vli, pub combined_index: *mut lzma_index, pub dest_index: *mut *mut lzma_index, - pub external_seek_pos: *mut uint64_t, - pub memlimit: uint64_t, + pub external_seek_pos: *mut u64, + pub memlimit: u64, pub first_header_flags: lzma_stream_flags, pub header_flags: lzma_stream_flags, pub footer_flags: lzma_stream_flags, pub temp_pos: size_t, pub temp_size: size_t, - pub temp: [uint8_t; 8192], + pub temp: [u8; 8192], } -pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub type C2RustUnnamed_0 = c_uint; pub const SEQ_HEADER_COMPARE: C2RustUnnamed_0 = 7; pub const SEQ_HEADER_DECODE: C2RustUnnamed_0 = 6; pub const SEQ_INDEX_DECODE: C2RustUnnamed_0 = 5; @@ -269,55 +218,46 @@ pub const SEQ_FOOTER: C2RustUnnamed_0 = 3; pub const SEQ_PADDING_DECODE: C2RustUnnamed_0 = 2; pub const SEQ_PADDING_SEEK: C2RustUnnamed_0 = 1; pub const SEQ_MAGIC_BYTES: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; unsafe extern "C" fn fill_temp( mut coder: *mut lzma_file_info_coder, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, ) -> bool { - (*coder).file_cur_pos = (*coder) - .file_cur_pos - .wrapping_add( - lzma_bufcpy( - in_0, - in_pos, - in_size, - &raw mut (*coder).temp as *mut uint8_t, - &raw mut (*coder).temp_pos, - (*coder).temp_size, - ) as uint64_t, - ); + (*coder).file_cur_pos = (*coder).file_cur_pos.wrapping_add(lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).temp as *mut u8, + &raw mut (*coder).temp_pos, + (*coder).temp_size, + ) as u64); return (*coder).temp_pos < (*coder).temp_size; } unsafe extern "C" fn seek_to_pos( mut coder: *mut lzma_file_info_coder, - mut target_pos: uint64_t, + mut target_pos: u64, mut in_start: size_t, mut in_pos: *mut size_t, mut in_size: size_t, ) -> bool { - let pos_min: uint64_t = (*coder) + let pos_min: u64 = (*coder) .file_cur_pos - .wrapping_sub((*in_pos).wrapping_sub(in_start) as uint64_t); - let pos_max: uint64_t = (*coder) + .wrapping_sub((*in_pos).wrapping_sub(in_start) as u64); + let pos_max: u64 = (*coder) .file_cur_pos - .wrapping_add(in_size.wrapping_sub(*in_pos) as uint64_t); + .wrapping_add(in_size.wrapping_sub(*in_pos) as u64); let mut external_seek_needed: bool = false; if target_pos >= pos_min && target_pos <= pos_max { - *in_pos = (*in_pos) - .wrapping_add(target_pos.wrapping_sub((*coder).file_cur_pos) as size_t); + *in_pos = (*in_pos).wrapping_add(target_pos.wrapping_sub((*coder).file_cur_pos) as size_t); external_seek_needed = false_0 != 0; } else { *(*coder).external_seek_pos = target_pos; @@ -333,25 +273,26 @@ unsafe extern "C" fn reverse_seek( mut in_pos: *mut size_t, mut in_size: size_t, ) -> lzma_ret { - if (*coder).file_target_pos - < (2 as ::core::ffi::c_int * LZMA_STREAM_HEADER_SIZE) as uint64_t - { + if (*coder).file_target_pos < (2 as c_int * LZMA_STREAM_HEADER_SIZE) as u64 { return LZMA_DATA_ERROR; } (*coder).temp_pos = 0 as size_t; - if (*coder).file_target_pos.wrapping_sub(LZMA_STREAM_HEADER_SIZE as uint64_t) - < ::core::mem::size_of::<[uint8_t; 8192]>() as uint64_t + if (*coder) + .file_target_pos + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64) + < ::core::mem::size_of::<[u8; 8192]>() as u64 { (*coder).temp_size = (*coder) .file_target_pos - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as uint64_t) as size_t; + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64) as size_t; } else { - (*coder).temp_size = ::core::mem::size_of::<[uint8_t; 8192]>() as usize - as size_t; + (*coder).temp_size = ::core::mem::size_of::<[u8; 8192]>() as usize as size_t; } if seek_to_pos( coder, - (*coder).file_target_pos.wrapping_sub((*coder).temp_size as uint64_t), + (*coder) + .file_target_pos + .wrapping_sub((*coder).temp_size as u64), in_start, in_pos, in_size, @@ -360,26 +301,18 @@ unsafe extern "C" fn reverse_seek( } return LZMA_OK; } -unsafe extern "C" fn get_padding_size( - mut buf: *const uint8_t, - mut buf_size: size_t, -) -> size_t { +unsafe extern "C" fn get_padding_size(mut buf: *const u8, mut buf_size: size_t) -> size_t { let mut padding: size_t = 0 as size_t; - while buf_size > 0 as size_t - && { - buf_size = buf_size.wrapping_sub(1); - *buf.offset(buf_size as isize) as ::core::ffi::c_int - == 0 as ::core::ffi::c_int - } - { + while buf_size > 0 as size_t && { + buf_size = buf_size.wrapping_sub(1); + *buf.offset(buf_size as isize) as c_int == 0 as c_int + } { padding = padding.wrapping_add(1); } return padding; } unsafe extern "C" fn hide_format_error(mut ret: lzma_ret) -> lzma_ret { - if ret as ::core::ffi::c_uint - == LZMA_FORMAT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_FORMAT_ERROR as c_uint { ret = LZMA_DATA_ERROR; } return ret; @@ -387,7 +320,7 @@ unsafe extern "C" fn hide_format_error(mut ret: lzma_ret) -> lzma_ret { unsafe extern "C" fn decode_index( mut coder: *mut lzma_file_info_coder, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, mut update_file_cur_pos: bool, @@ -396,15 +329,13 @@ unsafe extern "C" fn decode_index( let ret: lzma_ret = (*coder) .index_decoder .code - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).index_decoder.coder, allocator, in_0, in_pos, in_size, - ::core::ptr::null_mut::(), + ::core::ptr::null_mut::(), ::core::ptr::null_mut::(), 0 as size_t, LZMA_RUN, @@ -415,17 +346,17 @@ unsafe extern "C" fn decode_index( if update_file_cur_pos { (*coder).file_cur_pos = (*coder) .file_cur_pos - .wrapping_add((*in_pos).wrapping_sub(in_start) as uint64_t); + .wrapping_add((*in_pos).wrapping_sub(in_start) as u64); } return ret; } unsafe extern "C" fn file_info_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -433,18 +364,16 @@ unsafe extern "C" fn file_info_decode( let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; let in_start: size_t = *in_pos; if (*coder).file_size.wrapping_sub((*coder).file_cur_pos) - < in_size.wrapping_sub(in_start) as uint64_t + < in_size.wrapping_sub(in_start) as u64 { - in_size = in_start - .wrapping_add( - (*coder).file_size.wrapping_sub((*coder).file_cur_pos) as size_t, - ); + in_size = + in_start.wrapping_add((*coder).file_size.wrapping_sub((*coder).file_cur_pos) as size_t); } loop { let mut current_block_142: u64; - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { - if (*coder).file_size < LZMA_STREAM_HEADER_SIZE as uint64_t { + if (*coder).file_size < LZMA_STREAM_HEADER_SIZE as u64 { return LZMA_FORMAT_ERROR; } if fill_temp(coder, in_0, in_pos, in_size) { @@ -452,16 +381,12 @@ unsafe extern "C" fn file_info_decode( } let ret_: lzma_ret = lzma_stream_header_decode( &raw mut (*coder).first_header_flags, - &raw mut (*coder).temp as *mut uint8_t, + &raw mut (*coder).temp as *mut u8, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - if (*coder).file_size > LZMA_VLI_MAX as uint64_t - || (*coder).file_size & 3 as uint64_t != 0 - { + if (*coder).file_size > LZMA_VLI_MAX as u64 || (*coder).file_size & 3 as u64 != 0 { return LZMA_DATA_ERROR; } (*coder).file_target_pos = (*coder).file_size; @@ -493,11 +418,8 @@ unsafe extern "C" fn file_info_decode( match current_block_142 { 10445208204442080639 => { (*coder).sequence = SEQ_PADDING_DECODE; - let ret__0: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size) - as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__0: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { return ret__0; } current_block_142 = 13242334135786603907; @@ -509,16 +431,14 @@ unsafe extern "C" fn file_info_decode( if fill_temp(coder, in_0, in_pos, in_size) { return LZMA_OK; } - let new_padding: size_t = get_padding_size( - &raw mut (*coder).temp as *mut uint8_t, - (*coder).temp_size, - ) as size_t; + let new_padding: size_t = + get_padding_size(&raw mut (*coder).temp as *mut u8, (*coder).temp_size) + as size_t; (*coder).stream_padding = (*coder) .stream_padding .wrapping_add(new_padding as lzma_vli); - (*coder).file_target_pos = (*coder) - .file_target_pos - .wrapping_sub(new_padding as uint64_t); + (*coder).file_target_pos = + (*coder).file_target_pos.wrapping_sub(new_padding as u64); if new_padding == (*coder).temp_size { (*coder).sequence = SEQ_PADDING_SEEK; current_block_142 = 13014351284863956202; @@ -530,15 +450,9 @@ unsafe extern "C" fn file_info_decode( (*coder).temp_size = (*coder).temp_size.wrapping_sub(new_padding); (*coder).temp_pos = (*coder).temp_size; if (*coder).temp_size < LZMA_STREAM_HEADER_SIZE as size_t { - let ret__1: lzma_ret = reverse_seek( - coder, - in_start, - in_pos, - in_size, - ) as lzma_ret; - if ret__1 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__1: lzma_ret = + reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; + if ret__1 as c_uint != LZMA_OK as c_uint { return ret__1; } } @@ -554,20 +468,15 @@ unsafe extern "C" fn file_info_decode( } (*coder).file_target_pos = (*coder) .file_target_pos - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as uint64_t); + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64); (*coder).temp_size = (*coder) .temp_size .wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); - let ret__2: lzma_ret = hide_format_error( - lzma_stream_footer_decode( - &raw mut (*coder).footer_flags, - (&raw mut (*coder).temp as *mut uint8_t) - .offset((*coder).temp_size as isize), - ), - ) as lzma_ret; - if ret__2 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__2: lzma_ret = hide_format_error(lzma_stream_footer_decode( + &raw mut (*coder).footer_flags, + (&raw mut (*coder).temp as *mut u8).offset((*coder).temp_size as isize), + )) as lzma_ret; + if ret__2 as c_uint != LZMA_OK as c_uint { return ret__2; } if (*coder).file_target_pos @@ -580,22 +489,16 @@ unsafe extern "C" fn file_info_decode( } (*coder).file_target_pos = (*coder) .file_target_pos - .wrapping_sub((*coder).footer_flags.backward_size as uint64_t); + .wrapping_sub((*coder).footer_flags.backward_size as u64); (*coder).sequence = SEQ_INDEX_INIT; - if (*coder).temp_size as lzma_vli >= (*coder).footer_flags.backward_size - { + if (*coder).temp_size as lzma_vli >= (*coder).footer_flags.backward_size { (*coder).temp_pos = ((*coder).temp_size as lzma_vli) - .wrapping_sub((*coder).footer_flags.backward_size) as size_t; + .wrapping_sub((*coder).footer_flags.backward_size) + as size_t; } else { (*coder).temp_pos = 0 as size_t; (*coder).temp_size = 0 as size_t; - if seek_to_pos( - coder, - (*coder).file_target_pos, - in_start, - in_pos, - in_size, - ) { + if seek_to_pos(coder, (*coder).file_target_pos, in_start, in_pos, in_size) { return LZMA_SEEK_NEEDED; } } @@ -605,7 +508,7 @@ unsafe extern "C" fn file_info_decode( } match current_block_142 { 9376024032952078885 => { - let mut memused: uint64_t = 0 as uint64_t; + let mut memused: u64 = 0 as u64; if !(*coder).combined_index.is_null() { memused = lzma_index_memused((*coder).combined_index); if memused > (*coder).memlimit { @@ -618,9 +521,7 @@ unsafe extern "C" fn file_info_decode( &raw mut (*coder).this_index, (*coder).memlimit.wrapping_sub(memused), ) as lzma_ret; - if ret__3 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__3 as c_uint != LZMA_OK as c_uint { return ret__3; } (*coder).index_remaining = (*coder).footer_flags.backward_size; @@ -636,29 +537,19 @@ unsafe extern "C" fn file_info_decode( ret = decode_index( coder, allocator, - &raw mut (*coder).temp as *mut uint8_t, + &raw mut (*coder).temp as *mut u8, &raw mut (*coder).temp_pos, (*coder).temp_size, false_0 != 0, ); } else { let mut in_stop: size_t = in_size; - if in_size.wrapping_sub(*in_pos) as lzma_vli - > (*coder).index_remaining - { - in_stop = (*in_pos) - .wrapping_add((*coder).index_remaining as size_t); + if in_size.wrapping_sub(*in_pos) as lzma_vli > (*coder).index_remaining { + in_stop = (*in_pos).wrapping_add((*coder).index_remaining as size_t); } - ret = decode_index( - coder, - allocator, - in_0, - in_pos, - in_stop, - true_0 != 0, - ); + ret = decode_index(coder, allocator, in_0, in_pos, in_stop, true_0 != 0); } - match ret as ::core::ffi::c_uint { + match ret as c_uint { 0 => { if (*coder).index_remaining == 0 as lzma_vli { return LZMA_DATA_ERROR; @@ -672,16 +563,13 @@ unsafe extern "C" fn file_info_decode( } _ => return ret, } - let seek_amount: uint64_t = (lzma_index_total_size((*coder).this_index) - as uint64_t) - .wrapping_add(LZMA_STREAM_HEADER_SIZE as uint64_t); + let seek_amount: u64 = (lzma_index_total_size((*coder).this_index) as u64) + .wrapping_add(LZMA_STREAM_HEADER_SIZE as u64); if (*coder).file_target_pos < seek_amount { return LZMA_DATA_ERROR; } - (*coder).file_target_pos = (*coder) - .file_target_pos - .wrapping_sub(seek_amount); - if (*coder).file_target_pos == 0 as uint64_t { + (*coder).file_target_pos = (*coder).file_target_pos.wrapping_sub(seek_amount); + if (*coder).file_target_pos == 0 as u64 { (*coder).header_flags = (*coder).first_header_flags; (*coder).sequence = SEQ_HEADER_COMPARE; current_block_142 = 13014351284863956202; @@ -689,7 +577,7 @@ unsafe extern "C" fn file_info_decode( (*coder).sequence = SEQ_HEADER_DECODE; (*coder).file_target_pos = (*coder) .file_target_pos - .wrapping_add(LZMA_STREAM_HEADER_SIZE as uint64_t); + .wrapping_add(LZMA_STREAM_HEADER_SIZE as u64); if (*coder).temp_size != 0 as size_t && ((*coder).temp_size as lzma_vli) .wrapping_sub((*coder).footer_flags.backward_size) @@ -698,18 +586,13 @@ unsafe extern "C" fn file_info_decode( (*coder).temp_pos = ((*coder).temp_size as lzma_vli) .wrapping_sub((*coder).footer_flags.backward_size) .wrapping_sub(seek_amount as lzma_vli) - .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) as size_t; + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) + as size_t; (*coder).temp_size = (*coder).temp_pos; } else { - let ret__4: lzma_ret = reverse_seek( - coder, - in_start, - in_pos, - in_size, - ) as lzma_ret; - if ret__4 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__4: lzma_ret = + reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; + if ret__4 as c_uint != LZMA_OK as c_uint { return ret__4; } } @@ -725,21 +608,16 @@ unsafe extern "C" fn file_info_decode( } (*coder).file_target_pos = (*coder) .file_target_pos - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as uint64_t); + .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64); (*coder).temp_size = (*coder) .temp_size .wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); (*coder).temp_pos = (*coder).temp_size; - let ret__5: lzma_ret = hide_format_error( - lzma_stream_header_decode( - &raw mut (*coder).header_flags, - (&raw mut (*coder).temp as *mut uint8_t) - .offset((*coder).temp_size as isize), - ), - ) as lzma_ret; - if ret__5 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__5: lzma_ret = hide_format_error(lzma_stream_header_decode( + &raw mut (*coder).header_flags, + (&raw mut (*coder).temp as *mut u8).offset((*coder).temp_size as isize), + )) as lzma_ret; + if ret__5 as c_uint != LZMA_OK as c_uint { return ret__5; } (*coder).sequence = SEQ_HEADER_COMPARE; @@ -753,120 +631,102 @@ unsafe extern "C" fn file_info_decode( &raw mut (*coder).header_flags, &raw mut (*coder).footer_flags, ) as lzma_ret; - if ret__6 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__6 as c_uint != LZMA_OK as c_uint { return ret__6; } - if lzma_index_stream_flags( - (*coder).this_index, - &raw mut (*coder).footer_flags, - ) as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + if lzma_index_stream_flags((*coder).this_index, &raw mut (*coder).footer_flags) + as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } - if lzma_index_stream_padding( - (*coder).this_index, - (*coder).stream_padding, - ) as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + if lzma_index_stream_padding((*coder).this_index, (*coder).stream_padding) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } (*coder).stream_padding = 0 as lzma_vli; if !(*coder).combined_index.is_null() { - let ret__7: lzma_ret = lzma_index_cat( - (*coder).this_index, - (*coder).combined_index, - allocator, - ) as lzma_ret; - if ret__7 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__7: lzma_ret = + lzma_index_cat((*coder).this_index, (*coder).combined_index, allocator) + as lzma_ret; + if ret__7 as c_uint != LZMA_OK as c_uint { return ret__7; } } (*coder).combined_index = (*coder).this_index; (*coder).this_index = ::core::ptr::null_mut::(); - if (*coder).file_target_pos == 0 as uint64_t { + if (*coder).file_target_pos == 0 as u64 { *(*coder).dest_index = (*coder).combined_index; (*coder).combined_index = ::core::ptr::null_mut::(); *in_pos = in_size; return LZMA_STREAM_END; } (*coder).sequence = (if (*coder).temp_size > 0 as size_t { - SEQ_PADDING_DECODE as ::core::ffi::c_int + SEQ_PADDING_DECODE as c_int } else { - SEQ_PADDING_SEEK as ::core::ffi::c_int + SEQ_PADDING_SEEK as c_int }) as C2RustUnnamed_0; } _ => {} } - }; + } } unsafe extern "C" fn file_info_decoder_memconfig( - mut coder_ptr: *mut ::core::ffi::c_void, - mut memusage: *mut uint64_t, - mut old_memlimit: *mut uint64_t, - mut new_memlimit: uint64_t, + mut coder_ptr: *mut c_void, + mut memusage: *mut u64, + mut old_memlimit: *mut u64, + mut new_memlimit: u64, ) -> lzma_ret { let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; - let mut combined_index_memusage: uint64_t = 0 as uint64_t; - let mut this_index_memusage: uint64_t = 0 as uint64_t; + let mut combined_index_memusage: u64 = 0 as u64; + let mut this_index_memusage: u64 = 0 as u64; if !(*coder).combined_index.is_null() { combined_index_memusage = lzma_index_memused((*coder).combined_index); } if !(*coder).this_index.is_null() { this_index_memusage = lzma_index_memused((*coder).this_index); - } else if (*coder).sequence as ::core::ffi::c_uint - == SEQ_INDEX_DECODE as ::core::ffi::c_int as ::core::ffi::c_uint - { - let mut dummy: uint64_t = 0; + } else if (*coder).sequence as c_uint == SEQ_INDEX_DECODE as c_uint { + let mut dummy: u64 = 0; if (*coder) .index_decoder .memconfig - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).index_decoder.coder, &raw mut this_index_memusage, &raw mut dummy, - 0 as uint64_t, - ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + 0 as u64, + ) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } } *memusage = combined_index_memusage.wrapping_add(this_index_memusage); - if *memusage == 0 as uint64_t { + if *memusage == 0 as u64 { *memusage = lzma_index_memusage(1 as lzma_vli, 0 as lzma_vli); } *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as uint64_t { + if new_memlimit != 0 as u64 { if new_memlimit < *memusage { return LZMA_MEMLIMIT_ERROR; } if (*coder).this_index.is_null() - && (*coder).sequence as ::core::ffi::c_uint - == SEQ_INDEX_DECODE as ::core::ffi::c_int as ::core::ffi::c_uint + && (*coder).sequence as c_uint == SEQ_INDEX_DECODE as c_uint { - let idec_new_memlimit: uint64_t = new_memlimit - .wrapping_sub(combined_index_memusage); - let mut dummy1: uint64_t = 0; - let mut dummy2: uint64_t = 0; + let idec_new_memlimit: u64 = new_memlimit.wrapping_sub(combined_index_memusage); + let mut dummy1: u64 = 0; + let mut dummy2: u64 = 0; if (*coder) .index_decoder .memconfig - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).index_decoder.coder, &raw mut dummy1, &raw mut dummy2, idec_new_memlimit, - ) as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + ) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } @@ -876,48 +736,46 @@ unsafe extern "C" fn file_info_decoder_memconfig( return LZMA_OK; } unsafe extern "C" fn file_info_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; lzma_next_end(&raw mut (*coder).index_decoder, allocator); lzma_index_end((*coder).this_index, allocator); lzma_index_end((*coder).combined_index, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma_file_info_decoder_init( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, - mut seek_pos: *mut uint64_t, + mut seek_pos: *mut u64, mut dest_index: *mut *mut lzma_index, - mut memlimit: uint64_t, - mut file_size: uint64_t, + mut memlimit: u64, + mut file_size: u64, ) -> lzma_ret { if ::core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - *mut uint64_t, + *mut u64, *mut *mut lzma_index, - uint64_t, - uint64_t, + u64, + u64, ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_file_info_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *mut uint64_t, - *mut *mut lzma_index, - uint64_t, - uint64_t, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + lzma_file_info_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut u64, + *mut *mut lzma_index, + u64, + u64, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -926,31 +784,28 @@ unsafe extern "C" fn lzma_file_info_decoder_init( unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - *mut uint64_t, + *mut u64, *mut *mut lzma_index, - uint64_t, - uint64_t, + u64, + u64, ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_file_info_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *mut uint64_t, - *mut *mut lzma_index, - uint64_t, - uint64_t, - ) -> lzma_ret, - ), - ); + >(Some( + lzma_file_info_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut u64, + *mut *mut lzma_index, + u64, + u64, + ) -> lzma_ret, + )); if dest_index.is_null() { return LZMA_PROG_ERROR; } - let mut coder: *mut lzma_file_info_coder = (*next).coder - as *mut lzma_file_info_coder; + let mut coder: *mut lzma_file_info_coder = (*next).coder as *mut lzma_file_info_coder; if coder.is_null() { coder = lzma_alloc( ::core::mem::size_of::() as size_t, @@ -959,49 +814,33 @@ unsafe extern "C" fn lzma_file_info_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( file_info_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - file_info_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + file_info_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*next).memconfig = Some( file_info_decoder_memconfig - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >; + as Option lzma_ret>; (*coder).index_decoder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -1014,8 +853,8 @@ unsafe extern "C" fn lzma_file_info_decoder_init( (*coder).combined_index = ::core::ptr::null_mut::(); } (*coder).sequence = SEQ_MAGIC_BYTES; - (*coder).file_cur_pos = 0 as uint64_t; - (*coder).file_target_pos = 0 as uint64_t; + (*coder).file_cur_pos = 0 as u64; + (*coder).file_target_pos = 0 as u64; (*coder).file_size = file_size; lzma_index_end((*coder).this_index, allocator); (*coder).this_index = ::core::ptr::null_mut::(); @@ -1024,7 +863,11 @@ unsafe extern "C" fn lzma_file_info_decoder_init( (*coder).stream_padding = 0 as lzma_vli; (*coder).dest_index = dest_index; (*coder).external_seek_pos = seek_pos; - (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).memlimit = if 1 as u64 > memlimit { + 1 as u64 + } else { + memlimit + }; (*coder).temp_pos = 0 as size_t; (*coder).temp_size = LZMA_STREAM_HEADER_SIZE as size_t; return LZMA_OK; @@ -1033,13 +876,11 @@ unsafe extern "C" fn lzma_file_info_decoder_init( pub unsafe extern "C" fn lzma_file_info_decoder( mut strm: *mut lzma_stream, mut dest_index: *mut *mut lzma_index, - mut memlimit: uint64_t, - mut file_size: uint64_t, + mut memlimit: u64, + mut file_size: u64, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = lzma_file_info_decoder_init( @@ -1050,15 +891,11 @@ pub unsafe extern "C" fn lzma_file_info_decoder( memlimit, file_size, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index f35340b2..693607d6 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -1,3 +1,5 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_raw_decoder_init( @@ -6,12 +8,6 @@ extern "C" { options: *const lzma_filter, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -33,7 +29,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -42,116 +37,84 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_decode( mut filters: *const lzma_filter, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { - if in_0.is_null() || in_pos.is_null() || *in_pos > in_size || out.is_null() - || out_pos.is_null() || *out_pos > out_size + if in_0.is_null() + || in_pos.is_null() + || *in_pos > in_size + || out.is_null() + || out_pos.is_null() + || *out_pos > out_size { return LZMA_PROG_ERROR; } let mut next: lzma_next_coder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -160,20 +123,13 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( update: None, set_out_limit: None, }; - let ret_: lzma_ret = lzma_raw_decoder_init(&raw mut next, allocator, filters) - as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = lzma_raw_decoder_init(&raw mut next, allocator, filters) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - let mut ret: lzma_ret = next - .code - .expect( - "non-null function pointer", - )( + let mut ret: lzma_ret = next.code.expect("non-null function pointer")( next.coder, allocator, in_0, @@ -184,32 +140,24 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( out_size, LZMA_FINISH, ); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { ret = LZMA_OK; } else { - if ret as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_OK as c_uint { if *in_pos != in_size { ret = LZMA_BUF_ERROR; } else if *out_pos != out_size { ret = LZMA_DATA_ERROR; } else { - let mut tmp: [uint8_t; 1] = [0; 1]; + let mut tmp: [u8; 1] = [0; 1]; let mut tmp_pos: size_t = 0 as size_t; - next - .code - .expect( - "non-null function pointer", - )( + next.code.expect("non-null function pointer")( next.coder, allocator, in_0, in_pos, in_size, - &raw mut tmp as *mut uint8_t, + &raw mut tmp as *mut u8, &raw mut tmp_pos, 1 as size_t, LZMA_FINISH, diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index 10bb4837..2314297d 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -1,3 +1,5 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_raw_encoder_init( @@ -6,12 +8,6 @@ extern "C" { filters: *const lzma_filter, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -33,7 +29,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -42,107 +37,73 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_encode( mut filters: *const lzma_filter, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { - if in_0.is_null() && in_size != 0 as size_t || out.is_null() || out_pos.is_null() + if in_0.is_null() && in_size != 0 as size_t + || out.is_null() + || out_pos.is_null() || *out_pos > out_size { return LZMA_PROG_ERROR; @@ -150,7 +111,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( let mut next: lzma_next_coder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -159,20 +120,13 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( update: None, set_out_limit: None, }; - let ret_: lzma_ret = lzma_raw_encoder_init(&raw mut next, allocator, filters) - as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = lzma_raw_encoder_init(&raw mut next, allocator, filters) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let out_start: size_t = *out_pos; let mut in_pos: size_t = 0 as size_t; - let mut ret: lzma_ret = next - .code - .expect( - "non-null function pointer", - )( + let mut ret: lzma_ret = next.code.expect("non-null function pointer")( next.coder, allocator, in_0, @@ -184,14 +138,10 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( LZMA_FINISH, ); lzma_next_end(&raw mut next, allocator); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { ret = LZMA_OK; } else { - if ret as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_OK as c_uint { ret = LZMA_BUF_ERROR; } *out_pos = out_start; diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 3ae950ff..b1083d94 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -1,14 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -16,15 +11,7 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,84 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -151,56 +104,53 @@ pub struct C2RustUnnamed { #[repr(C)] pub struct lzma_options_delta { pub type_0: lzma_delta_type, - pub dist: uint32_t, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, - pub reserved_int3: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub dist: u32, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } -pub type lzma_delta_type = ::core::ffi::c_uint; pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_bcj { - pub start_offset: uint32_t, + pub start_offset: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] @@ -208,7 +158,7 @@ pub const LZMA_MODE_FAST: lzma_mode = 1; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -223,39 +173,29 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_filter_coder { pub id: lzma_vli, pub init: lzma_init_function, - pub memusage: Option uint64_t>, + pub memusage: Option u64>, } -pub type lzma_filter_find = Option< - unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder, ->; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_FILTER_X86: ::core::ffi::c_ulonglong = 0x4 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_POWERPC: ::core::ffi::c_ulonglong = 0x5 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_IA64: ::core::ffi::c_ulonglong = 0x6 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARM: ::core::ffi::c_ulonglong = 0x7 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARMTHUMB: ::core::ffi::c_ulonglong = 0x8 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_SPARC: ::core::ffi::c_ulonglong = 0x9 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARM64: ::core::ffi::c_ulonglong = 0xa as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_RISCV: ::core::ffi::c_ulonglong = 0xb as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_DELTA: ::core::ffi::c_ulonglong = 0x3 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; -pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) - << 15 as ::core::ffi::c_int; +pub type lzma_filter_find = Option *const lzma_filter_coder>; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; +pub const LZMA_FILTER_X86: c_ulonglong = 0x4 as c_ulonglong; +pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5 as c_ulonglong; +pub const LZMA_FILTER_IA64: c_ulonglong = 0x6 as c_ulonglong; +pub const LZMA_FILTER_ARM: c_ulonglong = 0x7 as c_ulonglong; +pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8 as c_ulonglong; +pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9 as c_ulonglong; +pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa as c_ulonglong; +pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb as c_ulonglong; +pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3 as c_ulonglong; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; static mut features: [C2RustUnnamed; 13] = [ C2RustUnnamed { id: LZMA_FILTER_LZMA1 as lzma_vli, @@ -361,7 +301,7 @@ pub unsafe extern "C" fn lzma_filters_copy( } let mut dest: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5]; let mut ret: lzma_ret = LZMA_OK; let mut i: size_t = 0; @@ -391,10 +331,7 @@ pub unsafe extern "C" fn lzma_filters_copy( j = j.wrapping_add(1); } } - dest[i as usize].options = lzma_alloc( - features[j as usize].options_size, - allocator, - ); + dest[i as usize].options = lzma_alloc(features[j as usize].options_size, allocator); if dest[i as usize].options.is_null() { ret = LZMA_MEM_ERROR; current_block = 6392083060350426025; @@ -422,10 +359,9 @@ pub unsafe extern "C" fn lzma_filters_copy( dest[i as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; dest[i as usize].options = NULL; memcpy( - real_dest as *mut ::core::ffi::c_void, - &raw mut dest as *mut lzma_filter as *const ::core::ffi::c_void, - i - .wrapping_add(1 as size_t) + real_dest as *mut c_void, + &raw mut dest as *mut lzma_filter as *const c_void, + i.wrapping_add(1 as size_t) .wrapping_mul(::core::mem::size_of::() as size_t), ); return LZMA_OK; @@ -457,10 +393,7 @@ pub unsafe extern "C" fn lzma_validate_chain( mut filters: *const lzma_filter, mut count: *mut size_t, ) -> lzma_ret { - if filters.is_null() - || (*filters.offset(0 as ::core::ffi::c_int as isize)).id - == LZMA_VLI_UNKNOWN as lzma_vli - { + if filters.is_null() || (*filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_PROG_ERROR; } let mut changes_size_count: size_t = 0 as size_t; @@ -481,8 +414,8 @@ pub unsafe extern "C" fn lzma_validate_chain( } non_last_ok = features[j as usize].non_last_ok; last_ok = features[j as usize].last_ok; - changes_size_count = changes_size_count - .wrapping_add(features[j as usize].changes_size as size_t); + changes_size_count = + changes_size_count.wrapping_add(features[j as usize].changes_size as size_t); i = i.wrapping_add(1); if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { break; @@ -504,23 +437,21 @@ pub unsafe extern "C" fn lzma_raw_coder_init( ) -> lzma_ret { let mut count: size_t = 0; let ret_: lzma_ret = lzma_validate_chain(options, &raw mut count) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let mut filters: [lzma_filter_info; 5] = [lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5]; if is_encoder { let mut i: size_t = 0 as size_t; while i < count { let j: size_t = count.wrapping_sub(i).wrapping_sub(1 as size_t); - let fc: *const lzma_filter_coder = coder_find - .expect("non-null function pointer")((*options.offset(i as isize)).id) - as *const lzma_filter_coder; + let fc: *const lzma_filter_coder = + coder_find.expect("non-null function pointer")((*options.offset(i as isize)).id) + as *const lzma_filter_coder; if fc.is_null() || (*fc).init.is_none() { return LZMA_OPTIONS_ERROR; } @@ -532,9 +463,9 @@ pub unsafe extern "C" fn lzma_raw_coder_init( } else { let mut i_0: size_t = 0 as size_t; while i_0 < count { - let fc_0: *const lzma_filter_coder = coder_find - .expect("non-null function pointer")((*options.offset(i_0 as isize)).id) - as *const lzma_filter_coder; + let fc_0: *const lzma_filter_coder = + coder_find.expect("non-null function pointer")((*options.offset(i_0 as isize)).id) + as *const lzma_filter_coder; if fc_0.is_null() || (*fc_0).init.is_none() { return LZMA_OPTIONS_ERROR; } @@ -546,13 +477,10 @@ pub unsafe extern "C" fn lzma_raw_coder_init( } filters[count as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; filters[count as usize].init = None; - let ret: lzma_ret = lzma_next_filter_init( - next, - allocator, - &raw mut filters as *mut lzma_filter_info, - ) as lzma_ret; - if ret as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret: lzma_ret = + lzma_next_filter_init(next, allocator, &raw mut filters as *mut lzma_filter_info) + as lzma_ret; + if ret as c_uint != LZMA_OK as c_uint { lzma_next_end(next, allocator); } return ret; @@ -561,32 +489,28 @@ pub unsafe extern "C" fn lzma_raw_coder_init( pub unsafe extern "C" fn lzma_raw_coder_memusage( mut coder_find: lzma_filter_find, mut filters: *const lzma_filter, -) -> uint64_t { +) -> u64 { let mut tmp: size_t = 0; - if lzma_validate_chain(filters, &raw mut tmp) as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { - return UINT64_MAX as uint64_t; + if lzma_validate_chain(filters, &raw mut tmp) as c_uint != LZMA_OK as c_uint { + return UINT64_MAX as u64; } - let mut total: uint64_t = 0 as uint64_t; + let mut total: u64 = 0 as u64; let mut i: size_t = 0 as size_t; loop { - let fc: *const lzma_filter_coder = coder_find - .expect("non-null function pointer")((*filters.offset(i as isize)).id) - as *const lzma_filter_coder; + let fc: *const lzma_filter_coder = + coder_find.expect("non-null function pointer")((*filters.offset(i as isize)).id) + as *const lzma_filter_coder; if fc.is_null() { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } if (*fc).memusage.is_none() { - total = total.wrapping_add(1024 as uint64_t); + total = total.wrapping_add(1024 as u64); } else { - let usage: uint64_t = (*fc) - .memusage - .expect( - "non-null function pointer", - )((*filters.offset(i as isize)).options) as uint64_t; - if usage == UINT64_MAX as uint64_t { - return UINT64_MAX as uint64_t; + let usage: u64 = (*fc).memusage.expect("non-null function pointer")( + (*filters.offset(i as isize)).options, + ) as u64; + if usage == UINT64_MAX as u64 { + return UINT64_MAX as u64; } total = total.wrapping_add(usage); } @@ -595,5 +519,5 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( break; } } - return total.wrapping_add(LZMA_MEMUSAGE_BASE as uint64_t); + return total.wrapping_add(LZMA_MEMUSAGE_BASE as u64); } diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 3baedef9..0f9879bc 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -1,3 +1,5 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -8,20 +10,17 @@ extern "C" { coder_find_0: lzma_filter_find, is_encoder: bool, ) -> lzma_ret; - fn lzma_raw_coder_memusage( - coder_find_0: lzma_filter_find, - filters: *const lzma_filter, - ) -> uint64_t; + fn lzma_raw_coder_memusage(coder_find_0: lzma_filter_find, filters: *const lzma_filter) -> u64; fn lzma_lzma_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma_decoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64; fn lzma_lzma_props_decode( - options: *mut *mut ::core::ffi::c_void, + options: *mut *mut c_void, allocator: *const lzma_allocator, - props: *const uint8_t, + props: *const u8, props_size: size_t, ) -> lzma_ret; fn lzma_lzma2_decoder_init( @@ -29,11 +28,11 @@ extern "C" { allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma2_decoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_lzma2_decoder_memusage(options: *const c_void) -> u64; fn lzma_lzma2_props_decode( - options: *mut *mut ::core::ffi::c_void, + options: *mut *mut c_void, allocator: *const lzma_allocator, - props: *const uint8_t, + props: *const u8, props_size: size_t, ) -> lzma_ret; fn lzma_simple_x86_decoder_init( @@ -77,33 +76,25 @@ extern "C" { filters: *const lzma_filter_info, ) -> lzma_ret; fn lzma_simple_props_decode( - options: *mut *mut ::core::ffi::c_void, + options: *mut *mut c_void, allocator: *const lzma_allocator, - props: *const uint8_t, + props: *const u8, props_size: size_t, ) -> lzma_ret; - fn lzma_delta_coder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_delta_coder_memusage(options: *const c_void) -> u64; fn lzma_delta_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; fn lzma_delta_props_decode( - options: *mut *mut ::core::ffi::c_void, + options: *mut *mut c_void, allocator: *const lzma_allocator, - props: *const uint8_t, + props: *const u8, props_size: size_t, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -125,7 +116,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -134,17 +124,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -155,7 +137,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -167,68 +149,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -238,20 +195,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -262,12 +219,12 @@ pub struct lzma_stream { pub struct lzma_filter_decoder { pub id: lzma_vli, pub init: lzma_init_function, - pub memusage: Option uint64_t>, + pub memusage: Option u64>, pub props_decode: Option< unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, >, @@ -285,40 +242,32 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_coder { pub id: lzma_vli, pub init: lzma_init_function, - pub memusage: Option uint64_t>, + pub memusage: Option u64>, } -pub type lzma_filter_find = Option< - unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder, ->; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_FILTER_X86: ::core::ffi::c_ulonglong = 0x4 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_POWERPC: ::core::ffi::c_ulonglong = 0x5 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_IA64: ::core::ffi::c_ulonglong = 0x6 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARM: ::core::ffi::c_ulonglong = 0x7 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARMTHUMB: ::core::ffi::c_ulonglong = 0x8 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_SPARC: ::core::ffi::c_ulonglong = 0x9 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARM64: ::core::ffi::c_ulonglong = 0xa as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_RISCV: ::core::ffi::c_ulonglong = 0xb as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_DELTA: ::core::ffi::c_ulonglong = 0x3 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +pub type lzma_filter_find = Option *const lzma_filter_coder>; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_FILTER_X86: c_ulonglong = 0x4 as c_ulonglong; +pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5 as c_ulonglong; +pub const LZMA_FILTER_IA64: c_ulonglong = 0x6 as c_ulonglong; +pub const LZMA_FILTER_ARM: c_ulonglong = 0x7 as c_ulonglong; +pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8 as c_ulonglong; +pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9 as c_ulonglong; +pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa as c_ulonglong; +pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb as c_ulonglong; +pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3 as c_ulonglong; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; static mut decoders: [lzma_filter_decoder; 12] = [ lzma_filter_decoder { id: LZMA_FILTER_LZMA1 as lzma_vli, @@ -330,16 +279,13 @@ static mut decoders: [lzma_filter_decoder; 12] = [ *const lzma_filter_info, ) -> lzma_ret, ), - memusage: Some( - lzma_lzma_decoder_memusage - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), + memusage: Some(lzma_lzma_decoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), props_decode: Some( lzma_lzma_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -354,16 +300,13 @@ static mut decoders: [lzma_filter_decoder; 12] = [ *const lzma_filter_info, ) -> lzma_ret, ), - memusage: Some( - lzma_lzma_decoder_memusage - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), + memusage: Some(lzma_lzma_decoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), props_decode: Some( lzma_lzma_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -378,16 +321,13 @@ static mut decoders: [lzma_filter_decoder; 12] = [ *const lzma_filter_info, ) -> lzma_ret, ), - memusage: Some( - lzma_lzma2_decoder_memusage - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), + memusage: Some(lzma_lzma2_decoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), props_decode: Some( lzma_lzma2_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -406,9 +346,9 @@ static mut decoders: [lzma_filter_decoder; 12] = [ props_decode: Some( lzma_simple_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -427,9 +367,9 @@ static mut decoders: [lzma_filter_decoder; 12] = [ props_decode: Some( lzma_simple_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -448,9 +388,9 @@ static mut decoders: [lzma_filter_decoder; 12] = [ props_decode: Some( lzma_simple_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -469,9 +409,9 @@ static mut decoders: [lzma_filter_decoder; 12] = [ props_decode: Some( lzma_simple_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -490,9 +430,9 @@ static mut decoders: [lzma_filter_decoder; 12] = [ props_decode: Some( lzma_simple_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -511,9 +451,9 @@ static mut decoders: [lzma_filter_decoder; 12] = [ props_decode: Some( lzma_simple_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -532,9 +472,9 @@ static mut decoders: [lzma_filter_decoder; 12] = [ props_decode: Some( lzma_simple_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -553,9 +493,9 @@ static mut decoders: [lzma_filter_decoder; 12] = [ props_decode: Some( lzma_simple_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -570,16 +510,13 @@ static mut decoders: [lzma_filter_decoder; 12] = [ *const lzma_filter_info, ) -> lzma_ret, ), - memusage: Some( - lzma_delta_coder_memusage - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), + memusage: Some(lzma_delta_coder_memusage as unsafe extern "C" fn(*const c_void) -> u64), props_decode: Some( lzma_delta_props_decode as unsafe extern "C" fn( - *mut *mut ::core::ffi::c_void, + *mut *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, size_t, ) -> lzma_ret, ), @@ -592,8 +529,7 @@ unsafe extern "C" fn decoder_find(mut id: lzma_vli) -> *const lzma_filter_decode .wrapping_div(::core::mem::size_of::() as usize) { if decoders[i as usize].id == id { - return (&raw const decoders as *const lzma_filter_decoder) - .offset(i as isize); + return (&raw const decoders as *const lzma_filter_decoder).offset(i as isize); } i = i.wrapping_add(1); } @@ -603,11 +539,8 @@ unsafe extern "C" fn coder_find(mut id: lzma_vli) -> *const lzma_filter_coder { return decoder_find(id) as *const lzma_filter_coder; } #[no_mangle] -pub unsafe extern "C" fn lzma_filter_decoder_is_supported( - mut id: lzma_vli, -) -> lzma_bool { - return (decoder_find(id) != NULL as *const lzma_filter_decoder) as ::core::ffi::c_int - as lzma_bool; +pub unsafe extern "C" fn lzma_filter_decoder_is_supported(mut id: lzma_vli) -> lzma_bool { + return (decoder_find(id) != NULL as *const lzma_filter_decoder) as c_int as lzma_bool; } #[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder_init( @@ -629,9 +562,7 @@ pub unsafe extern "C" fn lzma_raw_decoder( mut options: *const lzma_filter, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = lzma_raw_decoder_init( @@ -639,22 +570,16 @@ pub unsafe extern "C" fn lzma_raw_decoder( (*strm).allocator, options, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_raw_decoder_memusage( - mut filters: *const lzma_filter, -) -> uint64_t { +pub unsafe extern "C" fn lzma_raw_decoder_memusage(mut filters: *const lzma_filter) -> u64 { return lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, @@ -664,25 +589,25 @@ pub unsafe extern "C" fn lzma_raw_decoder_memusage( pub unsafe extern "C" fn lzma_properties_decode( mut filter: *mut lzma_filter, mut allocator: *const lzma_allocator, - mut props: *const uint8_t, + mut props: *const u8, mut props_size: size_t, ) -> lzma_ret { (*filter).options = NULL; - let fd: *const lzma_filter_decoder = decoder_find((*filter).id) - as *const lzma_filter_decoder; + let fd: *const lzma_filter_decoder = decoder_find((*filter).id) as *const lzma_filter_decoder; if fd.is_null() { return LZMA_OPTIONS_ERROR; } if (*fd).props_decode.is_none() { return (if props_size == 0 as size_t { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int } else { - LZMA_OPTIONS_ERROR as ::core::ffi::c_int + LZMA_OPTIONS_ERROR as c_int }) as lzma_ret; } - return (*fd) - .props_decode - .expect( - "non-null function pointer", - )(&raw mut (*filter).options, allocator, props, props_size); + return (*fd).props_decode.expect("non-null function pointer")( + &raw mut (*filter).options, + allocator, + props, + props_size, + ); } diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index bee86fa8..ce378c3e 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -1,3 +1,5 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -8,31 +10,22 @@ extern "C" { coder_find_0: lzma_filter_find, is_encoder: bool, ) -> lzma_ret; - fn lzma_raw_coder_memusage( - coder_find_0: lzma_filter_find, - filters: *const lzma_filter, - ) -> uint64_t; + fn lzma_raw_coder_memusage(coder_find_0: lzma_filter_find, filters: *const lzma_filter) -> u64; fn lzma_lzma_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma_encoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; - fn lzma_lzma_props_encode( - options: *const ::core::ffi::c_void, - out: *mut uint8_t, - ) -> lzma_ret; + fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64; + fn lzma_lzma_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; fn lzma_lzma2_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma2_encoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; - fn lzma_lzma2_props_encode( - options: *const ::core::ffi::c_void, - out: *mut uint8_t, - ) -> lzma_ret; - fn lzma_lzma2_block_size(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64; + fn lzma_lzma2_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; + fn lzma_lzma2_block_size(options: *const c_void) -> u64; fn lzma_simple_x86_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -73,35 +66,17 @@ extern "C" { allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_simple_props_size( - size: *mut uint32_t, - options: *const ::core::ffi::c_void, - ) -> lzma_ret; - fn lzma_simple_props_encode( - options: *const ::core::ffi::c_void, - out: *mut uint8_t, - ) -> lzma_ret; - fn lzma_delta_coder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_simple_props_size(size: *mut u32, options: *const c_void) -> lzma_ret; + fn lzma_simple_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; + fn lzma_delta_coder_memusage(options: *const c_void) -> u64; fn lzma_delta_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_delta_props_encode( - options: *const ::core::ffi::c_void, - out: *mut uint8_t, - ) -> lzma_ret; + fn lzma_delta_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -123,7 +98,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -132,17 +106,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -153,7 +119,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -165,68 +131,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -236,20 +177,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -260,15 +201,11 @@ pub struct lzma_stream { pub struct lzma_filter_encoder { pub id: lzma_vli, pub init: lzma_init_function, - pub memusage: Option uint64_t>, - pub block_size: Option uint64_t>, - pub props_size_get: Option< - unsafe extern "C" fn(*mut uint32_t, *const ::core::ffi::c_void) -> lzma_ret, - >, - pub props_size_fixed: uint32_t, - pub props_encode: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void, *mut uint8_t) -> lzma_ret, - >, + pub memusage: Option u64>, + pub block_size: Option u64>, + pub props_size_get: Option lzma_ret>, + pub props_size_fixed: u32, + pub props_encode: Option lzma_ret>, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -283,44 +220,34 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_coder { pub id: lzma_vli, pub init: lzma_init_function, - pub memusage: Option uint64_t>, + pub memusage: Option u64>, } -pub type lzma_filter_find = Option< - unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder, ->; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_X86: ::core::ffi::c_ulonglong = 0x4 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_POWERPC: ::core::ffi::c_ulonglong = 0x5 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_IA64: ::core::ffi::c_ulonglong = 0x6 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARM: ::core::ffi::c_ulonglong = 0x7 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARMTHUMB: ::core::ffi::c_ulonglong = 0x8 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_SPARC: ::core::ffi::c_ulonglong = 0x9 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARM64: ::core::ffi::c_ulonglong = 0xa as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_RISCV: ::core::ffi::c_ulonglong = 0xb as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_DELTA: ::core::ffi::c_ulonglong = 0x3 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; +pub type lzma_filter_find = Option *const lzma_filter_coder>; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_X86: c_ulonglong = 0x4 as c_ulonglong; +pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5 as c_ulonglong; +pub const LZMA_FILTER_IA64: c_ulonglong = 0x6 as c_ulonglong; +pub const LZMA_FILTER_ARM: c_ulonglong = 0x7 as c_ulonglong; +pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8 as c_ulonglong; +pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9 as c_ulonglong; +pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa as c_ulonglong; +pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb as c_ulonglong; +pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3 as c_ulonglong; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; static mut encoders: [lzma_filter_encoder; 12] = [ lzma_filter_encoder { id: LZMA_FILTER_LZMA1 as lzma_vli, @@ -332,19 +259,12 @@ static mut encoders: [lzma_filter_encoder; 12] = [ *const lzma_filter_info, ) -> lzma_ret, ), - memusage: Some( - lzma_lzma_encoder_memusage - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), + memusage: Some(lzma_lzma_encoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), block_size: None, props_size_get: None, - props_size_fixed: 5 as uint32_t, + props_size_fixed: 5 as u32, props_encode: Some( - lzma_lzma_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_lzma_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -357,19 +277,12 @@ static mut encoders: [lzma_filter_encoder; 12] = [ *const lzma_filter_info, ) -> lzma_ret, ), - memusage: Some( - lzma_lzma_encoder_memusage - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), + memusage: Some(lzma_lzma_encoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), block_size: None, props_size_get: None, - props_size_fixed: 5 as uint32_t, + props_size_fixed: 5 as u32, props_encode: Some( - lzma_lzma_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_lzma_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -382,22 +295,12 @@ static mut encoders: [lzma_filter_encoder; 12] = [ *const lzma_filter_info, ) -> lzma_ret, ), - memusage: Some( - lzma_lzma2_encoder_memusage - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), - block_size: Some( - lzma_lzma2_block_size - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), + memusage: Some(lzma_lzma2_encoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), + block_size: Some(lzma_lzma2_block_size as unsafe extern "C" fn(*const c_void) -> u64), props_size_get: None, - props_size_fixed: 1 as uint32_t, + props_size_fixed: 1 as u32, props_encode: Some( - lzma_lzma2_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_lzma2_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -413,19 +316,11 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: None, block_size: None, props_size_get: Some( - lzma_simple_props_size - as unsafe extern "C" fn( - *mut uint32_t, - *const ::core::ffi::c_void, - ) -> lzma_ret, + lzma_simple_props_size as unsafe extern "C" fn(*mut u32, *const c_void) -> lzma_ret, ), props_size_fixed: 0, props_encode: Some( - lzma_simple_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_simple_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -441,19 +336,11 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: None, block_size: None, props_size_get: Some( - lzma_simple_props_size - as unsafe extern "C" fn( - *mut uint32_t, - *const ::core::ffi::c_void, - ) -> lzma_ret, + lzma_simple_props_size as unsafe extern "C" fn(*mut u32, *const c_void) -> lzma_ret, ), props_size_fixed: 0, props_encode: Some( - lzma_simple_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_simple_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -469,19 +356,11 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: None, block_size: None, props_size_get: Some( - lzma_simple_props_size - as unsafe extern "C" fn( - *mut uint32_t, - *const ::core::ffi::c_void, - ) -> lzma_ret, + lzma_simple_props_size as unsafe extern "C" fn(*mut u32, *const c_void) -> lzma_ret, ), props_size_fixed: 0, props_encode: Some( - lzma_simple_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_simple_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -497,19 +376,11 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: None, block_size: None, props_size_get: Some( - lzma_simple_props_size - as unsafe extern "C" fn( - *mut uint32_t, - *const ::core::ffi::c_void, - ) -> lzma_ret, + lzma_simple_props_size as unsafe extern "C" fn(*mut u32, *const c_void) -> lzma_ret, ), props_size_fixed: 0, props_encode: Some( - lzma_simple_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_simple_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -525,19 +396,11 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: None, block_size: None, props_size_get: Some( - lzma_simple_props_size - as unsafe extern "C" fn( - *mut uint32_t, - *const ::core::ffi::c_void, - ) -> lzma_ret, + lzma_simple_props_size as unsafe extern "C" fn(*mut u32, *const c_void) -> lzma_ret, ), props_size_fixed: 0, props_encode: Some( - lzma_simple_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_simple_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -553,19 +416,11 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: None, block_size: None, props_size_get: Some( - lzma_simple_props_size - as unsafe extern "C" fn( - *mut uint32_t, - *const ::core::ffi::c_void, - ) -> lzma_ret, + lzma_simple_props_size as unsafe extern "C" fn(*mut u32, *const c_void) -> lzma_ret, ), props_size_fixed: 0, props_encode: Some( - lzma_simple_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_simple_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -581,19 +436,11 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: None, block_size: None, props_size_get: Some( - lzma_simple_props_size - as unsafe extern "C" fn( - *mut uint32_t, - *const ::core::ffi::c_void, - ) -> lzma_ret, + lzma_simple_props_size as unsafe extern "C" fn(*mut u32, *const c_void) -> lzma_ret, ), props_size_fixed: 0, props_encode: Some( - lzma_simple_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_simple_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -609,19 +456,11 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: None, block_size: None, props_size_get: Some( - lzma_simple_props_size - as unsafe extern "C" fn( - *mut uint32_t, - *const ::core::ffi::c_void, - ) -> lzma_ret, + lzma_simple_props_size as unsafe extern "C" fn(*mut u32, *const c_void) -> lzma_ret, ), props_size_fixed: 0, props_encode: Some( - lzma_simple_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_simple_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, lzma_filter_encoder { @@ -634,19 +473,12 @@ static mut encoders: [lzma_filter_encoder; 12] = [ *const lzma_filter_info, ) -> lzma_ret, ), - memusage: Some( - lzma_delta_coder_memusage - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> uint64_t, - ), + memusage: Some(lzma_delta_coder_memusage as unsafe extern "C" fn(*const c_void) -> u64), block_size: None, props_size_get: None, - props_size_fixed: 1 as uint32_t, + props_size_fixed: 1 as u32, props_encode: Some( - lzma_delta_props_encode - as unsafe extern "C" fn( - *const ::core::ffi::c_void, - *mut uint8_t, - ) -> lzma_ret, + lzma_delta_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, ]; @@ -657,8 +489,7 @@ unsafe extern "C" fn encoder_find(mut id: lzma_vli) -> *const lzma_filter_encode .wrapping_div(::core::mem::size_of::() as usize) { if encoders[i as usize].id == id { - return (&raw const encoders as *const lzma_filter_encoder) - .offset(i as isize); + return (&raw const encoders as *const lzma_filter_encoder).offset(i as isize); } i = i.wrapping_add(1); } @@ -668,11 +499,8 @@ unsafe extern "C" fn coder_find(mut id: lzma_vli) -> *const lzma_filter_coder { return encoder_find(id) as *const lzma_filter_coder; } #[no_mangle] -pub unsafe extern "C" fn lzma_filter_encoder_is_supported( - mut id: lzma_vli, -) -> lzma_bool { - return (encoder_find(id) != NULL as *const lzma_filter_encoder) as ::core::ffi::c_int - as lzma_bool; +pub unsafe extern "C" fn lzma_filter_encoder_is_supported(mut id: lzma_vli) -> lzma_bool { + return (encoder_find(id) != NULL as *const lzma_filter_encoder) as c_int as lzma_bool; } #[no_mangle] pub unsafe extern "C" fn lzma_filters_update( @@ -682,7 +510,7 @@ pub unsafe extern "C" fn lzma_filters_update( if (*(*strm).internal).next.update.is_none() { return LZMA_PROG_ERROR; } - if lzma_raw_encoder_memusage(filters) == UINT64_MAX as uint64_t { + if lzma_raw_encoder_memusage(filters) == UINT64_MAX as u64 { return LZMA_OPTIONS_ERROR; } let mut count: size_t = 1 as size_t; @@ -691,21 +519,19 @@ pub unsafe extern "C" fn lzma_filters_update( } let mut reversed_filters: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5]; let mut i: size_t = 0 as size_t; while i < count { - reversed_filters[count.wrapping_sub(i).wrapping_sub(1 as size_t) as usize] = *filters - .offset(i as isize); + reversed_filters[count.wrapping_sub(i).wrapping_sub(1 as size_t) as usize] = + *filters.offset(i as isize); i = i.wrapping_add(1); } reversed_filters[count as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; return (*(*strm).internal) .next .update - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*(*strm).internal).next.coder, (*strm).allocator, filters, @@ -732,9 +558,7 @@ pub unsafe extern "C" fn lzma_raw_encoder( mut filters: *const lzma_filter, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = lzma_raw_coder_init( @@ -742,97 +566,83 @@ pub unsafe extern "C" fn lzma_raw_encoder( (*strm).allocator, filters, Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), - 1 as ::core::ffi::c_int != 0, + 1 as c_int != 0, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal) - .supported_actions[LZMA_SYNC_FLUSH as ::core::ffi::c_int as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_raw_encoder_memusage( - mut filters: *const lzma_filter, -) -> uint64_t { +pub unsafe extern "C" fn lzma_raw_encoder_memusage(mut filters: *const lzma_filter) -> u64 { return lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, ); } #[no_mangle] -pub unsafe extern "C" fn lzma_mt_block_size( - mut filters: *const lzma_filter, -) -> uint64_t { +pub unsafe extern "C" fn lzma_mt_block_size(mut filters: *const lzma_filter) -> u64 { if filters.is_null() { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } - let mut max: uint64_t = 0 as uint64_t; + let mut max: u64 = 0 as u64; let mut i: size_t = 0 as size_t; while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { - let fe: *const lzma_filter_encoder = encoder_find( - (*filters.offset(i as isize)).id, - ) as *const lzma_filter_encoder; + let fe: *const lzma_filter_encoder = + encoder_find((*filters.offset(i as isize)).id) as *const lzma_filter_encoder; if fe.is_null() { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } if (*fe).block_size.is_some() { - let size: uint64_t = (*fe) - .block_size - .expect( - "non-null function pointer", - )((*filters.offset(i as isize)).options) as uint64_t; + let size: u64 = (*fe).block_size.expect("non-null function pointer")( + (*filters.offset(i as isize)).options, + ) as u64; if size > max { max = size; } } i = i.wrapping_add(1); } - return if max == 0 as uint64_t { UINT64_MAX as uint64_t } else { max }; + return if max == 0 as u64 { + UINT64_MAX as u64 + } else { + max + }; } #[no_mangle] pub unsafe extern "C" fn lzma_properties_size( - mut size: *mut uint32_t, + mut size: *mut u32, mut filter: *const lzma_filter, ) -> lzma_ret { - let fe: *const lzma_filter_encoder = encoder_find((*filter).id) - as *const lzma_filter_encoder; + let fe: *const lzma_filter_encoder = encoder_find((*filter).id) as *const lzma_filter_encoder; if fe.is_null() { return (if (*filter).id <= LZMA_VLI_MAX as lzma_vli { - LZMA_OPTIONS_ERROR as ::core::ffi::c_int + LZMA_OPTIONS_ERROR as c_int } else { - LZMA_PROG_ERROR as ::core::ffi::c_int + LZMA_PROG_ERROR as c_int }) as lzma_ret; } if (*fe).props_size_get.is_none() { *size = (*fe).props_size_fixed; return LZMA_OK; } - return (*fe) - .props_size_get - .expect("non-null function pointer")(size, (*filter).options); + return (*fe).props_size_get.expect("non-null function pointer")(size, (*filter).options); } #[no_mangle] pub unsafe extern "C" fn lzma_properties_encode( mut filter: *const lzma_filter, - mut props: *mut uint8_t, + mut props: *mut u8, ) -> lzma_ret { - let fe: *const lzma_filter_encoder = encoder_find((*filter).id) - as *const lzma_filter_encoder; + let fe: *const lzma_filter_encoder = encoder_find((*filter).id) as *const lzma_filter_encoder; if fe.is_null() { return LZMA_PROG_ERROR; } if (*fe).props_encode.is_none() { return LZMA_OK; } - return (*fe) - .props_encode - .expect("non-null function pointer")((*filter).options, props); + return (*fe).props_encode.expect("non-null function pointer")((*filter).options, props); } diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 1f979aee..5d98c4c7 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -1,23 +1,20 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_vli_decode( vli: *mut lzma_vli, vli_pos: *mut size_t, - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, ) -> lzma_ret; fn lzma_properties_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, - props: *const uint8_t, + props: *const u8, props_size: size_t, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -42,36 +39,24 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const LZMA_FILTER_RESERVED_START: ::core::ffi::c_ulonglong = (1 - as ::core::ffi::c_ulonglong) << 62 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const LZMA_FILTER_RESERVED_START: c_ulonglong = (1 as c_ulonglong) << 62 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_decode( mut filter: *mut lzma_filter, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, ) -> lzma_ret { @@ -83,9 +68,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( in_pos, in_size, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { @@ -99,9 +82,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( in_pos, in_size, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { return ret__0; } if (in_size.wrapping_sub(*in_pos) as lzma_vli) < props_size { diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index fbcf7884..6b68bb39 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -1,24 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_vli_encode( vli: lzma_vli, vli_pos: *mut size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; - fn lzma_vli_size(vli: lzma_vli) -> uint32_t; - fn lzma_properties_size(size: *mut uint32_t, filter: *const lzma_filter) -> lzma_ret; - fn lzma_properties_encode( - filter: *const lzma_filter, - props: *mut uint8_t, - ) -> lzma_ret; + fn lzma_vli_size(vli: lzma_vli) -> u32; + fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret; + fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -44,35 +37,29 @@ pub const LZMA_OK: lzma_ret = 0; #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub const LZMA_FILTER_RESERVED_START: ::core::ffi::c_ulonglong = (1 - as ::core::ffi::c_ulonglong) << 62 as ::core::ffi::c_int; +pub const LZMA_FILTER_RESERVED_START: c_ulonglong = (1 as c_ulonglong) << 62 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_size( - mut size: *mut uint32_t, + mut size: *mut u32, mut filter: *const lzma_filter, ) -> lzma_ret { if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { return LZMA_PROG_ERROR; } let ret_: lzma_ret = lzma_properties_size(size, filter) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } *size = (*size) - .wrapping_add( - lzma_vli_size((*filter).id).wrapping_add(lzma_vli_size(*size as lzma_vli)), - ); + .wrapping_add(lzma_vli_size((*filter).id).wrapping_add(lzma_vli_size(*size as lzma_vli))); return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_encode( mut filter: *const lzma_filter, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { @@ -86,16 +73,12 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( out_pos, out_size, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - let mut props_size: uint32_t = 0; + let mut props_size: u32 = 0; let ret__0: lzma_ret = lzma_properties_size(&raw mut props_size, filter) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { return ret__0; } let ret__1: lzma_ret = lzma_vli_encode( @@ -105,19 +88,15 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( out_pos, out_size, ) as lzma_ret; - if ret__1 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__1 as c_uint != LZMA_OK as c_uint { return ret__1; } if out_size.wrapping_sub(*out_pos) < props_size as size_t { return LZMA_PROG_ERROR; } - let ret__2: lzma_ret = lzma_properties_encode(filter, out.offset(*out_pos as isize)) - as lzma_ret; - if ret__2 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__2: lzma_ret = + lzma_properties_encode(filter, out.offset(*out_pos as isize)) as lzma_ret; + if ret__2 as c_uint != LZMA_OK as c_uint { return ret__2; } *out_pos = (*out_pos).wrapping_add(props_size as size_t); diff --git a/liblzma-rs/src/common/hardware_cputhreads.rs b/liblzma-rs/src/common/hardware_cputhreads.rs index ec8be0ad..27939b19 100644 --- a/liblzma-rs/src/common/hardware_cputhreads.rs +++ b/liblzma-rs/src/common/hardware_cputhreads.rs @@ -1,8 +1,8 @@ +use crate::types::*; extern "C" { - fn tuklib_cpucores() -> uint32_t; + fn tuklib_cpucores() -> u32; } -pub type uint32_t = u32; #[no_mangle] -pub unsafe extern "C" fn lzma_cputhreads() -> uint32_t { +pub unsafe extern "C" fn lzma_cputhreads() -> u32 { return tuklib_cpucores(); } diff --git a/liblzma-rs/src/common/hardware_physmem.rs b/liblzma-rs/src/common/hardware_physmem.rs index 63664e95..9403d84f 100644 --- a/liblzma-rs/src/common/hardware_physmem.rs +++ b/liblzma-rs/src/common/hardware_physmem.rs @@ -1,8 +1,8 @@ +use crate::types::*; extern "C" { - fn tuklib_physmem() -> uint64_t; + fn tuklib_physmem() -> u64; } -pub type uint64_t = u64; #[no_mangle] -pub unsafe extern "C" fn lzma_physmem() -> uint64_t { +pub unsafe extern "C" fn lzma_physmem() -> u64 { return tuklib_physmem(); } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 518906e9..f15d3604 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -1,28 +1,16 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_vli_size(vli: lzma_vli) -> uint32_t; + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn lzma_vli_size(vli: lzma_vli) -> u32; fn lzma_stream_flags_compare( a: *const lzma_stream_flags, b: *const lzma_stream_flags, ) -> lzma_ret; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -47,20 +35,10 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -68,7 +46,7 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -83,8 +61,8 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } #[derive(Copy, Clone)] #[repr(C)] @@ -95,7 +73,7 @@ pub struct lzma_index_s { pub record_count: lzma_vli, pub index_list_size: lzma_vli, pub prealloc: size_t, - pub checks: uint32_t, + pub checks: u32, } #[derive(Copy, Clone)] #[repr(C)] @@ -103,7 +81,7 @@ pub struct index_tree { pub root: *mut index_tree_node, pub leftmost: *mut index_tree_node, pub rightmost: *mut index_tree_node, - pub count: uint32_t, + pub count: u32, } pub type index_tree_node = index_tree_node_s; #[derive(Copy, Clone)] @@ -126,7 +104,7 @@ pub struct lzma_index_iter { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed { - pub p: *const ::core::ffi::c_void, + pub p: *const c_void, pub s: size_t, pub v: lzma_vli, } @@ -146,18 +124,18 @@ pub struct C2RustUnnamed_0 { pub reserved_vli2: lzma_vli, pub reserved_vli3: lzma_vli, pub reserved_vli4: lzma_vli, - pub reserved_ptr1: *const ::core::ffi::c_void, - pub reserved_ptr2: *const ::core::ffi::c_void, - pub reserved_ptr3: *const ::core::ffi::c_void, - pub reserved_ptr4: *const ::core::ffi::c_void, + pub reserved_ptr1: *const c_void, + pub reserved_ptr2: *const c_void, + pub reserved_ptr3: *const c_void, + pub reserved_ptr4: *const c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct C2RustUnnamed_1 { pub flags: *const lzma_stream_flags, - pub reserved_ptr1: *const ::core::ffi::c_void, - pub reserved_ptr2: *const ::core::ffi::c_void, - pub reserved_ptr3: *const ::core::ffi::c_void, + pub reserved_ptr1: *const c_void, + pub reserved_ptr2: *const c_void, + pub reserved_ptr3: *const c_void, pub number: lzma_vli, pub block_count: lzma_vli, pub compressed_offset: lzma_vli, @@ -170,7 +148,7 @@ pub struct C2RustUnnamed_1 { pub reserved_vli3: lzma_vli, pub reserved_vli4: lzma_vli, } -pub type lzma_index_iter_mode = ::core::ffi::c_uint; +pub type lzma_index_iter_mode = c_uint; pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; @@ -194,7 +172,7 @@ pub struct index_group { #[repr(C)] pub struct index_stream { pub node: index_tree_node, - pub number: uint32_t, + pub number: u32, pub block_number_base: lzma_vli, pub groups: index_tree, pub record_count: lzma_vli, @@ -216,40 +194,33 @@ pub struct index_cat_info { pub uncompressed_size: lzma_vli, pub file_size: lzma_vli, pub block_number_add: lzma_vli, - pub stream_number_add: uint32_t, + pub stream_number_add: u32, pub streams: *mut index_tree, } -pub type C2RustUnnamed_2 = ::core::ffi::c_uint; -pub type C2RustUnnamed_3 = ::core::ffi::c_uint; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const UINTPTR_MAX: ::core::ffi::c_ulong = 18446744073709551615 - as ::core::ffi::c_ulong; -pub const SIZE_MAX: ::core::ffi::c_ulong = UINTPTR_MAX; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub type C2RustUnnamed_2 = c_uint; +pub type C2RustUnnamed_3 = c_uint; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; +pub const SIZE_MAX: c_ulong = UINTPTR_MAX; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn bsr32(mut n: uint32_t) -> uint32_t { - return n.leading_zeros() as i32 as uint32_t ^ 31 as uint32_t; +unsafe extern "C" fn bsr32(mut n: u32) -> u32 { + return n.leading_zeros() as i32 as u32 ^ 31 as u32; } #[inline] -unsafe extern "C" fn ctz32(mut n: uint32_t) -> uint32_t { - return n.trailing_zeros() as i32 as uint32_t; +unsafe extern "C" fn ctz32(mut n: u32) -> u32 { + return n.trailing_zeros() as i32 as u32; } -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; -pub const LZMA_BACKWARD_SIZE_MAX: ::core::ffi::c_ulonglong = (1 - as ::core::ffi::c_ulonglong) << 34 as ::core::ffi::c_int; -pub const UNPADDED_SIZE_MIN: ::core::ffi::c_ulonglong = 5 as ::core::ffi::c_ulonglong; -pub const UNPADDED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX - & !(3 as ::core::ffi::c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = (1 as c_ulonglong) << 34 as c_int; +pub const UNPADDED_SIZE_MIN: c_ulonglong = 5 as c_ulonglong; +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !(3 as c_ulonglong); #[inline] unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); @@ -259,18 +230,15 @@ unsafe extern "C" fn index_size_unpadded( mut count: lzma_vli, mut index_list_size: lzma_vli, ) -> lzma_vli { - return ((1 as uint32_t).wrapping_add(lzma_vli_size(count)) as lzma_vli) + return ((1 as u32).wrapping_add(lzma_vli_size(count)) as lzma_vli) .wrapping_add(index_list_size) .wrapping_add(4 as lzma_vli); } #[inline] -unsafe extern "C" fn index_size( - mut count: lzma_vli, - mut index_list_size: lzma_vli, -) -> lzma_vli { +unsafe extern "C" fn index_size(mut count: lzma_vli, mut index_list_size: lzma_vli) -> lzma_vli { return vli_ceil4(index_size_unpadded(count, index_list_size)); } -pub const INDEX_GROUP_SIZE: ::core::ffi::c_int = 512 as ::core::ffi::c_int; +pub const INDEX_GROUP_SIZE: c_int = 512 as c_int; pub const PREALLOC_MAX: usize = (SIZE_MAX as usize) .wrapping_sub(::core::mem::size_of::() as usize) .wrapping_div(::core::mem::size_of::() as usize); @@ -278,14 +246,12 @@ unsafe extern "C" fn index_tree_init(mut tree: *mut index_tree) { (*tree).root = ::core::ptr::null_mut::(); (*tree).leftmost = ::core::ptr::null_mut::(); (*tree).rightmost = ::core::ptr::null_mut::(); - (*tree).count = 0 as uint32_t; + (*tree).count = 0 as u32; } unsafe extern "C" fn index_tree_node_end( mut node: *mut index_tree_node, mut allocator: *const lzma_allocator, - mut free_func: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), - >, + mut free_func: Option ()>, ) { if !(*node).left.is_null() { index_tree_node_end((*node).left, allocator, free_func); @@ -293,26 +259,18 @@ unsafe extern "C" fn index_tree_node_end( if !(*node).right.is_null() { index_tree_node_end((*node).right, allocator, free_func); } - free_func - .expect( - "non-null function pointer", - )(node as *mut ::core::ffi::c_void, allocator); + free_func.expect("non-null function pointer")(node as *mut c_void, allocator); } unsafe extern "C" fn index_tree_end( mut tree: *mut index_tree, mut allocator: *const lzma_allocator, - mut free_func: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), - >, + mut free_func: Option ()>, ) { if !(*tree).root.is_null() { index_tree_node_end((*tree).root, allocator, free_func); } } -unsafe extern "C" fn index_tree_append( - mut tree: *mut index_tree, - mut node: *mut index_tree_node, -) { +unsafe extern "C" fn index_tree_append(mut tree: *mut index_tree, mut node: *mut index_tree_node) { (*node).parent = (*tree).rightmost; (*node).left = ::core::ptr::null_mut::(); (*node).right = ::core::ptr::null_mut::(); @@ -325,13 +283,13 @@ unsafe extern "C" fn index_tree_append( } (*(*tree).rightmost).right = node; (*tree).rightmost = node; - let mut up: uint32_t = (*tree).count ^ (1 as uint32_t) << bsr32((*tree).count); - if up != 0 as uint32_t { - up = ctz32((*tree).count).wrapping_add(2 as uint32_t); + let mut up: u32 = (*tree).count ^ (1 as u32) << bsr32((*tree).count); + if up != 0 as u32 { + up = ctz32((*tree).count).wrapping_add(2 as u32); loop { node = (*node).parent; up = up.wrapping_sub(1); - if !(up > 0 as uint32_t) { + if !(up > 0 as u32) { break; } } @@ -350,27 +308,23 @@ unsafe extern "C" fn index_tree_append( (*node).parent = pivot; } } -unsafe extern "C" fn index_tree_next( - mut node: *const index_tree_node, -) -> *mut ::core::ffi::c_void { +unsafe extern "C" fn index_tree_next(mut node: *const index_tree_node) -> *mut c_void { if !(*node).right.is_null() { node = (*node).right; while !(*node).left.is_null() { node = (*node).left; } - return node as *mut ::core::ffi::c_void; + return node as *mut c_void; } - while !(*node).parent.is_null() - && (*(*node).parent).right == node as *mut index_tree_node - { + while !(*node).parent.is_null() && (*(*node).parent).right == node as *mut index_tree_node { node = (*node).parent; } - return (*node).parent as *mut ::core::ffi::c_void; + return (*node).parent as *mut c_void; } unsafe extern "C" fn index_tree_locate( mut tree: *const index_tree, mut target: lzma_vli, -) -> *mut ::core::ffi::c_void { +) -> *mut c_void { let mut result: *const index_tree_node = ::core::ptr::null::(); let mut node: *const index_tree_node = (*tree).root; while !node.is_null() { @@ -381,19 +335,18 @@ unsafe extern "C" fn index_tree_locate( node = (*node).right; } } - return result as *mut ::core::ffi::c_void; + return result as *mut c_void; } unsafe extern "C" fn index_stream_init( mut compressed_base: lzma_vli, mut uncompressed_base: lzma_vli, - mut stream_number: uint32_t, + mut stream_number: u32, mut block_number_base: lzma_vli, mut allocator: *const lzma_allocator, ) -> *mut index_stream { - let mut s: *mut index_stream = lzma_alloc( - ::core::mem::size_of::() as size_t, - allocator, - ) as *mut index_stream; + let mut s: *mut index_stream = + lzma_alloc(::core::mem::size_of::() as size_t, allocator) + as *mut index_stream; if s.is_null() { return ::core::ptr::null_mut::(); } @@ -407,35 +360,22 @@ unsafe extern "C" fn index_stream_init( index_tree_init(&raw mut (*s).groups); (*s).record_count = 0 as lzma_vli; (*s).index_list_size = 0 as lzma_vli; - (*s).stream_flags.version = UINT32_MAX as uint32_t; + (*s).stream_flags.version = UINT32_MAX as u32; (*s).stream_padding = 0 as lzma_vli; return s; } -unsafe extern "C" fn index_stream_end( - mut node: *mut ::core::ffi::c_void, - mut allocator: *const lzma_allocator, -) { +unsafe extern "C" fn index_stream_end(mut node: *mut c_void, mut allocator: *const lzma_allocator) { let mut s: *mut index_stream = node as *mut index_stream; index_tree_end( &raw mut (*s).groups, allocator, - Some( - lzma_free - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), - ), + Some(lzma_free as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()), ); - lzma_free(s as *mut ::core::ffi::c_void, allocator); + lzma_free(s as *mut c_void, allocator); } -unsafe extern "C" fn index_init_plain( - mut allocator: *const lzma_allocator, -) -> *mut lzma_index { - let mut i: *mut lzma_index = lzma_alloc( - ::core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_index; +unsafe extern "C" fn index_init_plain(mut allocator: *const lzma_allocator) -> *mut lzma_index { + let mut i: *mut lzma_index = + lzma_alloc(::core::mem::size_of::() as size_t, allocator) as *mut lzma_index; if !i.is_null() { index_tree_init(&raw mut (*i).streams); (*i).uncompressed_size = 0 as lzma_vli; @@ -443,14 +383,12 @@ unsafe extern "C" fn index_init_plain( (*i).record_count = 0 as lzma_vli; (*i).index_list_size = 0 as lzma_vli; (*i).prealloc = INDEX_GROUP_SIZE as size_t; - (*i).checks = 0 as uint32_t; + (*i).checks = 0 as u32; } return i; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_init( - mut allocator: *const lzma_allocator, -) -> *mut lzma_index { +pub unsafe extern "C" fn lzma_index_init(mut allocator: *const lzma_allocator) -> *mut lzma_index { let mut i: *mut lzma_index = index_init_plain(allocator); if i.is_null() { return ::core::ptr::null_mut::(); @@ -458,12 +396,12 @@ pub unsafe extern "C" fn lzma_index_init( let mut s: *mut index_stream = index_stream_init( 0 as lzma_vli, 0 as lzma_vli, - 1 as uint32_t, + 1 as u32, 0 as lzma_vli, allocator, ); if s.is_null() { - lzma_free(i as *mut ::core::ffi::c_void, allocator); + lzma_free(i as *mut c_void, allocator); return ::core::ptr::null_mut::(); } index_tree_append(&raw mut (*i).streams, &raw mut (*s).node); @@ -479,33 +417,23 @@ pub unsafe extern "C" fn lzma_index_end( &raw mut (*i).streams, allocator, Some( - index_stream_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + index_stream_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ), ); - lzma_free(i as *mut ::core::ffi::c_void, allocator); + lzma_free(i as *mut c_void, allocator); } } #[no_mangle] -pub unsafe extern "C" fn lzma_index_prealloc( - mut i: *mut lzma_index, - mut records: lzma_vli, -) { +pub unsafe extern "C" fn lzma_index_prealloc(mut i: *mut lzma_index, mut records: lzma_vli) { if records > PREALLOC_MAX as lzma_vli { records = PREALLOC_MAX as lzma_vli; } (*i).prealloc = records as size_t; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_memusage( - mut streams: lzma_vli, - mut blocks: lzma_vli, -) -> uint64_t { - let alloc_overhead: size_t = (4 as size_t) - .wrapping_mul(::core::mem::size_of::<*mut ::core::ffi::c_void>() as size_t); +pub unsafe extern "C" fn lzma_index_memusage(mut streams: lzma_vli, mut blocks: lzma_vli) -> u64 { + let alloc_overhead: size_t = + (4 as size_t).wrapping_mul(::core::mem::size_of::<*mut c_void>() as size_t); let stream_base: size_t = (::core::mem::size_of::() as size_t) .wrapping_add(::core::mem::size_of::() as size_t) .wrapping_add((2 as size_t).wrapping_mul(alloc_overhead)); @@ -519,24 +447,26 @@ pub unsafe extern "C" fn lzma_index_memusage( .wrapping_add(INDEX_GROUP_SIZE as lzma_vli) .wrapping_sub(1 as lzma_vli) .wrapping_div(INDEX_GROUP_SIZE as lzma_vli); - let streams_mem: uint64_t = (streams as uint64_t) - .wrapping_mul(stream_base as uint64_t); - let groups_mem: uint64_t = (groups as uint64_t).wrapping_mul(group_base as uint64_t); - let index_base: uint64_t = (::core::mem::size_of::() as usize) - .wrapping_add(alloc_overhead as usize) as uint64_t; - let limit: uint64_t = (UINT64_MAX as uint64_t).wrapping_sub(index_base); - if streams == 0 as lzma_vli || streams > UINT32_MAX as lzma_vli + let streams_mem: u64 = (streams as u64).wrapping_mul(stream_base as u64); + let groups_mem: u64 = (groups as u64).wrapping_mul(group_base as u64); + let index_base: u64 = (::core::mem::size_of::() as usize) + .wrapping_add(alloc_overhead as usize) as u64; + let limit: u64 = (UINT64_MAX as u64).wrapping_sub(index_base); + if streams == 0 as lzma_vli + || streams > UINT32_MAX as lzma_vli || blocks > LZMA_VLI_MAX as lzma_vli - || streams > limit.wrapping_div(stream_base as uint64_t) - || groups > limit.wrapping_div(group_base as uint64_t) + || streams > limit.wrapping_div(stream_base as u64) + || groups > limit.wrapping_div(group_base as u64) || limit.wrapping_sub(streams_mem) < groups_mem { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } - return index_base.wrapping_add(streams_mem).wrapping_add(groups_mem); + return index_base + .wrapping_add(streams_mem) + .wrapping_add(groups_mem); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_memused(mut i: *const lzma_index) -> uint64_t { +pub unsafe extern "C" fn lzma_index_memused(mut i: *const lzma_index) -> u64 { return lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count); } #[no_mangle] @@ -570,7 +500,7 @@ unsafe extern "C" fn index_file_size( mut stream_padding: lzma_vli, ) -> lzma_vli { let mut file_size: lzma_vli = compressed_base - .wrapping_add((2 as ::core::ffi::c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) + .wrapping_add((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) .wrapping_add(stream_padding) .wrapping_add(vli_ceil4(unpadded_sum)); if file_size > LZMA_VLI_MAX as lzma_vli { @@ -591,8 +521,7 @@ pub unsafe extern "C" fn lzma_index_file_size(mut i: *const lzma_index) -> lzma_ if g.is_null() { 0 as lzma_vli } else { - (*(&raw const (*g).records as *const index_record) - .offset((*g).last as isize)) + (*(&raw const (*g).records as *const index_record).offset((*g).last as isize)) .unpadded_sum }, (*s).record_count, @@ -601,27 +530,23 @@ pub unsafe extern "C" fn lzma_index_file_size(mut i: *const lzma_index) -> lzma_ ); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_uncompressed_size( - mut i: *const lzma_index, -) -> lzma_vli { +pub unsafe extern "C" fn lzma_index_uncompressed_size(mut i: *const lzma_index) -> lzma_vli { return (*i).uncompressed_size; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_checks(mut i: *const lzma_index) -> uint32_t { - let mut checks: uint32_t = (*i).checks; +pub unsafe extern "C" fn lzma_index_checks(mut i: *const lzma_index) -> u32 { + let mut checks: u32 = (*i).checks; let mut s: *const index_stream = (*i).streams.rightmost as *const index_stream; - if (*s).stream_flags.version != UINT32_MAX as uint32_t { - checks = (checks as ::core::ffi::c_uint - | (1 as ::core::ffi::c_uint) - << (*s).stream_flags.check as ::core::ffi::c_uint) as uint32_t; + if (*s).stream_flags.version != UINT32_MAX as u32 { + checks = (checks as c_uint | (1 as c_uint) << (*s).stream_flags.check as c_uint) as u32; } return checks; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_padding_size(mut i: *const lzma_index) -> uint32_t { +pub unsafe extern "C" fn lzma_index_padding_size(mut i: *const lzma_index) -> u32 { return ((4 as lzma_vli) .wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) - & 3 as lzma_vli) as uint32_t; + & 3 as lzma_vli) as u32; } #[no_mangle] pub unsafe extern "C" fn lzma_index_stream_flags( @@ -631,11 +556,8 @@ pub unsafe extern "C" fn lzma_index_stream_flags( if i.is_null() || stream_flags.is_null() { return LZMA_PROG_ERROR; } - let ret_: lzma_ret = lzma_stream_flags_compare(stream_flags, stream_flags) - as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = lzma_stream_flags_compare(stream_flags, stream_flags) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let mut s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; @@ -647,7 +569,8 @@ pub unsafe extern "C" fn lzma_index_stream_padding( mut i: *mut lzma_index, mut stream_padding: lzma_vli, ) -> lzma_ret { - if i.is_null() || stream_padding > LZMA_VLI_MAX as lzma_vli + if i.is_null() + || stream_padding > LZMA_VLI_MAX as lzma_vli || stream_padding & 3 as lzma_vli != 0 as lzma_vli { return LZMA_PROG_ERROR; @@ -669,7 +592,8 @@ pub unsafe extern "C" fn lzma_index_append( mut unpadded_size: lzma_vli, mut uncompressed_size: lzma_vli, ) -> lzma_ret { - if i.is_null() || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli + if i.is_null() + || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli || uncompressed_size > LZMA_VLI_MAX as lzma_vli { @@ -681,18 +605,16 @@ pub unsafe extern "C" fn lzma_index_append( 0 as lzma_vli } else { vli_ceil4( - (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)) - .unpadded_sum, + (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).unpadded_sum, ) as lzma_vli }; let uncompressed_base: lzma_vli = if g.is_null() { 0 as lzma_vli } else { - (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)) - .uncompressed_sum + (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).uncompressed_sum }; - let index_list_size_add: uint32_t = (lzma_vli_size(unpadded_size) as uint32_t) - .wrapping_add(lzma_vli_size(uncompressed_size) as uint32_t); + let index_list_size_add: u32 = + (lzma_vli_size(unpadded_size) as u32).wrapping_add(lzma_vli_size(uncompressed_size) as u32); if uncompressed_base.wrapping_add(uncompressed_size) > LZMA_VLI_MAX as lzma_vli { return LZMA_DATA_ERROR; } @@ -703,7 +625,8 @@ pub unsafe extern "C" fn lzma_index_append( (*s).node.compressed_base, compressed_base.wrapping_add(unpadded_size), (*s).record_count.wrapping_add(1 as lzma_vli), - (*s).index_list_size.wrapping_add(index_list_size_add as lzma_vli), + (*s).index_list_size + .wrapping_add(index_list_size_add as lzma_vli), (*s).stream_padding, ) == LZMA_VLI_UNKNOWN as lzma_vli { @@ -711,7 +634,8 @@ pub unsafe extern "C" fn lzma_index_append( } if index_size( (*i).record_count.wrapping_add(1 as lzma_vli), - (*i).index_list_size.wrapping_add(index_list_size_add as lzma_vli), + (*i).index_list_size + .wrapping_add(index_list_size_add as lzma_vli), ) > LZMA_BACKWARD_SIZE_MAX as lzma_vli { return LZMA_DATA_ERROR; @@ -720,12 +644,10 @@ pub unsafe extern "C" fn lzma_index_append( (*g).last = (*g).last.wrapping_add(1); } else { g = lzma_alloc( - (::core::mem::size_of::() as size_t) - .wrapping_add( - (*i) - .prealloc - .wrapping_mul(::core::mem::size_of::() as size_t), - ), + (::core::mem::size_of::() as size_t).wrapping_add( + (*i).prealloc + .wrapping_mul(::core::mem::size_of::() as size_t), + ), allocator, ) as *mut index_group; if g.is_null() { @@ -739,10 +661,10 @@ pub unsafe extern "C" fn lzma_index_append( (*g).number_base = (*s).record_count.wrapping_add(1 as lzma_vli); index_tree_append(&raw mut (*s).groups, &raw mut (*g).node); } - (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)) - .uncompressed_sum = uncompressed_base.wrapping_add(uncompressed_size); - (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)) - .unpadded_sum = compressed_base.wrapping_add(unpadded_size); + (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).uncompressed_sum = + uncompressed_base.wrapping_add(uncompressed_size); + (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).unpadded_sum = + compressed_base.wrapping_add(unpadded_size); (*s).record_count = (*s).record_count.wrapping_add(1); (*s).index_list_size = (*s) .index_list_size @@ -768,10 +690,7 @@ unsafe extern "C" fn index_cat_helper( .node .uncompressed_base .wrapping_add((*info).uncompressed_size); - (*this).node.compressed_base = (*this) - .node - .compressed_base - .wrapping_add((*info).file_size); + (*this).node.compressed_base = (*this).node.compressed_base.wrapping_add((*info).file_size); (*this).number = (*this).number.wrapping_add((*info).stream_number_add); (*this).block_number_base = (*this) .block_number_base @@ -792,19 +711,17 @@ pub unsafe extern "C" fn lzma_index_cat( } let dest_file_size: lzma_vli = lzma_index_file_size(dest) as lzma_vli; if dest_file_size.wrapping_add(lzma_index_file_size(src)) > LZMA_VLI_MAX as lzma_vli - || (*dest).uncompressed_size.wrapping_add((*src).uncompressed_size) + || (*dest) + .uncompressed_size + .wrapping_add((*src).uncompressed_size) > LZMA_VLI_MAX as lzma_vli { return LZMA_DATA_ERROR; } - let dest_size: lzma_vli = index_size_unpadded( - (*dest).record_count, - (*dest).index_list_size, - ) as lzma_vli; - let src_size: lzma_vli = index_size_unpadded( - (*src).record_count, - (*src).index_list_size, - ) as lzma_vli; + let dest_size: lzma_vli = + index_size_unpadded((*dest).record_count, (*dest).index_list_size) as lzma_vli; + let src_size: lzma_vli = + index_size_unpadded((*src).record_count, (*src).index_list_size) as lzma_vli; if vli_ceil4(dest_size.wrapping_add(src_size)) > LZMA_BACKWARD_SIZE_MAX as lzma_vli { return LZMA_DATA_ERROR; } @@ -812,13 +729,11 @@ pub unsafe extern "C" fn lzma_index_cat( let mut g: *mut index_group = (*s).groups.rightmost as *mut index_group; if !g.is_null() && (*g).last.wrapping_add(1 as size_t) < (*g).allocated { let mut newg: *mut index_group = lzma_alloc( - (::core::mem::size_of::() as size_t) - .wrapping_add( - (*g) - .last - .wrapping_add(1 as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), - ), + (::core::mem::size_of::() as size_t).wrapping_add( + (*g).last + .wrapping_add(1 as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + ), allocator, ) as *mut index_group; if newg.is_null() { @@ -829,8 +744,8 @@ pub unsafe extern "C" fn lzma_index_cat( (*newg).last = (*g).last; (*newg).number_base = (*g).number_base; memcpy( - &raw mut (*newg).records as *mut index_record as *mut ::core::ffi::c_void, - &raw mut (*g).records as *mut index_record as *const ::core::ffi::c_void, + &raw mut (*newg).records as *mut index_record as *mut c_void, + &raw mut (*g).records as *mut index_record as *const c_void, (*newg) .allocated .wrapping_mul(::core::mem::size_of::() as size_t), @@ -843,7 +758,7 @@ pub unsafe extern "C" fn lzma_index_cat( (*s).groups.root = &raw mut (*newg).node; } (*s).groups.rightmost = &raw mut (*newg).node; - lzma_free(g as *mut ::core::ffi::c_void, allocator); + lzma_free(g as *mut c_void, allocator); } (*dest).checks = lzma_index_checks(dest); let info: index_cat_info = index_cat_info { @@ -859,11 +774,9 @@ pub unsafe extern "C" fn lzma_index_cat( .wrapping_add((*src).uncompressed_size); (*dest).total_size = (*dest).total_size.wrapping_add((*src).total_size); (*dest).record_count = (*dest).record_count.wrapping_add((*src).record_count); - (*dest).index_list_size = (*dest) - .index_list_size - .wrapping_add((*src).index_list_size); + (*dest).index_list_size = (*dest).index_list_size.wrapping_add((*src).index_list_size); (*dest).checks |= (*src).checks; - lzma_free(src as *mut ::core::ffi::c_void, allocator); + lzma_free(src as *mut c_void, allocator); return LZMA_OK; } unsafe extern "C" fn index_dup_stream( @@ -891,16 +804,15 @@ unsafe extern "C" fn index_dup_stream( return dest; } let mut destg: *mut index_group = lzma_alloc( - (::core::mem::size_of::() as lzma_vli) - .wrapping_add( - (*src) - .record_count - .wrapping_mul(::core::mem::size_of::() as lzma_vli), - ) as size_t, + (::core::mem::size_of::() as lzma_vli).wrapping_add( + (*src) + .record_count + .wrapping_mul(::core::mem::size_of::() as lzma_vli), + ) as size_t, allocator, ) as *mut index_group; if destg.is_null() { - index_stream_end(dest as *mut ::core::ffi::c_void, allocator); + index_stream_end(dest as *mut c_void, allocator); return ::core::ptr::null_mut::(); } (*destg).node.uncompressed_base = 0 as lzma_vli; @@ -912,10 +824,8 @@ unsafe extern "C" fn index_dup_stream( let mut i: size_t = 0 as size_t; loop { memcpy( - (&raw mut (*destg).records as *mut index_record).offset(i as isize) - as *mut ::core::ffi::c_void, - &raw const (*srcg).records as *const index_record - as *const ::core::ffi::c_void, + (&raw mut (*destg).records as *mut index_record).offset(i as isize) as *mut c_void, + &raw const (*srcg).records as *const index_record as *const c_void, (*srcg) .last .wrapping_add(1 as size_t) @@ -943,8 +853,7 @@ pub unsafe extern "C" fn lzma_index_dup( (*dest).total_size = (*src).total_size; (*dest).record_count = (*src).record_count; (*dest).index_list_size = (*src).index_list_size; - let mut srcstream: *const index_stream = (*src).streams.leftmost - as *const index_stream; + let mut srcstream: *const index_stream = (*src).streams.leftmost as *const index_stream; loop { let mut deststream: *mut index_stream = index_dup_stream(srcstream, allocator); if deststream.is_null() { @@ -960,44 +869,30 @@ pub unsafe extern "C" fn lzma_index_dup( return dest; } unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { - let mut i: *const lzma_index = (*iter) - .internal[ITER_INDEX as ::core::ffi::c_int as usize] - .p as *const lzma_index; - let mut stream: *const index_stream = (*iter) - .internal[ITER_STREAM as ::core::ffi::c_int as usize] - .p as *const index_stream; - let mut group: *const index_group = (*iter) - .internal[ITER_GROUP as ::core::ffi::c_int as usize] - .p as *const index_group; - let record: size_t = (*iter).internal[ITER_RECORD as ::core::ffi::c_int as usize].s; + let mut i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; + let mut stream: *const index_stream = + (*iter).internal[ITER_STREAM as usize].p as *const index_stream; + let mut group: *const index_group = + (*iter).internal[ITER_GROUP as usize].p as *const index_group; + let record: size_t = (*iter).internal[ITER_RECORD as usize].s; if group.is_null() { - (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_LEFTMOST - as ::core::ffi::c_int as size_t; + (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_LEFTMOST as size_t; } else if (*i).streams.rightmost != &raw const (*stream).node as *mut index_tree_node || (*stream).groups.rightmost != &raw const (*group).node as *mut index_tree_node { - (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_NORMAL - as ::core::ffi::c_int as size_t; - } else if (*stream).groups.leftmost - != &raw const (*group).node as *mut index_tree_node - { - (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_NEXT - as ::core::ffi::c_int as size_t; - (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = (*group) - .node - .parent as *const ::core::ffi::c_void; + (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NORMAL as size_t; + } else if (*stream).groups.leftmost != &raw const (*group).node as *mut index_tree_node { + (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NEXT as size_t; + (*iter).internal[ITER_GROUP as usize].p = (*group).node.parent as *const c_void; } else { - (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_LEFTMOST - as ::core::ffi::c_int as size_t; - (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = ::core::ptr::null::< - ::core::ffi::c_void, - >(); + (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_LEFTMOST as size_t; + (*iter).internal[ITER_GROUP as usize].p = ::core::ptr::null::(); } (*iter).stream.number = (*stream).number as lzma_vli; (*iter).stream.block_count = (*stream).record_count; (*iter).stream.compressed_offset = (*stream).node.compressed_base; (*iter).stream.uncompressed_offset = (*stream).node.uncompressed_base; - (*iter).stream.flags = if (*stream).stream_flags.version == UINT32_MAX as uint32_t { + (*iter).stream.flags = if (*stream).stream_flags.version == UINT32_MAX as u32 { ::core::ptr::null::() } else { &raw const (*stream).stream_flags @@ -1005,31 +900,25 @@ unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { (*iter).stream.padding = (*stream).stream_padding; if (*stream).groups.rightmost.is_null() { (*iter).stream.compressed_size = index_size(0 as lzma_vli, 0 as lzma_vli) - .wrapping_add( - (2 as ::core::ffi::c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli, - ); + .wrapping_add((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli); (*iter).stream.uncompressed_size = 0 as lzma_vli; } else { let mut g: *const index_group = (*stream).groups.rightmost as *const index_group; - (*iter).stream.compressed_size = ((2 as ::core::ffi::c_int - * LZMA_STREAM_HEADER_SIZE) as lzma_vli) - .wrapping_add(index_size((*stream).record_count, (*stream).index_list_size)) - .wrapping_add( - vli_ceil4( - (*(&raw const (*g).records as *const index_record) - .offset((*g).last as isize)) - .unpadded_sum, - ), - ); - (*iter).stream.uncompressed_size = (*(&raw const (*g).records - as *const index_record) + (*iter).stream.compressed_size = ((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) + .wrapping_add(index_size( + (*stream).record_count, + (*stream).index_list_size, + )) + .wrapping_add(vli_ceil4( + (*(&raw const (*g).records as *const index_record).offset((*g).last as isize)) + .unpadded_sum, + )); + (*iter).stream.uncompressed_size = (*(&raw const (*g).records as *const index_record) .offset((*g).last as isize)) - .uncompressed_sum; + .uncompressed_sum; } if !group.is_null() { - (*iter).block.number_in_stream = (*group) - .number_base - .wrapping_add(record as lzma_vli); + (*iter).block.number_in_stream = (*group).number_base.wrapping_add(record as lzma_vli); (*iter).block.number_in_file = (*iter) .block .number_in_stream @@ -1040,7 +929,7 @@ unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { vli_ceil4( (*(&raw const (*group).records as *const index_record) .offset(record.wrapping_sub(1 as size_t) as isize)) - .unpadded_sum, + .unpadded_sum, ) }; (*iter).block.uncompressed_stream_offset = if record == 0 as size_t { @@ -1048,18 +937,16 @@ unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { } else { (*(&raw const (*group).records as *const index_record) .offset(record.wrapping_sub(1 as size_t) as isize)) - .uncompressed_sum + .uncompressed_sum }; - (*iter).block.uncompressed_size = (*(&raw const (*group).records - as *const index_record) + (*iter).block.uncompressed_size = (*(&raw const (*group).records as *const index_record) .offset(record as isize)) - .uncompressed_sum - .wrapping_sub((*iter).block.uncompressed_stream_offset); - (*iter).block.unpadded_size = (*(&raw const (*group).records - as *const index_record) + .uncompressed_sum + .wrapping_sub((*iter).block.uncompressed_stream_offset); + (*iter).block.unpadded_size = (*(&raw const (*group).records as *const index_record) .offset(record as isize)) - .unpadded_sum - .wrapping_sub((*iter).block.compressed_stream_offset); + .unpadded_sum + .wrapping_sub((*iter).block.compressed_stream_offset); (*iter).block.total_size = vli_ceil4((*iter).block.unpadded_size); (*iter).block.compressed_stream_offset = (*iter) .block @@ -1080,54 +967,37 @@ pub unsafe extern "C" fn lzma_index_iter_init( mut iter: *mut lzma_index_iter, mut i: *const lzma_index, ) { - (*iter).internal[ITER_INDEX as ::core::ffi::c_int as usize].p = i - as *const ::core::ffi::c_void; + (*iter).internal[ITER_INDEX as usize].p = i as *const c_void; lzma_index_iter_rewind(iter); } #[no_mangle] pub unsafe extern "C" fn lzma_index_iter_rewind(mut iter: *mut lzma_index_iter) { - (*iter).internal[ITER_STREAM as ::core::ffi::c_int as usize].p = ::core::ptr::null::< - ::core::ffi::c_void, - >(); - (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = ::core::ptr::null::< - ::core::ffi::c_void, - >(); - (*iter).internal[ITER_RECORD as ::core::ffi::c_int as usize].s = 0 as size_t; - (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s = ITER_METHOD_NORMAL - as ::core::ffi::c_int as size_t; + (*iter).internal[ITER_STREAM as usize].p = ::core::ptr::null::(); + (*iter).internal[ITER_GROUP as usize].p = ::core::ptr::null::(); + (*iter).internal[ITER_RECORD as usize].s = 0 as size_t; + (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NORMAL as size_t; } #[no_mangle] pub unsafe extern "C" fn lzma_index_iter_next( mut iter: *mut lzma_index_iter, mut mode: lzma_index_iter_mode, ) -> lzma_bool { - if mode as ::core::ffi::c_uint - > LZMA_INDEX_ITER_NONEMPTY_BLOCK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if mode as c_uint > LZMA_INDEX_ITER_NONEMPTY_BLOCK as c_uint { return true_0 as lzma_bool; } - let mut i: *const lzma_index = (*iter) - .internal[ITER_INDEX as ::core::ffi::c_int as usize] - .p as *const lzma_index; - let mut stream: *const index_stream = (*iter) - .internal[ITER_STREAM as ::core::ffi::c_int as usize] - .p as *const index_stream; + let mut i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; + let mut stream: *const index_stream = + (*iter).internal[ITER_STREAM as usize].p as *const index_stream; let mut group: *const index_group = ::core::ptr::null::(); - let mut record: size_t = (*iter) - .internal[ITER_RECORD as ::core::ffi::c_int as usize] - .s; - if mode as ::core::ffi::c_uint - != LZMA_INDEX_ITER_STREAM as ::core::ffi::c_int as ::core::ffi::c_uint - { - match (*iter).internal[ITER_METHOD as ::core::ffi::c_int as usize].s { + let mut record: size_t = (*iter).internal[ITER_RECORD as usize].s; + if mode as c_uint != LZMA_INDEX_ITER_STREAM as c_uint { + match (*iter).internal[ITER_METHOD as usize].s { 0 => { - group = (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p - as *const index_group; + group = (*iter).internal[ITER_GROUP as usize].p as *const index_group; } 1 => { group = index_tree_next( - (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p - as *const index_tree_node, + (*iter).internal[ITER_GROUP as usize].p as *const index_tree_node, ) as *const index_group; } 2 => { @@ -1139,12 +1009,9 @@ pub unsafe extern "C" fn lzma_index_iter_next( loop { if stream.is_null() { stream = (*i).streams.leftmost as *const index_stream; - if mode as ::core::ffi::c_uint - >= LZMA_INDEX_ITER_BLOCK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if mode as c_uint >= LZMA_INDEX_ITER_BLOCK as c_uint { while (*stream).groups.leftmost.is_null() { - stream = index_tree_next(&raw const (*stream).node) - as *const index_stream; + stream = index_tree_next(&raw const (*stream).node) as *const index_stream; if stream.is_null() { return true_0 as lzma_bool; } @@ -1161,14 +1028,11 @@ pub unsafe extern "C" fn lzma_index_iter_next( } if group.is_null() { loop { - stream = index_tree_next(&raw const (*stream).node) - as *const index_stream; + stream = index_tree_next(&raw const (*stream).node) as *const index_stream; if stream.is_null() { return true_0 as lzma_bool; } - if !(mode as ::core::ffi::c_uint - >= LZMA_INDEX_ITER_BLOCK as ::core::ffi::c_int - as ::core::ffi::c_uint + if !(mode as c_uint >= LZMA_INDEX_ITER_BLOCK as c_uint && (*stream).groups.leftmost.is_null()) { break; @@ -1177,35 +1041,28 @@ pub unsafe extern "C" fn lzma_index_iter_next( group = (*stream).groups.leftmost as *const index_group; } } - if !(mode as ::core::ffi::c_uint - == LZMA_INDEX_ITER_NONEMPTY_BLOCK as ::core::ffi::c_int - as ::core::ffi::c_uint) - { + if !(mode as c_uint == LZMA_INDEX_ITER_NONEMPTY_BLOCK as c_uint) { break; } if record == 0 as size_t { if !((*group).node.uncompressed_base - == (*(&raw const (*group).records as *const index_record) - .offset(0 as ::core::ffi::c_int as isize)) + == (*(&raw const (*group).records as *const index_record).offset(0 as isize)) .uncompressed_sum) { break; } } else if !((*(&raw const (*group).records as *const index_record) .offset(record.wrapping_sub(1 as size_t) as isize)) - .uncompressed_sum - == (*(&raw const (*group).records as *const index_record) - .offset(record as isize)) + .uncompressed_sum + == (*(&raw const (*group).records as *const index_record).offset(record as isize)) .uncompressed_sum) { break; } } - (*iter).internal[ITER_STREAM as ::core::ffi::c_int as usize].p = stream - as *const ::core::ffi::c_void; - (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = group - as *const ::core::ffi::c_void; - (*iter).internal[ITER_RECORD as ::core::ffi::c_int as usize].s = record; + (*iter).internal[ITER_STREAM as usize].p = stream as *const c_void; + (*iter).internal[ITER_GROUP as usize].p = group as *const c_void; + (*iter).internal[ITER_RECORD as usize].s = record; iter_set_info(iter); return false_0 as lzma_bool; } @@ -1214,39 +1071,31 @@ pub unsafe extern "C" fn lzma_index_iter_locate( mut iter: *mut lzma_index_iter, mut target: lzma_vli, ) -> lzma_bool { - let mut i: *const lzma_index = (*iter) - .internal[ITER_INDEX as ::core::ffi::c_int as usize] - .p as *const lzma_index; + let mut i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; if (*i).uncompressed_size <= target { return true_0 as lzma_bool; } - let mut stream: *const index_stream = index_tree_locate( - &raw const (*i).streams, - target, - ) as *const index_stream; + let mut stream: *const index_stream = + index_tree_locate(&raw const (*i).streams, target) as *const index_stream; target = target.wrapping_sub((*stream).node.uncompressed_base); - let mut group: *const index_group = index_tree_locate( - &raw const (*stream).groups, - target, - ) as *const index_group; + let mut group: *const index_group = + index_tree_locate(&raw const (*stream).groups, target) as *const index_group; let mut left: size_t = 0 as size_t; let mut right: size_t = (*group).last; while left < right { - let pos: size_t = left - .wrapping_add(right.wrapping_sub(left).wrapping_div(2 as size_t)); + let pos: size_t = left.wrapping_add(right.wrapping_sub(left).wrapping_div(2 as size_t)); if (*(&raw const (*group).records as *const index_record).offset(pos as isize)) - .uncompressed_sum <= target + .uncompressed_sum + <= target { left = pos.wrapping_add(1 as size_t); } else { right = pos; } } - (*iter).internal[ITER_STREAM as ::core::ffi::c_int as usize].p = stream - as *const ::core::ffi::c_void; - (*iter).internal[ITER_GROUP as ::core::ffi::c_int as usize].p = group - as *const ::core::ffi::c_void; - (*iter).internal[ITER_RECORD as ::core::ffi::c_int as usize].s = left; + (*iter).internal[ITER_STREAM as usize].p = stream as *const c_void; + (*iter).internal[ITER_GROUP as usize].p = group as *const c_void; + (*iter).internal[ITER_RECORD as usize].s = left; iter_set_info(iter); return false_0 as lzma_bool; } diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index acae1705..9f0d3d20 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -1,16 +1,20 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; #[repr(C)] -pub struct lzma_index_s { _opaque: [u8; 0] } +pub struct lzma_index_s { + _opaque: [u8; 0], +} extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_vli_decode( vli: *mut lzma_vli, vli_pos: *mut size_t, - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, ) -> lzma_ret; - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; - fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> uint64_t; + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; + fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64; fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); fn lzma_index_append( @@ -19,25 +23,14 @@ extern "C" { unpadded_size: lzma_vli, uncompressed_size: lzma_vli, ) -> lzma_ret; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_index_padding_size(i: *const lzma_index) -> uint32_t; + fn lzma_index_padding_size(i: *const lzma_index) -> u32; fn lzma_index_prealloc(i: *mut lzma_index, records: lzma_vli); } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -59,7 +52,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -68,17 +60,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -89,7 +73,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -101,68 +85,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -172,20 +131,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -196,16 +155,16 @@ pub type lzma_index = lzma_index_s; #[repr(C)] pub struct lzma_index_coder { pub sequence: C2RustUnnamed_0, - pub memlimit: uint64_t, + pub memlimit: u64, pub index: *mut lzma_index, pub index_ptr: *mut *mut lzma_index, pub count: lzma_vli, pub unpadded_size: lzma_vli, pub uncompressed_size: lzma_vli, pub pos: size_t, - pub crc32: uint32_t, + pub crc32: u32, } -pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub type C2RustUnnamed_0 = c_uint; pub const SEQ_CRC32: C2RustUnnamed_0 = 7; pub const SEQ_PADDING: C2RustUnnamed_0 = 6; pub const SEQ_PADDING_INIT: C2RustUnnamed_0 = 5; @@ -214,26 +173,21 @@ pub const SEQ_UNPADDED: C2RustUnnamed_0 = 3; pub const SEQ_MEMUSAGE: C2RustUnnamed_0 = 2; pub const SEQ_COUNT: C2RustUnnamed_0 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const UNPADDED_SIZE_MIN: ::core::ffi::c_ulonglong = 5 as ::core::ffi::c_ulonglong; -pub const UNPADDED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX - & !(3 as ::core::ffi::c_ulonglong); -pub const INDEX_INDICATOR: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const UNPADDED_SIZE_MIN: c_ulonglong = 5 as c_ulonglong; +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !(3 as c_ulonglong); +pub const INDEX_INDICATOR: c_int = 0 as c_int; unsafe extern "C" fn index_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -243,12 +197,11 @@ unsafe extern "C" fn index_decode( let in_start: size_t = *in_pos; let mut ret: lzma_ret = LZMA_OK; while *in_pos < in_size { - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) as ::core::ffi::c_int != INDEX_INDICATOR - { + if *in_0.offset(fresh0 as isize) as c_int != INDEX_INDICATOR { return LZMA_DATA_ERROR; } (*coder).sequence = SEQ_COUNT; @@ -262,9 +215,7 @@ unsafe extern "C" fn index_decode( in_pos, in_size, ); - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_STREAM_END as c_uint { break; } (*coder).pos = 0 as size_t; @@ -275,30 +226,19 @@ unsafe extern "C" fn index_decode( current_block = 7642845755631126846; } 3 | 4 => { - let mut size: *mut lzma_vli = if (*coder).sequence as ::core::ffi::c_uint - == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint - { - &raw mut (*coder).unpadded_size - } else { - &raw mut (*coder).uncompressed_size - }; - ret = lzma_vli_decode( - size, - &raw mut (*coder).pos, - in_0, - in_pos, - in_size, - ); - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + let mut size: *mut lzma_vli = + if (*coder).sequence as c_uint == SEQ_UNPADDED as c_uint { + &raw mut (*coder).unpadded_size + } else { + &raw mut (*coder).uncompressed_size + }; + ret = lzma_vli_decode(size, &raw mut (*coder).pos, in_0, in_pos, in_size); + if ret as c_uint != LZMA_STREAM_END as c_uint { break; } ret = LZMA_OK; (*coder).pos = 0 as size_t; - if (*coder).sequence as ::core::ffi::c_uint - == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*coder).sequence as c_uint == SEQ_UNPADDED as c_uint { if (*coder).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || (*coder).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli { @@ -312,16 +252,14 @@ unsafe extern "C" fn index_decode( (*coder).unpadded_size, (*coder).uncompressed_size, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } (*coder).count = (*coder).count.wrapping_sub(1); (*coder).sequence = (if (*coder).count == 0 as lzma_vli { - SEQ_PADDING_INIT as ::core::ffi::c_int + SEQ_PADDING_INIT as c_int } else { - SEQ_UNPADDED as ::core::ffi::c_int + SEQ_UNPADDED as c_int }) as C2RustUnnamed_0; } continue; @@ -345,9 +283,7 @@ unsafe extern "C" fn index_decode( (*coder).pos = (*coder).pos.wrapping_sub(1); let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh1 as isize) as ::core::ffi::c_int - != 0 as ::core::ffi::c_int - { + if *in_0.offset(fresh1 as isize) as c_int != 0 as c_int { return LZMA_DATA_ERROR; } continue; @@ -361,17 +297,16 @@ unsafe extern "C" fn index_decode( } } 7642845755631126846 => { - if lzma_index_memusage(1 as lzma_vli, (*coder).count) > (*coder).memlimit - { + if lzma_index_memusage(1 as lzma_vli, (*coder).count) > (*coder).memlimit { ret = LZMA_MEMLIMIT_ERROR; break; } else { lzma_index_prealloc((*coder).index, (*coder).count); ret = LZMA_OK; (*coder).sequence = (if (*coder).count == 0 as lzma_vli { - SEQ_PADDING_INIT as ::core::ffi::c_int + SEQ_PADDING_INIT as c_int } else { - SEQ_UNPADDED as ::core::ffi::c_int + SEQ_UNPADDED as c_int }) as C2RustUnnamed_0; continue; } @@ -384,8 +319,8 @@ unsafe extern "C" fn index_decode( } let fresh2 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if (*coder).crc32 >> (*coder).pos.wrapping_mul(8 as size_t) - & 0xff as uint32_t != *in_0.offset(fresh2 as isize) as uint32_t + if (*coder).crc32 >> (*coder).pos.wrapping_mul(8 as size_t) & 0xff as u32 + != *in_0.offset(fresh2 as isize) as u32 { return LZMA_DATA_ERROR; } @@ -400,32 +335,28 @@ unsafe extern "C" fn index_decode( } let in_used: size_t = (*in_pos).wrapping_sub(in_start); if in_used > 0 as size_t { - (*coder).crc32 = lzma_crc32( - in_0.offset(in_start as isize), - in_used, - (*coder).crc32, - ); + (*coder).crc32 = lzma_crc32(in_0.offset(in_start as isize), in_used, (*coder).crc32); } return ret; } unsafe extern "C" fn index_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; lzma_index_end((*coder).index, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn index_decoder_memconfig( - mut coder_ptr: *mut ::core::ffi::c_void, - mut memusage: *mut uint64_t, - mut old_memlimit: *mut uint64_t, - mut new_memlimit: uint64_t, + mut coder_ptr: *mut c_void, + mut memusage: *mut u64, + mut old_memlimit: *mut u64, + mut new_memlimit: u64, ) -> lzma_ret { let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; *memusage = lzma_index_memusage(1 as lzma_vli, (*coder).count); *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as uint64_t { + if new_memlimit != 0 as u64 { if new_memlimit < *memusage { return LZMA_MEMLIMIT_ERROR; } @@ -437,7 +368,7 @@ unsafe extern "C" fn index_decoder_reset( mut coder: *mut lzma_index_coder, mut allocator: *const lzma_allocator, mut i: *mut *mut lzma_index, - mut memlimit: uint64_t, + mut memlimit: u64, ) -> lzma_ret { (*coder).index_ptr = i; *i = ::core::ptr::null_mut::(); @@ -446,10 +377,14 @@ unsafe extern "C" fn index_decoder_reset( return LZMA_MEM_ERROR; } (*coder).sequence = SEQ_INDICATOR; - (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; + (*coder).memlimit = if 1 as u64 > memlimit { + 1 as u64 + } else { + memlimit + }; (*coder).count = 0 as lzma_vli; (*coder).pos = 0 as size_t; - (*coder).crc32 = 0 as uint32_t; + (*coder).crc32 = 0 as u32; return LZMA_OK; } #[no_mangle] @@ -457,7 +392,7 @@ pub unsafe extern "C" fn lzma_index_decoder_init( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, mut i: *mut *mut lzma_index, - mut memlimit: uint64_t, + mut memlimit: u64, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -465,21 +400,19 @@ pub unsafe extern "C" fn lzma_index_decoder_init( *mut lzma_next_coder, *const lzma_allocator, *mut *mut lzma_index, - uint64_t, + u64, ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_index_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *mut *mut lzma_index, - uint64_t, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + lzma_index_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut *mut lzma_index, + u64, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -489,21 +422,19 @@ pub unsafe extern "C" fn lzma_index_decoder_init( *mut lzma_next_coder, *const lzma_allocator, *mut *mut lzma_index, - uint64_t, + u64, ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_index_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *mut *mut lzma_index, - uint64_t, - ) -> lzma_ret, - ), - ); + >(Some( + lzma_index_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *mut *mut lzma_index, + u64, + ) -> lzma_ret, + )); if i.is_null() { return LZMA_PROG_ERROR; } @@ -516,45 +447,29 @@ pub unsafe extern "C" fn lzma_index_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( index_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - index_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + index_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*next).memconfig = Some( index_decoder_memconfig - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >; + as Option lzma_ret>; (*coder).index = ::core::ptr::null_mut::(); } else { lzma_index_end((*coder).index, allocator); @@ -565,15 +480,13 @@ pub unsafe extern "C" fn lzma_index_decoder_init( pub unsafe extern "C" fn lzma_index_decoder( mut strm: *mut lzma_stream, mut i: *mut *mut lzma_index, - mut memlimit: uint64_t, + mut memlimit: u64, ) -> lzma_ret { if !i.is_null() { *i = ::core::ptr::null_mut::(); } let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = lzma_index_decoder_init( @@ -582,32 +495,27 @@ pub unsafe extern "C" fn lzma_index_decoder( i, memlimit, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_index_buffer_decode( mut i: *mut *mut lzma_index, - mut memlimit: *mut uint64_t, + mut memlimit: *mut u64, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, ) -> lzma_ret { if !i.is_null() { *i = ::core::ptr::null_mut::(); } - if i.is_null() || memlimit.is_null() || in_0.is_null() || in_pos.is_null() - || *in_pos > in_size + if i.is_null() || memlimit.is_null() || in_0.is_null() || in_pos.is_null() || *in_pos > in_size { return LZMA_PROG_ERROR; } @@ -622,39 +530,30 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( pos: 0, crc32: 0, }; - let ret_: lzma_ret = index_decoder_reset(&raw mut coder, allocator, i, *memlimit) - as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = index_decoder_reset(&raw mut coder, allocator, i, *memlimit) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let in_start: size_t = *in_pos; let mut ret: lzma_ret = index_decode( - &raw mut coder as *mut ::core::ffi::c_void, + &raw mut coder as *mut c_void, allocator, in_0, in_pos, in_size, - ::core::ptr::null_mut::(), + ::core::ptr::null_mut::(), ::core::ptr::null_mut::(), 0 as size_t, LZMA_RUN, ); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { ret = LZMA_OK; } else { lzma_index_end(coder.index, allocator); *in_pos = in_start; - if ret as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_OK as c_uint { ret = LZMA_DATA_ERROR; - } else if ret as ::core::ffi::c_uint - == LZMA_MEMLIMIT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint - { + } else if ret as c_uint == LZMA_MEMLIMIT_ERROR as c_uint { *memlimit = lzma_index_memusage(1 as lzma_vli, coder.count); } } diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index d8774069..125863e1 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -1,41 +1,30 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_void}; #[repr(C)] -pub struct lzma_index_s { _opaque: [u8; 0] } +pub struct lzma_index_s { + _opaque: [u8; 0], +} extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_vli_encode( vli: lzma_vli, vli_pos: *mut size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli; fn lzma_index_size(i: *const lzma_index) -> lzma_vli; fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index); - fn lzma_index_iter_next( - iter: *mut lzma_index_iter, - mode: lzma_index_iter_mode, - ) -> lzma_bool; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_index_iter_next(iter: *mut lzma_index_iter, mode: lzma_index_iter_mode) -> lzma_bool; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_index_padding_size(i: *const lzma_index) -> uint32_t; + fn lzma_index_padding_size(i: *const lzma_index) -> u32; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -57,7 +46,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -66,17 +54,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -87,7 +67,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -99,68 +79,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -170,20 +125,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -192,7 +147,7 @@ pub struct lzma_stream { #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -207,8 +162,8 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] @@ -221,7 +176,7 @@ pub struct lzma_index_iter { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_0 { - pub p: *const ::core::ffi::c_void, + pub p: *const c_void, pub s: size_t, pub v: lzma_vli, } @@ -241,18 +196,18 @@ pub struct C2RustUnnamed_1 { pub reserved_vli2: lzma_vli, pub reserved_vli3: lzma_vli, pub reserved_vli4: lzma_vli, - pub reserved_ptr1: *const ::core::ffi::c_void, - pub reserved_ptr2: *const ::core::ffi::c_void, - pub reserved_ptr3: *const ::core::ffi::c_void, - pub reserved_ptr4: *const ::core::ffi::c_void, + pub reserved_ptr1: *const c_void, + pub reserved_ptr2: *const c_void, + pub reserved_ptr3: *const c_void, + pub reserved_ptr4: *const c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct C2RustUnnamed_2 { pub flags: *const lzma_stream_flags, - pub reserved_ptr1: *const ::core::ffi::c_void, - pub reserved_ptr2: *const ::core::ffi::c_void, - pub reserved_ptr3: *const ::core::ffi::c_void, + pub reserved_ptr1: *const c_void, + pub reserved_ptr2: *const c_void, + pub reserved_ptr3: *const c_void, pub number: lzma_vli, pub block_count: lzma_vli, pub compressed_offset: lzma_vli, @@ -265,7 +220,7 @@ pub struct C2RustUnnamed_2 { pub reserved_vli3: lzma_vli, pub reserved_vli4: lzma_vli, } -pub type lzma_index_iter_mode = ::core::ffi::c_uint; +pub type lzma_index_iter_mode = c_uint; pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; @@ -277,9 +232,9 @@ pub struct lzma_index_coder { pub index: *const lzma_index, pub iter: lzma_index_iter, pub pos: size_t, - pub crc32: uint32_t, + pub crc32: u32, } -pub type C2RustUnnamed_3 = ::core::ffi::c_uint; +pub type C2RustUnnamed_3 = c_uint; pub const SEQ_CRC32: C2RustUnnamed_3 = 6; pub const SEQ_PADDING: C2RustUnnamed_3 = 5; pub const SEQ_NEXT: C2RustUnnamed_3 = 4; @@ -287,19 +242,17 @@ pub const SEQ_UNCOMPRESSED: C2RustUnnamed_3 = 3; pub const SEQ_UNPADDED: C2RustUnnamed_3 = 2; pub const SEQ_COUNT: C2RustUnnamed_3 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_3 = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const INDEX_INDICATOR: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const true_0: c_int = 1 as c_int; +pub const INDEX_INDICATOR: c_int = 0 as c_int; unsafe extern "C" fn index_encode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -309,25 +262,17 @@ unsafe extern "C" fn index_encode( let out_start: size_t = *out_pos; let mut ret: lzma_ret = LZMA_OK; while *out_pos < out_size { - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { - *out.offset(*out_pos as isize) = INDEX_INDICATOR as uint8_t; + *out.offset(*out_pos as isize) = INDEX_INDICATOR as u8; *out_pos = (*out_pos).wrapping_add(1); (*coder).sequence = SEQ_COUNT; continue; } 1 => { let count: lzma_vli = lzma_index_block_count((*coder).index) as lzma_vli; - ret = lzma_vli_encode( - count, - &raw mut (*coder).pos, - out, - out_pos, - out_size, - ); - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + ret = lzma_vli_encode(count, &raw mut (*coder).pos, out, out_pos, out_size); + if ret as c_uint != LZMA_STREAM_END as c_uint { break; } ret = LZMA_OK; @@ -336,9 +281,7 @@ unsafe extern "C" fn index_encode( continue; } 4 => { - if lzma_index_iter_next(&raw mut (*coder).iter, LZMA_INDEX_ITER_BLOCK) - != 0 - { + if lzma_index_iter_next(&raw mut (*coder).iter, LZMA_INDEX_ITER_BLOCK) != 0 { (*coder).pos = lzma_index_padding_size((*coder).index) as size_t; (*coder).sequence = SEQ_PADDING; continue; @@ -355,7 +298,7 @@ unsafe extern "C" fn index_encode( (*coder).pos = (*coder).pos.wrapping_sub(1); let fresh0 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0 as uint8_t; + *out.offset(fresh0 as isize) = 0 as u8; continue; } else { (*coder).crc32 = lzma_crc32( @@ -374,23 +317,13 @@ unsafe extern "C" fn index_encode( } match current_block { 10048703153582371463 => { - let size: lzma_vli = if (*coder).sequence as ::core::ffi::c_uint - == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint - { + let size: lzma_vli = if (*coder).sequence as c_uint == SEQ_UNPADDED as c_uint { (*coder).iter.block.unpadded_size } else { (*coder).iter.block.uncompressed_size }; - ret = lzma_vli_encode( - size, - &raw mut (*coder).pos, - out, - out_pos, - out_size, - ); - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + ret = lzma_vli_encode(size, &raw mut (*coder).pos, out, out_pos, out_size); + if ret as c_uint != LZMA_STREAM_END as c_uint { break; } ret = LZMA_OK; @@ -403,8 +336,8 @@ unsafe extern "C" fn index_encode( return LZMA_OK; } *out.offset(*out_pos as isize) = ((*coder).crc32 - >> (*coder).pos.wrapping_mul(8 as size_t) & 0xff as uint32_t) - as uint8_t; + >> (*coder).pos.wrapping_mul(8 as size_t) + & 0xff as u32) as u8; *out_pos = (*out_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); if !((*coder).pos < 4 as size_t) { @@ -417,16 +350,12 @@ unsafe extern "C" fn index_encode( } let out_used: size_t = (*out_pos).wrapping_sub(out_start); if out_used > 0 as size_t { - (*coder).crc32 = lzma_crc32( - out.offset(out_start as isize), - out_used, - (*coder).crc32, - ); + (*coder).crc32 = lzma_crc32(out.offset(out_start as isize), out_used, (*coder).crc32); } return ret; } unsafe extern "C" fn index_encoder_end( - mut coder: *mut ::core::ffi::c_void, + mut coder: *mut c_void, mut allocator: *const lzma_allocator, ) { lzma_free(coder, allocator); @@ -439,7 +368,7 @@ unsafe extern "C" fn index_encoder_reset( (*coder).sequence = SEQ_INDICATOR; (*coder).index = i; (*coder).pos = 0 as size_t; - (*coder).crc32 = 0 as uint32_t; + (*coder).crc32 = 0 as u32; } #[no_mangle] pub unsafe extern "C" fn lzma_index_encoder_init( @@ -456,16 +385,14 @@ pub unsafe extern "C" fn lzma_index_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_index_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_index, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + lzma_index_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_index, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -478,16 +405,14 @@ pub unsafe extern "C" fn lzma_index_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - lzma_index_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_index, - ) -> lzma_ret, - ), - ); + >(Some( + lzma_index_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_index, + ) -> lzma_ret, + )); if i.is_null() { return LZMA_PROG_ERROR; } @@ -502,23 +427,19 @@ pub unsafe extern "C" fn lzma_index_encoder_init( (*next).code = Some( index_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - index_encoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + index_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; } index_encoder_reset((*next).coder as *mut lzma_index_coder, i); @@ -530,32 +451,24 @@ pub unsafe extern "C" fn lzma_index_encoder( mut i: *const lzma_index, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - let ret__0: lzma_ret = lzma_index_encoder_init( - &raw mut (*(*strm).internal).next, - (*strm).allocator, - i, - ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__0: lzma_ret = + lzma_index_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, i) + as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_index_buffer_encode( mut i: *const lzma_index, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { @@ -571,9 +484,9 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( iter: lzma_index_iter { stream: C2RustUnnamed_2 { flags: ::core::ptr::null::(), - reserved_ptr1: ::core::ptr::null::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null::<::core::ffi::c_void>(), - reserved_ptr3: ::core::ptr::null::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null::(), + reserved_ptr2: ::core::ptr::null::(), + reserved_ptr3: ::core::ptr::null::(), number: 0, block_count: 0, compressed_offset: 0, @@ -600,13 +513,13 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( reserved_vli2: 0, reserved_vli3: 0, reserved_vli4: 0, - reserved_ptr1: ::core::ptr::null::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null::<::core::ffi::c_void>(), - reserved_ptr3: ::core::ptr::null::<::core::ffi::c_void>(), - reserved_ptr4: ::core::ptr::null::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null::(), + reserved_ptr2: ::core::ptr::null::(), + reserved_ptr3: ::core::ptr::null::(), + reserved_ptr4: ::core::ptr::null::(), }, internal: [C2RustUnnamed_0 { - p: ::core::ptr::null::<::core::ffi::c_void>(), + p: ::core::ptr::null::(), }; 6], }, pos: 0, @@ -615,9 +528,9 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( index_encoder_reset(&raw mut coder, i); let out_start: size_t = *out_pos; let mut ret: lzma_ret = index_encode( - &raw mut coder as *mut ::core::ffi::c_void, + &raw mut coder as *mut c_void, ::core::ptr::null::(), - ::core::ptr::null::(), + ::core::ptr::null::(), ::core::ptr::null_mut::(), 0 as size_t, out, @@ -625,9 +538,7 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( out_size, LZMA_RUN, ); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { ret = LZMA_OK; } else { *out_pos = out_start; diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 975894ab..a5a230f2 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -1,39 +1,28 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcmp( - __s1: *const ::core::ffi::c_void, - __s2: *const ::core::ffi::c_void, - __n: size_t, - ) -> ::core::ffi::c_int; + fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; fn lzma_vli_decode( vli: *mut lzma_vli, vli_pos: *mut size_t, - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, ) -> lzma_ret; - fn lzma_vli_size(vli: lzma_vli) -> uint32_t; - fn lzma_check_size(check: lzma_check) -> uint32_t; - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_vli_size(vli: lzma_vli) -> u32; + fn lzma_check_size(check: lzma_check) -> u32; + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); fn lzma_check_update( check: *mut lzma_check_state, type_0: lzma_check, - buf: *const uint8_t, + buf: *const u8, size: size_t, ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -58,20 +47,10 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -86,7 +65,7 @@ pub struct lzma_index_hash_s { pub unpadded_size: lzma_vli, pub uncompressed_size: lzma_vli, pub pos: size_t, - pub crc32: uint32_t, + pub crc32: u32, } #[derive(Copy, Clone)] #[repr(C)] @@ -106,24 +85,24 @@ pub struct lzma_check_state { #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed { - pub crc32: uint32_t, - pub crc64: uint64_t, + pub crc32: u32, + pub crc64: u64, pub sha256: lzma_sha256_state, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_sha256_state { - pub state: [uint32_t; 8], - pub size: uint64_t, + pub state: [u32; 8], + pub size: u64, } #[derive(Copy, Clone)] #[repr(C)] pub union C2RustUnnamed_0 { - pub u8_0: [uint8_t; 64], - pub u32_0: [uint32_t; 16], - pub u64_0: [uint64_t; 8], + pub u8_0: [u8; 64], + pub u32_0: [u32; 16], + pub u64_0: [u64; 8], } -pub type C2RustUnnamed_1 = ::core::ffi::c_uint; +pub type C2RustUnnamed_1 = c_uint; pub const SEQ_CRC32: C2RustUnnamed_1 = 6; pub const SEQ_PADDING: C2RustUnnamed_1 = 5; pub const SEQ_PADDING_INIT: C2RustUnnamed_1 = 4; @@ -132,21 +111,15 @@ pub const SEQ_UNPADDED: C2RustUnnamed_1 = 2; pub const SEQ_COUNT: C2RustUnnamed_1 = 1; pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; pub type lzma_index_hash = lzma_index_hash_s; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; -pub const LZMA_BACKWARD_SIZE_MAX: ::core::ffi::c_ulonglong = (1 - as ::core::ffi::c_ulonglong) << 34 as ::core::ffi::c_int; -pub const UNPADDED_SIZE_MIN: ::core::ffi::c_ulonglong = 5 as ::core::ffi::c_ulonglong; -pub const UNPADDED_SIZE_MAX: ::core::ffi::c_ulonglong = LZMA_VLI_MAX - & !(3 as ::core::ffi::c_ulonglong); -pub const INDEX_INDICATOR: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = (1 as c_ulonglong) << 34 as c_int; +pub const UNPADDED_SIZE_MIN: c_ulonglong = 5 as c_ulonglong; +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !(3 as c_ulonglong); +pub const INDEX_INDICATOR: c_int = 0 as c_int; #[inline] unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); @@ -156,15 +129,12 @@ unsafe extern "C" fn index_size_unpadded( mut count: lzma_vli, mut index_list_size: lzma_vli, ) -> lzma_vli { - return ((1 as uint32_t).wrapping_add(lzma_vli_size(count)) as lzma_vli) + return ((1 as u32).wrapping_add(lzma_vli_size(count)) as lzma_vli) .wrapping_add(index_list_size) .wrapping_add(4 as lzma_vli); } #[inline] -unsafe extern "C" fn index_size( - mut count: lzma_vli, - mut index_list_size: lzma_vli, -) -> lzma_vli { +unsafe extern "C" fn index_size(mut count: lzma_vli, mut index_list_size: lzma_vli) -> lzma_vli { return vli_ceil4(index_size_unpadded(count, index_list_size)); } #[inline] @@ -204,7 +174,7 @@ pub unsafe extern "C" fn lzma_index_hash_init( (*index_hash).unpadded_size = 0 as lzma_vli; (*index_hash).uncompressed_size = 0 as lzma_vli; (*index_hash).pos = 0 as size_t; - (*index_hash).crc32 = 0 as uint32_t; + (*index_hash).crc32 = 0 as u32; lzma_check_init(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); lzma_check_init(&raw mut (*index_hash).records.check, LZMA_CHECK_SHA256); return index_hash; @@ -214,13 +184,14 @@ pub unsafe extern "C" fn lzma_index_hash_end( mut index_hash: *mut lzma_index_hash, mut allocator: *const lzma_allocator, ) { - lzma_free(index_hash as *mut ::core::ffi::c_void, allocator); + lzma_free(index_hash as *mut c_void, allocator); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_hash_size( - mut index_hash: *const lzma_index_hash, -) -> lzma_vli { - return index_size((*index_hash).blocks.count, (*index_hash).blocks.index_list_size); +pub unsafe extern "C" fn lzma_index_hash_size(mut index_hash: *const lzma_index_hash) -> lzma_vli { + return index_size( + (*index_hash).blocks.count, + (*index_hash).blocks.index_list_size, + ); } unsafe extern "C" fn hash_append( mut info: *mut lzma_index_hash_info, @@ -228,21 +199,16 @@ unsafe extern "C" fn hash_append( mut uncompressed_size: lzma_vli, ) { (*info).blocks_size = (*info).blocks_size.wrapping_add(vli_ceil4(unpadded_size)); - (*info).uncompressed_size = (*info) - .uncompressed_size - .wrapping_add(uncompressed_size); - (*info).index_list_size = (*info) - .index_list_size - .wrapping_add( - lzma_vli_size(unpadded_size).wrapping_add(lzma_vli_size(uncompressed_size)) - as lzma_vli, - ); + (*info).uncompressed_size = (*info).uncompressed_size.wrapping_add(uncompressed_size); + (*info).index_list_size = (*info).index_list_size.wrapping_add( + lzma_vli_size(unpadded_size).wrapping_add(lzma_vli_size(uncompressed_size)) as lzma_vli, + ); (*info).count = (*info).count.wrapping_add(1); let sizes: [lzma_vli; 2] = [unpadded_size, uncompressed_size]; lzma_check_update( &raw mut (*info).check, LZMA_CHECK_SHA256, - &raw const sizes as *const lzma_vli as *const uint8_t, + &raw const sizes as *const lzma_vli as *const u8, ::core::mem::size_of::<[lzma_vli; 2]>() as size_t, ); } @@ -253,19 +219,24 @@ pub unsafe extern "C" fn lzma_index_hash_append( mut uncompressed_size: lzma_vli, ) -> lzma_ret { if index_hash.is_null() - || (*index_hash).sequence as ::core::ffi::c_uint - != SEQ_BLOCK as ::core::ffi::c_int as ::core::ffi::c_uint + || (*index_hash).sequence as c_uint != SEQ_BLOCK as c_uint || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli || uncompressed_size > LZMA_VLI_MAX as lzma_vli { return LZMA_PROG_ERROR; } - hash_append(&raw mut (*index_hash).blocks, unpadded_size, uncompressed_size); + hash_append( + &raw mut (*index_hash).blocks, + unpadded_size, + uncompressed_size, + ); if (*index_hash).blocks.blocks_size > LZMA_VLI_MAX as lzma_vli || (*index_hash).blocks.uncompressed_size > LZMA_VLI_MAX as lzma_vli - || index_size((*index_hash).blocks.count, (*index_hash).blocks.index_list_size) - > LZMA_BACKWARD_SIZE_MAX as lzma_vli + || index_size( + (*index_hash).blocks.count, + (*index_hash).blocks.index_list_size, + ) > LZMA_BACKWARD_SIZE_MAX as lzma_vli || index_stream_size( (*index_hash).blocks.blocks_size, (*index_hash).blocks.count, @@ -279,7 +250,7 @@ pub unsafe extern "C" fn lzma_index_hash_append( #[no_mangle] pub unsafe extern "C" fn lzma_index_hash_decode( mut index_hash: *mut lzma_index_hash, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, ) -> lzma_ret { @@ -290,12 +261,11 @@ pub unsafe extern "C" fn lzma_index_hash_decode( let in_start: size_t = *in_pos; let mut ret: lzma_ret = LZMA_OK; while *in_pos < in_size { - match (*index_hash).sequence as ::core::ffi::c_uint { + match (*index_hash).sequence as c_uint { 0 => { let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) as ::core::ffi::c_int != INDEX_INDICATOR - { + if *in_0.offset(fresh0 as isize) as c_int != INDEX_INDICATOR { return LZMA_DATA_ERROR; } (*index_hash).sequence = SEQ_COUNT; @@ -309,9 +279,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( in_pos, in_size, ); - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_STREAM_END as c_uint { break; } if (*index_hash).remaining != (*index_hash).blocks.count { @@ -320,38 +288,26 @@ pub unsafe extern "C" fn lzma_index_hash_decode( ret = LZMA_OK; (*index_hash).pos = 0 as size_t; (*index_hash).sequence = (if (*index_hash).remaining == 0 as lzma_vli { - SEQ_PADDING_INIT as ::core::ffi::c_int + SEQ_PADDING_INIT as c_int } else { - SEQ_UNPADDED as ::core::ffi::c_int + SEQ_UNPADDED as c_int }) as C2RustUnnamed_1; continue; } 2 | 3 => { - let mut size: *mut lzma_vli = if (*index_hash).sequence - as ::core::ffi::c_uint - == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint - { - &raw mut (*index_hash).unpadded_size - } else { - &raw mut (*index_hash).uncompressed_size - }; - ret = lzma_vli_decode( - size, - &raw mut (*index_hash).pos, - in_0, - in_pos, - in_size, - ); - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + let mut size: *mut lzma_vli = + if (*index_hash).sequence as c_uint == SEQ_UNPADDED as c_uint { + &raw mut (*index_hash).unpadded_size + } else { + &raw mut (*index_hash).uncompressed_size + }; + ret = lzma_vli_decode(size, &raw mut (*index_hash).pos, in_0, in_pos, in_size); + if ret as c_uint != LZMA_STREAM_END as c_uint { break; } ret = LZMA_OK; (*index_hash).pos = 0 as size_t; - if (*index_hash).sequence as ::core::ffi::c_uint - == SEQ_UNPADDED as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*index_hash).sequence as c_uint == SEQ_UNPADDED as c_uint { if (*index_hash).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || (*index_hash).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli { @@ -364,8 +320,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( (*index_hash).unpadded_size, (*index_hash).uncompressed_size, ); - if (*index_hash).blocks.blocks_size - < (*index_hash).records.blocks_size + if (*index_hash).blocks.blocks_size < (*index_hash).records.blocks_size || (*index_hash).blocks.uncompressed_size < (*index_hash).records.uncompressed_size || (*index_hash).blocks.index_list_size @@ -374,23 +329,19 @@ pub unsafe extern "C" fn lzma_index_hash_decode( return LZMA_DATA_ERROR; } (*index_hash).remaining = (*index_hash).remaining.wrapping_sub(1); - (*index_hash).sequence = (if (*index_hash).remaining == 0 as lzma_vli - { - SEQ_PADDING_INIT as ::core::ffi::c_int + (*index_hash).sequence = (if (*index_hash).remaining == 0 as lzma_vli { + SEQ_PADDING_INIT as c_int } else { - SEQ_UNPADDED as ::core::ffi::c_int + SEQ_UNPADDED as c_int }) as C2RustUnnamed_1; } continue; } 4 => { - (*index_hash).pos = ((4 as lzma_vli) - .wrapping_sub( - index_size_unpadded( - (*index_hash).records.count, - (*index_hash).records.index_list_size, - ), - ) & 3 as lzma_vli) as size_t; + (*index_hash).pos = ((4 as lzma_vli).wrapping_sub(index_size_unpadded( + (*index_hash).records.count, + (*index_hash).records.index_list_size, + )) & 3 as lzma_vli) as size_t; (*index_hash).sequence = SEQ_PADDING; current_block = 12753679906265593574; } @@ -408,15 +359,12 @@ pub unsafe extern "C" fn lzma_index_hash_decode( (*index_hash).pos = (*index_hash).pos.wrapping_sub(1); let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh1 as isize) as ::core::ffi::c_int - != 0 as ::core::ffi::c_int - { + if *in_0.offset(fresh1 as isize) as c_int != 0 as c_int { return LZMA_DATA_ERROR; } continue; } else { - if (*index_hash).blocks.blocks_size - != (*index_hash).records.blocks_size + if (*index_hash).blocks.blocks_size != (*index_hash).records.blocks_size || (*index_hash).blocks.uncompressed_size != (*index_hash).records.uncompressed_size || (*index_hash).blocks.index_list_size @@ -424,21 +372,14 @@ pub unsafe extern "C" fn lzma_index_hash_decode( { return LZMA_DATA_ERROR; } - lzma_check_finish( - &raw mut (*index_hash).blocks.check, - LZMA_CHECK_SHA256, - ); - lzma_check_finish( - &raw mut (*index_hash).records.check, - LZMA_CHECK_SHA256, - ); + lzma_check_finish(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); + lzma_check_finish(&raw mut (*index_hash).records.check, LZMA_CHECK_SHA256); if memcmp( - &raw mut (*index_hash).blocks.check.buffer.u8_0 as *mut uint8_t - as *const ::core::ffi::c_void, - &raw mut (*index_hash).records.check.buffer.u8_0 as *mut uint8_t - as *const ::core::ffi::c_void, + &raw mut (*index_hash).blocks.check.buffer.u8_0 as *mut u8 as *const c_void, + &raw mut (*index_hash).records.check.buffer.u8_0 as *mut u8 + as *const c_void, lzma_check_size(LZMA_CHECK_SHA256) as size_t, - ) != 0 as ::core::ffi::c_int + ) != 0 as c_int { return LZMA_DATA_ERROR; } @@ -458,8 +399,8 @@ pub unsafe extern "C" fn lzma_index_hash_decode( } let fresh2 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8 as size_t) - & 0xff as uint32_t != *in_0.offset(fresh2 as isize) as uint32_t + if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8 as size_t) & 0xff as u32 + != *in_0.offset(fresh2 as isize) as u32 { return LZMA_DATA_ERROR; } @@ -472,11 +413,8 @@ pub unsafe extern "C" fn lzma_index_hash_decode( } let in_used: size_t = (*in_pos).wrapping_sub(in_start); if in_used > 0 as size_t { - (*index_hash).crc32 = lzma_crc32( - in_0.offset(in_start as isize), - in_used, - (*index_hash).crc32, - ); + (*index_hash).crc32 = + lzma_crc32(in_0.offset(in_start as isize), in_used, (*index_hash).crc32); } return ret; } diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 2757dca8..c6d59407 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -1,11 +1,10 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -14,10 +13,10 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -26,19 +25,9 @@ extern "C" { allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma_decoder_memusage_nocheck( - options: *const ::core::ffi::c_void, - ) -> uint64_t; + fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -60,7 +49,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -69,17 +57,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -90,7 +70,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -102,68 +82,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -173,82 +128,80 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, } -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzip_coder { pub sequence: C2RustUnnamed_0, - pub version: uint32_t, - pub crc32: uint32_t, - pub uncompressed_size: uint64_t, - pub member_size: uint64_t, - pub memlimit: uint64_t, - pub memusage: uint64_t, + pub version: u32, + pub crc32: u32, + pub uncompressed_size: u64, + pub member_size: u64, + pub memlimit: u64, + pub memusage: u64, pub tell_any_check: bool, pub ignore_check: bool, pub concatenated: bool, pub first_member: bool, pub pos: size_t, - pub buffer: [uint8_t; 20], + pub buffer: [u8; 20], pub options: lzma_options_lzma, pub lzma_decoder: lzma_next_coder, } -pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub type C2RustUnnamed_0 = c_uint; pub const SEQ_MEMBER_FOOTER: C2RustUnnamed_0 = 5; pub const SEQ_LZMA_STREAM: C2RustUnnamed_0 = 4; pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; @@ -261,7 +214,7 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -270,80 +223,58 @@ pub type lzma_init_function = Option< *const lzma_filter_info, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { - let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; - num - |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - num - |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 16 as ::core::ffi::c_int; - num - |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) - << 24 as ::core::ffi::c_int; +unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { + let mut num: u32 = *buf.offset(0 as isize) as u32; + num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; + num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; + num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; return num; } #[inline] -unsafe extern "C" fn read64le(mut buf: *const uint8_t) -> uint64_t { - let mut num: uint64_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint64_t; - num - |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint64_t) - << 8 as ::core::ffi::c_int; - num - |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint64_t) - << 16 as ::core::ffi::c_int; - num - |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint64_t) - << 24 as ::core::ffi::c_int; - num - |= (*buf.offset(4 as ::core::ffi::c_int as isize) as uint64_t) - << 32 as ::core::ffi::c_int; - num - |= (*buf.offset(5 as ::core::ffi::c_int as isize) as uint64_t) - << 40 as ::core::ffi::c_int; - num - |= (*buf.offset(6 as ::core::ffi::c_int as isize) as uint64_t) - << 48 as ::core::ffi::c_int; - num - |= (*buf.offset(7 as ::core::ffi::c_int as isize) as uint64_t) - << 56 as ::core::ffi::c_int; +unsafe extern "C" fn read64le(mut buf: *const u8) -> u64 { + let mut num: u64 = *buf.offset(0 as isize) as u64; + num |= (*buf.offset(1 as isize) as u64) << 8 as c_int; + num |= (*buf.offset(2 as isize) as u64) << 16 as c_int; + num |= (*buf.offset(3 as isize) as u64) << 24 as c_int; + num |= (*buf.offset(4 as isize) as u64) << 32 as c_int; + num |= (*buf.offset(5 as isize) as u64) << 40 as c_int; + num |= (*buf.offset(6 as isize) as u64) << 48 as c_int; + num |= (*buf.offset(7 as isize) as u64) << 56 as c_int; return num; } -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 - as ::core::ffi::c_ulonglong; -pub const LZMA_TELL_NO_CHECK: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; -pub const LZMA_TELL_UNSUPPORTED_CHECK: ::core::ffi::c_uint = 0x2 as ::core::ffi::c_uint; -pub const LZMA_TELL_ANY_CHECK: ::core::ffi::c_uint = 0x4 as ::core::ffi::c_uint; -pub const LZMA_IGNORE_CHECK: ::core::ffi::c_uint = 0x10 as ::core::ffi::c_uint; -pub const LZMA_CONCATENATED: ::core::ffi::c_uint = 0x8 as ::core::ffi::c_uint; -pub const LZMA_FAIL_FAST: ::core::ffi::c_uint = 0x20 as ::core::ffi::c_uint; -pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) - << 15 as ::core::ffi::c_int; -pub const LZMA_SUPPORTED_FLAGS: ::core::ffi::c_uint = LZMA_TELL_NO_CHECK - | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK | LZMA_IGNORE_CHECK - | LZMA_CONCATENATED | LZMA_FAIL_FAST; -pub const LZIP_V0_FOOTER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; -pub const LZIP_V1_FOOTER_SIZE: ::core::ffi::c_int = 20 as ::core::ffi::c_int; -pub const LZIP_LC: ::core::ffi::c_int = 3 as ::core::ffi::c_int; -pub const LZIP_LP: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZIP_PB: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1 as c_uint; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2 as c_uint; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10 as c_uint; +pub const LZMA_CONCATENATED: c_uint = 0x8 as c_uint; +pub const LZMA_FAIL_FAST: c_uint = 0x20 as c_uint; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK + | LZMA_TELL_UNSUPPORTED_CHECK + | LZMA_TELL_ANY_CHECK + | LZMA_IGNORE_CHECK + | LZMA_CONCATENATED + | LZMA_FAIL_FAST; +pub const LZIP_V0_FOOTER_SIZE: c_int = 12 as c_int; +pub const LZIP_V1_FOOTER_SIZE: c_int = 20 as c_int; +pub const LZIP_LC: c_int = 3 as c_int; +pub const LZIP_LP: c_int = 0 as c_int; +pub const LZIP_PB: c_int = 2 as c_int; unsafe extern "C" fn lzip_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -351,42 +282,35 @@ unsafe extern "C" fn lzip_decode( let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; loop { let mut current_block_80: u64; - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { - let lzip_id_string: [uint8_t; 4] = [ - 0x4c as ::core::ffi::c_int as uint8_t, - 0x5a as ::core::ffi::c_int as uint8_t, - 0x49 as ::core::ffi::c_int as uint8_t, - 0x50 as ::core::ffi::c_int as uint8_t, - ]; - while (*coder).pos < ::core::mem::size_of::<[uint8_t; 4]>() as usize { + let lzip_id_string: [u8; 4] = [0x4c as u8, 0x5a as u8, 0x49 as u8, 0x50 as u8]; + while (*coder).pos < ::core::mem::size_of::<[u8; 4]>() as usize { if *in_pos >= in_size { return (if !(*coder).first_member - && action as ::core::ffi::c_uint - == LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + && action as c_uint == LZMA_FINISH as c_uint { - LZMA_STREAM_END as ::core::ffi::c_int + LZMA_STREAM_END as c_int } else { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int }) as lzma_ret; } - if *in_0.offset(*in_pos as isize) as ::core::ffi::c_int - != lzip_id_string[(*coder).pos as usize] as ::core::ffi::c_int + if *in_0.offset(*in_pos as isize) as c_int + != lzip_id_string[(*coder).pos as usize] as c_int { return (if !(*coder).first_member { - LZMA_STREAM_END as ::core::ffi::c_int + LZMA_STREAM_END as c_int } else { - LZMA_FORMAT_ERROR as ::core::ffi::c_int + LZMA_FORMAT_ERROR as c_int }) as lzma_ret; } *in_pos = (*in_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); } (*coder).pos = 0 as size_t; - (*coder).crc32 = 0 as uint32_t; - (*coder).uncompressed_size = 0 as uint64_t; - (*coder).member_size = ::core::mem::size_of::<[uint8_t; 4]>() - as uint64_t; + (*coder).crc32 = 0 as u32; + (*coder).uncompressed_size = 0 as u64; + (*coder).member_size = ::core::mem::size_of::<[u8; 4]>() as u64; (*coder).sequence = SEQ_VERSION; current_block_80 = 11220331375136032509; } @@ -414,8 +338,8 @@ unsafe extern "C" fn lzip_decode( } let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - (*coder).version = *in_0.offset(fresh0 as isize) as uint32_t; - if (*coder).version > 1 as uint32_t { + (*coder).version = *in_0.offset(fresh0 as isize) as u32; + if (*coder).version > 1 as u32 { return LZMA_OPTIONS_ERROR; } (*coder).member_size = (*coder).member_size.wrapping_add(1); @@ -434,25 +358,25 @@ unsafe extern "C" fn lzip_decode( } let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - let ds: uint32_t = *in_0.offset(fresh1 as isize) as uint32_t; + let ds: u32 = *in_0.offset(fresh1 as isize) as u32; (*coder).member_size = (*coder).member_size.wrapping_add(1); - let b2log: uint32_t = ds & 0x1f as uint32_t; - let fracnum: uint32_t = ds >> 5 as ::core::ffi::c_int; - if b2log < 12 as uint32_t || b2log > 29 as uint32_t - || b2log == 12 as uint32_t && fracnum > 0 as uint32_t + let b2log: u32 = ds & 0x1f as u32; + let fracnum: u32 = ds >> 5 as c_int; + if b2log < 12 as u32 + || b2log > 29 as u32 + || b2log == 12 as u32 && fracnum > 0 as u32 { return LZMA_DATA_ERROR; } - (*coder).options.dict_size = ((1 as uint32_t) << b2log) - .wrapping_sub(fracnum << b2log.wrapping_sub(4 as uint32_t)); - (*coder).options.preset_dict = ::core::ptr::null::(); - (*coder).options.lc = LZIP_LC as uint32_t; - (*coder).options.lp = LZIP_LP as uint32_t; - (*coder).options.pb = LZIP_PB as uint32_t; - (*coder).memusage = lzma_lzma_decoder_memusage_nocheck( - &raw mut (*coder).options as *const ::core::ffi::c_void, - ) - .wrapping_add(LZMA_MEMUSAGE_BASE as uint64_t); + (*coder).options.dict_size = + ((1 as u32) << b2log).wrapping_sub(fracnum << b2log.wrapping_sub(4 as u32)); + (*coder).options.preset_dict = ::core::ptr::null::(); + (*coder).options.lc = LZIP_LC as u32; + (*coder).options.lp = LZIP_LP as u32; + (*coder).options.pb = LZIP_PB as u32; + (*coder).memusage = + lzma_lzma_decoder_memusage_nocheck(&raw mut (*coder).options as *const c_void) + .wrapping_add(LZMA_MEMUSAGE_BASE as u64); (*coder).sequence = SEQ_CODER_INIT; current_block_80 = 15476230294461844687; } @@ -472,14 +396,15 @@ unsafe extern "C" fn lzip_decode( *mut lzma_next_coder, *const lzma_allocator, *const lzma_filter_info, - ) -> lzma_ret, + ) + -> lzma_ret, ), - options: &raw mut (*coder).options as *mut ::core::ffi::c_void, + options: &raw mut (*coder).options as *mut c_void, }, lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }, ]; let ret_: lzma_ret = lzma_next_filter_init( @@ -487,12 +412,10 @@ unsafe extern "C" fn lzip_decode( allocator, &raw const filters as *const lzma_filter_info, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - (*coder).crc32 = 0 as uint32_t; + (*coder).crc32 = 0 as u32; (*coder).sequence = SEQ_LZMA_STREAM; current_block_80 = 13394712405657322686; } @@ -505,9 +428,7 @@ unsafe extern "C" fn lzip_decode( let ret: lzma_ret = (*coder) .lzma_decoder .code - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).lzma_decoder.coder, allocator, in_0, @@ -521,27 +442,21 @@ unsafe extern "C" fn lzip_decode( let out_used: size_t = (*out_pos).wrapping_sub(out_start); (*coder).member_size = (*coder) .member_size - .wrapping_add((*in_pos).wrapping_sub(in_start) as uint64_t); - (*coder).uncompressed_size = (*coder) - .uncompressed_size - .wrapping_add(out_used as uint64_t); + .wrapping_add((*in_pos).wrapping_sub(in_start) as u64); + (*coder).uncompressed_size = + (*coder).uncompressed_size.wrapping_add(out_used as u64); if !(*coder).ignore_check && out_used > 0 as size_t { - (*coder).crc32 = lzma_crc32( - out.offset(out_start as isize), - out_used, - (*coder).crc32, - ); + (*coder).crc32 = + lzma_crc32(out.offset(out_start as isize), out_used, (*coder).crc32); } - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_STREAM_END as c_uint { return ret; } (*coder).sequence = SEQ_MEMBER_FOOTER; } _ => {} } - let footer_size: size_t = (if (*coder).version == 0 as uint32_t { + let footer_size: size_t = (if (*coder).version == 0 as u32 { LZIP_V0_FOOTER_SIZE } else { LZIP_V1_FOOTER_SIZE @@ -550,7 +465,7 @@ unsafe extern "C" fn lzip_decode( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, &raw mut (*coder).pos, footer_size, ); @@ -558,32 +473,21 @@ unsafe extern "C" fn lzip_decode( return LZMA_OK; } (*coder).pos = 0 as size_t; - (*coder).member_size = (*coder) - .member_size - .wrapping_add(footer_size as uint64_t); + (*coder).member_size = (*coder).member_size.wrapping_add(footer_size as u64); if !(*coder).ignore_check && (*coder).crc32 - != read32le( - (&raw mut (*coder).buffer as *mut uint8_t) - .offset(0 as ::core::ffi::c_int as isize) as *mut uint8_t, - ) + != read32le((&raw mut (*coder).buffer as *mut u8).offset(0 as isize) as *mut u8) { return LZMA_DATA_ERROR; } if (*coder).uncompressed_size - != read64le( - (&raw mut (*coder).buffer as *mut uint8_t) - .offset(4 as ::core::ffi::c_int as isize) as *mut uint8_t, - ) + != read64le((&raw mut (*coder).buffer as *mut u8).offset(4 as isize) as *mut u8) { return LZMA_DATA_ERROR; } - if (*coder).version > 0 as uint32_t { + if (*coder).version > 0 as u32 { if (*coder).member_size - != read64le( - (&raw mut (*coder).buffer as *mut uint8_t) - .offset(12 as ::core::ffi::c_int as isize) as *mut uint8_t, - ) + != read64le((&raw mut (*coder).buffer as *mut u8).offset(12 as isize) as *mut u8) { return LZMA_DATA_ERROR; } @@ -593,31 +497,29 @@ unsafe extern "C" fn lzip_decode( } (*coder).first_member = false_0 != 0; (*coder).sequence = SEQ_ID_STRING; - }; + } } unsafe extern "C" fn lzip_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; lzma_next_end(&raw mut (*coder).lzma_decoder, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } -unsafe extern "C" fn lzip_decoder_get_check( - mut coder_ptr: *const ::core::ffi::c_void, -) -> lzma_check { +unsafe extern "C" fn lzip_decoder_get_check(mut coder_ptr: *const c_void) -> lzma_check { return LZMA_CHECK_CRC32; } unsafe extern "C" fn lzip_decoder_memconfig( - mut coder_ptr: *mut ::core::ffi::c_void, - mut memusage: *mut uint64_t, - mut old_memlimit: *mut uint64_t, - mut new_memlimit: uint64_t, + mut coder_ptr: *mut c_void, + mut memusage: *mut u64, + mut old_memlimit: *mut u64, + mut new_memlimit: u64, ) -> lzma_ret { let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; *memusage = (*coder).memusage; *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as uint64_t { + if new_memlimit != 0 as u64 { if new_memlimit < (*coder).memusage { return LZMA_MEMLIMIT_ERROR; } @@ -629,55 +531,41 @@ unsafe extern "C" fn lzip_decoder_memconfig( pub unsafe extern "C" fn lzma_lzip_decoder_init( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, - mut memlimit: uint64_t, - mut flags: uint32_t, + mut memlimit: u64, + mut flags: u32, ) -> lzma_ret { if ::core::mem::transmute::< Option< - unsafe extern "C" fn( + unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, + >, + uintptr_t, + >(Some( + lzma_lzip_decoder_init + as unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, - uint32_t, + u64, + u32, ) -> lzma_ret, - >, - uintptr_t, - >( - Some( - lzma_lzip_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - uint32_t, - ) -> lzma_ret, - ), - ) != (*next).init + )) != (*next).init { lzma_next_end(next, allocator); } (*next).init = ::core::mem::transmute::< Option< - unsafe extern "C" fn( + unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, + >, + uintptr_t, + >(Some( + lzma_lzip_decoder_init + as unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, - uint32_t, + u64, + u32, ) -> lzma_ret, - >, - uintptr_t, - >( - Some( - lzma_lzip_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - uint32_t, - ) -> lzma_ret, - ), - ); - if flags & !(LZMA_SUPPORTED_FLAGS as uint32_t) != 0 { + )); + if flags & !(LZMA_SUPPORTED_FLAGS as u32) != 0 { return LZMA_OPTIONS_ERROR; } let mut coder: *mut lzma_lzip_coder = (*next).coder as *mut lzma_lzip_coder; @@ -689,53 +577,36 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( lzip_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - lzip_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + lzip_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; - (*next).get_check = Some( - lzip_decoder_get_check - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - ) as Option lzma_check>; + (*next).get_check = + Some(lzip_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check) + as Option lzma_check>; (*next).memconfig = Some( lzip_decoder_memconfig - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >; + as Option lzma_ret>; (*coder).lzma_decoder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -746,11 +617,15 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( }; } (*coder).sequence = SEQ_ID_STRING; - (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; - (*coder).memusage = LZMA_MEMUSAGE_BASE as uint64_t; - (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as uint32_t != 0 as uint32_t; - (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as uint32_t != 0 as uint32_t; - (*coder).concatenated = flags & LZMA_CONCATENATED as uint32_t != 0 as uint32_t; + (*coder).memlimit = if 1 as u64 > memlimit { + 1 as u64 + } else { + memlimit + }; + (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; + (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as u32 != 0 as u32; + (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as u32 != 0 as u32; + (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0 as u32; (*coder).first_member = true_0 != 0; (*coder).pos = 0 as size_t; return LZMA_OK; @@ -758,13 +633,11 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( #[no_mangle] pub unsafe extern "C" fn lzma_lzip_decoder( mut strm: *mut lzma_stream, - mut memlimit: uint64_t, - mut flags: uint32_t, + mut memlimit: u64, + mut flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = lzma_lzip_decoder_init( @@ -773,15 +646,11 @@ pub unsafe extern "C" fn lzma_lzip_decoder( memlimit, flags, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index 7172b5f2..6cf1b7df 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -1,10 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -17,18 +16,9 @@ extern "C" { allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: uint8_t) -> bool; + fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -50,7 +40,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -59,17 +48,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -80,7 +61,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -92,68 +73,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -163,69 +119,67 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, } -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_microlzma_coder { pub lzma: lzma_next_coder, - pub comp_size: uint64_t, + pub comp_size: u64, pub uncomp_size: lzma_vli, - pub dict_size: uint32_t, + pub dict_size: u32, pub uncomp_size_is_exact: bool, pub props_decoded: bool, } @@ -235,7 +189,7 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -244,27 +198,22 @@ pub type lzma_init_function = Option< *const lzma_filter_info, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 - as ::core::ffi::c_ulonglong; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; unsafe extern "C" fn microlzma_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -272,7 +221,7 @@ unsafe extern "C" fn microlzma_decode( let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - if in_size.wrapping_sub(*in_pos) as uint64_t > (*coder).comp_size { + if in_size.wrapping_sub(*in_pos) as u64 > (*coder).comp_size { in_size = (*in_pos).wrapping_add((*coder).comp_size as size_t); } if !(*coder).uncomp_size_is_exact @@ -286,8 +235,8 @@ unsafe extern "C" fn microlzma_decode( } let mut options: lzma_options_lzma = lzma_options_lzma { dict_size: (*coder).dict_size, - preset_dict: ::core::ptr::null::(), - preset_dict_size: 0 as uint32_t, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0 as u32, lc: 0, lp: 0, pb: 0, @@ -295,9 +244,9 @@ unsafe extern "C" fn microlzma_decode( nice_len: 0, mf: 0 as lzma_match_finder, depth: 0, - ext_flags: 0 as uint32_t, - ext_size_low: UINT32_MAX as uint32_t, - ext_size_high: UINT32_MAX as uint32_t, + ext_flags: 0 as u32, + ext_size_low: UINT32_MAX as u32, + ext_size_high: UINT32_MAX as u32, reserved_int4: 0, reserved_int5: 0, reserved_int6: 0, @@ -307,17 +256,16 @@ unsafe extern "C" fn microlzma_decode( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), }; if (*coder).uncomp_size_is_exact { - options.ext_size_low = (*coder).uncomp_size as uint32_t; - options.ext_size_high = ((*coder).uncomp_size >> 32 as ::core::ffi::c_int) - as uint32_t; + options.ext_size_low = (*coder).uncomp_size as u32; + options.ext_size_high = ((*coder).uncomp_size >> 32 as c_int) as u32; } if lzma_lzma_lclppb_decode( &raw mut options, - !(*in_0.offset(*in_pos as isize) as ::core::ffi::c_int) as uint8_t, + !(*in_0.offset(*in_pos as isize) as c_int) as u8, ) { return LZMA_OPTIONS_ERROR; } @@ -333,12 +281,12 @@ unsafe extern "C" fn microlzma_decode( *const lzma_filter_info, ) -> lzma_ret, ), - options: &raw mut options as *mut ::core::ffi::c_void, + options: &raw mut options as *mut c_void, }, lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }, ]; let ret_: lzma_ret = lzma_next_filter_init( @@ -346,19 +294,12 @@ unsafe extern "C" fn microlzma_decode( allocator, &raw mut filters as *mut lzma_filter_info, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - let dummy_in: uint8_t = 0 as uint8_t; + let dummy_in: u8 = 0 as u8; let mut dummy_in_pos: size_t = 0 as size_t; - if (*coder) - .lzma - .code - .expect( - "non-null function pointer", - )( + if (*coder).lzma.code.expect("non-null function pointer")( (*coder).lzma.coder, allocator, &raw const dummy_in, @@ -368,18 +309,14 @@ unsafe extern "C" fn microlzma_decode( out_pos, out_size, LZMA_RUN, - ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + ) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } (*coder).props_decoded = true_0 != 0; } - let mut ret: lzma_ret = (*coder) - .lzma - .code - .expect( - "non-null function pointer", - )( + let mut ret: lzma_ret = (*coder).lzma.code.expect("non-null function pointer")( (*coder).lzma.coder, allocator, in_0, @@ -392,21 +329,16 @@ unsafe extern "C" fn microlzma_decode( ); (*coder).comp_size = (*coder) .comp_size - .wrapping_sub((*in_pos).wrapping_sub(in_start) as uint64_t); + .wrapping_sub((*in_pos).wrapping_sub(in_start) as u64); if (*coder).uncomp_size_is_exact { - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - && (*coder).comp_size != 0 as uint64_t - { + if ret as c_uint == LZMA_STREAM_END as c_uint && (*coder).comp_size != 0 as u64 { ret = LZMA_DATA_ERROR; } } else { (*coder).uncomp_size = (*coder) .uncomp_size .wrapping_sub((*out_pos).wrapping_sub(out_start) as lzma_vli); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { ret = LZMA_DATA_ERROR; } else if (*coder).uncomp_size == 0 as lzma_vli { ret = LZMA_STREAM_END; @@ -415,46 +347,44 @@ unsafe extern "C" fn microlzma_decode( return ret; } unsafe extern "C" fn microlzma_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; lzma_next_end(&raw mut (*coder).lzma, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn microlzma_decoder_init( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, - mut comp_size: uint64_t, - mut uncomp_size: uint64_t, + mut comp_size: u64, + mut uncomp_size: u64, mut uncomp_size_is_exact: bool, - mut dict_size: uint32_t, + mut dict_size: u32, ) -> lzma_ret { if ::core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, - uint64_t, + u64, + u64, bool, - uint32_t, + u32, ) -> lzma_ret, >, uintptr_t, - >( - Some( - microlzma_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - uint64_t, - bool, - uint32_t, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + microlzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + u64, + u64, + bool, + u32, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -463,28 +393,25 @@ unsafe extern "C" fn microlzma_decoder_init( unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, - uint64_t, + u64, + u64, bool, - uint32_t, + u32, ) -> lzma_ret, >, uintptr_t, - >( - Some( - microlzma_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - uint64_t, - bool, - uint32_t, - ) -> lzma_ret, - ), - ); - let mut coder: *mut lzma_microlzma_coder = (*next).coder - as *mut lzma_microlzma_coder; + >(Some( + microlzma_decoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + u64, + u64, + bool, + u32, + ) -> lzma_ret, + )); + let mut coder: *mut lzma_microlzma_coder = (*next).coder as *mut lzma_microlzma_coder; if coder.is_null() { coder = lzma_alloc( ::core::mem::size_of::() as size_t, @@ -493,32 +420,28 @@ unsafe extern "C" fn microlzma_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( microlzma_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - microlzma_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + microlzma_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*coder).lzma = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -528,7 +451,7 @@ unsafe extern "C" fn microlzma_decoder_init( set_out_limit: None, }; } - if uncomp_size > LZMA_VLI_MAX as uint64_t { + if uncomp_size > LZMA_VLI_MAX as u64 { return LZMA_OPTIONS_ERROR; } (*coder).comp_size = comp_size; @@ -541,15 +464,13 @@ unsafe extern "C" fn microlzma_decoder_init( #[no_mangle] pub unsafe extern "C" fn lzma_microlzma_decoder( mut strm: *mut lzma_stream, - mut comp_size: uint64_t, - mut uncomp_size: uint64_t, + mut comp_size: u64, + mut uncomp_size: u64, mut uncomp_size_is_exact: lzma_bool, - mut dict_size: uint32_t, + mut dict_size: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = microlzma_decoder_init( @@ -560,15 +481,11 @@ pub unsafe extern "C" fn lzma_microlzma_decoder( uncomp_size_is_exact != 0, dict_size, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index 802b0aa2..f5a6656c 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -1,10 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -17,20 +16,9 @@ extern "C" { allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; - fn lzma_lzma_lclppb_encode( - options: *const lzma_options_lzma, - byte: *mut uint8_t, - ) -> bool; + fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -52,7 +40,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -61,17 +48,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -82,7 +61,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -94,68 +73,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -165,61 +119,59 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, } -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } pub type lzma_filter_info = lzma_filter_info_s; #[derive(Copy, Clone)] @@ -227,7 +179,7 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -240,25 +192,21 @@ pub type lzma_init_function = Option< #[repr(C)] pub struct lzma_microlzma_coder { pub lzma: lzma_next_coder, - pub props: uint8_t, + pub props: u8, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 - as ::core::ffi::c_ulonglong; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; unsafe extern "C" fn microlzma_encode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -266,26 +214,20 @@ unsafe extern "C" fn microlzma_encode( let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; let out_start: size_t = *out_pos; let in_start: size_t = *in_pos; - let mut uncomp_size: uint64_t = 0; + let mut uncomp_size: u64 = 0; if (*coder) .lzma .set_out_limit - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).lzma.coder, &raw mut uncomp_size, - out_size.wrapping_sub(*out_pos) as uint64_t, - ) as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + out_size.wrapping_sub(*out_pos) as u64, + ) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } - let ret: lzma_ret = (*coder) - .lzma - .code - .expect( - "non-null function pointer", - )( + let ret: lzma_ret = (*coder).lzma.code.expect("non-null function pointer")( (*coder).lzma.coder, allocator, in_0, @@ -296,27 +238,23 @@ unsafe extern "C" fn microlzma_encode( out_size, action, ) as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { - if ret as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret as c_uint == LZMA_OK as c_uint { return LZMA_PROG_ERROR; } return ret; } - *out.offset(out_start as isize) = !((*coder).props as ::core::ffi::c_int) as uint8_t; + *out.offset(out_start as isize) = !((*coder).props as c_int) as u8; *in_pos = in_start.wrapping_add(uncomp_size as size_t); return ret; } unsafe extern "C" fn microlzma_encoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; lzma_next_end(&raw mut (*coder).lzma, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn microlzma_encoder_init( mut next: *mut lzma_next_coder, @@ -332,16 +270,14 @@ unsafe extern "C" fn microlzma_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - microlzma_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_options_lzma, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + microlzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -354,18 +290,15 @@ unsafe extern "C" fn microlzma_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - microlzma_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_options_lzma, - ) -> lzma_ret, - ), - ); - let mut coder: *mut lzma_microlzma_coder = (*next).coder - as *mut lzma_microlzma_coder; + >(Some( + microlzma_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_options_lzma, + ) -> lzma_ret, + )); + let mut coder: *mut lzma_microlzma_coder = (*next).coder as *mut lzma_microlzma_coder; if coder.is_null() { coder = lzma_alloc( ::core::mem::size_of::() as size_t, @@ -374,32 +307,28 @@ unsafe extern "C" fn microlzma_encoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( microlzma_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - microlzma_encoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + microlzma_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*coder).lzma = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -423,12 +352,12 @@ unsafe extern "C" fn microlzma_encoder_init( *const lzma_filter_info, ) -> lzma_ret, ), - options: options as *mut ::core::ffi::c_void, + options: options as *mut c_void, }, lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }, ]; return lzma_next_filter_init( @@ -443,9 +372,7 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( mut options: *const lzma_options_lzma, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = microlzma_encoder_init( @@ -453,13 +380,10 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( (*strm).allocator, options, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/mod.rs b/liblzma-rs/src/common/mod.rs index 537545fc..eec2ca1a 100644 --- a/liblzma-rs/src/common/mod.rs +++ b/liblzma-rs/src/common/mod.rs @@ -35,10 +35,13 @@ pub mod outqueue; pub mod stream_buffer_decoder; pub mod stream_buffer_encoder; pub mod stream_decoder; +pub mod stream_decoder_mt; pub mod stream_encoder; +pub mod stream_encoder_mt; pub mod stream_flags_common; pub mod stream_flags_decoder; pub mod stream_flags_encoder; +pub mod stream_mt; pub mod string_conversion; pub mod vli_decoder; pub mod vli_encoder; diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index f1e81152..3a1903ea 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,24 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulong, c_ulonglong, c_void}; extern "C" { - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -43,24 +36,15 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } -pub type lzma_vli = uint64_t; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_outbuf_s { pub next: *mut lzma_outbuf, - pub worker: *mut ::core::ffi::c_void, + pub worker: *mut c_void, pub allocated: size_t, pub pos: size_t, pub decoder_in_pos: size_t, @@ -68,7 +52,7 @@ pub struct lzma_outbuf_s { pub finish_ret: lzma_ret, pub unpadded_size: lzma_vli, pub uncompressed_size: lzma_vli, - pub buf: [uint8_t; 0], + pub buf: [u8; 0], } pub type lzma_outbuf = lzma_outbuf_s; #[derive(Copy, Clone)] @@ -78,42 +62,32 @@ pub struct lzma_outq { pub tail: *mut lzma_outbuf, pub read_pos: size_t, pub cache: *mut lzma_outbuf, - pub mem_allocated: uint64_t, - pub mem_in_use: uint64_t, - pub bufs_in_use: uint32_t, - pub bufs_allocated: uint32_t, - pub bufs_limit: uint32_t, + pub mem_allocated: u64, + pub mem_in_use: u64, + pub bufs_in_use: u32, + pub bufs_allocated: u32, + pub bufs_limit: u32, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const UINTPTR_MAX: ::core::ffi::c_ulong = 18446744073709551615 - as ::core::ffi::c_ulong; -pub const SIZE_MAX: ::core::ffi::c_ulong = UINTPTR_MAX; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_THREADS_MAX: ::core::ffi::c_int = 16384 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; +pub const SIZE_MAX: c_ulong = UINTPTR_MAX; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; #[inline] -unsafe extern "C" fn lzma_outq_outbuf_memusage(mut buf_size: size_t) -> uint64_t { - return (::core::mem::size_of::() as usize) - .wrapping_add(buf_size as usize) as uint64_t; +unsafe extern "C" fn lzma_outq_outbuf_memusage(mut buf_size: size_t) -> u64 { + return (::core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; } #[no_mangle] -pub unsafe extern "C" fn lzma_outq_memusage( - mut buf_size_max: uint64_t, - mut threads: uint32_t, -) -> uint64_t { - let limit: uint64_t = (UINT64_MAX as uint64_t) - .wrapping_div( - (2 as ::core::ffi::c_int * 16384 as ::core::ffi::c_int) as uint64_t, - ) - .wrapping_div(2 as uint64_t); - if threads > LZMA_THREADS_MAX as uint32_t || buf_size_max > limit { - return UINT64_MAX as uint64_t; +pub unsafe extern "C" fn lzma_outq_memusage(mut buf_size_max: u64, mut threads: u32) -> u64 { + let limit: u64 = (UINT64_MAX as u64) + .wrapping_div((2 as c_int * 16384 as c_int) as u64) + .wrapping_div(2 as u64); + if threads > LZMA_THREADS_MAX as u32 || buf_size_max > limit { + return UINT64_MAX as u64; } - return ((2 as uint32_t).wrapping_mul(threads) as uint64_t) + return ((2 as u32).wrapping_mul(threads) as u64) .wrapping_mul(lzma_outq_outbuf_memusage(buf_size_max as size_t)); } unsafe extern "C" fn move_head_to_cache( @@ -145,7 +119,7 @@ unsafe extern "C" fn free_one_cached_buffer( (*outq).mem_allocated = (*outq) .mem_allocated .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); - lzma_free(buf as *mut ::core::ffi::c_void, allocator); + lzma_free(buf as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_outq_clear_cache( @@ -176,12 +150,12 @@ pub unsafe extern "C" fn lzma_outq_clear_cache2( pub unsafe extern "C" fn lzma_outq_init( mut outq: *mut lzma_outq, mut allocator: *const lzma_allocator, - mut threads: uint32_t, + mut threads: u32, ) -> lzma_ret { - if threads > LZMA_THREADS_MAX as uint32_t { + if threads > LZMA_THREADS_MAX as u32 { return LZMA_OPTIONS_ERROR; } - let bufs_limit: uint32_t = (2 as uint32_t).wrapping_mul(threads); + let bufs_limit: u32 = (2 as u32).wrapping_mul(threads); while !(*outq).head.is_null() { move_head_to_cache(outq, allocator); } @@ -211,10 +185,7 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( if !(*outq).cache.is_null() && (*(*outq).cache).allocated == size { return LZMA_OK; } - if size - > (SIZE_MAX as usize) - .wrapping_sub(::core::mem::size_of::() as usize) - { + if size > (SIZE_MAX as usize).wrapping_sub(::core::mem::size_of::() as usize) { return LZMA_MEM_ERROR; } let alloc_size: size_t = lzma_outq_outbuf_memusage(size) as size_t; @@ -226,13 +197,13 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( (*(*outq).cache).next = ::core::ptr::null_mut::(); (*(*outq).cache).allocated = size; (*outq).bufs_allocated = (*outq).bufs_allocated.wrapping_add(1); - (*outq).mem_allocated = (*outq).mem_allocated.wrapping_add(alloc_size as uint64_t); + (*outq).mem_allocated = (*outq).mem_allocated.wrapping_add(alloc_size as u64); return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_outq_get_buf( mut outq: *mut lzma_outq, - mut worker: *mut ::core::ffi::c_void, + mut worker: *mut c_void, ) -> *mut lzma_outbuf { let mut buf: *mut lzma_outbuf = (*outq).cache; (*outq).cache = (*buf).next; @@ -261,25 +232,24 @@ pub unsafe extern "C" fn lzma_outq_is_readable(mut outq: *const lzma_outq) -> bo if (*outq).head.is_null() { return false_0 != 0; } - return (*outq).read_pos < (*(*outq).head).pos - || (*(*outq).head).finished as ::core::ffi::c_int != 0; + return (*outq).read_pos < (*(*outq).head).pos || (*(*outq).head).finished as c_int != 0; } #[no_mangle] pub unsafe extern "C" fn lzma_outq_read( mut outq: *mut lzma_outq, mut allocator: *const lzma_allocator, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut unpadded_size: *mut lzma_vli, mut uncompressed_size: *mut lzma_vli, ) -> lzma_ret { - if (*outq).bufs_in_use == 0 as uint32_t { + if (*outq).bufs_in_use == 0 as u32 { return LZMA_OK; } let mut buf: *mut lzma_outbuf = (*outq).head; lzma_bufcpy( - &raw mut (*buf).buf as *mut uint8_t, + &raw mut (*buf).buf as *mut u8, &raw mut (*outq).read_pos, (*buf).pos, out, @@ -303,15 +273,10 @@ pub unsafe extern "C" fn lzma_outq_read( #[no_mangle] pub unsafe extern "C" fn lzma_outq_enable_partial_output( mut outq: *mut lzma_outq, - mut enable_partial_output: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void) -> (), - >, + mut enable_partial_output: Option ()>, ) { - if !(*outq).head.is_null() && !(*(*outq).head).finished - && !(*(*outq).head).worker.is_null() - { - enable_partial_output - .expect("non-null function pointer")((*(*outq).head).worker); + if !(*outq).head.is_null() && !(*(*outq).head).finished && !(*(*outq).head).worker.is_null() { + enable_partial_output.expect("non-null function pointer")((*(*outq).head).worker); (*(*outq).head).worker = NULL; } } diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index 12e303e0..69a0f04b 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -1,19 +1,14 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_stream_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, - memlimit: uint64_t, - flags: uint32_t, + memlimit: u64, + flags: u32, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -35,7 +30,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -44,122 +38,89 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_ANY_CHECK: ::core::ffi::c_uint = 0x4 as ::core::ffi::c_uint; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; #[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_decode( - mut memlimit: *mut uint64_t, - mut flags: uint32_t, + mut memlimit: *mut u64, + mut flags: u32, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { - if in_pos.is_null() || in_0.is_null() && *in_pos != in_size || *in_pos > in_size - || out_pos.is_null() || out.is_null() && *out_pos != out_size + if in_pos.is_null() + || in_0.is_null() && *in_pos != in_size + || *in_pos > in_size + || out_pos.is_null() + || out.is_null() && *out_pos != out_size || *out_pos > out_size { return LZMA_PROG_ERROR; } - if flags & LZMA_TELL_ANY_CHECK as uint32_t != 0 { + if flags & LZMA_TELL_ANY_CHECK as u32 != 0 { return LZMA_PROG_ERROR; } let mut stream_decoder: lzma_next_coder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -168,21 +129,12 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( update: None, set_out_limit: None, }; - let mut ret: lzma_ret = lzma_stream_decoder_init( - &raw mut stream_decoder, - allocator, - *memlimit, - flags, - ); - if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let mut ret: lzma_ret = + lzma_stream_decoder_init(&raw mut stream_decoder, allocator, *memlimit, flags); + if ret as c_uint == LZMA_OK as c_uint { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - ret = stream_decoder - .code - .expect( - "non-null function pointer", - )( + ret = stream_decoder.code.expect("non-null function pointer")( stream_decoder.coder, allocator, in_0, @@ -193,30 +145,25 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( out_size, LZMA_FINISH, ); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { ret = LZMA_OK; } else { *in_pos = in_start; *out_pos = out_start; - if ret as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_OK as c_uint { if *in_pos == in_size { ret = LZMA_DATA_ERROR; } else { ret = LZMA_BUF_ERROR; } - } else if ret as ::core::ffi::c_uint - == LZMA_MEMLIMIT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint - { - let mut memusage: uint64_t = 0; - stream_decoder - .memconfig - .expect( - "non-null function pointer", - )(stream_decoder.coder, memlimit, &raw mut memusage, 0 as uint64_t); + } else if ret as c_uint == LZMA_MEMLIMIT_ERROR as c_uint { + let mut memusage: u64 = 0; + stream_decoder.memconfig.expect("non-null function pointer")( + stream_decoder.coder, + memlimit, + &raw mut memusage, + 0 as u64, + ); } } } diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 742e79fb..2f114203 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -1,23 +1,21 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; #[repr(C)] -pub struct lzma_index_s { _opaque: [u8; 0] } +pub struct lzma_index_s { + _opaque: [u8; 0], +} extern "C" { fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_stream_header_encode( - options: *const lzma_stream_flags, - out: *mut uint8_t, - ) -> lzma_ret; - fn lzma_stream_footer_encode( - options: *const lzma_stream_flags, - out: *mut uint8_t, - ) -> lzma_ret; + fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; + fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t; fn lzma_block_buffer_encode( block: *mut lzma_block, allocator: *const lzma_allocator, - in_0: *const uint8_t, + in_0: *const u8, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; @@ -32,20 +30,12 @@ extern "C" { fn lzma_index_size(i: *const lzma_index) -> lzma_vli; fn lzma_index_buffer_encode( i: *const lzma_index, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -70,26 +60,16 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -97,7 +77,7 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -112,25 +92,25 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -150,37 +130,30 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const LZMA_VLI_BYTES_MAX: ::core::ffi::c_int = 9 as ::core::ffi::c_int; -pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; -pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; -pub const INDEX_BOUND: ::core::ffi::c_int = 1 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int + 2 as ::core::ffi::c_int * LZMA_VLI_BYTES_MAX - + 4 as ::core::ffi::c_int + 3 as ::core::ffi::c_int & !(3 as ::core::ffi::c_int); -pub const HEADERS_BOUND: ::core::ffi::c_int = 2 as ::core::ffi::c_int - * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const INDEX_BOUND: c_int = + 1 as c_int + 1 as c_int + 2 as c_int * LZMA_VLI_BYTES_MAX + 4 as c_int + 3 as c_int + & !(3 as c_int); +pub const HEADERS_BOUND: c_int = 2 as c_int * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; #[no_mangle] -pub unsafe extern "C" fn lzma_stream_buffer_bound( - mut uncompressed_size: size_t, -) -> size_t { +pub unsafe extern "C" fn lzma_stream_buffer_bound(mut uncompressed_size: size_t) -> size_t { let block_bound: size_t = lzma_block_buffer_bound(uncompressed_size) as size_t; if block_bound == 0 as size_t { return 0 as size_t; } - if (if (18446744073709551615 as ::core::ffi::c_ulonglong) - < (18446744073709551615 as ::core::ffi::c_ulonglong) - .wrapping_div(2 as ::core::ffi::c_ulonglong) + if (if (18446744073709551615 as c_ulonglong) + < (18446744073709551615 as c_ulonglong).wrapping_div(2 as c_ulonglong) { - 18446744073709551615 as ::core::ffi::c_ulonglong + 18446744073709551615 as c_ulonglong } else { - (18446744073709551615 as ::core::ffi::c_ulonglong) - .wrapping_div(2 as ::core::ffi::c_ulonglong) + (18446744073709551615 as c_ulonglong).wrapping_div(2 as c_ulonglong) }) - .wrapping_sub(block_bound as ::core::ffi::c_ulonglong) - < HEADERS_BOUND as ::core::ffi::c_ulonglong + .wrapping_sub(block_bound as c_ulonglong) + < HEADERS_BOUND as c_ulonglong { return 0 as size_t; } @@ -191,16 +164,18 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( mut filters: *mut lzma_filter, mut check: lzma_check, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos_ptr: *mut size_t, mut out_size: size_t, ) -> lzma_ret { if filters.is_null() - || check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint - || in_0.is_null() && in_size != 0 as size_t || out.is_null() - || out_pos_ptr.is_null() || *out_pos_ptr > out_size + || check as c_uint > LZMA_CHECK_ID_MAX as c_uint + || in_0.is_null() && in_size != 0 as size_t + || out.is_null() + || out_pos_ptr.is_null() + || *out_pos_ptr > out_size { return LZMA_PROG_ERROR; } @@ -208,14 +183,12 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( return LZMA_UNSUPPORTED_CHECK; } let mut out_pos: size_t = *out_pos_ptr; - if out_size.wrapping_sub(out_pos) - <= (2 as ::core::ffi::c_int * LZMA_STREAM_HEADER_SIZE) as size_t - { + if out_size.wrapping_sub(out_pos) <= (2 as c_int * LZMA_STREAM_HEADER_SIZE) as size_t { return LZMA_BUF_ERROR; } out_size = out_size.wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); let mut stream_flags: lzma_stream_flags = lzma_stream_flags { - version: 0 as uint32_t, + version: 0 as u32, backward_size: 0, check: check, reserved_enum1: LZMA_RESERVED_ENUM, @@ -233,23 +206,23 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( reserved_int1: 0, reserved_int2: 0, }; - if lzma_stream_header_encode(&raw mut stream_flags, out.offset(out_pos as isize)) - as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + if lzma_stream_header_encode(&raw mut stream_flags, out.offset(out_pos as isize)) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); let mut block: lzma_block = lzma_block { - version: 0 as uint32_t, + version: 0 as u32, header_size: 0, check: check, compressed_size: 0, uncompressed_size: 0, filters: filters, raw_check: [0; 64], - reserved_ptr1: ::core::ptr::null_mut::<::core::ffi::c_void>(), - reserved_ptr2: ::core::ptr::null_mut::<::core::ffi::c_void>(), - reserved_ptr3: ::core::ptr::null_mut::<::core::ffi::c_void>(), + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr3: ::core::ptr::null_mut::(), reserved_int1: 0, reserved_int2: 0, reserved_int3: 0, @@ -281,9 +254,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( &raw mut out_pos, out_size, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } } @@ -300,18 +271,16 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( block.uncompressed_size, ); } - if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_OK as c_uint { ret = lzma_index_buffer_encode(i, out, &raw mut out_pos, out_size); stream_flags.backward_size = lzma_index_size(i); } lzma_index_end(i, allocator); - if ret as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_OK as c_uint { return ret; } - if lzma_stream_footer_encode(&raw mut stream_flags, out.offset(out_pos as isize)) - as ::core::ffi::c_uint != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + if lzma_stream_footer_encode(&raw mut stream_flags, out.offset(out_pos as isize)) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 3f625e4b..f6aff12c 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -1,18 +1,16 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; #[repr(C)] -pub struct lzma_index_hash_s { _opaque: [u8; 0] } +pub struct lzma_index_hash_s { + _opaque: [u8; 0], +} extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); - fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> uint64_t; - fn lzma_stream_header_decode( - options: *mut lzma_stream_flags, - in_0: *const uint8_t, - ) -> lzma_ret; - fn lzma_stream_footer_decode( - options: *mut lzma_stream_flags, - in_0: *const uint8_t, - ) -> lzma_ret; + fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; + fn lzma_stream_header_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; + fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; fn lzma_stream_flags_compare( a: *const lzma_stream_flags, b: *const lzma_stream_flags, @@ -20,17 +18,14 @@ extern "C" { fn lzma_block_header_decode( block: *mut lzma_block, allocator: *const lzma_allocator, - in_0: *const uint8_t, + in_0: *const u8, ) -> lzma_ret; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; fn lzma_index_hash_init( index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator, ) -> *mut lzma_index_hash; - fn lzma_index_hash_end( - index_hash: *mut lzma_index_hash, - allocator: *const lzma_allocator, - ); + fn lzma_index_hash_end(index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator); fn lzma_index_hash_append( index_hash: *mut lzma_index_hash, unpadded_size: lzma_vli, @@ -38,23 +33,20 @@ extern "C" { ) -> lzma_ret; fn lzma_index_hash_decode( index_hash: *mut lzma_index_hash, - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, ) -> lzma_ret; fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -64,16 +56,7 @@ extern "C" { block: *mut lzma_block, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -95,7 +78,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -104,17 +86,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -125,7 +99,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -137,68 +111,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -208,20 +157,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -235,8 +184,8 @@ pub struct lzma_stream_coder { pub block_options: lzma_block, pub stream_flags: lzma_stream_flags, pub index_hash: *mut lzma_index_hash, - pub memlimit: uint64_t, - pub memusage: uint64_t, + pub memlimit: u64, + pub memusage: u64, pub tell_no_check: bool, pub tell_unsupported_check: bool, pub tell_any_check: bool, @@ -244,13 +193,13 @@ pub struct lzma_stream_coder { pub concatenated: bool, pub first_stream: bool, pub pos: size_t, - pub buffer: [uint8_t; 1024], + pub buffer: [u8; 1024], } pub type lzma_index_hash = lzma_index_hash_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -265,24 +214,24 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -302,7 +251,7 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub type C2RustUnnamed_0 = c_uint; pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 6; pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; pub const SEQ_INDEX: C2RustUnnamed_0 = 4; @@ -310,28 +259,27 @@ pub const SEQ_BLOCK_RUN: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_NO_CHECK: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; -pub const LZMA_TELL_UNSUPPORTED_CHECK: ::core::ffi::c_uint = 0x2 as ::core::ffi::c_uint; -pub const LZMA_TELL_ANY_CHECK: ::core::ffi::c_uint = 0x4 as ::core::ffi::c_uint; -pub const LZMA_IGNORE_CHECK: ::core::ffi::c_uint = 0x10 as ::core::ffi::c_uint; -pub const LZMA_CONCATENATED: ::core::ffi::c_uint = 0x8 as ::core::ffi::c_uint; -pub const LZMA_FAIL_FAST: ::core::ffi::c_uint = 0x20 as ::core::ffi::c_uint; -pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; -pub const LZMA_MEMUSAGE_BASE: ::core::ffi::c_ulonglong = (1 as ::core::ffi::c_ulonglong) - << 15 as ::core::ffi::c_int; -pub const LZMA_SUPPORTED_FLAGS: ::core::ffi::c_uint = LZMA_TELL_NO_CHECK - | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK | LZMA_IGNORE_CHECK - | LZMA_CONCATENATED | LZMA_FAIL_FAST; -pub const INDEX_INDICATOR: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1 as c_uint; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2 as c_uint; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10 as c_uint; +pub const LZMA_CONCATENATED: c_uint = 0x8 as c_uint; +pub const LZMA_FAIL_FAST: c_uint = 0x20 as c_uint; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK + | LZMA_TELL_UNSUPPORTED_CHECK + | LZMA_TELL_ANY_CHECK + | LZMA_IGNORE_CHECK + | LZMA_CONCATENATED + | LZMA_FAIL_FAST; +pub const INDEX_INDICATOR: c_int = 0 as c_int; unsafe extern "C" fn stream_decoder_reset( mut coder: *mut lzma_stream_coder, mut allocator: *const lzma_allocator, @@ -345,12 +293,12 @@ unsafe extern "C" fn stream_decoder_reset( return LZMA_OK; } unsafe extern "C" fn stream_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -358,13 +306,13 @@ unsafe extern "C" fn stream_decode( let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; loop { let mut current_block_100: u64; - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { lzma_bufcpy( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, &raw mut (*coder).pos, LZMA_STREAM_HEADER_SIZE as size_t, ); @@ -374,30 +322,26 @@ unsafe extern "C" fn stream_decode( (*coder).pos = 0 as size_t; let ret: lzma_ret = lzma_stream_header_decode( &raw mut (*coder).stream_flags, - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { - return (if ret as ::core::ffi::c_uint - == LZMA_FORMAT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + if ret as c_uint != LZMA_OK as c_uint { + return (if ret as c_uint == LZMA_FORMAT_ERROR as c_uint && !(*coder).first_stream { - LZMA_DATA_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + LZMA_DATA_ERROR as c_uint } else { - ret as ::core::ffi::c_uint + ret as c_uint }) as lzma_ret; } (*coder).first_stream = false_0 != 0; (*coder).block_options.check = (*coder).stream_flags.check; (*coder).sequence = SEQ_BLOCK_HEADER; - if (*coder).tell_no_check as ::core::ffi::c_int != 0 - && (*coder).stream_flags.check as ::core::ffi::c_uint - == LZMA_CHECK_NONE as ::core::ffi::c_int as ::core::ffi::c_uint + if (*coder).tell_no_check as c_int != 0 + && (*coder).stream_flags.check as c_uint == LZMA_CHECK_NONE as c_uint { return LZMA_NO_CHECK; } - if (*coder).tell_unsupported_check as ::core::ffi::c_int != 0 + if (*coder).tell_unsupported_check as c_int != 0 && lzma_check_is_supported((*coder).stream_flags.check) == 0 { return LZMA_UNSUPPORTED_CHECK; @@ -420,15 +364,9 @@ unsafe extern "C" fn stream_decode( if *in_pos >= in_size { return LZMA_OK; } - let ret_2: lzma_ret = lzma_index_hash_decode( - (*coder).index_hash, - in_0, - in_pos, - in_size, - ) as lzma_ret; - if ret_2 as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_2: lzma_ret = + lzma_index_hash_decode((*coder).index_hash, in_0, in_pos, in_size) as lzma_ret; + if ret_2 as c_uint != LZMA_STREAM_END as c_uint { return ret_2; } (*coder).sequence = SEQ_STREAM_FOOTER; @@ -448,16 +386,14 @@ unsafe extern "C" fn stream_decode( return LZMA_OK; } if (*coder).pos == 0 as size_t { - if *in_0.offset(*in_pos as isize) as ::core::ffi::c_int - == INDEX_INDICATOR - { + if *in_0.offset(*in_pos as isize) as c_int == INDEX_INDICATOR { (*coder).sequence = SEQ_INDEX; current_block_100 = 16789764818708874114; } else { - (*coder).block_options.header_size = (*in_0 - .offset(*in_pos as isize) as uint32_t) - .wrapping_add(1 as uint32_t) - .wrapping_mul(4 as uint32_t); + (*coder).block_options.header_size = (*in_0.offset(*in_pos as isize) + as u32) + .wrapping_add(1 as u32) + .wrapping_mul(4 as u32); current_block_100 = 13242334135786603907; } } else { @@ -470,7 +406,7 @@ unsafe extern "C" fn stream_decode( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, &raw mut (*coder).pos, (*coder).block_options.header_size as size_t, ); @@ -488,7 +424,7 @@ unsafe extern "C" fn stream_decode( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, &raw mut (*coder).pos, LZMA_STREAM_HEADER_SIZE as size_t, ); @@ -517,31 +453,23 @@ unsafe extern "C" fn stream_decode( }; let ret_3: lzma_ret = lzma_stream_footer_decode( &raw mut footer_flags, - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret_3 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { - return (if ret_3 as ::core::ffi::c_uint - == LZMA_FORMAT_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint - { - LZMA_DATA_ERROR as ::core::ffi::c_int as ::core::ffi::c_uint + if ret_3 as c_uint != LZMA_OK as c_uint { + return (if ret_3 as c_uint == LZMA_FORMAT_ERROR as c_uint { + LZMA_DATA_ERROR as c_uint } else { - ret_3 as ::core::ffi::c_uint + ret_3 as c_uint }) as lzma_ret; } - if lzma_index_hash_size((*coder).index_hash) - != footer_flags.backward_size - { + if lzma_index_hash_size((*coder).index_hash) != footer_flags.backward_size { return LZMA_DATA_ERROR; } let ret__1: lzma_ret = lzma_stream_flags_compare( &raw mut (*coder).stream_flags, &raw mut footer_flags, ) as lzma_ret; - if ret__1 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__1 as c_uint != LZMA_OK as c_uint { return ret__1; } if !(*coder).concatenated { @@ -556,20 +484,16 @@ unsafe extern "C" fn stream_decode( 15462640364611497761 => { loop { if *in_pos >= in_size { - if action as ::core::ffi::c_uint - != LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint - { + if action as c_uint != LZMA_FINISH as c_uint { return LZMA_OK; } return (if (*coder).pos == 0 as size_t { - LZMA_STREAM_END as ::core::ffi::c_int + LZMA_STREAM_END as c_int } else { - LZMA_DATA_ERROR as ::core::ffi::c_int + LZMA_DATA_ERROR as c_int }) as lzma_ret; } - if *in_0.offset(*in_pos as isize) as ::core::ffi::c_int - != 0 as ::core::ffi::c_int - { + if *in_0.offset(*in_pos as isize) as c_int != 0 as c_int { break; } *in_pos = (*in_pos).wrapping_add(1); @@ -579,38 +503,32 @@ unsafe extern "C" fn stream_decode( *in_pos = (*in_pos).wrapping_add(1); return LZMA_DATA_ERROR; } - let ret__2: lzma_ret = stream_decoder_reset(coder, allocator) - as lzma_ret; - if ret__2 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__2: lzma_ret = stream_decoder_reset(coder, allocator) as lzma_ret; + if ret__2 as c_uint != LZMA_OK as c_uint { return ret__2; } current_block_100 = 16789764818708874114; } 3500765272169221397 => { - (*coder).block_options.version = 1 as uint32_t; + (*coder).block_options.version = 1 as u32; let mut filters: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5]; (*coder).block_options.filters = &raw mut filters as *mut lzma_filter; let ret_: lzma_ret = lzma_block_header_decode( &raw mut (*coder).block_options, allocator, - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } (*coder).block_options.ignore_check = (*coder).ignore_check as lzma_bool; - let memusage: uint64_t = lzma_raw_decoder_memusage( - &raw mut filters as *mut lzma_filter, - ) as uint64_t; + let memusage: u64 = + lzma_raw_decoder_memusage(&raw mut filters as *mut lzma_filter) as u64; let mut ret_0: lzma_ret = LZMA_OK; - if memusage == UINT64_MAX as uint64_t { + if memusage == UINT64_MAX as u64 { ret_0 = LZMA_OPTIONS_ERROR; } else { (*coder).memusage = memusage; @@ -626,9 +544,7 @@ unsafe extern "C" fn stream_decode( } lzma_filters_free(&raw mut filters as *mut lzma_filter, allocator); (*coder).block_options.filters = ::core::ptr::null_mut::(); - if ret_0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_0 as c_uint != LZMA_OK as c_uint { return ret_0; } (*coder).sequence = SEQ_BLOCK_RUN; @@ -641,9 +557,7 @@ unsafe extern "C" fn stream_decode( let ret_1: lzma_ret = (*coder) .block_decoder .code - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).block_decoder.coder, allocator, in_0, @@ -654,9 +568,7 @@ unsafe extern "C" fn stream_decode( out_size, action, ) as lzma_ret; - if ret_1 as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_1 as c_uint != LZMA_STREAM_END as c_uint { return ret_1; } let ret__0: lzma_ret = lzma_index_hash_append( @@ -664,42 +576,38 @@ unsafe extern "C" fn stream_decode( lzma_block_unpadded_size(&raw mut (*coder).block_options), (*coder).block_options.uncompressed_size, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { return ret__0; } (*coder).sequence = SEQ_BLOCK_HEADER; } _ => {} } - }; + } } unsafe extern "C" fn stream_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; lzma_next_end(&raw mut (*coder).block_decoder, allocator); lzma_index_hash_end((*coder).index_hash, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } -unsafe extern "C" fn stream_decoder_get_check( - mut coder_ptr: *const ::core::ffi::c_void, -) -> lzma_check { +unsafe extern "C" fn stream_decoder_get_check(mut coder_ptr: *const c_void) -> lzma_check { let mut coder: *const lzma_stream_coder = coder_ptr as *const lzma_stream_coder; return (*coder).stream_flags.check; } unsafe extern "C" fn stream_decoder_memconfig( - mut coder_ptr: *mut ::core::ffi::c_void, - mut memusage: *mut uint64_t, - mut old_memlimit: *mut uint64_t, - mut new_memlimit: uint64_t, + mut coder_ptr: *mut c_void, + mut memusage: *mut u64, + mut old_memlimit: *mut u64, + mut new_memlimit: u64, ) -> lzma_ret { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; *memusage = (*coder).memusage; *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as uint64_t { + if new_memlimit != 0 as u64 { if new_memlimit < (*coder).memusage { return LZMA_MEMLIMIT_ERROR; } @@ -711,55 +619,41 @@ unsafe extern "C" fn stream_decoder_memconfig( pub unsafe extern "C" fn lzma_stream_decoder_init( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, - mut memlimit: uint64_t, - mut flags: uint32_t, + mut memlimit: u64, + mut flags: u32, ) -> lzma_ret { if ::core::mem::transmute::< Option< - unsafe extern "C" fn( + unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, + >, + uintptr_t, + >(Some( + lzma_stream_decoder_init + as unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, - uint32_t, + u64, + u32, ) -> lzma_ret, - >, - uintptr_t, - >( - Some( - lzma_stream_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - uint32_t, - ) -> lzma_ret, - ), - ) != (*next).init + )) != (*next).init { lzma_next_end(next, allocator); } (*next).init = ::core::mem::transmute::< Option< - unsafe extern "C" fn( + unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, + >, + uintptr_t, + >(Some( + lzma_stream_decoder_init + as unsafe extern "C" fn( *mut lzma_next_coder, *const lzma_allocator, - uint64_t, - uint32_t, + u64, + u32, ) -> lzma_ret, - >, - uintptr_t, - >( - Some( - lzma_stream_decoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - uint64_t, - uint32_t, - ) -> lzma_ret, - ), - ); - if flags & !(LZMA_SUPPORTED_FLAGS as uint32_t) != 0 { + )); + if flags & !(LZMA_SUPPORTED_FLAGS as u32) != 0 { return LZMA_OPTIONS_ERROR; } let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; @@ -771,53 +665,36 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( stream_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - stream_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + stream_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; - (*next).get_check = Some( - stream_decoder_get_check - as unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - ) as Option lzma_check>; + (*next).get_check = + Some(stream_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check) + as Option lzma_check>; (*next).memconfig = Some( stream_decoder_memconfig - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >; + as Option lzma_ret>; (*coder).block_decoder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -828,27 +705,28 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( }; (*coder).index_hash = ::core::ptr::null_mut::(); } - (*coder).memlimit = if 1 as uint64_t > memlimit { 1 as uint64_t } else { memlimit }; - (*coder).memusage = LZMA_MEMUSAGE_BASE as uint64_t; - (*coder).tell_no_check = flags & LZMA_TELL_NO_CHECK as uint32_t != 0 as uint32_t; - (*coder).tell_unsupported_check = flags & LZMA_TELL_UNSUPPORTED_CHECK as uint32_t - != 0 as uint32_t; - (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as uint32_t != 0 as uint32_t; - (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as uint32_t != 0 as uint32_t; - (*coder).concatenated = flags & LZMA_CONCATENATED as uint32_t != 0 as uint32_t; + (*coder).memlimit = if 1 as u64 > memlimit { + 1 as u64 + } else { + memlimit + }; + (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; + (*coder).tell_no_check = flags & LZMA_TELL_NO_CHECK as u32 != 0 as u32; + (*coder).tell_unsupported_check = flags & LZMA_TELL_UNSUPPORTED_CHECK as u32 != 0 as u32; + (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as u32 != 0 as u32; + (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as u32 != 0 as u32; + (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0 as u32; (*coder).first_stream = true_0 != 0; return stream_decoder_reset(coder, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder( mut strm: *mut lzma_stream, - mut memlimit: uint64_t, - mut flags: uint32_t, + mut memlimit: u64, + mut flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = lzma_stream_decoder_init( @@ -857,15 +735,11 @@ pub unsafe extern "C" fn lzma_stream_decoder( memlimit, flags, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs new file mode 100644 index 00000000..58c70caf --- /dev/null +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -0,0 +1,2151 @@ +use crate::types::*; +use core::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; +pub enum lzma_index_hash_s {} +extern "C" { + fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; + fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; + fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; + fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> c_int; + fn pthread_cond_signal(_: *mut pthread_cond_t) -> c_int; + fn pthread_cond_timedwait( + _: *mut pthread_cond_t, + _: *mut pthread_mutex_t, + _: *const timespec, + ) -> c_int; + fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> c_int; + fn pthread_create( + _: *mut pthread_t, + _: *const pthread_attr_t, + _: Option *mut c_void>, + _: *mut c_void, + ) -> c_int; + fn pthread_join(_: pthread_t, _: *mut *mut c_void) -> c_int; + fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> c_int; + fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> c_int; + fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> c_int; + fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> c_int; + fn pthread_sigmask(_: c_int, _: *const sigset_t, _: *mut sigset_t) -> c_int; + fn lzma_end(strm: *mut lzma_stream); + fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; + fn lzma_check_size(check: lzma_check) -> u32; + fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); + fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; + fn lzma_stream_header_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; + fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; + fn lzma_stream_flags_compare( + a: *const lzma_stream_flags, + b: *const lzma_stream_flags, + ) -> lzma_ret; + fn lzma_block_header_decode( + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const u8, + ) -> lzma_ret; + fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; + fn lzma_index_hash_init( + index_hash: *mut lzma_index_hash, + allocator: *const lzma_allocator, + ) -> *mut lzma_index_hash; + fn lzma_index_hash_end(index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator); + fn lzma_index_hash_append( + index_hash: *mut lzma_index_hash, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, + ) -> lzma_ret; + fn lzma_index_hash_decode( + index_hash: *mut lzma_index_hash, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_block_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, + ) -> lzma_ret; + fn lzma_outq_init( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + threads: u32, + ) -> lzma_ret; + fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator); + fn lzma_outq_clear_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator); + fn lzma_outq_clear_cache2( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + keep_size: size_t, + ); + fn lzma_outq_prealloc_buf( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + size: size_t, + ) -> lzma_ret; + fn lzma_outq_get_buf(outq: *mut lzma_outq, worker: *mut c_void) -> *mut lzma_outbuf; + fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool; + fn lzma_outq_read( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + unpadded_size: *mut lzma_vli, + uncompressed_size: *mut lzma_vli, + ) -> lzma_ret; + fn lzma_outq_enable_partial_output( + outq: *mut lzma_outq, + enable_partial_output: Option ()>, + ); +} +pub type __uint32_t = u32; +pub type __darwin_time_t = c_long; +pub type __darwin_sigset_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __darwin_pthread_handler_rec { + pub __routine: Option ()>, + pub __arg: *mut c_void, + pub __next: *mut __darwin_pthread_handler_rec, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_attr_t { + pub __sig: c_long, + pub __opaque: [c_char; 56], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_cond_t { + pub __sig: c_long, + pub __opaque: [c_char; 40], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_condattr_t { + pub __sig: c_long, + pub __opaque: [c_char; 8], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_mutex_t { + pub __sig: c_long, + pub __opaque: [c_char; 56], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_mutexattr_t { + pub __sig: c_long, + pub __opaque: [c_char; 8], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_t { + pub __sig: c_long, + pub __cleanup_stack: *mut __darwin_pthread_handler_rec, + pub __opaque: [c_char; 8176], +} +pub type __darwin_pthread_attr_t = _opaque_pthread_attr_t; +pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; +pub type __darwin_pthread_condattr_t = _opaque_pthread_condattr_t; +pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; +pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t; +pub type __darwin_pthread_t = *mut _opaque_pthread_t; +pub type pthread_attr_t = __darwin_pthread_attr_t; +pub type sigset_t = __darwin_sigset_t; +pub type time_t = __darwin_time_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct timespec { + pub tv_sec: __darwin_time_t, + pub tv_nsec: c_long, +} +pub type clockid_t = c_uint; +pub const _CLOCK_THREAD_CPUTIME_ID: clockid_t = 16; +pub const _CLOCK_PROCESS_CPUTIME_ID: clockid_t = 12; +pub const _CLOCK_UPTIME_RAW_APPROX: clockid_t = 9; +pub const _CLOCK_UPTIME_RAW: clockid_t = 8; +pub const _CLOCK_MONOTONIC_RAW_APPROX: clockid_t = 5; +pub const _CLOCK_MONOTONIC_RAW: clockid_t = 4; +pub const _CLOCK_MONOTONIC: clockid_t = 6; +pub const _CLOCK_REALTIME: clockid_t = 0; +pub type pthread_cond_t = __darwin_pthread_cond_t; +pub type pthread_condattr_t = __darwin_pthread_condattr_t; +pub type pthread_mutex_t = __darwin_pthread_mutex_t; +pub type pthread_mutexattr_t = __darwin_pthread_mutexattr_t; +pub type pthread_t = __darwin_pthread_t; +pub type mythread = pthread_t; +pub type mythread_mutex = pthread_mutex_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mythread_cond { + pub cond: pthread_cond_t, + pub clk_id: clockid_t, +} +pub type mythread_condtime = timespec; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, + pub update: Option< + unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option lzma_ret>, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut c_void, +} +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option ()>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const u8, + *mut size_t, + size_t, + *mut u8, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const u8, + pub avail_in: size_t, + pub total_in: u64, + pub next_out: *mut u8, + pub avail_out: size_t, + pub total_out: u64, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mt { + pub flags: u32, + pub threads: u32, + pub block_size: u64, + pub timeout: u32, + pub preset: u32, + pub filters: *const lzma_filter, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub memlimit_threading: u64, + pub memlimit_stop: u64, + pub reserved_int7: u64, + pub reserved_int8: u64, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_coder { + pub sequence: C2RustUnnamed_0, + pub block_decoder: lzma_next_coder, + pub block_options: lzma_block, + pub filters: [lzma_filter; 5], + pub stream_flags: lzma_stream_flags, + pub index_hash: *mut lzma_index_hash, + pub timeout: u32, + pub thread_error: lzma_ret, + pub pending_error: lzma_ret, + pub threads_max: u32, + pub threads_initialized: u32, + pub threads: *mut worker_thread, + pub threads_free: *mut worker_thread, + pub thr: *mut worker_thread, + pub outq: lzma_outq, + pub mutex: mythread_mutex, + pub cond: mythread_cond, + pub memlimit_threading: u64, + pub memlimit_stop: u64, + pub mem_direct_mode: u64, + pub mem_in_use: u64, + pub mem_cached: u64, + pub mem_next_filters: u64, + pub mem_next_in: u64, + pub mem_next_block: u64, + pub progress_in: u64, + pub progress_out: u64, + pub tell_no_check: bool, + pub tell_unsupported_check: bool, + pub tell_any_check: bool, + pub ignore_check: bool, + pub concatenated: bool, + pub fail_fast: bool, + pub first_stream: bool, + pub out_was_filled: bool, + pub pos: size_t, + pub buffer: [u8; 1024], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_outq { + pub head: *mut lzma_outbuf, + pub tail: *mut lzma_outbuf, + pub read_pos: size_t, + pub cache: *mut lzma_outbuf, + pub mem_allocated: u64, + pub mem_in_use: u64, + pub bufs_in_use: u32, + pub bufs_allocated: u32, + pub bufs_limit: u32, +} +pub type lzma_outbuf = lzma_outbuf_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_outbuf_s { + pub next: *mut lzma_outbuf, + pub worker: *mut c_void, + pub allocated: size_t, + pub pos: size_t, + pub decoder_in_pos: size_t, + pub finished: bool, + pub finish_ret: lzma_ret, + pub unpadded_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub buf: [u8; 0], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct worker_thread { + pub state: worker_state, + pub in_0: *mut u8, + pub in_size: size_t, + pub in_filled: size_t, + pub in_pos: size_t, + pub out_pos: size_t, + pub coder: *mut lzma_stream_coder, + pub allocator: *const lzma_allocator, + pub outbuf: *mut lzma_outbuf, + pub progress_in: size_t, + pub progress_out: size_t, + pub partial_update_enabled: bool, + pub partial_update_started: bool, + pub block_decoder: lzma_next_coder, + pub block_options: lzma_block, + pub mem_filters: u64, + pub next: *mut worker_thread, + pub mutex: mythread_mutex, + pub cond: mythread_cond, + pub thread_id: mythread, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: u32, + pub header_size: u32, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub type worker_state = c_uint; +pub const THR_EXIT: worker_state = 2; +pub const THR_RUN: worker_state = 1; +pub const THR_IDLE: worker_state = 0; +pub type lzma_index_hash = lzma_index_hash_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: u32, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: u32, + pub reserved_int2: u32, +} +pub type C2RustUnnamed_0 = c_uint; +pub const SEQ_ERROR: C2RustUnnamed_0 = 11; +pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 10; +pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 9; +pub const SEQ_INDEX_DECODE: C2RustUnnamed_0 = 8; +pub const SEQ_INDEX_WAIT_OUTPUT: C2RustUnnamed_0 = 7; +pub const SEQ_BLOCK_DIRECT_RUN: C2RustUnnamed_0 = 6; +pub const SEQ_BLOCK_DIRECT_INIT: C2RustUnnamed_0 = 5; +pub const SEQ_BLOCK_THR_RUN: C2RustUnnamed_0 = 4; +pub const SEQ_BLOCK_THR_INIT: C2RustUnnamed_0 = 3; +pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; +pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; +pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; +pub const SIZE_MAX: c_ulong = UINTPTR_MAX; +pub const SIG_SETMASK: c_int = 3 as c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const MYTHREAD_RET_VALUE: *mut c_void = NULL; +#[inline] +unsafe extern "C" fn mythread_sigmask( + mut how: c_int, + mut set: *const sigset_t, + mut oset: *mut sigset_t, +) { + let mut ret: c_int = pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t); +} +#[inline] +unsafe extern "C" fn mythread_create( + mut thread: *mut mythread, + mut func: Option *mut c_void>, + mut arg: *mut c_void, +) -> c_int { + let mut old: sigset_t = 0; + let mut all: sigset_t = 0; + all = !(0 as sigset_t); + mythread_sigmask(SIG_SETMASK, &raw mut all, &raw mut old); + let ret: c_int = pthread_create( + thread as *mut pthread_t, + ::core::ptr::null::(), + func as Option *mut c_void>, + arg as *mut c_void, + ) as c_int; + mythread_sigmask( + SIG_SETMASK, + &raw mut old, + ::core::ptr::null_mut::(), + ); + return ret; +} +#[inline] +unsafe extern "C" fn mythread_join(mut thread: mythread) -> c_int { + return pthread_join(thread as pthread_t, ::core::ptr::null_mut::<*mut c_void>()); +} +#[inline] +unsafe extern "C" fn mythread_mutex_init(mut mutex: *mut mythread_mutex) -> c_int { + return pthread_mutex_init( + mutex as *mut pthread_mutex_t, + ::core::ptr::null::(), + ); +} +#[inline] +unsafe extern "C" fn mythread_mutex_destroy(mut mutex: *mut mythread_mutex) { + let mut ret: c_int = pthread_mutex_destroy(mutex as *mut pthread_mutex_t); +} +#[inline] +unsafe extern "C" fn mythread_mutex_lock(mut mutex: *mut mythread_mutex) { + let mut ret: c_int = pthread_mutex_lock(mutex as *mut pthread_mutex_t); +} +#[inline] +unsafe extern "C" fn mythread_mutex_unlock(mut mutex: *mut mythread_mutex) { + let mut ret: c_int = pthread_mutex_unlock(mutex as *mut pthread_mutex_t); +} +#[inline] +unsafe extern "C" fn mythread_cond_init(mut mycond: *mut mythread_cond) -> c_int { + (*mycond).clk_id = _CLOCK_REALTIME; + return pthread_cond_init( + &raw mut (*mycond).cond, + ::core::ptr::null::(), + ); +} +#[inline] +unsafe extern "C" fn mythread_cond_destroy(mut cond: *mut mythread_cond) { + let mut ret: c_int = pthread_cond_destroy(&raw mut (*cond).cond); +} +#[inline] +unsafe extern "C" fn mythread_cond_signal(mut cond: *mut mythread_cond) { + let mut ret: c_int = pthread_cond_signal(&raw mut (*cond).cond); +} +#[inline] +unsafe extern "C" fn mythread_cond_wait( + mut cond: *mut mythread_cond, + mut mutex: *mut mythread_mutex, +) { + let mut ret: c_int = pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t); +} +#[inline] +unsafe extern "C" fn mythread_cond_timedwait( + mut cond: *mut mythread_cond, + mut mutex: *mut mythread_mutex, + mut condtime: *const mythread_condtime, +) -> c_int { + let mut ret: c_int = pthread_cond_timedwait( + &raw mut (*cond).cond, + mutex as *mut pthread_mutex_t, + condtime as *const timespec, + ); + return ret; +} +#[inline] +unsafe extern "C" fn mythread_condtime_set( + mut condtime: *mut mythread_condtime, + mut cond: *const mythread_cond, + mut timeout_ms: u32, +) { + (*condtime).tv_sec = timeout_ms.wrapping_div(1000 as u32) as time_t as __darwin_time_t; + (*condtime).tv_nsec = timeout_ms + .wrapping_rem(1000 as u32) + .wrapping_mul(1000000 as u32) as c_long; + let mut now: timespec = timespec { + tv_sec: 0, + tv_nsec: 0, + }; + let mut ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); + (*condtime).tv_sec += now.tv_sec; + (*condtime).tv_nsec += now.tv_nsec; + if (*condtime).tv_nsec >= 1000000000 as c_long { + (*condtime).tv_nsec -= 1000000000 as c_long; + (*condtime).tv_sec += 1; + } +} +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1 as c_uint; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2 as c_uint; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10 as c_uint; +pub const LZMA_CONCATENATED: c_uint = 0x8 as c_uint; +pub const LZMA_FAIL_FAST: c_uint = 0x20 as c_uint; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK + | LZMA_TELL_UNSUPPORTED_CHECK + | LZMA_TELL_ANY_CHECK + | LZMA_IGNORE_CHECK + | LZMA_CONCATENATED + | LZMA_FAIL_FAST; +pub const INDEX_INDICATOR: c_int = 0 as c_int; +#[inline] +unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { + return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); +} +#[inline] +unsafe extern "C" fn lzma_outq_has_buf(mut outq: *const lzma_outq) -> bool { + return (*outq).bufs_in_use < (*outq).bufs_limit; +} +#[inline] +unsafe extern "C" fn lzma_outq_is_empty(mut outq: *const lzma_outq) -> bool { + return (*outq).bufs_in_use == 0 as u32; +} +#[inline] +unsafe extern "C" fn lzma_outq_outbuf_memusage(mut buf_size: size_t) -> u64 { + return (::core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; +} +unsafe extern "C" fn worker_enable_partial_update(mut thr_ptr: *mut c_void) { + let mut thr: *mut worker_thread = thr_ptr as *mut worker_thread; + let mut mythread_i_325: c_uint = 0 as c_uint; + while if mythread_i_325 != 0 { + mythread_mutex_unlock(&raw mut (*thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_325: c_uint = 0 as c_uint; + while mythread_j_325 == 0 { + (*thr).partial_update_enabled = true_0 != 0; + mythread_cond_signal(&raw mut (*thr).cond); + mythread_j_325 = 1 as c_uint; + } + mythread_i_325 = 1 as c_uint; + } +} +unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { + let mut thr: *mut worker_thread = thr_ptr as *mut worker_thread; + let mut in_filled: size_t = 0; + let mut partial_update_enabled: bool = false; + let mut ret: lzma_ret = LZMA_OK; + loop { + mythread_mutex_lock(&raw mut (*thr).mutex); + loop { + if (*thr).state as c_uint == THR_IDLE as c_uint { + mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + } else { + if (*thr).state as c_uint == THR_EXIT as c_uint { + mythread_mutex_unlock(&raw mut (*thr).mutex); + lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); + lzma_next_end(&raw mut (*thr).block_decoder, (*thr).allocator); + mythread_mutex_destroy(&raw mut (*thr).mutex); + mythread_cond_destroy(&raw mut (*thr).cond); + return MYTHREAD_RET_VALUE; + } + (*thr).progress_in = (*thr).in_pos; + (*thr).progress_out = (*thr).out_pos; + in_filled = (*thr).in_filled; + partial_update_enabled = (*thr).partial_update_enabled; + if !(in_filled == (*thr).in_pos + && !(partial_update_enabled as c_int != 0 && !(*thr).partial_update_started)) + { + break; + } + mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + } + } + mythread_mutex_unlock(&raw mut (*thr).mutex); + let chunk_size: size_t = 16384 as size_t; + if in_filled.wrapping_sub((*thr).in_pos) > chunk_size { + in_filled = (*thr).in_pos.wrapping_add(chunk_size); + } + ret = (*thr) + .block_decoder + .code + .expect("non-null function pointer")( + (*thr).block_decoder.coder, + (*thr).allocator, + (*thr).in_0, + &raw mut (*thr).in_pos, + in_filled, + &raw mut (*(*thr).outbuf).buf as *mut u8, + &raw mut (*thr).out_pos, + (*(*thr).outbuf).allocated, + LZMA_RUN, + ); + if ret as c_uint == LZMA_OK as c_uint { + if partial_update_enabled { + (*thr).partial_update_started = true_0 != 0; + let mut mythread_i_415: c_uint = 0 as c_uint; + while if mythread_i_415 != 0 { + mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_415: c_uint = 0 as c_uint; + while mythread_j_415 == 0 { + (*(*thr).outbuf).pos = (*thr).out_pos; + (*(*thr).outbuf).decoder_in_pos = (*thr).in_pos; + mythread_cond_signal(&raw mut (*(*thr).coder).cond); + mythread_j_415 = 1 as c_uint; + } + mythread_i_415 = 1 as c_uint; + } + } + } else { + let mut mythread_i_434: c_uint = 0 as c_uint; + while if mythread_i_434 != 0 { + mythread_mutex_unlock(&raw mut (*thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_434: c_uint = 0 as c_uint; + while mythread_j_434 == 0 { + if ret as c_uint == LZMA_STREAM_END as c_uint + && (*thr).in_filled != (*thr).in_size + { + ret = LZMA_PROG_ERROR; + } + if (*thr).state as c_uint != THR_EXIT as c_uint { + (*thr).state = THR_IDLE; + } + mythread_j_434 = 1 as c_uint; + } + mythread_i_434 = 1 as c_uint; + } + if ret as c_uint == LZMA_STREAM_END as c_uint { + lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); + (*thr).in_0 = ::core::ptr::null_mut::(); + } + let mut mythread_i_458: c_uint = 0 as c_uint; + while if mythread_i_458 != 0 { + mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_458: c_uint = 0 as c_uint; + while mythread_j_458 == 0 { + (*(*thr).coder).progress_in = (*(*thr).coder) + .progress_in + .wrapping_add((*thr).in_pos as u64); + (*(*thr).coder).progress_out = (*(*thr).coder) + .progress_out + .wrapping_add((*thr).out_pos as u64); + (*thr).progress_in = 0 as size_t; + (*thr).progress_out = 0 as size_t; + (*(*thr).outbuf).pos = (*thr).out_pos; + (*(*thr).outbuf).decoder_in_pos = (*thr).in_pos; + (*(*thr).outbuf).finished = true_0 != 0; + (*(*thr).outbuf).finish_ret = ret; + (*thr).outbuf = ::core::ptr::null_mut::(); + if ret as c_uint != LZMA_STREAM_END as c_uint + && (*(*thr).coder).thread_error as c_uint == LZMA_OK as c_uint + { + (*(*thr).coder).thread_error = ret; + } + if ret as c_uint == LZMA_STREAM_END as c_uint { + (*(*thr).coder).mem_in_use = (*(*thr).coder) + .mem_in_use + .wrapping_sub((*thr).in_size as u64); + (*(*thr).coder).mem_in_use = + (*(*thr).coder).mem_in_use.wrapping_sub((*thr).mem_filters); + (*(*thr).coder).mem_cached = + (*(*thr).coder).mem_cached.wrapping_add((*thr).mem_filters); + (*thr).next = (*(*thr).coder).threads_free; + (*(*thr).coder).threads_free = thr; + } + mythread_cond_signal(&raw mut (*(*thr).coder).cond); + mythread_j_458 = 1 as c_uint; + } + mythread_i_458 = 1 as c_uint; + } + } + } +} +unsafe extern "C" fn threads_end( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) { + let mut i: u32 = 0 as u32; + while i < (*coder).threads_initialized { + let mut mythread_i_502: c_uint = 0 as c_uint; + while if mythread_i_502 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_502: c_uint = 0 as c_uint; + while mythread_j_502 == 0 { + (*(*coder).threads.offset(i as isize)).state = THR_EXIT; + mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); + mythread_j_502 = 1 as c_uint; + } + mythread_i_502 = 1 as c_uint; + } + i = i.wrapping_add(1); + } + let mut i_0: u32 = 0 as u32; + while i_0 < (*coder).threads_initialized { + mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); + i_0 = i_0.wrapping_add(1); + } + lzma_free((*coder).threads as *mut c_void, allocator); + (*coder).threads_initialized = 0 as u32; + (*coder).threads = ::core::ptr::null_mut::(); + (*coder).threads_free = ::core::ptr::null_mut::(); + (*coder).mem_in_use = 0 as u64; + (*coder).mem_cached = 0 as u64; +} +unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder) { + let mut i: u32 = 0 as u32; + while i < (*coder).threads_initialized { + let mut mythread_i_538: c_uint = 0 as c_uint; + while if mythread_i_538 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_538: c_uint = 0 as c_uint; + while mythread_j_538 == 0 { + (*(*coder).threads.offset(i as isize)).state = THR_IDLE; + mythread_j_538 = 1 as c_uint; + } + mythread_i_538 = 1 as c_uint; + } + i = i.wrapping_add(1); + } +} +unsafe extern "C" fn initialize_new_thread( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + if (*coder).threads.is_null() { + (*coder).threads = lzma_alloc( + ((*coder).threads_max as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + allocator, + ) as *mut worker_thread; + if (*coder).threads.is_null() { + return LZMA_MEM_ERROR; + } + } + let mut thr: *mut worker_thread = (*coder) + .threads + .offset((*coder).threads_initialized as isize) + as *mut worker_thread; + if !(mythread_mutex_init(&raw mut (*thr).mutex) != 0) { + if !(mythread_cond_init(&raw mut (*thr).cond) != 0) { + (*thr).state = THR_IDLE; + (*thr).in_0 = ::core::ptr::null_mut::(); + (*thr).in_size = 0 as size_t; + (*thr).allocator = allocator; + (*thr).coder = coder as *mut lzma_stream_coder; + (*thr).outbuf = ::core::ptr::null_mut::(); + (*thr).block_decoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*thr).mem_filters = 0 as u64; + if mythread_create( + &raw mut (*thr).thread_id, + Some(worker_decoder as unsafe extern "C" fn(*mut c_void) -> *mut c_void), + thr as *mut c_void, + ) != 0 + { + mythread_cond_destroy(&raw mut (*thr).cond); + } else { + (*coder).threads_initialized = (*coder).threads_initialized.wrapping_add(1); + (*coder).thr = thr; + return LZMA_OK; + } + } + mythread_mutex_destroy(&raw mut (*thr).mutex); + } + return LZMA_MEM_ERROR; +} +unsafe extern "C" fn get_thread( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + let mut mythread_i_608: c_uint = 0 as c_uint; + while if mythread_i_608 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_608: c_uint = 0 as c_uint; + while mythread_j_608 == 0 { + if !(*coder).threads_free.is_null() { + (*coder).thr = (*coder).threads_free; + (*coder).threads_free = (*(*coder).threads_free).next; + (*coder).mem_cached = (*coder) + .mem_cached + .wrapping_sub((*(*coder).thr).mem_filters); + } + mythread_j_608 = 1 as c_uint; + } + mythread_i_608 = 1 as c_uint; + } + if (*coder).thr.is_null() { + let ret_: lzma_ret = initialize_new_thread(coder, allocator) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + } + (*(*coder).thr).in_filled = 0 as size_t; + (*(*coder).thr).in_pos = 0 as size_t; + (*(*coder).thr).out_pos = 0 as size_t; + (*(*coder).thr).progress_in = 0 as size_t; + (*(*coder).thr).progress_out = 0 as size_t; + (*(*coder).thr).partial_update_enabled = false_0 != 0; + (*(*coder).thr).partial_update_started = false_0 != 0; + return LZMA_OK; +} +unsafe extern "C" fn read_output_and_wait( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, + mut out: *mut u8, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut input_is_possible: *mut bool, + mut waiting_allowed: bool, + mut wait_abs: *mut mythread_condtime, + mut has_blocked: *mut bool, +) -> lzma_ret { + let mut ret: lzma_ret = LZMA_OK; + let mut mythread_i_654: c_uint = 0 as c_uint; + while if mythread_i_654 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_654: c_uint = 0 as c_uint; + while mythread_j_654 == 0 { + loop { + let out_start: size_t = *out_pos; + loop { + ret = lzma_outq_read( + &raw mut (*coder).outq, + allocator, + out, + out_pos, + out_size, + ::core::ptr::null_mut::(), + ::core::ptr::null_mut::(), + ); + if ret as c_uint == LZMA_STREAM_END as c_uint { + lzma_outq_enable_partial_output( + &raw mut (*coder).outq, + Some( + worker_enable_partial_update + as unsafe extern "C" fn(*mut c_void) -> (), + ), + ); + } + if !(ret as c_uint == LZMA_STREAM_END as c_uint) { + break; + } + } + if ret as c_uint != LZMA_OK as c_uint { + break; + } + if *out_pos == out_size && *out_pos != out_start { + (*coder).out_was_filled = true_0 != 0; + } + if (*coder).thread_error as c_uint != LZMA_OK as c_uint { + if (*coder).fail_fast { + ret = (*coder).thread_error; + break; + } else { + (*coder).pending_error = LZMA_PROG_ERROR; + } + } + if !input_is_possible.is_null() + && (*coder) + .memlimit_threading + .wrapping_sub((*coder).mem_in_use) + .wrapping_sub((*coder).outq.mem_in_use) + >= (*coder).mem_next_block + && lzma_outq_has_buf(&raw mut (*coder).outq) as c_int != 0 + && ((*coder).threads_initialized < (*coder).threads_max + || !(*coder).threads_free.is_null()) + { + *input_is_possible = true_0 != 0; + break; + } else { + if !waiting_allowed { + break; + } + if lzma_outq_is_empty(&raw mut (*coder).outq) { + break; + } + if lzma_outq_is_readable(&raw mut (*coder).outq) { + break; + } + if !(*coder).thr.is_null() + && (*(*coder).thr).partial_update_enabled as c_int != 0 + { + if (*(*(*coder).thr).outbuf).decoder_in_pos == (*(*coder).thr).in_filled { + break; + } + } + if (*coder).timeout != 0 as u32 { + if !*has_blocked { + *has_blocked = true_0 != 0; + mythread_condtime_set( + wait_abs, + &raw mut (*coder).cond, + (*coder).timeout, + ); + } + if mythread_cond_timedwait( + &raw mut (*coder).cond, + &raw mut (*coder).mutex, + wait_abs, + ) != 0 as c_int + { + ret = LZMA_RET_INTERNAL1; + break; + } + } else { + mythread_cond_wait(&raw mut (*coder).cond, &raw mut (*coder).mutex); + } + if !(ret as c_uint == LZMA_OK as c_uint) { + break; + } + } + } + mythread_j_654 = 1 as c_uint; + } + mythread_i_654 = 1 as c_uint; + } + if ret as c_uint != LZMA_OK as c_uint && ret as c_uint != LZMA_RET_INTERNAL1 as c_uint { + threads_stop(coder); + } + return ret; +} +unsafe extern "C" fn decode_block_header( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, + mut in_0: *const u8, + mut in_pos: *mut size_t, + mut in_size: size_t, +) -> lzma_ret { + if *in_pos >= in_size { + return LZMA_OK; + } + if (*coder).pos == 0 as size_t { + if *in_0.offset(*in_pos as isize) as c_int == INDEX_INDICATOR { + return LZMA_RET_INTERNAL2; + } + (*coder).block_options.header_size = (*in_0.offset(*in_pos as isize) as u32) + .wrapping_add(1 as u32) + .wrapping_mul(4 as u32); + } + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).buffer as *mut u8, + &raw mut (*coder).pos, + (*coder).block_options.header_size as size_t, + ); + if (*coder).pos < (*coder).block_options.header_size as size_t { + return LZMA_OK; + } + (*coder).pos = 0 as size_t; + (*coder).block_options.version = 1 as u32; + (*coder).block_options.filters = &raw mut (*coder).filters as *mut lzma_filter; + let ret_: lzma_ret = lzma_block_header_decode( + &raw mut (*coder).block_options, + allocator, + &raw mut (*coder).buffer as *mut u8, + ) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + (*coder).block_options.ignore_check = (*coder).ignore_check as lzma_bool; + return LZMA_STREAM_END; +} +unsafe extern "C" fn comp_blk_size(mut coder: *const lzma_stream_coder) -> size_t { + return vli_ceil4((*coder).block_options.compressed_size) + .wrapping_add(lzma_check_size((*coder).stream_flags.check) as lzma_vli) + as size_t; +} +unsafe extern "C" fn is_direct_mode_needed(mut size: lzma_vli) -> bool { + return size == LZMA_VLI_UNKNOWN as lzma_vli + || size > SIZE_MAX.wrapping_div(3 as c_ulong) as lzma_vli; +} +unsafe extern "C" fn stream_decoder_reset( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + (*coder).index_hash = lzma_index_hash_init((*coder).index_hash, allocator); + if (*coder).index_hash.is_null() { + return LZMA_MEM_ERROR; + } + (*coder).sequence = SEQ_STREAM_HEADER; + (*coder).pos = 0 as size_t; + return LZMA_OK; +} +unsafe extern "C" fn stream_decode_mt( + mut coder_ptr: *mut c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const u8, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut u8, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let mut wait_abs: mythread_condtime = timespec { + tv_sec: 0, + tv_nsec: 0, + }; + let mut has_blocked: bool = false_0 != 0; + let waiting_allowed: bool = + action as c_uint == LZMA_FINISH as c_uint || *in_pos == in_size && !(*coder).out_was_filled; + (*coder).out_was_filled = false_0 != 0; + loop { + let mut current_block_239: u64; + match (*coder).sequence as c_uint { + 0 => { + let in_old: size_t = *in_pos; + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).buffer as *mut u8, + &raw mut (*coder).pos, + LZMA_STREAM_HEADER_SIZE as size_t, + ); + (*coder).progress_in = (*coder) + .progress_in + .wrapping_add((*in_pos).wrapping_sub(in_old) as u64); + if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { + return LZMA_OK; + } + (*coder).pos = 0 as size_t; + let ret: lzma_ret = lzma_stream_header_decode( + &raw mut (*coder).stream_flags, + &raw mut (*coder).buffer as *mut u8, + ) as lzma_ret; + if ret as c_uint != LZMA_OK as c_uint { + return (if ret as c_uint == LZMA_FORMAT_ERROR as c_uint + && !(*coder).first_stream + { + LZMA_DATA_ERROR as c_uint + } else { + ret as c_uint + }) as lzma_ret; + } + (*coder).first_stream = false_0 != 0; + (*coder).block_options.check = (*coder).stream_flags.check; + (*coder).sequence = SEQ_BLOCK_HEADER; + if (*coder).tell_no_check as c_int != 0 + && (*coder).stream_flags.check as c_uint == LZMA_CHECK_NONE as c_uint + { + return LZMA_NO_CHECK; + } + if (*coder).tell_unsupported_check as c_int != 0 + && lzma_check_is_supported((*coder).stream_flags.check) == 0 + { + return LZMA_UNSUPPORTED_CHECK; + } + if (*coder).tell_any_check { + return LZMA_GET_CHECK; + } + current_block_239 = 7149356873433890176; + } + 1 => { + current_block_239 = 7149356873433890176; + } + 2 => { + current_block_239 = 3123434771885419771; + } + 3 => { + current_block_239 = 11441799814184323368; + } + 4 => { + current_block_239 = 7728257318064351663; + } + 5 => { + let ret__3: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + ::core::ptr::null_mut::(), + 1 as c_int != 0, + &raw mut wait_abs, + &raw mut has_blocked, + ) as lzma_ret; + if ret__3 as c_uint != LZMA_OK as c_uint { + return ret__3; + } + if !lzma_outq_is_empty(&raw mut (*coder).outq) { + return LZMA_OK; + } + lzma_outq_clear_cache(&raw mut (*coder).outq, allocator); + threads_end(coder, allocator); + let ret_3: lzma_ret = lzma_block_decoder_init( + &raw mut (*coder).block_decoder, + allocator, + &raw mut (*coder).block_options, + ) as lzma_ret; + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + (*coder).block_options.filters = ::core::ptr::null_mut::(); + if ret_3 as c_uint != LZMA_OK as c_uint { + return ret_3; + } + (*coder).mem_direct_mode = (*coder).mem_next_filters; + (*coder).sequence = SEQ_BLOCK_DIRECT_RUN; + current_block_239 = 7173345243791314703; + } + 6 => { + current_block_239 = 7173345243791314703; + } + 7 => { + let ret__5: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + ::core::ptr::null_mut::(), + 1 as c_int != 0, + &raw mut wait_abs, + &raw mut has_blocked, + ) as lzma_ret; + if ret__5 as c_uint != LZMA_OK as c_uint { + return ret__5; + } + if !lzma_outq_is_empty(&raw mut (*coder).outq) { + return LZMA_OK; + } + (*coder).sequence = SEQ_INDEX_DECODE; + current_block_239 = 13812071707085482240; + } + 8 => { + current_block_239 = 13812071707085482240; + } + 9 => { + current_block_239 = 15174413556390356007; + } + 10 => { + current_block_239 = 17073193239823527980; + } + 11 => { + if !(*coder).fail_fast { + let ret__8: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + ::core::ptr::null_mut::(), + 1 as c_int != 0, + &raw mut wait_abs, + &raw mut has_blocked, + ) as lzma_ret; + if ret__8 as c_uint != LZMA_OK as c_uint { + return ret__8; + } + if !lzma_outq_is_empty(&raw mut (*coder).outq) { + return LZMA_OK; + } + } + return (*coder).pending_error; + } + _ => return LZMA_PROG_ERROR, + } + match current_block_239 { + 7173345243791314703 => { + let in_old_1: size_t = *in_pos; + let out_old: size_t = *out_pos; + let ret_4: lzma_ret = (*coder) + .block_decoder + .code + .expect("non-null function pointer")( + (*coder).block_decoder.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ) as lzma_ret; + (*coder).progress_in = (*coder) + .progress_in + .wrapping_add((*in_pos).wrapping_sub(in_old_1) as u64); + (*coder).progress_out = (*coder) + .progress_out + .wrapping_add((*out_pos).wrapping_sub(out_old) as u64); + if ret_4 as c_uint != LZMA_STREAM_END as c_uint { + return ret_4; + } + let ret__4: lzma_ret = lzma_index_hash_append( + (*coder).index_hash, + lzma_block_unpadded_size(&raw mut (*coder).block_options), + (*coder).block_options.uncompressed_size, + ) as lzma_ret; + if ret__4 as c_uint != LZMA_OK as c_uint { + return ret__4; + } + (*coder).sequence = SEQ_BLOCK_HEADER; + current_block_239 = 11639917216603986996; + } + 7149356873433890176 => { + let in_old_0: size_t = *in_pos; + let ret_0: lzma_ret = + decode_block_header(coder, allocator, in_0, in_pos, in_size) as lzma_ret; + (*coder).progress_in = (*coder) + .progress_in + .wrapping_add((*in_pos).wrapping_sub(in_old_0) as u64); + if ret_0 as c_uint == LZMA_OK as c_uint { + if action as c_uint == LZMA_FINISH as c_uint && (*coder).fail_fast as c_int != 0 + { + threads_stop(coder); + return LZMA_DATA_ERROR; + } + let ret_: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + ::core::ptr::null_mut::(), + waiting_allowed, + &raw mut wait_abs, + &raw mut has_blocked, + ) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + if (*coder).pending_error as c_uint != LZMA_OK as c_uint { + (*coder).sequence = SEQ_ERROR; + } else { + return LZMA_OK; + } + current_block_239 = 11639917216603986996; + } else if ret_0 as c_uint == LZMA_RET_INTERNAL2 as c_uint { + (*coder).sequence = SEQ_INDEX_WAIT_OUTPUT; + current_block_239 = 11639917216603986996; + } else if ret_0 as c_uint != LZMA_STREAM_END as c_uint { + (*coder).pending_error = ret_0; + (*coder).sequence = SEQ_ERROR; + current_block_239 = 11639917216603986996; + } else { + (*coder).mem_next_filters = + lzma_raw_decoder_memusage(&raw mut (*coder).filters as *mut lzma_filter); + if (*coder).mem_next_filters == UINT64_MAX as u64 { + (*coder).pending_error = LZMA_OPTIONS_ERROR; + (*coder).sequence = SEQ_ERROR; + current_block_239 = 11639917216603986996; + } else { + (*coder).sequence = SEQ_BLOCK_INIT; + current_block_239 = 3123434771885419771; + } + } + } + 13812071707085482240 => { + if *in_pos >= in_size { + return LZMA_OK; + } + let in_old_2: size_t = *in_pos; + let ret_5: lzma_ret = + lzma_index_hash_decode((*coder).index_hash, in_0, in_pos, in_size) as lzma_ret; + (*coder).progress_in = (*coder) + .progress_in + .wrapping_add((*in_pos).wrapping_sub(in_old_2) as u64); + if ret_5 as c_uint != LZMA_STREAM_END as c_uint { + return ret_5; + } + (*coder).sequence = SEQ_STREAM_FOOTER; + current_block_239 = 15174413556390356007; + } + _ => {} + } + match current_block_239 { + 3123434771885419771 => { + if (*coder).mem_next_filters > (*coder).memlimit_stop { + let ret__0: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + ::core::ptr::null_mut::(), + 1 as c_int != 0, + &raw mut wait_abs, + &raw mut has_blocked, + ) as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { + return ret__0; + } + if !lzma_outq_is_empty(&raw mut (*coder).outq) { + return LZMA_OK; + } + return LZMA_MEMLIMIT_ERROR; + } + if is_direct_mode_needed((*coder).block_options.compressed_size) as c_int != 0 + || is_direct_mode_needed((*coder).block_options.uncompressed_size) as c_int != 0 + { + (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; + current_block_239 = 11639917216603986996; + } else { + (*coder).mem_next_in = comp_blk_size(coder) as u64; + let mem_buffers: u64 = + (*coder).mem_next_in.wrapping_add(lzma_outq_outbuf_memusage( + (*coder).block_options.uncompressed_size as size_t, + ) as u64); + if (UINT64_MAX as u64).wrapping_sub(mem_buffers) < (*coder).mem_next_filters { + (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; + current_block_239 = 11639917216603986996; + } else { + (*coder).mem_next_block = + (*coder).mem_next_filters.wrapping_add(mem_buffers); + if (*coder).mem_next_block > (*coder).memlimit_threading { + (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; + current_block_239 = 11639917216603986996; + } else { + lzma_next_end(&raw mut (*coder).block_decoder, allocator); + (*coder).mem_direct_mode = 0 as u64; + let ret_1: lzma_ret = lzma_index_hash_append( + (*coder).index_hash, + lzma_block_unpadded_size(&raw mut (*coder).block_options), + (*coder).block_options.uncompressed_size, + ) as lzma_ret; + if ret_1 as c_uint != LZMA_OK as c_uint { + (*coder).pending_error = ret_1; + (*coder).sequence = SEQ_ERROR; + current_block_239 = 11639917216603986996; + } else { + (*coder).sequence = SEQ_BLOCK_THR_INIT; + current_block_239 = 11441799814184323368; + } + } + } + } + } + 15174413556390356007 => { + let in_old_3: size_t = *in_pos; + lzma_bufcpy( + in_0, + in_pos, + in_size, + &raw mut (*coder).buffer as *mut u8, + &raw mut (*coder).pos, + LZMA_STREAM_HEADER_SIZE as size_t, + ); + (*coder).progress_in = (*coder) + .progress_in + .wrapping_add((*in_pos).wrapping_sub(in_old_3) as u64); + if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { + return LZMA_OK; + } + (*coder).pos = 0 as size_t; + let mut footer_flags: lzma_stream_flags = lzma_stream_flags { + version: 0, + backward_size: 0, + check: LZMA_CHECK_NONE, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_bool1: 0, + reserved_bool2: 0, + reserved_bool3: 0, + reserved_bool4: 0, + reserved_bool5: 0, + reserved_bool6: 0, + reserved_bool7: 0, + reserved_bool8: 0, + reserved_int1: 0, + reserved_int2: 0, + }; + let ret_6: lzma_ret = lzma_stream_footer_decode( + &raw mut footer_flags, + &raw mut (*coder).buffer as *mut u8, + ) as lzma_ret; + if ret_6 as c_uint != LZMA_OK as c_uint { + return (if ret_6 as c_uint == LZMA_FORMAT_ERROR as c_uint { + LZMA_DATA_ERROR as c_uint + } else { + ret_6 as c_uint + }) as lzma_ret; + } + if lzma_index_hash_size((*coder).index_hash) != footer_flags.backward_size { + return LZMA_DATA_ERROR; + } + let ret__6: lzma_ret = lzma_stream_flags_compare( + &raw mut (*coder).stream_flags, + &raw mut footer_flags, + ) as lzma_ret; + if ret__6 as c_uint != LZMA_OK as c_uint { + return ret__6; + } + if !(*coder).concatenated { + return LZMA_STREAM_END; + } + (*coder).sequence = SEQ_STREAM_PADDING; + current_block_239 = 17073193239823527980; + } + _ => {} + } + match current_block_239 { + 17073193239823527980 => { + loop { + if *in_pos >= in_size { + if action as c_uint != LZMA_FINISH as c_uint { + return LZMA_OK; + } + return (if (*coder).pos == 0 as size_t { + LZMA_STREAM_END as c_int + } else { + LZMA_DATA_ERROR as c_int + }) as lzma_ret; + } + if *in_0.offset(*in_pos as isize) as c_int != 0 as c_int { + break; + } + *in_pos = (*in_pos).wrapping_add(1); + (*coder).progress_in = (*coder).progress_in.wrapping_add(1); + (*coder).pos = (*coder).pos.wrapping_add(1 as size_t) & 3 as size_t; + } + if (*coder).pos != 0 as size_t { + *in_pos = (*in_pos).wrapping_add(1); + (*coder).progress_in = (*coder).progress_in.wrapping_add(1); + return LZMA_DATA_ERROR; + } + let ret__7: lzma_ret = stream_decoder_reset(coder, allocator) as lzma_ret; + if ret__7 as c_uint != LZMA_OK as c_uint { + return ret__7; + } + current_block_239 = 11639917216603986996; + } + 11441799814184323368 => { + let mut block_can_start: bool = false_0 != 0; + let ret__1: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + &raw mut block_can_start, + 1 as c_int != 0, + &raw mut wait_abs, + &raw mut has_blocked, + ) as lzma_ret; + if ret__1 as c_uint != LZMA_OK as c_uint { + return ret__1; + } + if (*coder).pending_error as c_uint != LZMA_OK as c_uint { + (*coder).sequence = SEQ_ERROR; + current_block_239 = 11639917216603986996; + } else { + if !block_can_start { + return LZMA_OK; + } + let mut mem_in_use: u64 = 0 as u64; + let mut mem_cached: u64 = 0 as u64; + let mut thr: *mut worker_thread = ::core::ptr::null_mut::(); + let mut mythread_i_1347: c_uint = 0 as c_uint; + while if mythread_i_1347 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1347: c_uint = 0 as c_uint; + while mythread_j_1347 == 0 { + mem_in_use = (*coder).mem_in_use; + mem_cached = (*coder).mem_cached; + thr = (*coder).threads_free; + mythread_j_1347 = 1 as c_uint; + } + mythread_i_1347 = 1 as c_uint; + } + let mem_max: u64 = (*coder) + .memlimit_threading + .wrapping_sub((*coder).mem_next_block); + if mem_in_use + .wrapping_add(mem_cached) + .wrapping_add((*coder).outq.mem_allocated) + > mem_max + { + lzma_outq_clear_cache2( + &raw mut (*coder).outq, + allocator, + (*coder).block_options.uncompressed_size as size_t, + ); + } + let mut mem_freed: u64 = 0 as u64; + if !thr.is_null() + && mem_in_use + .wrapping_add(mem_cached) + .wrapping_add((*coder).outq.mem_in_use) + > mem_max + { + if (*thr).mem_filters <= (*coder).mem_next_filters { + thr = (*thr).next; + } + while !thr.is_null() { + lzma_next_end(&raw mut (*thr).block_decoder, allocator); + mem_freed = mem_freed.wrapping_add((*thr).mem_filters); + (*thr).mem_filters = 0 as u64; + thr = (*thr).next; + } + } + let mut mythread_i_1410: c_uint = 0 as c_uint; + while if mythread_i_1410 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1410: c_uint = 0 as c_uint; + while mythread_j_1410 == 0 { + (*coder).mem_cached = (*coder).mem_cached.wrapping_sub(mem_freed); + (*coder).mem_in_use = (*coder).mem_in_use.wrapping_add( + (*coder).mem_next_in.wrapping_add((*coder).mem_next_filters), + ); + mythread_j_1410 = 1 as c_uint; + } + mythread_i_1410 = 1 as c_uint; + } + let mut ret_2: lzma_ret = lzma_outq_prealloc_buf( + &raw mut (*coder).outq, + allocator, + (*coder).block_options.uncompressed_size as size_t, + ); + if ret_2 as c_uint != LZMA_OK as c_uint { + threads_stop(coder); + return ret_2; + } + ret_2 = get_thread(coder, allocator); + if ret_2 as c_uint != LZMA_OK as c_uint { + threads_stop(coder); + return ret_2; + } + (*(*coder).thr).mem_filters = (*coder).mem_next_filters; + (*(*coder).thr).block_options = (*coder).block_options; + ret_2 = lzma_block_decoder_init( + &raw mut (*(*coder).thr).block_decoder, + allocator, + &raw mut (*(*coder).thr).block_options, + ); + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + (*(*coder).thr).block_options.filters = ::core::ptr::null_mut::(); + if ret_2 as c_uint != LZMA_OK as c_uint { + (*coder).pending_error = ret_2; + (*coder).sequence = SEQ_ERROR; + current_block_239 = 11639917216603986996; + } else { + (*(*coder).thr).in_size = (*coder).mem_next_in as size_t; + (*(*coder).thr).in_0 = + lzma_alloc((*(*coder).thr).in_size, allocator) as *mut u8; + if (*(*coder).thr).in_0.is_null() { + threads_stop(coder); + return LZMA_MEM_ERROR; + } + (*(*coder).thr).outbuf = + lzma_outq_get_buf(&raw mut (*coder).outq, (*coder).thr as *mut c_void); + let mut mythread_i_1478: c_uint = 0 as c_uint; + while if mythread_i_1478 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1478: c_uint = 0 as c_uint; + while mythread_j_1478 == 0 { + (*(*coder).thr).state = THR_RUN; + mythread_cond_signal(&raw mut (*(*coder).thr).cond); + mythread_j_1478 = 1 as c_uint; + } + mythread_i_1478 = 1 as c_uint; + } + let mut mythread_i_1486: c_uint = 0 as c_uint; + while if mythread_i_1486 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1486: c_uint = 0 as c_uint; + while mythread_j_1486 == 0 { + lzma_outq_enable_partial_output( + &raw mut (*coder).outq, + Some( + worker_enable_partial_update + as unsafe extern "C" fn(*mut c_void) -> (), + ), + ); + mythread_j_1486 = 1 as c_uint; + } + mythread_i_1486 = 1 as c_uint; + } + (*coder).sequence = SEQ_BLOCK_THR_RUN; + current_block_239 = 7728257318064351663; + } + } + } + _ => {} + } + match current_block_239 { + 7728257318064351663 => { + if action as c_uint == LZMA_FINISH as c_uint && (*coder).fail_fast as c_int != 0 { + let in_avail: size_t = in_size.wrapping_sub(*in_pos); + let in_needed: size_t = (*(*coder).thr) + .in_size + .wrapping_sub((*(*coder).thr).in_filled); + if in_avail < in_needed { + threads_stop(coder); + return LZMA_DATA_ERROR; + } + } + let mut cur_in_filled: size_t = (*(*coder).thr).in_filled; + lzma_bufcpy( + in_0, + in_pos, + in_size, + (*(*coder).thr).in_0, + &raw mut cur_in_filled, + (*(*coder).thr).in_size, + ); + let mut mythread_i_1517: c_uint = 0 as c_uint; + while if mythread_i_1517 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1517: c_uint = 0 as c_uint; + while mythread_j_1517 == 0 { + (*(*coder).thr).in_filled = cur_in_filled; + mythread_cond_signal(&raw mut (*(*coder).thr).cond); + mythread_j_1517 = 1 as c_uint; + } + mythread_i_1517 = 1 as c_uint; + } + let ret__2: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + ::core::ptr::null_mut::(), + waiting_allowed as c_int != 0 && *in_pos == in_size, + &raw mut wait_abs, + &raw mut has_blocked, + ) as lzma_ret; + if ret__2 as c_uint != LZMA_OK as c_uint { + return ret__2; + } + if (*coder).pending_error as c_uint != LZMA_OK as c_uint { + (*coder).sequence = SEQ_ERROR; + } else { + if (*(*coder).thr).in_filled < (*(*coder).thr).in_size { + return LZMA_OK; + } + (*coder).thr = ::core::ptr::null_mut::(); + (*coder).sequence = SEQ_BLOCK_HEADER; + } + } + _ => {} + } + } +} +unsafe extern "C" fn stream_decoder_mt_end( + mut coder_ptr: *mut c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + threads_end(coder, allocator); + lzma_outq_end(&raw mut (*coder).outq, allocator); + lzma_next_end(&raw mut (*coder).block_decoder, allocator); + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_index_hash_end((*coder).index_hash, allocator); + lzma_free(coder as *mut c_void, allocator); +} +unsafe extern "C" fn stream_decoder_mt_get_check(mut coder_ptr: *const c_void) -> lzma_check { + let mut coder: *const lzma_stream_coder = coder_ptr as *const lzma_stream_coder; + return (*coder).stream_flags.check; +} +unsafe extern "C" fn stream_decoder_mt_memconfig( + mut coder_ptr: *mut c_void, + mut memusage: *mut u64, + mut old_memlimit: *mut u64, + mut new_memlimit: u64, +) -> lzma_ret { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let mut mythread_i_1829: c_uint = 0 as c_uint; + while if mythread_i_1829 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1829: c_uint = 0 as c_uint; + while mythread_j_1829 == 0 { + *memusage = (*coder) + .mem_direct_mode + .wrapping_add((*coder).mem_in_use) + .wrapping_add((*coder).mem_cached) + .wrapping_add((*coder).outq.mem_allocated); + mythread_j_1829 = 1 as c_uint; + } + mythread_i_1829 = 1 as c_uint; + } + if *memusage < LZMA_MEMUSAGE_BASE as u64 { + *memusage = LZMA_MEMUSAGE_BASE as u64; + } + *old_memlimit = (*coder).memlimit_stop; + if new_memlimit != 0 as u64 { + if new_memlimit < *memusage { + return LZMA_MEMLIMIT_ERROR; + } + (*coder).memlimit_stop = new_memlimit; + } + return LZMA_OK; +} +unsafe extern "C" fn stream_decoder_mt_get_progress( + mut coder_ptr: *mut c_void, + mut progress_in: *mut u64, + mut progress_out: *mut u64, +) { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let mut mythread_i_1862: c_uint = 0 as c_uint; + while if mythread_i_1862 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1862: c_uint = 0 as c_uint; + while mythread_j_1862 == 0 { + *progress_in = (*coder).progress_in; + *progress_out = (*coder).progress_out; + let mut i: size_t = 0 as size_t; + while i < (*coder).threads_initialized as size_t { + let mut mythread_i_1867: c_uint = 0 as c_uint; + while if mythread_i_1867 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1867: c_uint = 0 as c_uint; + while mythread_j_1867 == 0 { + *progress_in = (*progress_in).wrapping_add( + (*(*coder).threads.offset(i as isize)).progress_in as u64, + ); + *progress_out = (*progress_out).wrapping_add( + (*(*coder).threads.offset(i as isize)).progress_out as u64, + ); + mythread_j_1867 = 1 as c_uint; + } + mythread_i_1867 = 1 as c_uint; + } + i = i.wrapping_add(1); + } + mythread_j_1862 = 1 as c_uint; + } + mythread_i_1862 = 1 as c_uint; + } +} +unsafe extern "C" fn stream_decoder_mt_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut options: *const lzma_mt, +) -> lzma_ret { + let mut coder: *mut lzma_stream_coder = ::core::ptr::null_mut::(); + if (*options).threads == 0 as u32 || (*options).threads > LZMA_THREADS_MAX as u32 { + return LZMA_OPTIONS_ERROR; + } + if (*options).flags & !(LZMA_SUPPORTED_FLAGS as u32) != 0 { + return LZMA_OPTIONS_ERROR; + } + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_mt, + ) -> lzma_ret, + >, + uintptr_t, + >(Some( + stream_decoder_mt_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_mt, + ) -> lzma_ret, + )) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_mt, + ) -> lzma_ret, + >, + uintptr_t, + >(Some( + stream_decoder_mt_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_mt, + ) -> lzma_ret, + )); + coder = (*next).coder as *mut lzma_stream_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_stream_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut c_void; + if mythread_mutex_init(&raw mut (*coder).mutex) != 0 { + lzma_free(coder as *mut c_void, allocator); + return LZMA_MEM_ERROR; + } + if mythread_cond_init(&raw mut (*coder).cond) != 0 { + mythread_mutex_destroy(&raw mut (*coder).mutex); + lzma_free(coder as *mut c_void, allocator); + return LZMA_MEM_ERROR; + } + (*next).code = Some( + stream_decode_mt + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const u8, + *mut size_t, + size_t, + *mut u8, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + stream_decoder_mt_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), + ) as lzma_end_function; + (*next).get_check = + Some(stream_decoder_mt_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check) + as Option lzma_check>; + (*next).memconfig = Some( + stream_decoder_mt_memconfig + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, + ) + as Option lzma_ret>; + (*next).get_progress = Some( + stream_decoder_mt_get_progress + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> (), + ) + as Option ()>; + (*coder).filters[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + memset( + &raw mut (*coder).outq as *mut c_void, + 0 as c_int, + ::core::mem::size_of::() as size_t, + ); + (*coder).block_decoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*coder).mem_direct_mode = 0 as u64; + (*coder).index_hash = ::core::ptr::null_mut::(); + (*coder).threads = ::core::ptr::null_mut::(); + (*coder).threads_free = ::core::ptr::null_mut::(); + (*coder).threads_initialized = 0 as u32; + } + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + threads_end(coder, allocator); + (*coder).mem_in_use = 0 as u64; + (*coder).mem_cached = 0 as u64; + (*coder).mem_next_block = 0 as u64; + (*coder).progress_in = 0 as u64; + (*coder).progress_out = 0 as u64; + (*coder).sequence = SEQ_STREAM_HEADER; + (*coder).thread_error = LZMA_OK; + (*coder).pending_error = LZMA_OK; + (*coder).thr = ::core::ptr::null_mut::(); + (*coder).timeout = (*options).timeout; + (*coder).memlimit_threading = if 1 as u64 > (*options).memlimit_threading { + 1 as u64 + } else { + (*options).memlimit_threading + }; + (*coder).memlimit_stop = if 1 as u64 > (*options).memlimit_stop { + 1 as u64 + } else { + (*options).memlimit_stop + }; + if (*coder).memlimit_threading > (*coder).memlimit_stop { + (*coder).memlimit_threading = (*coder).memlimit_stop; + } + (*coder).tell_no_check = (*options).flags & LZMA_TELL_NO_CHECK as u32 != 0 as u32; + (*coder).tell_unsupported_check = + (*options).flags & LZMA_TELL_UNSUPPORTED_CHECK as u32 != 0 as u32; + (*coder).tell_any_check = (*options).flags & LZMA_TELL_ANY_CHECK as u32 != 0 as u32; + (*coder).ignore_check = (*options).flags & LZMA_IGNORE_CHECK as u32 != 0 as u32; + (*coder).concatenated = (*options).flags & LZMA_CONCATENATED as u32 != 0 as u32; + (*coder).fail_fast = (*options).flags & LZMA_FAIL_FAST as u32 != 0 as u32; + (*coder).first_stream = true_0 != 0; + (*coder).out_was_filled = false_0 != 0; + (*coder).pos = 0 as size_t; + (*coder).threads_max = (*options).threads; + let ret_: lzma_ret = + lzma_outq_init(&raw mut (*coder).outq, allocator, (*coder).threads_max) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + return stream_decoder_reset(coder, allocator); +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_decoder_mt( + mut strm: *mut lzma_stream, + mut options: *const lzma_mt, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + let ret__0: lzma_ret = stream_decoder_mt_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + options, + ) as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + return LZMA_OK; +} diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index f7365996..fbeb492c 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -1,11 +1,11 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; #[repr(C)] -pub struct lzma_index_s { _opaque: [u8; 0] } +pub struct lzma_index_s { + _opaque: [u8; 0], +} extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_end(strm: *mut lzma_stream); fn lzma_filters_copy( src: *const lzma_filter, @@ -13,16 +13,10 @@ extern "C" { allocator: *const lzma_allocator, ) -> lzma_ret; fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); - fn lzma_stream_header_encode( - options: *const lzma_stream_flags, - out: *mut uint8_t, - ) -> lzma_ret; - fn lzma_stream_footer_encode( - options: *const lzma_stream_flags, - out: *mut uint8_t, - ) -> lzma_ret; + fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; + fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; - fn lzma_block_header_encode(block: *const lzma_block, out: *mut uint8_t) -> lzma_ret; + fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); @@ -33,18 +27,15 @@ extern "C" { uncompressed_size: lzma_vli, ) -> lzma_ret; fn lzma_index_size(i: *const lzma_index) -> lzma_vli; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -59,16 +50,7 @@ extern "C" { i: *const lzma_index, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -90,7 +72,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -99,17 +80,9 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] @@ -120,7 +93,7 @@ pub struct lzma_internal_s { pub supported_actions: [bool; 5], pub allow_buf_error: bool, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const ISEQ_ERROR: C2RustUnnamed = 6; pub const ISEQ_END: C2RustUnnamed = 5; pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; @@ -132,68 +105,43 @@ pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -203,20 +151,20 @@ pub type lzma_internal = lzma_internal_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { - pub next_in: *const uint8_t, + pub next_in: *const u8, pub avail_in: size_t, - pub total_in: uint64_t, - pub next_out: *mut uint8_t, + pub total_in: u64, + pub next_out: *mut u8, pub avail_out: size_t, - pub total_out: uint64_t, + pub total_out: u64, pub allocator: *const lzma_allocator, pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_ptr4: *mut ::core::ffi::c_void, - pub seek_pos: uint64_t, - pub reserved_int2: uint64_t, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, pub reserved_int3: size_t, pub reserved_int4: size_t, pub reserved_enum1: lzma_reserved_enum, @@ -234,24 +182,24 @@ pub struct lzma_stream_coder { pub index: *mut lzma_index, pub buffer_pos: size_t, pub buffer_size: size_t, - pub buffer: [uint8_t; 1024], + pub buffer: [u8; 1024], } pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { - pub version: uint32_t, - pub header_size: uint32_t, + pub version: u32, + pub header_size: u32, pub check: lzma_check, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub filters: *mut lzma_filter, - pub raw_check: [uint8_t; 64], - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, - pub reserved_ptr3: *mut ::core::ffi::c_void, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, pub reserved_int3: lzma_vli, pub reserved_int4: lzma_vli, pub reserved_int5: lzma_vli, @@ -271,7 +219,7 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub type C2RustUnnamed_0 = ::core::ffi::c_uint; +pub type C2RustUnnamed_0 = c_uint; pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; pub const SEQ_INDEX_ENCODE: C2RustUnnamed_0 = 4; pub const SEQ_BLOCK_ENCODE: C2RustUnnamed_0 = 3; @@ -281,7 +229,7 @@ pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -296,30 +244,24 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: ::core::ffi::c_int = 12 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; unsafe extern "C" fn block_encoder_init( mut coder: *mut lzma_stream_coder, mut allocator: *const lzma_allocator, ) -> lzma_ret { (*coder).block_options.compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).block_options.uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; - let ret_: lzma_ret = lzma_block_header_size(&raw mut (*coder).block_options) - as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = lzma_block_header_size(&raw mut (*coder).block_options) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } return lzma_block_encoder_init( @@ -329,22 +271,22 @@ unsafe extern "C" fn block_encoder_init( ); } unsafe extern "C" fn stream_encode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; while *out_pos < out_size { - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 | 2 | 5 => { lzma_bufcpy( - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, &raw mut (*coder).buffer_pos, (*coder).buffer_size, out, @@ -354,9 +296,7 @@ unsafe extern "C" fn stream_encode( if (*coder).buffer_pos < (*coder).buffer_size { return LZMA_OK; } - if (*coder).sequence as ::core::ffi::c_uint - == SEQ_STREAM_FOOTER as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*coder).sequence as c_uint == SEQ_STREAM_FOOTER as c_uint { return LZMA_STREAM_END; } (*coder).buffer_pos = 0 as size_t; @@ -364,15 +304,11 @@ unsafe extern "C" fn stream_encode( } 1 => { if *in_pos == in_size { - if action as ::core::ffi::c_uint - != LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint - { - return (if action as ::core::ffi::c_uint - == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint - { - LZMA_OK as ::core::ffi::c_int + if action as c_uint != LZMA_FINISH as c_uint { + return (if action as c_uint == LZMA_RUN as c_uint { + LZMA_OK as c_int } else { - LZMA_STREAM_END as ::core::ffi::c_int + LZMA_STREAM_END as c_int }) as lzma_ret; } let ret_: lzma_ret = lzma_index_encoder_init( @@ -380,28 +316,23 @@ unsafe extern "C" fn stream_encode( allocator, (*coder).index, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } (*coder).sequence = SEQ_INDEX_ENCODE; } else { if !(*coder).block_encoder_is_initialized { - let ret__0: lzma_ret = block_encoder_init(coder, allocator) - as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret__0: lzma_ret = block_encoder_init(coder, allocator) as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { return ret__0; } } (*coder).block_encoder_is_initialized = false_0 != 0; if lzma_block_header_encode( &raw mut (*coder).block_options, - &raw mut (*coder).buffer as *mut uint8_t, - ) as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + &raw mut (*coder).buffer as *mut u8, + ) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } @@ -420,9 +351,7 @@ unsafe extern "C" fn stream_encode( let ret: lzma_ret = (*coder) .block_encoder .code - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).block_encoder.coder, allocator, in_0, @@ -433,25 +362,20 @@ unsafe extern "C" fn stream_encode( out_size, convert[action as usize], ) as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - || action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + if ret as c_uint != LZMA_STREAM_END as c_uint + || action as c_uint == LZMA_SYNC_FLUSH as c_uint { return ret; } - let unpadded_size: lzma_vli = lzma_block_unpadded_size( - &raw mut (*coder).block_options, - ) as lzma_vli; + let unpadded_size: lzma_vli = + lzma_block_unpadded_size(&raw mut (*coder).block_options) as lzma_vli; let ret__1: lzma_ret = lzma_index_append( (*coder).index, allocator, unpadded_size, (*coder).block_options.uncompressed_size, ) as lzma_ret; - if ret__1 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__1 as c_uint != LZMA_OK as c_uint { return ret__1; } (*coder).sequence = SEQ_BLOCK_INIT; @@ -460,12 +384,10 @@ unsafe extern "C" fn stream_encode( let ret_0: lzma_ret = (*coder) .index_encoder .code - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).index_encoder.coder, allocator, - ::core::ptr::null::(), + ::core::ptr::null::(), ::core::ptr::null_mut::(), 0 as size_t, out, @@ -473,13 +395,11 @@ unsafe extern "C" fn stream_encode( out_size, LZMA_RUN, ) as lzma_ret; - if ret_0 as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_0 as c_uint != LZMA_STREAM_END as c_uint { return ret_0; } let stream_flags: lzma_stream_flags = lzma_stream_flags { - version: 0 as uint32_t, + version: 0 as u32, backward_size: lzma_index_size((*coder).index), check: (*coder).block_options.check, reserved_enum1: LZMA_RESERVED_ENUM, @@ -499,9 +419,9 @@ unsafe extern "C" fn stream_encode( }; if lzma_stream_footer_encode( &raw const stream_flags, - &raw mut (*coder).buffer as *mut uint8_t, - ) as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint + &raw mut (*coder).buffer as *mut u8, + ) as c_uint + != LZMA_OK as c_uint { return LZMA_PROG_ERROR; } @@ -514,7 +434,7 @@ unsafe extern "C" fn stream_encode( return LZMA_OK; } unsafe extern "C" fn stream_encoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; @@ -522,10 +442,10 @@ unsafe extern "C" fn stream_encoder_end( lzma_next_end(&raw mut (*coder).index_encoder, allocator); lzma_index_end((*coder).index, allocator); lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn stream_encoder_update( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, mut filters: *const lzma_filter, mut reversed_filters: *const lzma_filter, @@ -535,45 +455,35 @@ unsafe extern "C" fn stream_encoder_update( let mut ret: lzma_ret = LZMA_OK; let mut temp: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5]; - let ret_: lzma_ret = lzma_filters_copy( - filters, - &raw mut temp as *mut lzma_filter, - allocator, - ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = + lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - if (*coder).sequence as ::core::ffi::c_uint - <= SEQ_BLOCK_INIT as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*coder).sequence as c_uint <= SEQ_BLOCK_INIT as c_uint { (*coder).block_encoder_is_initialized = false_0 != 0; (*coder).block_options.filters = &raw mut temp as *mut lzma_filter; ret = block_encoder_init(coder, allocator); (*coder).block_options.filters = &raw mut (*coder).filters as *mut lzma_filter; - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_OK as c_uint { current_block = 9913398440939854562; } else { (*coder).block_encoder_is_initialized = true_0 != 0; current_block = 8236137900636309791; } - } else if (*coder).sequence as ::core::ffi::c_uint - <= SEQ_BLOCK_ENCODE as ::core::ffi::c_int as ::core::ffi::c_uint - { + } else if (*coder).sequence as c_uint <= SEQ_BLOCK_ENCODE as c_uint { ret = (*coder) .block_encoder .update - .expect( - "non-null function pointer", - )((*coder).block_encoder.coder, allocator, filters, reversed_filters); - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + .expect("non-null function pointer")( + (*coder).block_encoder.coder, + allocator, + filters, + reversed_filters, + ); + if ret as c_uint != LZMA_OK as c_uint { current_block = 9913398440939854562; } else { current_block = 8236137900636309791; @@ -590,9 +500,8 @@ unsafe extern "C" fn stream_encoder_update( _ => { lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); memcpy( - &raw mut (*coder).filters as *mut lzma_filter - as *mut ::core::ffi::c_void, - &raw mut temp as *mut lzma_filter as *const ::core::ffi::c_void, + &raw mut (*coder).filters as *mut lzma_filter as *mut c_void, + &raw mut temp as *mut lzma_filter as *const c_void, ::core::mem::size_of::<[lzma_filter; 5]>() as size_t, ); return LZMA_OK; @@ -615,17 +524,15 @@ unsafe extern "C" fn stream_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - stream_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter, - lzma_check, - ) -> lzma_ret, - ), - ) != (*next).init + >(Some( + stream_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter, + lzma_check, + ) -> lzma_ret, + )) != (*next).init { lzma_next_end(next, allocator); } @@ -639,17 +546,15 @@ unsafe extern "C" fn stream_encoder_init( ) -> lzma_ret, >, uintptr_t, - >( - Some( - stream_encoder_init - as unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter, - lzma_check, - ) -> lzma_ret, - ), - ); + >(Some( + stream_encoder_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter, + lzma_check, + ) -> lzma_ret, + )); if filters.is_null() { return LZMA_PROG_ERROR; } @@ -662,32 +567,28 @@ unsafe extern "C" fn stream_encoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( stream_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - stream_encoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + stream_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*next).update = Some( stream_encoder_update as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -695,18 +596,17 @@ unsafe extern "C" fn stream_encoder_init( ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >; - (*coder).filters[0 as ::core::ffi::c_int as usize].id = LZMA_VLI_UNKNOWN - as lzma_vli; + (*coder).filters[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).block_encoder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -718,7 +618,7 @@ unsafe extern "C" fn stream_encoder_init( (*coder).index_encoder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -730,7 +630,7 @@ unsafe extern "C" fn stream_encoder_init( (*coder).index = ::core::ptr::null_mut::(); } (*coder).sequence = SEQ_STREAM_HEADER; - (*coder).block_options.version = 0 as uint32_t; + (*coder).block_options.version = 0 as u32; (*coder).block_options.check = check; lzma_index_end((*coder).index, allocator); (*coder).index = lzma_index_init(allocator); @@ -738,7 +638,7 @@ unsafe extern "C" fn stream_encoder_init( return LZMA_MEM_ERROR; } let mut stream_flags: lzma_stream_flags = lzma_stream_flags { - version: 0 as uint32_t, + version: 0 as u32, backward_size: 0, check: check, reserved_enum1: LZMA_RESERVED_ENUM, @@ -756,19 +656,16 @@ unsafe extern "C" fn stream_encoder_init( reserved_int1: 0, reserved_int2: 0, }; - let ret_: lzma_ret = lzma_stream_header_encode( - &raw mut stream_flags, - &raw mut (*coder).buffer as *mut uint8_t, - ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = + lzma_stream_header_encode(&raw mut stream_flags, &raw mut (*coder).buffer as *mut u8) + as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } (*coder).buffer_pos = 0 as size_t; (*coder).buffer_size = LZMA_STREAM_HEADER_SIZE as size_t; return stream_encoder_update( - coder as *mut ::core::ffi::c_void, + coder as *mut c_void, allocator, filters, ::core::ptr::null::(), @@ -781,9 +678,7 @@ pub unsafe extern "C" fn lzma_stream_encoder( mut check: lzma_check, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } let ret__0: lzma_ret = stream_encoder_init( @@ -792,22 +687,14 @@ pub unsafe extern "C" fn lzma_stream_encoder( filters, check, ) as lzma_ret; - if ret__0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret__0 as c_uint != LZMA_OK as c_uint { lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal) - .supported_actions[LZMA_SYNC_FLUSH as ::core::ffi::c_int as usize] = true_0 != 0; - (*(*strm).internal) - .supported_actions[LZMA_FULL_FLUSH as ::core::ffi::c_int as usize] = true_0 != 0; - (*(*strm).internal) - .supported_actions[LZMA_FULL_BARRIER as ::core::ffi::c_int as usize] = true_0 - != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as ::core::ffi::c_int as usize] = true_0 - != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FULL_FLUSH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FULL_BARRIER as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; return LZMA_OK; } diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs new file mode 100644 index 00000000..7af08dee --- /dev/null +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -0,0 +1,1961 @@ +use crate::types::*; +use core::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulonglong, c_void}; +pub enum lzma_index_s {} +extern "C" { + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; + fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; + fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; + fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> c_int; + fn pthread_cond_signal(_: *mut pthread_cond_t) -> c_int; + fn pthread_cond_timedwait( + _: *mut pthread_cond_t, + _: *mut pthread_mutex_t, + _: *const timespec, + ) -> c_int; + fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> c_int; + fn pthread_create( + _: *mut pthread_t, + _: *const pthread_attr_t, + _: Option *mut c_void>, + _: *mut c_void, + ) -> c_int; + fn pthread_join(_: pthread_t, _: *mut *mut c_void) -> c_int; + fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> c_int; + fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> c_int; + fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> c_int; + fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> c_int; + fn pthread_sigmask(_: c_int, _: *const sigset_t, _: *mut sigset_t) -> c_int; + fn lzma_end(strm: *mut lzma_stream); + fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; + fn lzma_filters_copy( + src: *const lzma_filter, + dest: *mut lzma_filter, + allocator: *const lzma_allocator, + ) -> lzma_ret; + fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); + fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64; + fn lzma_mt_block_size(filters: *const lzma_filter) -> u64; + fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; + fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; + fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; + fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret; + fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; + fn lzma_block_uncomp_encode( + block: *mut lzma_block, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; + fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; + fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); + fn lzma_index_append( + i: *mut lzma_index, + allocator: *const lzma_allocator, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, + ) -> lzma_ret; + fn lzma_index_size(i: *const lzma_index) -> lzma_vli; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); + fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + fn lzma_bufcpy( + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; + fn lzma_block_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, + ) -> lzma_ret; + fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64; + fn lzma_index_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + i: *const lzma_index, + ) -> lzma_ret; + fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64; + fn lzma_outq_init( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + threads: u32, + ) -> lzma_ret; + fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator); + fn lzma_outq_prealloc_buf( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + size: size_t, + ) -> lzma_ret; + fn lzma_outq_get_buf(outq: *mut lzma_outq, worker: *mut c_void) -> *mut lzma_outbuf; + fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool; + fn lzma_outq_read( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + unpadded_size: *mut lzma_vli, + uncompressed_size: *mut lzma_vli, + ) -> lzma_ret; +} +pub type __uint32_t = u32; +pub type __darwin_time_t = c_long; +pub type __darwin_sigset_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __darwin_pthread_handler_rec { + pub __routine: Option ()>, + pub __arg: *mut c_void, + pub __next: *mut __darwin_pthread_handler_rec, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_attr_t { + pub __sig: c_long, + pub __opaque: [c_char; 56], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_cond_t { + pub __sig: c_long, + pub __opaque: [c_char; 40], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_condattr_t { + pub __sig: c_long, + pub __opaque: [c_char; 8], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_mutex_t { + pub __sig: c_long, + pub __opaque: [c_char; 56], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_mutexattr_t { + pub __sig: c_long, + pub __opaque: [c_char; 8], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_t { + pub __sig: c_long, + pub __cleanup_stack: *mut __darwin_pthread_handler_rec, + pub __opaque: [c_char; 8176], +} +pub type __darwin_pthread_attr_t = _opaque_pthread_attr_t; +pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; +pub type __darwin_pthread_condattr_t = _opaque_pthread_condattr_t; +pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; +pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t; +pub type __darwin_pthread_t = *mut _opaque_pthread_t; +pub type pthread_attr_t = __darwin_pthread_attr_t; +pub type sigset_t = __darwin_sigset_t; +pub type time_t = __darwin_time_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct timespec { + pub tv_sec: __darwin_time_t, + pub tv_nsec: c_long, +} +pub type clockid_t = c_uint; +pub const _CLOCK_THREAD_CPUTIME_ID: clockid_t = 16; +pub const _CLOCK_PROCESS_CPUTIME_ID: clockid_t = 12; +pub const _CLOCK_UPTIME_RAW_APPROX: clockid_t = 9; +pub const _CLOCK_UPTIME_RAW: clockid_t = 8; +pub const _CLOCK_MONOTONIC_RAW_APPROX: clockid_t = 5; +pub const _CLOCK_MONOTONIC_RAW: clockid_t = 4; +pub const _CLOCK_MONOTONIC: clockid_t = 6; +pub const _CLOCK_REALTIME: clockid_t = 0; +pub type pthread_cond_t = __darwin_pthread_cond_t; +pub type pthread_condattr_t = __darwin_pthread_condattr_t; +pub type pthread_mutex_t = __darwin_pthread_mutex_t; +pub type pthread_mutexattr_t = __darwin_pthread_mutexattr_t; +pub type pthread_t = __darwin_pthread_t; +pub type mythread = pthread_t; +pub type mythread_mutex = pthread_mutex_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mythread_cond { + pub cond: pthread_cond_t, + pub clk_id: clockid_t, +} +pub type mythread_condtime = timespec; +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_OK: lzma_ret = 0; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_RUN: lzma_action = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: C2RustUnnamed, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type C2RustUnnamed = c_uint; +pub const ISEQ_ERROR: C2RustUnnamed = 6; +pub const ISEQ_END: C2RustUnnamed = 5; +pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; +pub const ISEQ_FINISH: C2RustUnnamed = 3; +pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; +pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; +pub const ISEQ_RUN: C2RustUnnamed = 0; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, + pub update: Option< + unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option lzma_ret>, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut c_void, +} +pub const LZMA_CHECK_SHA256: lzma_check = 10; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub type lzma_end_function = Option ()>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const u8, + *mut size_t, + size_t, + *mut u8, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_internal = lzma_internal_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const u8, + pub avail_in: size_t, + pub total_in: u64, + pub next_out: *mut u8, + pub avail_out: size_t, + pub total_out: u64, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} +pub const LZMA_MF_BT4: lzma_match_finder = 20; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; +pub const LZMA_MODE_FAST: lzma_mode = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, + pub mode: lzma_mode, + pub nice_len: u32, + pub mf: lzma_match_finder, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mt { + pub flags: u32, + pub threads: u32, + pub block_size: u64, + pub timeout: u32, + pub preset: u32, + pub filters: *const lzma_filter, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub memlimit_threading: u64, + pub memlimit_stop: u64, + pub reserved_int7: u64, + pub reserved_int8: u64, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, +} +pub type worker_thread = worker_thread_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct worker_thread_s { + pub state: worker_state, + pub in_0: *mut u8, + pub in_size: size_t, + pub outbuf: *mut lzma_outbuf, + pub coder: *mut lzma_stream_coder, + pub allocator: *const lzma_allocator, + pub progress_in: u64, + pub progress_out: u64, + pub block_encoder: lzma_next_coder, + pub block_options: lzma_block, + pub filters: [lzma_filter; 5], + pub next: *mut worker_thread, + pub mutex: mythread_mutex, + pub cond: mythread_cond, + pub thread_id: mythread, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: u32, + pub header_size: u32, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} +pub type lzma_stream_coder = lzma_stream_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_coder_s { + pub sequence: C2RustUnnamed_0, + pub block_size: size_t, + pub filters: [lzma_filter; 5], + pub filters_cache: [lzma_filter; 5], + pub index: *mut lzma_index, + pub index_encoder: lzma_next_coder, + pub stream_flags: lzma_stream_flags, + pub header: [u8; 12], + pub header_pos: size_t, + pub outq: lzma_outq, + pub outbuf_alloc_size: size_t, + pub timeout: u32, + pub thread_error: lzma_ret, + pub threads: *mut worker_thread, + pub threads_max: u32, + pub threads_initialized: u32, + pub threads_free: *mut worker_thread, + pub thr: *mut worker_thread, + pub progress_in: u64, + pub progress_out: u64, + pub mutex: mythread_mutex, + pub cond: mythread_cond, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_outq { + pub head: *mut lzma_outbuf, + pub tail: *mut lzma_outbuf, + pub read_pos: size_t, + pub cache: *mut lzma_outbuf, + pub mem_allocated: u64, + pub mem_in_use: u64, + pub bufs_in_use: u32, + pub bufs_allocated: u32, + pub bufs_limit: u32, +} +pub type lzma_outbuf = lzma_outbuf_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_outbuf_s { + pub next: *mut lzma_outbuf, + pub worker: *mut c_void, + pub allocated: size_t, + pub pos: size_t, + pub decoder_in_pos: size_t, + pub finished: bool, + pub finish_ret: lzma_ret, + pub unpadded_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub buf: [u8; 0], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: u32, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: u32, + pub reserved_int2: u32, +} +pub type lzma_index = lzma_index_s; +pub type C2RustUnnamed_0 = c_uint; +pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 3; +pub const SEQ_INDEX: C2RustUnnamed_0 = 2; +pub const SEQ_BLOCK: C2RustUnnamed_0 = 1; +pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; +pub type worker_state = c_uint; +pub const THR_EXIT: worker_state = 4; +pub const THR_STOP: worker_state = 3; +pub const THR_FINISH: worker_state = 2; +pub const THR_RUN: worker_state = 1; +pub const THR_IDLE: worker_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_easy { + pub filters: [lzma_filter; 5], + pub opt_lzma: lzma_options_lzma, +} +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const SIG_SETMASK: c_int = 3 as c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const MYTHREAD_RET_VALUE: *mut c_void = NULL; +#[inline] +unsafe extern "C" fn mythread_sigmask( + mut how: c_int, + mut set: *const sigset_t, + mut oset: *mut sigset_t, +) { + let mut ret: c_int = pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t); +} +#[inline] +unsafe extern "C" fn mythread_create( + mut thread: *mut mythread, + mut func: Option *mut c_void>, + mut arg: *mut c_void, +) -> c_int { + let mut old: sigset_t = 0; + let mut all: sigset_t = 0; + all = !(0 as sigset_t); + mythread_sigmask(SIG_SETMASK, &raw mut all, &raw mut old); + let ret: c_int = pthread_create( + thread as *mut pthread_t, + ::core::ptr::null::(), + func as Option *mut c_void>, + arg as *mut c_void, + ) as c_int; + mythread_sigmask( + SIG_SETMASK, + &raw mut old, + ::core::ptr::null_mut::(), + ); + return ret; +} +#[inline] +unsafe extern "C" fn mythread_join(mut thread: mythread) -> c_int { + return pthread_join(thread as pthread_t, ::core::ptr::null_mut::<*mut c_void>()); +} +#[inline] +unsafe extern "C" fn mythread_mutex_init(mut mutex: *mut mythread_mutex) -> c_int { + return pthread_mutex_init( + mutex as *mut pthread_mutex_t, + ::core::ptr::null::(), + ); +} +#[inline] +unsafe extern "C" fn mythread_mutex_destroy(mut mutex: *mut mythread_mutex) { + let mut ret: c_int = pthread_mutex_destroy(mutex as *mut pthread_mutex_t); +} +#[inline] +unsafe extern "C" fn mythread_mutex_lock(mut mutex: *mut mythread_mutex) { + let mut ret: c_int = pthread_mutex_lock(mutex as *mut pthread_mutex_t); +} +#[inline] +unsafe extern "C" fn mythread_mutex_unlock(mut mutex: *mut mythread_mutex) { + let mut ret: c_int = pthread_mutex_unlock(mutex as *mut pthread_mutex_t); +} +#[inline] +unsafe extern "C" fn mythread_cond_init(mut mycond: *mut mythread_cond) -> c_int { + (*mycond).clk_id = _CLOCK_REALTIME; + return pthread_cond_init( + &raw mut (*mycond).cond, + ::core::ptr::null::(), + ); +} +#[inline] +unsafe extern "C" fn mythread_cond_destroy(mut cond: *mut mythread_cond) { + let mut ret: c_int = pthread_cond_destroy(&raw mut (*cond).cond); +} +#[inline] +unsafe extern "C" fn mythread_cond_signal(mut cond: *mut mythread_cond) { + let mut ret: c_int = pthread_cond_signal(&raw mut (*cond).cond); +} +#[inline] +unsafe extern "C" fn mythread_cond_wait( + mut cond: *mut mythread_cond, + mut mutex: *mut mythread_mutex, +) { + let mut ret: c_int = pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t); +} +#[inline] +unsafe extern "C" fn mythread_cond_timedwait( + mut cond: *mut mythread_cond, + mut mutex: *mut mythread_mutex, + mut condtime: *const mythread_condtime, +) -> c_int { + let mut ret: c_int = pthread_cond_timedwait( + &raw mut (*cond).cond, + mutex as *mut pthread_mutex_t, + condtime as *const timespec, + ); + return ret; +} +#[inline] +unsafe extern "C" fn mythread_condtime_set( + mut condtime: *mut mythread_condtime, + mut cond: *const mythread_cond, + mut timeout_ms: u32, +) { + (*condtime).tv_sec = timeout_ms.wrapping_div(1000 as u32) as time_t as __darwin_time_t; + (*condtime).tv_nsec = timeout_ms + .wrapping_rem(1000 as u32) + .wrapping_mul(1000000 as u32) as c_long; + let mut now: timespec = timespec { + tv_sec: 0, + tv_nsec: 0, + }; + let mut ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); + (*condtime).tv_sec += now.tv_sec; + (*condtime).tv_nsec += now.tv_nsec; + if (*condtime).tv_nsec >= 1000000000 as c_long { + (*condtime).tv_nsec -= 1000000000 as c_long; + (*condtime).tv_sec += 1; + } +} +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +#[inline] +unsafe extern "C" fn lzma_outq_has_buf(mut outq: *const lzma_outq) -> bool { + return (*outq).bufs_in_use < (*outq).bufs_limit; +} +#[inline] +unsafe extern "C" fn lzma_outq_is_empty(mut outq: *const lzma_outq) -> bool { + return (*outq).bufs_in_use == 0 as u32; +} +pub const BLOCK_SIZE_MAX: c_ulonglong = UINT64_MAX.wrapping_div(LZMA_THREADS_MAX as c_ulonglong); +unsafe extern "C" fn worker_error(mut thr: *mut worker_thread, mut ret: lzma_ret) { + let mut mythread_i_207: c_uint = 0 as c_uint; + while if mythread_i_207 != 0 { + mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_207: c_uint = 0 as c_uint; + while mythread_j_207 == 0 { + if (*(*thr).coder).thread_error as c_uint == LZMA_OK as c_uint { + (*(*thr).coder).thread_error = ret; + } + mythread_cond_signal(&raw mut (*(*thr).coder).cond); + mythread_j_207 = 1 as c_uint; + } + mythread_i_207 = 1 as c_uint; + } +} +unsafe extern "C" fn worker_encode( + mut thr: *mut worker_thread, + mut out_pos: *mut size_t, + mut state: worker_state, +) -> worker_state { + (*thr).block_options = lzma_block { + version: 0 as u32, + header_size: 0, + check: (*(*thr).coder).stream_flags.check, + compressed_size: (*(*thr).outbuf).allocated as lzma_vli, + uncompressed_size: (*(*thr).coder).block_size as lzma_vli, + filters: &raw mut (*thr).filters as *mut lzma_filter, + raw_check: [0; 64], + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr3: ::core::ptr::null_mut::(), + reserved_int1: 0, + reserved_int2: 0, + reserved_int3: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + ignore_check: 0, + reserved_bool2: 0, + reserved_bool3: 0, + reserved_bool4: 0, + reserved_bool5: 0, + reserved_bool6: 0, + reserved_bool7: 0, + reserved_bool8: 0, + }; + let mut ret: lzma_ret = lzma_block_header_size(&raw mut (*thr).block_options); + if ret as c_uint != LZMA_OK as c_uint { + worker_error(thr, ret); + return THR_STOP; + } + ret = lzma_block_encoder_init( + &raw mut (*thr).block_encoder, + (*thr).allocator, + &raw mut (*thr).block_options, + ); + if ret as c_uint != LZMA_OK as c_uint { + worker_error(thr, ret); + return THR_STOP; + } + let mut in_pos: size_t = 0 as size_t; + let mut in_size: size_t = 0 as size_t; + *out_pos = (*thr).block_options.header_size as size_t; + let out_size: size_t = (*(*thr).outbuf).allocated; + loop { + let mut mythread_i_258: c_uint = 0 as c_uint; + while if mythread_i_258 != 0 { + mythread_mutex_unlock(&raw mut (*thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_258: c_uint = 0 as c_uint; + while mythread_j_258 == 0 { + (*thr).progress_in = in_pos as u64; + (*thr).progress_out = *out_pos as u64; + while in_size == (*thr).in_size && (*thr).state as c_uint == THR_RUN as c_uint { + mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + } + state = (*thr).state; + in_size = (*thr).in_size; + mythread_j_258 = 1 as c_uint; + } + mythread_i_258 = 1 as c_uint; + } + if state as c_uint >= THR_STOP as c_uint { + return state; + } + let mut action: lzma_action = (if state as c_uint == THR_FINISH as c_uint { + LZMA_FINISH as c_int + } else { + LZMA_RUN as c_int + }) as lzma_action; + static mut in_chunk_max: size_t = 16384 as size_t; + let mut in_limit: size_t = in_size; + if in_size.wrapping_sub(in_pos) > in_chunk_max { + in_limit = in_pos.wrapping_add(in_chunk_max); + action = LZMA_RUN; + } + ret = (*thr) + .block_encoder + .code + .expect("non-null function pointer")( + (*thr).block_encoder.coder, + (*thr).allocator, + (*thr).in_0, + &raw mut in_pos, + in_limit, + &raw mut (*(*thr).outbuf).buf as *mut u8, + out_pos, + out_size, + action, + ); + if !(ret as c_uint == LZMA_OK as c_uint && *out_pos < out_size) { + break; + } + } + match ret as c_uint { + 1 => { + ret = lzma_block_header_encode( + &raw mut (*thr).block_options, + &raw mut (*(*thr).outbuf).buf as *mut u8, + ); + if ret as c_uint != LZMA_OK as c_uint { + worker_error(thr, ret); + return THR_STOP; + } + } + 0 => { + let mut mythread_i_321: c_uint = 0 as c_uint; + while if mythread_i_321 != 0 { + mythread_mutex_unlock(&raw mut (*thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_321: c_uint = 0 as c_uint; + while mythread_j_321 == 0 { + while (*thr).state as c_uint == THR_RUN as c_uint { + mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + } + state = (*thr).state; + in_size = (*thr).in_size; + mythread_j_321 = 1 as c_uint; + } + mythread_i_321 = 1 as c_uint; + } + if state as c_uint >= THR_STOP as c_uint { + return state; + } + *out_pos = 0 as size_t; + ret = lzma_block_uncomp_encode( + &raw mut (*thr).block_options, + (*thr).in_0, + in_size, + &raw mut (*(*thr).outbuf).buf as *mut u8, + out_pos, + out_size, + ); + if ret as c_uint != LZMA_OK as c_uint { + worker_error(thr, LZMA_PROG_ERROR); + return THR_STOP; + } + } + _ => { + worker_error(thr, ret); + return THR_STOP; + } + } + (*(*thr).outbuf).unpadded_size = lzma_block_unpadded_size(&raw mut (*thr).block_options); + (*(*thr).outbuf).uncompressed_size = (*thr).block_options.uncompressed_size; + return THR_FINISH; +} +unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { + let mut thr: *mut worker_thread = thr_ptr as *mut worker_thread; + let mut state: worker_state = THR_IDLE; + loop { + let mut mythread_i_370: c_uint = 0 as c_uint; + while if mythread_i_370 != 0 { + mythread_mutex_unlock(&raw mut (*thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_370: c_uint = 0 as c_uint; + while mythread_j_370 == 0 { + loop { + if (*thr).state as c_uint == THR_STOP as c_uint { + (*thr).state = THR_IDLE; + mythread_cond_signal(&raw mut (*thr).cond); + } + state = (*thr).state; + if state as c_uint != THR_IDLE as c_uint { + break; + } + mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + } + mythread_j_370 = 1 as c_uint; + } + mythread_i_370 = 1 as c_uint; + } + let mut out_pos: size_t = 0 as size_t; + if state as c_uint <= THR_FINISH as c_uint { + state = worker_encode(thr, &raw mut out_pos, state); + } + if state as c_uint == THR_EXIT as c_uint { + break; + } + let mut mythread_i_401: c_uint = 0 as c_uint; + while if mythread_i_401 != 0 { + mythread_mutex_unlock(&raw mut (*thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_401: c_uint = 0 as c_uint; + while mythread_j_401 == 0 { + if (*thr).state as c_uint != THR_EXIT as c_uint { + (*thr).state = THR_IDLE; + mythread_cond_signal(&raw mut (*thr).cond); + } + mythread_j_401 = 1 as c_uint; + } + mythread_i_401 = 1 as c_uint; + } + let mut mythread_i_408: c_uint = 0 as c_uint; + while if mythread_i_408 != 0 { + mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_408: c_uint = 0 as c_uint; + while mythread_j_408 == 0 { + if state as c_uint == THR_FINISH as c_uint { + (*(*thr).outbuf).pos = out_pos; + (*(*thr).outbuf).finished = true_0 != 0; + } + (*(*thr).coder).progress_in = (*(*thr).coder) + .progress_in + .wrapping_add((*(*thr).outbuf).uncompressed_size as u64); + (*(*thr).coder).progress_out = + (*(*thr).coder).progress_out.wrapping_add(out_pos as u64); + (*thr).progress_in = 0 as u64; + (*thr).progress_out = 0 as u64; + (*thr).next = (*(*thr).coder).threads_free; + (*(*thr).coder).threads_free = thr; + mythread_cond_signal(&raw mut (*(*thr).coder).cond); + mythread_j_408 = 1 as c_uint; + } + mythread_i_408 = 1 as c_uint; + } + } + lzma_filters_free( + &raw mut (*thr).filters as *mut lzma_filter, + (*thr).allocator, + ); + mythread_mutex_destroy(&raw mut (*thr).mutex); + mythread_cond_destroy(&raw mut (*thr).cond); + lzma_next_end(&raw mut (*thr).block_encoder, (*thr).allocator); + lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); + return MYTHREAD_RET_VALUE; +} +unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder, mut wait_for_threads: bool) { + let mut i: u32 = 0 as u32; + while i < (*coder).threads_initialized { + let mut mythread_i_449: c_uint = 0 as c_uint; + while if mythread_i_449 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_449: c_uint = 0 as c_uint; + while mythread_j_449 == 0 { + (*(*coder).threads.offset(i as isize)).state = THR_STOP; + mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); + mythread_j_449 = 1 as c_uint; + } + mythread_i_449 = 1 as c_uint; + } + i = i.wrapping_add(1); + } + if !wait_for_threads { + return; + } + let mut i_0: u32 = 0 as u32; + while i_0 < (*coder).threads_initialized { + let mut mythread_i_460: c_uint = 0 as c_uint; + while if mythread_i_460 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i_0 as isize)).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i_0 as isize)).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_460: c_uint = 0 as c_uint; + while mythread_j_460 == 0 { + while (*(*coder).threads.offset(i_0 as isize)).state as c_uint != THR_IDLE as c_uint + { + mythread_cond_wait( + &raw mut (*(*coder).threads.offset(i_0 as isize)).cond, + &raw mut (*(*coder).threads.offset(i_0 as isize)).mutex, + ); + } + mythread_j_460 = 1 as c_uint; + } + mythread_i_460 = 1 as c_uint; + } + i_0 = i_0.wrapping_add(1); + } +} +unsafe extern "C" fn threads_end( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) { + let mut i: u32 = 0 as u32; + while i < (*coder).threads_initialized { + let mut mythread_i_477: c_uint = 0 as c_uint; + while if mythread_i_477 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_477: c_uint = 0 as c_uint; + while mythread_j_477 == 0 { + (*(*coder).threads.offset(i as isize)).state = THR_EXIT; + mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); + mythread_j_477 = 1 as c_uint; + } + mythread_i_477 = 1 as c_uint; + } + i = i.wrapping_add(1); + } + let mut i_0: u32 = 0 as u32; + while i_0 < (*coder).threads_initialized { + let mut ret: c_int = mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); + i_0 = i_0.wrapping_add(1); + } + lzma_free((*coder).threads as *mut c_void, allocator); +} +unsafe extern "C" fn initialize_new_thread( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + let mut thr: *mut worker_thread = (*coder) + .threads + .offset((*coder).threads_initialized as isize) + as *mut worker_thread; + (*thr).in_0 = lzma_alloc((*coder).block_size, allocator) as *mut u8; + if (*thr).in_0.is_null() { + return LZMA_MEM_ERROR; + } + if !(mythread_mutex_init(&raw mut (*thr).mutex) != 0) { + if !(mythread_cond_init(&raw mut (*thr).cond) != 0) { + (*thr).state = THR_IDLE; + (*thr).allocator = allocator; + (*thr).coder = coder; + (*thr).progress_in = 0 as u64; + (*thr).progress_out = 0 as u64; + (*thr).block_encoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*thr).filters[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + if mythread_create( + &raw mut (*thr).thread_id, + Some(worker_start as unsafe extern "C" fn(*mut c_void) -> *mut c_void), + thr as *mut c_void, + ) != 0 + { + mythread_cond_destroy(&raw mut (*thr).cond); + } else { + (*coder).threads_initialized = (*coder).threads_initialized.wrapping_add(1); + (*coder).thr = thr; + return LZMA_OK; + } + } + mythread_mutex_destroy(&raw mut (*thr).mutex); + } + lzma_free((*thr).in_0 as *mut c_void, allocator); + return LZMA_MEM_ERROR; +} +unsafe extern "C" fn get_thread( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, +) -> lzma_ret { + if !lzma_outq_has_buf(&raw mut (*coder).outq) { + return LZMA_OK; + } + let ret_: lzma_ret = lzma_outq_prealloc_buf( + &raw mut (*coder).outq, + allocator, + (*coder).outbuf_alloc_size, + ) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + if (*coder).filters_cache[0 as usize].id == LZMA_VLI_UNKNOWN as lzma_vli { + let ret__0: lzma_ret = lzma_filters_copy( + &raw mut (*coder).filters as *mut lzma_filter, + &raw mut (*coder).filters_cache as *mut lzma_filter, + allocator, + ) as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { + return ret__0; + } + } + let mut mythread_i_560: c_uint = 0 as c_uint; + while if mythread_i_560 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_560: c_uint = 0 as c_uint; + while mythread_j_560 == 0 { + if !(*coder).threads_free.is_null() { + (*coder).thr = (*coder).threads_free; + (*coder).threads_free = (*(*coder).threads_free).next; + } + mythread_j_560 = 1 as c_uint; + } + mythread_i_560 = 1 as c_uint; + } + if (*coder).thr.is_null() { + if (*coder).threads_initialized == (*coder).threads_max { + return LZMA_OK; + } + let ret__1: lzma_ret = initialize_new_thread(coder, allocator) as lzma_ret; + if ret__1 as c_uint != LZMA_OK as c_uint { + return ret__1; + } + } + let mut mythread_i_578: c_uint = 0 as c_uint; + while if mythread_i_578 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_578: c_uint = 0 as c_uint; + while mythread_j_578 == 0 { + (*(*coder).thr).state = THR_RUN; + (*(*coder).thr).in_size = 0 as size_t; + (*(*coder).thr).outbuf = lzma_outq_get_buf(&raw mut (*coder).outq, NULL); + lzma_filters_free( + &raw mut (*(*coder).thr).filters as *mut lzma_filter, + allocator, + ); + memcpy( + &raw mut (*(*coder).thr).filters as *mut lzma_filter as *mut c_void, + &raw mut (*coder).filters_cache as *mut lzma_filter as *const c_void, + ::core::mem::size_of::<[lzma_filter; 5]>() as size_t, + ); + (*coder).filters_cache[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + mythread_cond_signal(&raw mut (*(*coder).thr).cond); + mythread_j_578 = 1 as c_uint; + } + mythread_i_578 = 1 as c_uint; + } + return LZMA_OK; +} +unsafe extern "C" fn stream_encode_in( + mut coder: *mut lzma_stream_coder, + mut allocator: *const lzma_allocator, + mut in_0: *const u8, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + while *in_pos < in_size || !(*coder).thr.is_null() && action as c_uint != LZMA_RUN as c_uint { + if (*coder).thr.is_null() { + let ret: lzma_ret = get_thread(coder, allocator) as lzma_ret; + if (*coder).thr.is_null() { + return ret; + } + } + let mut thr_in_size: size_t = (*(*coder).thr).in_size; + lzma_bufcpy( + in_0, + in_pos, + in_size, + (*(*coder).thr).in_0, + &raw mut thr_in_size, + (*coder).block_size, + ); + let finish: bool = thr_in_size == (*coder).block_size + || *in_pos == in_size && action as c_uint != LZMA_RUN as c_uint; + let mut block_error: bool = false_0 != 0; + let mut mythread_i_628: c_uint = 0 as c_uint; + while if mythread_i_628 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_628: c_uint = 0 as c_uint; + while mythread_j_628 == 0 { + if (*(*coder).thr).state as c_uint == THR_IDLE as c_uint { + block_error = true_0 != 0; + } else { + (*(*coder).thr).in_size = thr_in_size; + if finish { + (*(*coder).thr).state = THR_FINISH; + } + mythread_cond_signal(&raw mut (*(*coder).thr).cond); + } + mythread_j_628 = 1 as c_uint; + } + mythread_i_628 = 1 as c_uint; + } + if block_error { + let mut ret_0: lzma_ret = LZMA_OK; + let mut mythread_i_649: c_uint = 0 as c_uint; + while if mythread_i_649 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_649: c_uint = 0 as c_uint; + while mythread_j_649 == 0 { + ret_0 = (*coder).thread_error; + mythread_j_649 = 1 as c_uint; + } + mythread_i_649 = 1 as c_uint; + } + return ret_0; + } + if finish { + (*coder).thr = ::core::ptr::null_mut::(); + } + } + return LZMA_OK; +} +unsafe extern "C" fn wait_for_work( + mut coder: *mut lzma_stream_coder, + mut wait_abs: *mut mythread_condtime, + mut has_blocked: *mut bool, + mut has_input: bool, +) -> bool { + if (*coder).timeout != 0 as u32 && !*has_blocked { + *has_blocked = true_0 != 0; + mythread_condtime_set(wait_abs, &raw mut (*coder).cond, (*coder).timeout); + } + let mut timed_out: bool = false_0 != 0; + let mut mythread_i_689: c_uint = 0 as c_uint; + while if mythread_i_689 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_689: c_uint = 0 as c_uint; + while mythread_j_689 == 0 { + while (!has_input + || (*coder).threads_free.is_null() + || !lzma_outq_has_buf(&raw mut (*coder).outq)) + && !lzma_outq_is_readable(&raw mut (*coder).outq) + && (*coder).thread_error as c_uint == LZMA_OK as c_uint + && !timed_out + { + if (*coder).timeout != 0 as u32 { + timed_out = mythread_cond_timedwait( + &raw mut (*coder).cond, + &raw mut (*coder).mutex, + wait_abs, + ) != 0 as c_int; + } else { + mythread_cond_wait(&raw mut (*coder).cond, &raw mut (*coder).mutex); + } + } + mythread_j_689 = 1 as c_uint; + } + mythread_i_689 = 1 as c_uint; + } + return timed_out; +} +unsafe extern "C" fn stream_encode_mt( + mut coder_ptr: *mut c_void, + mut allocator: *const lzma_allocator, + mut in_0: *const u8, + mut in_pos: *mut size_t, + mut in_size: size_t, + mut out: *mut u8, + mut out_pos: *mut size_t, + mut out_size: size_t, + mut action: lzma_action, +) -> lzma_ret { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + 's_270: { + let mut current_block_53: u64; + match (*coder).sequence as c_uint { + 0 => { + lzma_bufcpy( + &raw mut (*coder).header as *mut u8, + &raw mut (*coder).header_pos, + ::core::mem::size_of::<[u8; 12]>() as size_t, + out, + out_pos, + out_size, + ); + if (*coder).header_pos < ::core::mem::size_of::<[u8; 12]>() as usize { + return LZMA_OK; + } + (*coder).header_pos = 0 as size_t; + (*coder).sequence = SEQ_BLOCK; + current_block_53 = 18046538441878631153; + } + 1 => { + current_block_53 = 18046538441878631153; + } + 2 => { + current_block_53 = 7301844830188010456; + } + 3 => { + current_block_53 = 8365064614624041636; + } + _ => { + break 's_270; + } + } + match current_block_53 { + 18046538441878631153 => { + let mut unpadded_size: lzma_vli = 0 as lzma_vli; + let mut uncompressed_size: lzma_vli = 0 as lzma_vli; + let mut ret: lzma_ret = LZMA_OK; + let mut has_blocked: bool = false_0 != 0; + let mut wait_abs: mythread_condtime = timespec { + tv_sec: 0 as __darwin_time_t, + tv_nsec: 0, + }; + loop { + let mut mythread_i_747: c_uint = 0 as c_uint; + while if mythread_i_747 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_747: c_uint = 0 as c_uint; + while mythread_j_747 == 0 { + ret = (*coder).thread_error; + if ret as c_uint != LZMA_OK as c_uint { + break; + } + ret = lzma_outq_read( + &raw mut (*coder).outq, + allocator, + out, + out_pos, + out_size, + &raw mut unpadded_size, + &raw mut uncompressed_size, + ); + mythread_j_747 = 1 as c_uint; + } + mythread_i_747 = 1 as c_uint; + } + if ret as c_uint == LZMA_STREAM_END as c_uint { + ret = lzma_index_append( + (*coder).index, + allocator, + unpadded_size, + uncompressed_size, + ); + if ret as c_uint != LZMA_OK as c_uint { + threads_stop(coder, false_0 != 0); + return ret; + } + if *out_pos < out_size { + continue; + } + } + if ret as c_uint != LZMA_OK as c_uint { + threads_stop(coder, false_0 != 0); + return ret; + } + ret = stream_encode_in(coder, allocator, in_0, in_pos, in_size, action); + if ret as c_uint != LZMA_OK as c_uint { + threads_stop(coder, false_0 != 0); + return ret; + } + if *in_pos == in_size { + if action as c_uint == LZMA_RUN as c_uint { + return LZMA_OK; + } + if action as c_uint == LZMA_FULL_BARRIER as c_uint { + return LZMA_STREAM_END; + } + if lzma_outq_is_empty(&raw mut (*coder).outq) { + if action as c_uint == LZMA_FINISH as c_uint { + break; + } + if action as c_uint == LZMA_FULL_FLUSH as c_uint { + return LZMA_STREAM_END; + } + } + } + if *out_pos == out_size { + return LZMA_OK; + } + if wait_for_work( + coder, + &raw mut wait_abs, + &raw mut has_blocked, + *in_pos < in_size, + ) { + return LZMA_RET_INTERNAL1; + } + } + let ret_: lzma_ret = lzma_index_encoder_init( + &raw mut (*coder).index_encoder, + allocator, + (*coder).index, + ) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + (*coder).sequence = SEQ_INDEX; + (*coder).progress_out = (*coder).progress_out.wrapping_add( + lzma_index_size((*coder).index) + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) + as u64, + ); + current_block_53 = 7301844830188010456; + } + _ => {} + } + match current_block_53 { + 7301844830188010456 => { + let ret_0: lzma_ret = (*coder) + .index_encoder + .code + .expect("non-null function pointer")( + (*coder).index_encoder.coder, + allocator, + ::core::ptr::null::(), + ::core::ptr::null_mut::(), + 0 as size_t, + out, + out_pos, + out_size, + LZMA_RUN, + ) as lzma_ret; + if ret_0 as c_uint != LZMA_STREAM_END as c_uint { + return ret_0; + } + (*coder).stream_flags.backward_size = lzma_index_size((*coder).index); + if lzma_stream_footer_encode( + &raw mut (*coder).stream_flags, + &raw mut (*coder).header as *mut u8, + ) as c_uint + != LZMA_OK as c_uint + { + return LZMA_PROG_ERROR; + } + (*coder).sequence = SEQ_STREAM_FOOTER; + } + _ => {} + } + lzma_bufcpy( + &raw mut (*coder).header as *mut u8, + &raw mut (*coder).header_pos, + ::core::mem::size_of::<[u8; 12]>() as size_t, + out, + out_pos, + out_size, + ); + return (if (*coder).header_pos < ::core::mem::size_of::<[u8; 12]>() as usize { + LZMA_OK as c_int + } else { + LZMA_STREAM_END as c_int + }) as lzma_ret; + } + return LZMA_PROG_ERROR; +} +unsafe extern "C" fn stream_encoder_mt_end( + mut coder_ptr: *mut c_void, + mut allocator: *const lzma_allocator, +) { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + threads_end(coder, allocator); + lzma_outq_end(&raw mut (*coder).outq, allocator); + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_filters_free( + &raw mut (*coder).filters_cache as *mut lzma_filter, + allocator, + ); + lzma_next_end(&raw mut (*coder).index_encoder, allocator); + lzma_index_end((*coder).index, allocator); + mythread_cond_destroy(&raw mut (*coder).cond); + mythread_mutex_destroy(&raw mut (*coder).mutex); + lzma_free(coder as *mut c_void, allocator); +} +unsafe extern "C" fn stream_encoder_mt_update( + mut coder_ptr: *mut c_void, + mut allocator: *const lzma_allocator, + mut filters: *const lzma_filter, + mut reversed_filters: *const lzma_filter, +) -> lzma_ret { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + if (*coder).sequence as c_uint > SEQ_BLOCK as c_uint { + return LZMA_PROG_ERROR; + } + if !(*coder).thr.is_null() { + return LZMA_PROG_ERROR; + } + if lzma_raw_encoder_memusage(filters) == UINT64_MAX as u64 { + return LZMA_OPTIONS_ERROR; + } + let mut temp: [lzma_filter; 5] = [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::(), + }; 5]; + let ret_: lzma_ret = + lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_filters_free( + &raw mut (*coder).filters_cache as *mut lzma_filter, + allocator, + ); + memcpy( + &raw mut (*coder).filters as *mut lzma_filter as *mut c_void, + &raw mut temp as *mut lzma_filter as *const c_void, + ::core::mem::size_of::<[lzma_filter; 5]>() as size_t, + ); + return LZMA_OK; +} +unsafe extern "C" fn get_options( + mut options: *const lzma_mt, + mut opt_easy: *mut lzma_options_easy, + mut filters: *mut *const lzma_filter, + mut block_size: *mut u64, + mut outbuf_size_max: *mut u64, +) -> lzma_ret { + if options.is_null() { + return LZMA_PROG_ERROR; + } + if (*options).flags != 0 as u32 + || (*options).threads == 0 as u32 + || (*options).threads > LZMA_THREADS_MAX as u32 + { + return LZMA_OPTIONS_ERROR; + } + if !(*options).filters.is_null() { + *filters = (*options).filters; + } else { + if lzma_easy_preset(opt_easy, (*options).preset) { + return LZMA_OPTIONS_ERROR; + } + *filters = &raw mut (*opt_easy).filters as *mut lzma_filter; + } + if (*options).block_size > 0 as u64 { + *block_size = (*options).block_size; + } else { + *block_size = lzma_mt_block_size(*filters); + } + if *block_size > BLOCK_SIZE_MAX as u64 || *block_size == UINT64_MAX as u64 { + return LZMA_OPTIONS_ERROR; + } + *outbuf_size_max = lzma_block_buffer_bound64(*block_size); + if *outbuf_size_max == 0 as u64 { + return LZMA_MEM_ERROR; + } + return LZMA_OK; +} +unsafe extern "C" fn get_progress( + mut coder_ptr: *mut c_void, + mut progress_in: *mut u64, + mut progress_out: *mut u64, +) { + let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let mut mythread_i_1010: c_uint = 0 as c_uint; + while if mythread_i_1010 != 0 { + mythread_mutex_unlock(&raw mut (*coder).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*coder).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1010: c_uint = 0 as c_uint; + while mythread_j_1010 == 0 { + *progress_in = (*coder).progress_in; + *progress_out = (*coder).progress_out; + let mut i: size_t = 0 as size_t; + while i < (*coder).threads_initialized as size_t { + let mut mythread_i_1015: c_uint = 0 as c_uint; + while if mythread_i_1015 != 0 { + mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 0 as c_int + } else { + mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + 1 as c_int + } != 0 + { + let mut mythread_j_1015: c_uint = 0 as c_uint; + while mythread_j_1015 == 0 { + *progress_in = (*progress_in) + .wrapping_add((*(*coder).threads.offset(i as isize)).progress_in); + *progress_out = (*progress_out) + .wrapping_add((*(*coder).threads.offset(i as isize)).progress_out); + mythread_j_1015 = 1 as c_uint; + } + mythread_i_1015 = 1 as c_uint; + } + i = i.wrapping_add(1); + } + mythread_j_1010 = 1 as c_uint; + } + mythread_i_1010 = 1 as c_uint; + } +} +unsafe extern "C" fn stream_encoder_mt_init( + mut next: *mut lzma_next_coder, + mut allocator: *const lzma_allocator, + mut options: *const lzma_mt, +) -> lzma_ret { + if ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_mt, + ) -> lzma_ret, + >, + uintptr_t, + >(Some( + stream_encoder_mt_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_mt, + ) -> lzma_ret, + )) != (*next).init + { + lzma_next_end(next, allocator); + } + (*next).init = ::core::mem::transmute::< + Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_mt, + ) -> lzma_ret, + >, + uintptr_t, + >(Some( + stream_encoder_mt_init + as unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_mt, + ) -> lzma_ret, + )); + let mut easy: lzma_options_easy = lzma_options_easy { + filters: [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::(), + }; 5], + opt_lzma: lzma_options_lzma { + dict_size: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + lc: 0, + lp: 0, + pb: 0, + mode: 0 as lzma_mode, + nice_len: 0, + mf: 0 as lzma_match_finder, + depth: 0, + ext_flags: 0, + ext_size_low: 0, + ext_size_high: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), + }, + }; + let mut filters: *const lzma_filter = ::core::ptr::null::(); + let mut block_size: u64 = 0; + let mut outbuf_size_max: u64 = 0; + let ret_: lzma_ret = get_options( + options, + &raw mut easy, + &raw mut filters, + &raw mut block_size, + &raw mut outbuf_size_max, + ) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + if lzma_raw_encoder_memusage(filters) == UINT64_MAX as u64 { + return LZMA_OPTIONS_ERROR; + } + if (*options).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { + return LZMA_PROG_ERROR; + } + if lzma_check_is_supported((*options).check) == 0 { + return LZMA_UNSUPPORTED_CHECK; + } + let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; + if coder.is_null() { + coder = lzma_alloc( + ::core::mem::size_of::() as size_t, + allocator, + ) as *mut lzma_stream_coder; + if coder.is_null() { + return LZMA_MEM_ERROR; + } + (*next).coder = coder as *mut c_void; + if mythread_mutex_init(&raw mut (*coder).mutex) != 0 { + lzma_free(coder as *mut c_void, allocator); + (*next).coder = NULL; + return LZMA_MEM_ERROR; + } + if mythread_cond_init(&raw mut (*coder).cond) != 0 { + mythread_mutex_destroy(&raw mut (*coder).mutex); + lzma_free(coder as *mut c_void, allocator); + (*next).coder = NULL; + return LZMA_MEM_ERROR; + } + (*next).code = Some( + stream_encode_mt + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const u8, + *mut size_t, + size_t, + *mut u8, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ) as lzma_code_function; + (*next).end = Some( + stream_encoder_mt_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), + ) as lzma_end_function; + (*next).get_progress = + Some(get_progress as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> ()) + as Option ()>; + (*next).update = Some( + stream_encoder_mt_update + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ) + as Option< + unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >; + (*coder).filters[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters_cache[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).index_encoder = lzma_next_coder_s { + coder: NULL, + id: LZMA_VLI_UNKNOWN as lzma_vli, + init: ::core::ptr::null_mut::() as uintptr_t, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*coder).index = ::core::ptr::null_mut::(); + memset( + &raw mut (*coder).outq as *mut c_void, + 0 as c_int, + ::core::mem::size_of::() as size_t, + ); + (*coder).threads = ::core::ptr::null_mut::(); + (*coder).threads_max = 0 as u32; + (*coder).threads_initialized = 0 as u32; + } + (*coder).sequence = SEQ_STREAM_HEADER; + (*coder).block_size = block_size as size_t; + (*coder).outbuf_alloc_size = outbuf_size_max as size_t; + (*coder).thread_error = LZMA_OK; + (*coder).thr = ::core::ptr::null_mut::(); + if (*coder).threads_max != (*options).threads { + threads_end(coder, allocator); + (*coder).threads = ::core::ptr::null_mut::(); + (*coder).threads_max = 0 as u32; + (*coder).threads_initialized = 0 as u32; + (*coder).threads_free = ::core::ptr::null_mut::(); + (*coder).threads = lzma_alloc( + ((*options).threads as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), + allocator, + ) as *mut worker_thread; + if (*coder).threads.is_null() { + return LZMA_MEM_ERROR; + } + (*coder).threads_max = (*options).threads; + } else { + threads_stop(coder, true_0 != 0); + } + let ret__0: lzma_ret = + lzma_outq_init(&raw mut (*coder).outq, allocator, (*options).threads) as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { + return ret__0; + } + (*coder).timeout = (*options).timeout; + lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_filters_free( + &raw mut (*coder).filters_cache as *mut lzma_filter, + allocator, + ); + let ret__1: lzma_ret = lzma_filters_copy( + filters, + &raw mut (*coder).filters as *mut lzma_filter, + allocator, + ) as lzma_ret; + if ret__1 as c_uint != LZMA_OK as c_uint { + return ret__1; + } + lzma_index_end((*coder).index, allocator); + (*coder).index = lzma_index_init(allocator); + if (*coder).index.is_null() { + return LZMA_MEM_ERROR; + } + (*coder).stream_flags.version = 0 as u32; + (*coder).stream_flags.check = (*options).check; + let ret__2: lzma_ret = lzma_stream_header_encode( + &raw mut (*coder).stream_flags, + &raw mut (*coder).header as *mut u8, + ) as lzma_ret; + if ret__2 as c_uint != LZMA_OK as c_uint { + return ret__2; + } + (*coder).header_pos = 0 as size_t; + (*coder).progress_in = 0 as u64; + (*coder).progress_out = LZMA_STREAM_HEADER_SIZE as u64; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_encoder_mt( + mut strm: *mut lzma_stream, + mut options: *const lzma_mt, +) -> lzma_ret { + let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { + return ret_; + } + let ret__0: lzma_ret = stream_encoder_mt_init( + &raw mut (*(*strm).internal).next, + (*strm).allocator, + options, + ) as lzma_ret; + if ret__0 as c_uint != LZMA_OK as c_uint { + lzma_end(strm); + return ret__0; + } + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FULL_FLUSH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FULL_BARRIER as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + return LZMA_OK; +} +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(mut options: *const lzma_mt) -> u64 { + let mut easy: lzma_options_easy = lzma_options_easy { + filters: [lzma_filter { + id: 0, + options: ::core::ptr::null_mut::(), + }; 5], + opt_lzma: lzma_options_lzma { + dict_size: 0, + preset_dict: ::core::ptr::null::(), + preset_dict_size: 0, + lc: 0, + lp: 0, + pb: 0, + mode: 0 as lzma_mode, + nice_len: 0, + mf: 0 as lzma_match_finder, + depth: 0, + ext_flags: 0, + ext_size_low: 0, + ext_size_high: 0, + reserved_int4: 0, + reserved_int5: 0, + reserved_int6: 0, + reserved_int7: 0, + reserved_int8: 0, + reserved_enum1: LZMA_RESERVED_ENUM, + reserved_enum2: LZMA_RESERVED_ENUM, + reserved_enum3: LZMA_RESERVED_ENUM, + reserved_enum4: LZMA_RESERVED_ENUM, + reserved_ptr1: ::core::ptr::null_mut::(), + reserved_ptr2: ::core::ptr::null_mut::(), + }, + }; + let mut filters: *const lzma_filter = ::core::ptr::null::(); + let mut block_size: u64 = 0; + let mut outbuf_size_max: u64 = 0; + if get_options( + options, + &raw mut easy, + &raw mut filters, + &raw mut block_size, + &raw mut outbuf_size_max, + ) as c_uint + != LZMA_OK as c_uint + { + return UINT64_MAX as u64; + } + let inbuf_memusage: u64 = ((*options).threads as u64).wrapping_mul(block_size); + let mut filters_memusage: u64 = lzma_raw_encoder_memusage(filters); + if filters_memusage == UINT64_MAX as u64 { + return UINT64_MAX as u64; + } + filters_memusage = filters_memusage.wrapping_mul((*options).threads as u64); + let outq_memusage: u64 = lzma_outq_memusage(outbuf_size_max, (*options).threads) as u64; + if outq_memusage == UINT64_MAX as u64 { + return UINT64_MAX as u64; + } + let mut total_memusage: u64 = (LZMA_MEMUSAGE_BASE as u64) + .wrapping_add(::core::mem::size_of::() as u64) + .wrapping_add( + ((*options).threads as usize) + .wrapping_mul(::core::mem::size_of::() as usize) as u64, + ); + if (UINT64_MAX as u64).wrapping_sub(total_memusage) < inbuf_memusage { + return UINT64_MAX as u64; + } + total_memusage = total_memusage.wrapping_add(inbuf_memusage); + if (UINT64_MAX as u64).wrapping_sub(total_memusage) < filters_memusage { + return UINT64_MAX as u64; + } + total_memusage = total_memusage.wrapping_add(filters_memusage); + if (UINT64_MAX as u64).wrapping_sub(total_memusage) < outq_memusage { + return UINT64_MAX as u64; + } + return total_memusage.wrapping_add(outq_memusage); +} diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index b1c7589d..f1157fea 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -1,10 +1,6 @@ -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong}; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -26,8 +22,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -35,7 +29,7 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -50,52 +44,40 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; -pub const LZMA_BACKWARD_SIZE_MIN: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_BACKWARD_SIZE_MAX: ::core::ffi::c_ulonglong = (1 - as ::core::ffi::c_ulonglong) << 34 as ::core::ffi::c_int; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4 as c_int; +pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = (1 as c_ulonglong) << 34 as c_int; #[inline] -unsafe extern "C" fn is_backward_size_valid( - mut options: *const lzma_stream_flags, -) -> bool { +unsafe extern "C" fn is_backward_size_valid(mut options: *const lzma_stream_flags) -> bool { return (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli; } #[no_mangle] -pub static mut lzma_header_magic: [uint8_t; 6] = [ - 0xfd as ::core::ffi::c_int as uint8_t, - 0x37 as ::core::ffi::c_int as uint8_t, - 0x7a as ::core::ffi::c_int as uint8_t, - 0x58 as ::core::ffi::c_int as uint8_t, - 0x5a as ::core::ffi::c_int as uint8_t, - 0 as ::core::ffi::c_int as uint8_t, +pub static mut lzma_header_magic: [u8; 6] = [ + 0xfd as u8, 0x37 as u8, 0x7a as u8, 0x58 as u8, 0x5a as u8, 0 as u8, ]; #[no_mangle] -pub static mut lzma_footer_magic: [uint8_t; 2] = [ - 0x59 as ::core::ffi::c_int as uint8_t, - 0x5a as ::core::ffi::c_int as uint8_t, -]; +pub static mut lzma_footer_magic: [u8; 2] = [0x59 as u8, 0x5a as u8]; #[no_mangle] pub unsafe extern "C" fn lzma_stream_flags_compare( mut a: *const lzma_stream_flags, mut b: *const lzma_stream_flags, ) -> lzma_ret { - if (*a).version != 0 as uint32_t || (*b).version != 0 as uint32_t { + if (*a).version != 0 as u32 || (*b).version != 0 as u32 { return LZMA_OPTIONS_ERROR; } - if (*a).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint - || (*b).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint + if (*a).check as c_uint > LZMA_CHECK_ID_MAX as c_uint + || (*b).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { return LZMA_PROG_ERROR; } - if (*a).check as ::core::ffi::c_uint != (*b).check as ::core::ffi::c_uint { + if (*a).check as c_uint != (*b).check as c_uint { return LZMA_DATA_ERROR; } if (*a).backward_size != LZMA_VLI_UNKNOWN as lzma_vli diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 85985da0..6d360bed 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -1,22 +1,12 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcmp( - __s1: *const ::core::ffi::c_void, - __s2: *const ::core::ffi::c_void, - __n: size_t, - ) -> ::core::ffi::c_int; - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; - static lzma_header_magic: [uint8_t; 6]; - static lzma_footer_magic: [uint8_t; 2]; + fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; + static lzma_header_magic: [u8; 6]; + static lzma_footer_magic: [u8; 2]; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -38,8 +28,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -47,7 +35,7 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -62,67 +50,56 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { - let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; - num - |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - num - |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 16 as ::core::ffi::c_int; - num - |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) - << 24 as ::core::ffi::c_int; +unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { + let mut num: u32 = *buf.offset(0 as isize) as u32; + num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; + num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; + num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; return num; } -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_FLAGS_SIZE: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2 as c_int; unsafe extern "C" fn stream_flags_decode( mut options: *mut lzma_stream_flags, - mut in_0: *const uint8_t, + mut in_0: *const u8, ) -> bool { - if *in_0.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - != 0 as ::core::ffi::c_int - || *in_0.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - & 0xf0 as ::core::ffi::c_int != 0 + if *in_0.offset(0 as isize) as c_int != 0 as c_int + || *in_0.offset(1 as isize) as c_int & 0xf0 as c_int != 0 { return true_0 != 0; } - (*options).version = 0 as uint32_t; - (*options).check = (*in_0.offset(1 as ::core::ffi::c_int as isize) - as ::core::ffi::c_int & 0xf as ::core::ffi::c_int) as lzma_check; + (*options).version = 0 as u32; + (*options).check = (*in_0.offset(1 as isize) as c_int & 0xf as c_int) as lzma_check; return false_0 != 0; } #[no_mangle] pub unsafe extern "C" fn lzma_stream_header_decode( mut options: *mut lzma_stream_flags, - mut in_0: *const uint8_t, + mut in_0: *const u8, ) -> lzma_ret { if memcmp( - in_0 as *const ::core::ffi::c_void, - &raw const lzma_header_magic as *const uint8_t as *const ::core::ffi::c_void, - ::core::mem::size_of::<[uint8_t; 6]>() as size_t, - ) != 0 as ::core::ffi::c_int + in_0 as *const c_void, + &raw const lzma_header_magic as *const u8 as *const c_void, + ::core::mem::size_of::<[u8; 6]>() as size_t, + ) != 0 as c_int { return LZMA_FORMAT_ERROR; } - let crc: uint32_t = lzma_crc32( - in_0.offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize), + let crc: u32 = lzma_crc32( + in_0.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize), LZMA_STREAM_FLAGS_SIZE as size_t, - 0 as uint32_t, - ) as uint32_t; + 0 as u32, + ) as u32; if crc != read32le( - in_0 - .offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize) + in_0.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize), ) { @@ -130,7 +107,7 @@ pub unsafe extern "C" fn lzma_stream_header_decode( } if stream_flags_decode( options, - in_0.offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize), + in_0.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize), ) { return LZMA_OPTIONS_ERROR; } @@ -140,43 +117,33 @@ pub unsafe extern "C" fn lzma_stream_header_decode( #[no_mangle] pub unsafe extern "C" fn lzma_stream_footer_decode( mut options: *mut lzma_stream_flags, - mut in_0: *const uint8_t, + mut in_0: *const u8, ) -> lzma_ret { if memcmp( - in_0 - .offset( - (::core::mem::size_of::() as usize).wrapping_mul(2 as usize) - as isize, - ) - .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *const ::core::ffi::c_void, - &raw const lzma_footer_magic as *const uint8_t as *const ::core::ffi::c_void, - ::core::mem::size_of::<[uint8_t; 2]>() as size_t, - ) != 0 as ::core::ffi::c_int + in_0.offset((::core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize) + .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *const c_void, + &raw const lzma_footer_magic as *const u8 as *const c_void, + ::core::mem::size_of::<[u8; 2]>() as size_t, + ) != 0 as c_int { return LZMA_FORMAT_ERROR; } - let crc: uint32_t = lzma_crc32( - in_0.offset(::core::mem::size_of::() as usize as isize), - (::core::mem::size_of::() as size_t) - .wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), - 0 as uint32_t, - ) as uint32_t; + let crc: u32 = lzma_crc32( + in_0.offset(::core::mem::size_of::() as usize as isize), + (::core::mem::size_of::() as size_t).wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), + 0 as u32, + ) as u32; if crc != read32le(in_0) { return LZMA_DATA_ERROR; } if stream_flags_decode( options, - in_0 - .offset( - (::core::mem::size_of::() as usize).wrapping_mul(2 as usize) - as isize, - ), + in_0.offset((::core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize), ) { return LZMA_OPTIONS_ERROR; } - (*options).backward_size = read32le( - in_0.offset(::core::mem::size_of::() as usize as isize), - ) as lzma_vli; + (*options).backward_size = + read32le(in_0.offset(::core::mem::size_of::() as usize as isize)) as lzma_vli; (*options).backward_size = (*options) .backward_size .wrapping_add(1 as lzma_vli) diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index fb098f6b..1cb08f01 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -1,22 +1,12 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_crc32(buf: *const uint8_t, size: size_t, crc: uint32_t) -> uint32_t; - static lzma_header_magic: [uint8_t; 6]; - static lzma_footer_magic: [uint8_t; 2]; + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; + static lzma_header_magic: [u8; 6]; + static lzma_footer_magic: [u8; 2]; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -38,8 +28,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; @@ -47,7 +35,7 @@ pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { - pub version: uint32_t, + pub version: u32, pub backward_size: lzma_vli, pub check: lzma_check, pub reserved_enum1: lzma_reserved_enum, @@ -62,73 +50,65 @@ pub struct lzma_stream_flags { pub reserved_bool6: lzma_bool, pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, + pub reserved_int1: u32, + pub reserved_int2: u32, } -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { - *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; - *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) - as uint8_t; +unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { + *buf.offset(0 as isize) = num as u8; + *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; + *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; + *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; } -pub const LZMA_CHECK_ID_MAX: ::core::ffi::c_int = 15 as ::core::ffi::c_int; -pub const LZMA_BACKWARD_SIZE_MIN: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_BACKWARD_SIZE_MAX: ::core::ffi::c_ulonglong = (1 - as ::core::ffi::c_ulonglong) << 34 as ::core::ffi::c_int; -pub const LZMA_STREAM_FLAGS_SIZE: ::core::ffi::c_int = 2 as ::core::ffi::c_int; +pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4 as c_int; +pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = (1 as c_ulonglong) << 34 as c_int; +pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2 as c_int; #[inline] -unsafe extern "C" fn is_backward_size_valid( - mut options: *const lzma_stream_flags, -) -> bool { +unsafe extern "C" fn is_backward_size_valid(mut options: *const lzma_stream_flags) -> bool { return (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli; } unsafe extern "C" fn stream_flags_encode( mut options: *const lzma_stream_flags, - mut out: *mut uint8_t, + mut out: *mut u8, ) -> bool { - if (*options).check as ::core::ffi::c_uint > LZMA_CHECK_ID_MAX as ::core::ffi::c_uint - { + if (*options).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { return true_0 != 0; } - *out.offset(0 as ::core::ffi::c_int as isize) = 0 as uint8_t; - *out.offset(1 as ::core::ffi::c_int as isize) = (*options).check as uint8_t; + *out.offset(0 as isize) = 0 as u8; + *out.offset(1 as isize) = (*options).check as u8; return false_0 != 0; } #[no_mangle] pub unsafe extern "C" fn lzma_stream_header_encode( mut options: *const lzma_stream_flags, - mut out: *mut uint8_t, + mut out: *mut u8, ) -> lzma_ret { - if (*options).version != 0 as uint32_t { + if (*options).version != 0 as u32 { return LZMA_OPTIONS_ERROR; } memcpy( - out as *mut ::core::ffi::c_void, - &raw const lzma_header_magic as *const uint8_t as *const ::core::ffi::c_void, - ::core::mem::size_of::<[uint8_t; 6]>() as size_t, + out as *mut c_void, + &raw const lzma_header_magic as *const u8 as *const c_void, + ::core::mem::size_of::<[u8; 6]>() as size_t, ); if stream_flags_encode( options, - out.offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize), + out.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize), ) { return LZMA_PROG_ERROR; } - let crc: uint32_t = lzma_crc32( - out.offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize), + let crc: u32 = lzma_crc32( + out.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize), LZMA_STREAM_FLAGS_SIZE as size_t, - 0 as uint32_t, - ) as uint32_t; + 0 as u32, + ) as u32; write32le( - out - .offset(::core::mem::size_of::<[uint8_t; 6]>() as usize as isize) + out.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize), crc, ); @@ -137,37 +117,35 @@ pub unsafe extern "C" fn lzma_stream_header_encode( #[no_mangle] pub unsafe extern "C" fn lzma_stream_footer_encode( mut options: *const lzma_stream_flags, - mut out: *mut uint8_t, + mut out: *mut u8, ) -> lzma_ret { - if (*options).version != 0 as uint32_t { + if (*options).version != 0 as u32 { return LZMA_OPTIONS_ERROR; } if !is_backward_size_valid(options) { return LZMA_PROG_ERROR; } write32le( - out.offset(4 as ::core::ffi::c_int as isize), - (*options).backward_size.wrapping_div(4 as lzma_vli).wrapping_sub(1 as lzma_vli) - as uint32_t, + out.offset(4 as isize), + (*options) + .backward_size + .wrapping_div(4 as lzma_vli) + .wrapping_sub(1 as lzma_vli) as u32, ); - if stream_flags_encode( - options, - out.offset((2 as ::core::ffi::c_int * 4 as ::core::ffi::c_int) as isize), - ) { + if stream_flags_encode(options, out.offset((2 as c_int * 4 as c_int) as isize)) { return LZMA_PROG_ERROR; } - let crc: uint32_t = lzma_crc32( - out.offset(4 as ::core::ffi::c_int as isize), - (4 as ::core::ffi::c_int + LZMA_STREAM_FLAGS_SIZE) as size_t, - 0 as uint32_t, - ) as uint32_t; + let crc: u32 = lzma_crc32( + out.offset(4 as isize), + (4 as c_int + LZMA_STREAM_FLAGS_SIZE) as size_t, + 0 as u32, + ) as u32; write32le(out, crc); memcpy( - out - .offset((2 as ::core::ffi::c_int * 4 as ::core::ffi::c_int) as isize) - .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut ::core::ffi::c_void, - &raw const lzma_footer_magic as *const uint8_t as *const ::core::ffi::c_void, - ::core::mem::size_of::<[uint8_t; 2]>() as size_t, + out.offset((2 as c_int * 4 as c_int) as isize) + .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut c_void, + &raw const lzma_footer_magic as *const u8 as *const c_void, + ::core::mem::size_of::<[u8; 2]>() as size_t, ); return LZMA_OK; } diff --git a/liblzma-rs/src/common/stream_mt.rs b/liblzma-rs/src/common/stream_mt.rs new file mode 100644 index 00000000..6273bc64 --- /dev/null +++ b/liblzma-rs/src/common/stream_mt.rs @@ -0,0 +1,6 @@ +pub type lzma_mt = crate::common::stream_encoder_mt::lzma_mt; + +pub use crate::common::stream_decoder_mt::lzma_stream_decoder_mt; +pub use crate::common::stream_encoder_mt::{ + lzma_stream_encoder_mt, lzma_stream_encoder_mt_memusage, +}; diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 55d0b506..aa0d5aac 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -1,42 +1,17 @@ +use crate::types::*; +use core::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; extern "C" { - fn memchr( - __s: *const ::core::ffi::c_void, - __c: ::core::ffi::c_int, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn memcmp( - __s1: *const ::core::ffi::c_void, - __s2: *const ::core::ffi::c_void, - __n: size_t, - ) -> ::core::ffi::c_int; - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn strlen(__s: *const ::core::ffi::c_char) -> size_t; - fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: uint32_t) -> lzma_bool; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc_zero( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn memchr(__s: *const c_void, __c: c_int, __n: size_t) -> *mut c_void; + fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn strlen(__s: *const c_char) -> size_t; + fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_validate_chain(filters: *const lzma_filter, count: *mut size_t) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -61,50 +36,37 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; #[derive(Copy, Clone)] #[repr(C)] pub struct C2RustUnnamed { - pub name: [::core::ffi::c_char; 12], - pub opts_size: uint32_t, + pub name: [c_char; 12], + pub opts_size: u32, pub id: lzma_vli, pub parse: Option< - unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + unsafe extern "C" fn(*mut *const c_char, *const c_char, *mut c_void) -> *const c_char, >, pub optmap: *const option_map, - pub strfy_encoder: uint8_t, - pub strfy_decoder: uint8_t, + pub strfy_encoder: u8, + pub strfy_decoder: u8, pub allow_null: bool, } #[derive(Copy, Clone)] #[repr(C)] pub struct option_map { - pub name: [::core::ffi::c_char; 12], - pub type_0: uint8_t, - pub flags: uint8_t, - pub offset: uint16_t, + pub name: [c_char; 12], + pub type_0: u8, + pub flags: u8, + pub offset: u16, pub u: C2RustUnnamed_0, } #[derive(Copy, Clone)] @@ -116,267 +78,227 @@ pub union C2RustUnnamed_0 { #[derive(Copy, Clone)] #[repr(C)] pub struct C2RustUnnamed_1 { - pub min: uint32_t, - pub max: uint32_t, + pub min: u32, + pub max: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct name_value_map { - pub name: [::core::ffi::c_char; 12], - pub value: uint32_t, + pub name: [c_char; 12], + pub value: u32, } -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; pub const OPTMAP_TYPE_LZMA_MATCH_FINDER: C2RustUnnamed_2 = 2; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; pub const OPTMAP_TYPE_LZMA_MODE: C2RustUnnamed_2 = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } pub const OPTMAP_TYPE_LZMA_PRESET: C2RustUnnamed_2 = 3; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_delta { pub type_0: lzma_delta_type, - pub dist: uint32_t, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, - pub reserved_int3: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub dist: u32, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } -pub type lzma_delta_type = ::core::ffi::c_uint; pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_bcj { - pub start_offset: uint32_t, + pub start_offset: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_str { - pub buf: *mut ::core::ffi::c_char, + pub buf: *mut c_char, pub pos: size_t, } -pub type C2RustUnnamed_2 = ::core::ffi::c_uint; +pub type C2RustUnnamed_2 = c_uint; pub const OPTMAP_TYPE_UINT32: C2RustUnnamed_2 = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const INT_MAX: ::core::ffi::c_int = 2147483647 as ::core::ffi::c_int; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_STR_ALL_FILTERS: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; -pub const LZMA_STR_NO_VALIDATION: ::core::ffi::c_uint = 0x2 as ::core::ffi::c_uint; -pub const LZMA_STR_ENCODER: ::core::ffi::c_uint = 0x10 as ::core::ffi::c_uint; -pub const LZMA_STR_DECODER: ::core::ffi::c_uint = 0x20 as ::core::ffi::c_uint; -pub const LZMA_STR_GETOPT_LONG: ::core::ffi::c_uint = 0x40 as ::core::ffi::c_uint; -pub const LZMA_STR_NO_SPACES: ::core::ffi::c_uint = 0x80 as ::core::ffi::c_uint; -pub const LZMA_FILTER_X86: ::core::ffi::c_ulonglong = 0x4 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_POWERPC: ::core::ffi::c_ulonglong = 0x5 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_IA64: ::core::ffi::c_ulonglong = 0x6 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARM: ::core::ffi::c_ulonglong = 0x7 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARMTHUMB: ::core::ffi::c_ulonglong = 0x8 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_SPARC: ::core::ffi::c_ulonglong = 0x9 as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_ARM64: ::core::ffi::c_ulonglong = 0xa as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_RISCV: ::core::ffi::c_ulonglong = 0xb as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_DELTA: ::core::ffi::c_ulonglong = 0x3 as ::core::ffi::c_ulonglong; -pub const LZMA_DELTA_DIST_MIN: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const LZMA_DELTA_DIST_MAX: ::core::ffi::c_int = 256 as ::core::ffi::c_int; -pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA2: ::core::ffi::c_ulonglong = 0x21 as ::core::ffi::c_ulonglong; -pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; -pub const LZMA_DICT_SIZE_DEFAULT: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 23 as ::core::ffi::c_int; -pub const LZMA_LCLP_MIN: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_LCLP_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_PB_MIN: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_PB_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_PRESET_DEFAULT: ::core::ffi::c_uint = 6 as ::core::ffi::c_uint; -pub const LZMA_PRESET_EXTREME: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 31 as ::core::ffi::c_int; -pub const LZMA_FILTER_RESERVED_START: ::core::ffi::c_ulonglong = (1 - as ::core::ffi::c_ulonglong) << 62 as ::core::ffi::c_int; -pub const STR_ALLOC_SIZE: ::core::ffi::c_int = 800 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const INT_MAX: c_int = 2147483647 as c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; +pub const LZMA_STR_ALL_FILTERS: c_uint = 0x1 as c_uint; +pub const LZMA_STR_NO_VALIDATION: c_uint = 0x2 as c_uint; +pub const LZMA_STR_ENCODER: c_uint = 0x10 as c_uint; +pub const LZMA_STR_DECODER: c_uint = 0x20 as c_uint; +pub const LZMA_STR_GETOPT_LONG: c_uint = 0x40 as c_uint; +pub const LZMA_STR_NO_SPACES: c_uint = 0x80 as c_uint; +pub const LZMA_FILTER_X86: c_ulonglong = 0x4 as c_ulonglong; +pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5 as c_ulonglong; +pub const LZMA_FILTER_IA64: c_ulonglong = 0x6 as c_ulonglong; +pub const LZMA_FILTER_ARM: c_ulonglong = 0x7 as c_ulonglong; +pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8 as c_ulonglong; +pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9 as c_ulonglong; +pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa as c_ulonglong; +pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb as c_ulonglong; +pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3 as c_ulonglong; +pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; +pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; +pub const LZMA_DICT_SIZE_DEFAULT: c_uint = (1 as c_uint) << 23 as c_int; +pub const LZMA_LCLP_MIN: c_int = 0 as c_int; +pub const LZMA_LCLP_MAX: c_int = 4 as c_int; +pub const LZMA_PB_MIN: c_int = 0 as c_int; +pub const LZMA_PB_MAX: c_int = 4 as c_int; +pub const LZMA_PRESET_DEFAULT: c_uint = 6 as c_uint; +pub const LZMA_PRESET_EXTREME: c_uint = (1 as c_uint) << 31 as c_int; +pub const LZMA_FILTER_RESERVED_START: c_ulonglong = (1 as c_ulonglong) << 62 as c_int; +pub const STR_ALLOC_SIZE: c_int = 800 as c_int; unsafe extern "C" fn str_init( mut str: *mut lzma_str, mut allocator: *const lzma_allocator, ) -> lzma_ret { - (*str).buf = lzma_alloc(STR_ALLOC_SIZE as size_t, allocator) - as *mut ::core::ffi::c_char; + (*str).buf = lzma_alloc(STR_ALLOC_SIZE as size_t, allocator) as *mut c_char; if (*str).buf.is_null() { return LZMA_MEM_ERROR; } (*str).pos = 0 as size_t; return LZMA_OK; } -unsafe extern "C" fn str_free( - mut str: *mut lzma_str, - mut allocator: *const lzma_allocator, -) { - lzma_free((*str).buf as *mut ::core::ffi::c_void, allocator); +unsafe extern "C" fn str_free(mut str: *mut lzma_str, mut allocator: *const lzma_allocator) { + lzma_free((*str).buf as *mut c_void, allocator); } unsafe extern "C" fn str_is_full(mut str: *const lzma_str) -> bool { - return (*str).pos == (STR_ALLOC_SIZE - 1 as ::core::ffi::c_int) as size_t; + return (*str).pos == (STR_ALLOC_SIZE - 1 as c_int) as size_t; } unsafe extern "C" fn str_finish( - mut dest: *mut *mut ::core::ffi::c_char, + mut dest: *mut *mut c_char, mut str: *mut lzma_str, mut allocator: *const lzma_allocator, ) -> lzma_ret { if str_is_full(str) { - lzma_free((*str).buf as *mut ::core::ffi::c_void, allocator); - *dest = ::core::ptr::null_mut::<::core::ffi::c_char>(); + lzma_free((*str).buf as *mut c_void, allocator); + *dest = ::core::ptr::null_mut::(); return LZMA_PROG_ERROR; } - *(*str).buf.offset((*str).pos as isize) = '\0' as i32 as ::core::ffi::c_char; + *(*str).buf.offset((*str).pos as isize) = '\0' as i32 as c_char; *dest = (*str).buf; return LZMA_OK; } -unsafe extern "C" fn str_append_str( - mut str: *mut lzma_str, - mut s: *const ::core::ffi::c_char, -) { +unsafe extern "C" fn str_append_str(mut str: *mut lzma_str, mut s: *const c_char) { let len: size_t = strlen(s) as size_t; - let limit: size_t = ((STR_ALLOC_SIZE - 1 as ::core::ffi::c_int) as size_t) - .wrapping_sub((*str).pos); + let limit: size_t = ((STR_ALLOC_SIZE - 1 as c_int) as size_t).wrapping_sub((*str).pos); let copy_size: size_t = if len < limit { len } else { limit }; memcpy( - (*str).buf.offset((*str).pos as isize) as *mut ::core::ffi::c_void, - s as *const ::core::ffi::c_void, + (*str).buf.offset((*str).pos as isize) as *mut c_void, + s as *const c_void, copy_size, ); (*str).pos = (*str).pos.wrapping_add(copy_size); } -unsafe extern "C" fn str_append_u32( - mut str: *mut lzma_str, - mut v: uint32_t, - mut use_byte_suffix: bool, -) { - if v == 0 as uint32_t { - str_append_str(str, b"0\0" as *const u8 as *const ::core::ffi::c_char); +unsafe extern "C" fn str_append_u32(mut str: *mut lzma_str, mut v: u32, mut use_byte_suffix: bool) { + if v == 0 as u32 { + str_append_str(str, b"0\0" as *const u8 as *const c_char); } else { - static mut suffixes: [[::core::ffi::c_char; 4]; 4] = unsafe { + static mut suffixes: [[c_char; 4]; 4] = unsafe { [ - ::core::mem::transmute::< - [u8; 4], - [::core::ffi::c_char; 4], - >(*b"\0\0\0\0"), - ::core::mem::transmute::<[u8; 4], [::core::ffi::c_char; 4]>(*b"KiB\0"), - ::core::mem::transmute::<[u8; 4], [::core::ffi::c_char; 4]>(*b"MiB\0"), - ::core::mem::transmute::<[u8; 4], [::core::ffi::c_char; 4]>(*b"GiB\0"), + ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"\0\0\0\0"), + ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"KiB\0"), + ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"MiB\0"), + ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"GiB\0"), ] }; let mut suf: size_t = 0 as size_t; if use_byte_suffix { - while v & 1023 as uint32_t == 0 as uint32_t + while v & 1023 as u32 == 0 as u32 && suf - < (::core::mem::size_of::<[[::core::ffi::c_char; 4]; 4]>() as usize) - .wrapping_div( - ::core::mem::size_of::<[::core::ffi::c_char; 4]>() as usize, - ) + < (::core::mem::size_of::<[[c_char; 4]; 4]>() as usize) + .wrapping_div(::core::mem::size_of::<[c_char; 4]>() as usize) .wrapping_sub(1 as usize) { - v >>= 10 as ::core::ffi::c_int; + v >>= 10 as c_int; suf = suf.wrapping_add(1); } } - let mut buf: [::core::ffi::c_char; 16] = ::core::mem::transmute::< - [u8; 16], - [::core::ffi::c_char; 16], - >(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); - let mut pos: size_t = (::core::mem::size_of::<[::core::ffi::c_char; 16]>() - as size_t) - .wrapping_sub(1 as size_t); + let mut buf: [c_char; 16] = + ::core::mem::transmute::<[u8; 16], [c_char; 16]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); + let mut pos: size_t = + (::core::mem::size_of::<[c_char; 16]>() as size_t).wrapping_sub(1 as size_t); loop { pos = pos.wrapping_sub(1); - buf[pos as usize] = ('0' as i32 as uint32_t) - .wrapping_add(v.wrapping_rem(10 as uint32_t)) as ::core::ffi::c_char; - v = v.wrapping_div(10 as uint32_t); - if !(v != 0 as uint32_t) { + buf[pos as usize] = + ('0' as i32 as u32).wrapping_add(v.wrapping_rem(10 as u32)) as c_char; + v = v.wrapping_div(10 as u32); + if !(v != 0 as u32) { break; } } + str_append_str(str, (&raw mut buf as *mut c_char).offset(pos as isize)); str_append_str( str, - (&raw mut buf as *mut ::core::ffi::c_char).offset(pos as isize), - ); - str_append_str( - str, - &raw const *(&raw const suffixes as *const [::core::ffi::c_char; 4]) - .offset(suf as isize) as *const ::core::ffi::c_char, + &raw const *(&raw const suffixes as *const [c_char; 4]).offset(suf as isize) + as *const c_char, ); }; } -pub const NAME_LEN_MAX: ::core::ffi::c_int = 11 as ::core::ffi::c_int; -pub const OPTMAP_USE_NAME_VALUE_MAP: ::core::ffi::c_int = 0x1 as ::core::ffi::c_int; -pub const OPTMAP_USE_BYTE_SUFFIX: ::core::ffi::c_int = 0x2 as ::core::ffi::c_int; -pub const OPTMAP_NO_STRFY_ZERO: ::core::ffi::c_int = 0x4 as ::core::ffi::c_int; +pub const NAME_LEN_MAX: c_int = 11 as c_int; +pub const OPTMAP_USE_NAME_VALUE_MAP: c_int = 0x1 as c_int; +pub const OPTMAP_USE_BYTE_SUFFIX: c_int = 0x2 as c_int; +pub const OPTMAP_NO_STRFY_ZERO: c_int = 0x4 as c_int; static mut bcj_optmap: [option_map; 1] = unsafe { - [ - option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"start\0\0\0\0\0\0\0"), - type_0: 0, - flags: (OPTMAP_NO_STRFY_ZERO | OPTMAP_USE_BYTE_SUFFIX) as uint8_t, - offset: 0 as ::core::ffi::c_ulong as uint16_t, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { - min: 0 as uint32_t, - max: UINT32_MAX as uint32_t, - }, + [option_map { + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"start\0\0\0\0\0\0\0"), + type_0: 0, + flags: (OPTMAP_NO_STRFY_ZERO | OPTMAP_USE_BYTE_SUFFIX) as u8, + offset: 0 as c_ulong as u16, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: 0 as u32, + max: UINT32_MAX as u32, }, }, - ] + }] }; unsafe extern "C" fn parse_bcj( - str: *mut *const ::core::ffi::c_char, - mut str_end: *const ::core::ffi::c_char, - mut filter_options: *mut ::core::ffi::c_void, -) -> *const ::core::ffi::c_char { + str: *mut *const c_char, + mut str_end: *const c_char, + mut filter_options: *mut c_void, +) -> *const c_char { return parse_options( str, str_end, @@ -387,32 +309,27 @@ unsafe extern "C" fn parse_bcj( ); } static mut delta_optmap: [option_map; 1] = unsafe { - [ - option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"dist\0\0\0\0\0\0\0\0"), - type_0: 0, - flags: 0, - offset: 4 as ::core::ffi::c_ulong as uint16_t, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { - min: LZMA_DELTA_DIST_MIN as uint32_t, - max: LZMA_DELTA_DIST_MAX as uint32_t, - }, + [option_map { + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dist\0\0\0\0\0\0\0\0"), + type_0: 0, + flags: 0, + offset: 4 as c_ulong as u16, + u: C2RustUnnamed_0 { + range: C2RustUnnamed_1 { + min: LZMA_DELTA_DIST_MIN as u32, + max: LZMA_DELTA_DIST_MAX as u32, }, }, - ] + }] }; unsafe extern "C" fn parse_delta( - str: *mut *const ::core::ffi::c_char, - mut str_end: *const ::core::ffi::c_char, - mut filter_options: *mut ::core::ffi::c_void, -) -> *const ::core::ffi::c_char { + str: *mut *const c_char, + mut str_end: *const c_char, + mut filter_options: *mut c_void, +) -> *const c_char { let mut opts: *mut lzma_options_delta = filter_options as *mut lzma_options_delta; (*opts).type_0 = LZMA_DELTA_TYPE_BYTE; - (*opts).dist = LZMA_DELTA_DIST_MIN as uint32_t; + (*opts).dist = LZMA_DELTA_DIST_MIN as u32; return parse_options( str, str_end, @@ -422,126 +339,90 @@ unsafe extern "C" fn parse_delta( .wrapping_div(::core::mem::size_of::() as size_t), ); } -pub const LZMA12_PRESET_STR: [::core::ffi::c_char; 7] = unsafe { - ::core::mem::transmute::<[u8; 7], [::core::ffi::c_char; 7]>(*b"0-9[e]\0") -}; +pub const LZMA12_PRESET_STR: [c_char; 7] = + unsafe { ::core::mem::transmute::<[u8; 7], [c_char; 7]>(*b"0-9[e]\0") }; unsafe extern "C" fn parse_lzma12_preset( - str: *mut *const ::core::ffi::c_char, - mut str_end: *const ::core::ffi::c_char, - mut preset: *mut uint32_t, -) -> *const ::core::ffi::c_char { - if !(**str as ::core::ffi::c_int >= '0' as i32 - && **str as ::core::ffi::c_int <= '9' as i32) - { - return b"Unsupported preset\0" as *const u8 as *const ::core::ffi::c_char; + str: *mut *const c_char, + mut str_end: *const c_char, + mut preset: *mut u32, +) -> *const c_char { + if !(**str as c_int >= '0' as i32 && **str as c_int <= '9' as i32) { + return b"Unsupported preset\0" as *const u8 as *const c_char; } - *preset = (**str as ::core::ffi::c_int - '0' as i32) as uint32_t; + *preset = (**str as c_int - '0' as i32) as u32; loop { *str = (*str).offset(1); if !(*str < str_end) { break; } - match **str as ::core::ffi::c_int { + match **str as c_int { 101 => { - *preset = (*preset as ::core::ffi::c_uint | LZMA_PRESET_EXTREME) - as uint32_t; + *preset = (*preset as c_uint | LZMA_PRESET_EXTREME) as u32; } _ => { - return b"Unsupported flag in the preset\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Unsupported flag in the preset\0" as *const u8 as *const c_char; } } } - return ::core::ptr::null::<::core::ffi::c_char>(); + return ::core::ptr::null::(); } unsafe extern "C" fn set_lzma12_preset( - str: *mut *const ::core::ffi::c_char, - mut str_end: *const ::core::ffi::c_char, - mut filter_options: *mut ::core::ffi::c_void, -) -> *const ::core::ffi::c_char { - let mut preset: uint32_t = 0; - let mut errmsg: *const ::core::ffi::c_char = parse_lzma12_preset( - str, - str_end, - &raw mut preset, - ); + str: *mut *const c_char, + mut str_end: *const c_char, + mut filter_options: *mut c_void, +) -> *const c_char { + let mut preset: u32 = 0; + let mut errmsg: *const c_char = parse_lzma12_preset(str, str_end, &raw mut preset); if !errmsg.is_null() { return errmsg; } let mut opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; if lzma_lzma_preset(opts, preset) != 0 { - return b"Unsupported preset\0" as *const u8 as *const ::core::ffi::c_char; + return b"Unsupported preset\0" as *const u8 as *const c_char; } - return ::core::ptr::null::<::core::ffi::c_char>(); + return ::core::ptr::null::(); } static mut lzma12_mode_map: [name_value_map; 3] = unsafe { [ name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"fast\0\0\0\0\0\0\0\0"), - value: LZMA_MODE_FAST as ::core::ffi::c_int as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"fast\0\0\0\0\0\0\0\0"), + value: LZMA_MODE_FAST as u32, }, name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"normal\0\0\0\0\0\0"), - value: LZMA_MODE_NORMAL as ::core::ffi::c_int as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"normal\0\0\0\0\0\0"), + value: LZMA_MODE_NORMAL as u32, }, name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), - value: 0 as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), + value: 0 as u32, }, ] }; static mut lzma12_mf_map: [name_value_map; 6] = unsafe { [ name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"hc3\0\0\0\0\0\0\0\0\0"), - value: LZMA_MF_HC3 as ::core::ffi::c_int as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"hc3\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_HC3 as u32, }, name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"hc4\0\0\0\0\0\0\0\0\0"), - value: LZMA_MF_HC4 as ::core::ffi::c_int as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"hc4\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_HC4 as u32, }, name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"bt2\0\0\0\0\0\0\0\0\0"), - value: LZMA_MF_BT2 as ::core::ffi::c_int as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt2\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_BT2 as u32, }, name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"bt3\0\0\0\0\0\0\0\0\0"), - value: LZMA_MF_BT3 as ::core::ffi::c_int as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt3\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_BT3 as u32, }, name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"bt4\0\0\0\0\0\0\0\0\0"), - value: LZMA_MF_BT4 as ::core::ffi::c_int as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt4\0\0\0\0\0\0\0\0\0"), + value: LZMA_MF_BT4 as u32, }, name_value_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), - value: 0 as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), + value: 0 as u32, }, ] }; @@ -555,13 +436,13 @@ static mut lzma12_optmap: [option_map; 9] = [option_map { }, }; 9]; unsafe extern "C" fn parse_lzma12( - str: *mut *const ::core::ffi::c_char, - mut str_end: *const ::core::ffi::c_char, - mut filter_options: *mut ::core::ffi::c_void, -) -> *const ::core::ffi::c_char { + str: *mut *const c_char, + mut str_end: *const c_char, + mut filter_options: *mut c_void, +) -> *const c_char { let mut opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; - let preset_ret: bool = lzma_lzma_preset(opts, LZMA_PRESET_DEFAULT as uint32_t) != 0; - let mut errmsg: *const ::core::ffi::c_char = parse_options( + let preset_ret: bool = lzma_lzma_preset(opts, LZMA_PRESET_DEFAULT as u32) != 0; + let mut errmsg: *const c_char = parse_options( str, str_end, filter_options, @@ -572,338 +453,279 @@ unsafe extern "C" fn parse_lzma12( if !errmsg.is_null() { return errmsg; } - if (*opts).lc.wrapping_add((*opts).lp) > LZMA_LCLP_MAX as uint32_t { - return b"The sum of lc and lp must not exceed 4\0" as *const u8 - as *const ::core::ffi::c_char; + if (*opts).lc.wrapping_add((*opts).lp) > LZMA_LCLP_MAX as u32 { + return b"The sum of lc and lp must not exceed 4\0" as *const u8 as *const c_char; } - return ::core::ptr::null::<::core::ffi::c_char>(); + return ::core::ptr::null::(); } static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { [ C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"lzma1\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma1\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_LZMA1 as lzma_vli, parse: Some( parse_lzma12 as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const lzma12_optmap as *const option_map, - strfy_encoder: 9 as uint8_t, - strfy_decoder: 5 as uint8_t, + strfy_encoder: 9 as u8, + strfy_decoder: 5 as u8, allow_null: false_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"lzma2\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma2\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_LZMA2 as lzma_vli, parse: Some( parse_lzma12 as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const lzma12_optmap as *const option_map, - strfy_encoder: 9 as uint8_t, - strfy_decoder: 2 as uint8_t, + strfy_encoder: 9 as u8, + strfy_decoder: 2 as u8, allow_null: false_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"x86\0\0\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"x86\0\0\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_X86 as lzma_vli, parse: Some( parse_bcj as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: true_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"arm\0\0\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm\0\0\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_ARM as lzma_vli, parse: Some( parse_bcj as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: true_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"armthumb\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"armthumb\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_ARMTHUMB as lzma_vli, parse: Some( parse_bcj as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: true_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"arm64\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm64\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_ARM64 as lzma_vli, parse: Some( parse_bcj as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: true_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"riscv\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"riscv\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_RISCV as lzma_vli, parse: Some( parse_bcj as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: true_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"powerpc\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"powerpc\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_POWERPC as lzma_vli, parse: Some( parse_bcj as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: true_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"ia64\0\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"ia64\0\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_IA64 as lzma_vli, parse: Some( parse_bcj as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: true_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"sparc\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"sparc\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_SPARC as lzma_vli, parse: Some( parse_bcj as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: true_0 != 0, }, C2RustUnnamed { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"delta\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as uint32_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"delta\0\0\0\0\0\0\0"), + opts_size: ::core::mem::size_of::() as u32, id: LZMA_FILTER_DELTA as lzma_vli, parse: Some( parse_delta as unsafe extern "C" fn( - *mut *const ::core::ffi::c_char, - *const ::core::ffi::c_char, - *mut ::core::ffi::c_void, - ) -> *const ::core::ffi::c_char, + *mut *const c_char, + *const c_char, + *mut c_void, + ) -> *const c_char, ), optmap: &raw const delta_optmap as *const option_map, - strfy_encoder: 1 as uint8_t, - strfy_decoder: 1 as uint8_t, + strfy_encoder: 1 as u8, + strfy_decoder: 1 as u8, allow_null: false_0 != 0, }, ] }; unsafe extern "C" fn parse_options( - str: *mut *const ::core::ffi::c_char, - mut str_end: *const ::core::ffi::c_char, - mut filter_options: *mut ::core::ffi::c_void, + str: *mut *const c_char, + mut str_end: *const c_char, + mut filter_options: *mut c_void, optmap: *const option_map, optmap_size: size_t, -) -> *const ::core::ffi::c_char { - while *str < str_end && **str as ::core::ffi::c_int != '\0' as i32 { - if **str as ::core::ffi::c_int == ',' as i32 { +) -> *const c_char { + while *str < str_end && **str as c_int != '\0' as i32 { + if **str as c_int == ',' as i32 { *str = (*str).offset(1); } else { - let str_len: size_t = str_end.offset_from(*str) as ::core::ffi::c_long - as size_t; - let mut name_eq_value_end: *const ::core::ffi::c_char = memchr( - *str as *const ::core::ffi::c_void, - ',' as i32, - str_len, - ) as *const ::core::ffi::c_char; + let str_len: size_t = str_end.offset_from(*str) as c_long as size_t; + let mut name_eq_value_end: *const c_char = + memchr(*str as *const c_void, ',' as i32, str_len) as *const c_char; if name_eq_value_end.is_null() { name_eq_value_end = str_end; } - let mut equals_sign: *const ::core::ffi::c_char = memchr( - *str as *const ::core::ffi::c_void, + let mut equals_sign: *const c_char = memchr( + *str as *const c_void, '=' as i32, - name_eq_value_end.offset_from(*str) as ::core::ffi::c_long as size_t, - ) as *const ::core::ffi::c_char; - if equals_sign.is_null() || **str as ::core::ffi::c_int == '=' as i32 { - return b"Options must be 'name=value' pairs separated with commas\0" - as *const u8 as *const ::core::ffi::c_char; + name_eq_value_end.offset_from(*str) as c_long as size_t, + ) as *const c_char; + if equals_sign.is_null() || **str as c_int == '=' as i32 { + return b"Options must be 'name=value' pairs separated with commas\0" as *const u8 + as *const c_char; } - let name_len: size_t = equals_sign.offset_from(*str) as ::core::ffi::c_long - as size_t; + let name_len: size_t = equals_sign.offset_from(*str) as c_long as size_t; if name_len > NAME_LEN_MAX as size_t { - return b"Unknown option name\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Unknown option name\0" as *const u8 as *const c_char; } let mut i: size_t = 0 as size_t; loop { if i == optmap_size { - return b"Unknown option name\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Unknown option name\0" as *const u8 as *const c_char; } if memcmp( - *str as *const ::core::ffi::c_void, - &raw const (*optmap.offset(i as isize)).name - as *const ::core::ffi::c_char as *const ::core::ffi::c_void, + *str as *const c_void, + &raw const (*optmap.offset(i as isize)).name as *const c_char as *const c_void, name_len, - ) == 0 as ::core::ffi::c_int - && (*optmap.offset(i as isize)).name[name_len as usize] - as ::core::ffi::c_int == '\0' as i32 + ) == 0 as c_int + && (*optmap.offset(i as isize)).name[name_len as usize] as c_int == '\0' as i32 { break; } i = i.wrapping_add(1); } - *str = equals_sign.offset(1 as ::core::ffi::c_int as isize); - let value_len: size_t = name_eq_value_end.offset_from(*str) - as ::core::ffi::c_long as size_t; + *str = equals_sign.offset(1 as isize); + let value_len: size_t = name_eq_value_end.offset_from(*str) as c_long as size_t; if value_len == 0 as size_t { - return b"Option value cannot be empty\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Option value cannot be empty\0" as *const u8 as *const c_char; } - if (*optmap.offset(i as isize)).type_0 as ::core::ffi::c_int - == OPTMAP_TYPE_LZMA_PRESET as ::core::ffi::c_int - { - let mut errmsg: *const ::core::ffi::c_char = set_lzma12_preset( - str, - name_eq_value_end, - filter_options, - ); + if (*optmap.offset(i as isize)).type_0 as c_int == OPTMAP_TYPE_LZMA_PRESET as c_int { + let mut errmsg: *const c_char = + set_lzma12_preset(str, name_eq_value_end, filter_options); if !errmsg.is_null() { return errmsg; } } else { - let mut v: uint32_t = 0; - if (*optmap.offset(i as isize)).flags as ::core::ffi::c_int - & OPTMAP_USE_NAME_VALUE_MAP != 0 - { + let mut v: u32 = 0; + if (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_NAME_VALUE_MAP != 0 { if value_len > NAME_LEN_MAX as size_t { - return b"Invalid option value\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Invalid option value\0" as *const u8 as *const c_char; } - let mut map: *const name_value_map = (*optmap.offset(i as isize)) - .u - .map; + let mut map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0 as size_t; loop { - if (*map.offset(j as isize)) - .name[0 as ::core::ffi::c_int as usize] as ::core::ffi::c_int - == '\0' as i32 - { - return b"Invalid option value\0" as *const u8 - as *const ::core::ffi::c_char; + if (*map.offset(j as isize)).name[0 as usize] as c_int == '\0' as i32 { + return b"Invalid option value\0" as *const u8 as *const c_char; } if memcmp( - *str as *const ::core::ffi::c_void, - &raw const (*map.offset(j as isize)).name - as *const ::core::ffi::c_char as *const ::core::ffi::c_void, + *str as *const c_void, + &raw const (*map.offset(j as isize)).name as *const c_char + as *const c_void, value_len, - ) == 0 as ::core::ffi::c_int - && (*map.offset(j as isize)).name[value_len as usize] - as ::core::ffi::c_int == '\0' as i32 + ) == 0 as c_int + && (*map.offset(j as isize)).name[value_len as usize] as c_int + == '\0' as i32 { v = (*map.offset(j as isize)).value; break; @@ -911,97 +733,84 @@ unsafe extern "C" fn parse_options( j = j.wrapping_add(1); } } - } else if (**str as ::core::ffi::c_int) < '0' as i32 - || **str as ::core::ffi::c_int > '9' as i32 - { + } else if (**str as c_int) < '0' as i32 || **str as c_int > '9' as i32 { return b"Value is not a non-negative decimal integer\0" as *const u8 - as *const ::core::ffi::c_char + as *const c_char; } else { - let mut p: *const ::core::ffi::c_char = *str; - v = 0 as uint32_t; + let mut p: *const c_char = *str; + v = 0 as u32; loop { - if v > (UINT32_MAX as uint32_t).wrapping_div(10 as uint32_t) { - return b"Value out of range\0" as *const u8 - as *const ::core::ffi::c_char; + if v > (UINT32_MAX as u32).wrapping_div(10 as u32) { + return b"Value out of range\0" as *const u8 as *const c_char; } - v = v.wrapping_mul(10 as uint32_t); - let add: uint32_t = (*p as ::core::ffi::c_int - '0' as i32) - as uint32_t; - if (UINT32_MAX as uint32_t).wrapping_sub(add) < v { - return b"Value out of range\0" as *const u8 - as *const ::core::ffi::c_char; + v = v.wrapping_mul(10 as u32); + let add: u32 = (*p as c_int - '0' as i32) as u32; + if (UINT32_MAX as u32).wrapping_sub(add) < v { + return b"Value out of range\0" as *const u8 as *const c_char; } v = v.wrapping_add(add); p = p.offset(1); if !(p < name_eq_value_end - && *p as ::core::ffi::c_int >= '0' as i32 - && *p as ::core::ffi::c_int <= '9' as i32) + && *p as c_int >= '0' as i32 + && *p as c_int <= '9' as i32) { break; } } if p < name_eq_value_end { - let mut multiplier_start: *const ::core::ffi::c_char = p; - if (*optmap.offset(i as isize)).flags as ::core::ffi::c_int - & OPTMAP_USE_BYTE_SUFFIX == 0 as ::core::ffi::c_int + let mut multiplier_start: *const c_char = p; + if (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_BYTE_SUFFIX + == 0 as c_int { *str = multiplier_start; return b"This option does not support any multiplier suffixes\0" - as *const u8 as *const ::core::ffi::c_char; + as *const u8 as *const c_char; } - let mut shift: uint32_t = 0; - match *p as ::core::ffi::c_int { + let mut shift: u32 = 0; + match *p as c_int { 107 | 75 => { - shift = 10 as uint32_t; + shift = 10 as u32; } 109 | 77 => { - shift = 20 as uint32_t; + shift = 20 as u32; } 103 | 71 => { - shift = 30 as uint32_t; + shift = 30 as u32; } _ => { *str = multiplier_start; return b"Invalid multiplier suffix (KiB, MiB, or GiB)\0" - as *const u8 as *const ::core::ffi::c_char; + as *const u8 + as *const c_char; } } p = p.offset(1); - if p < name_eq_value_end - && *p as ::core::ffi::c_int == 'i' as i32 - { + if p < name_eq_value_end && *p as c_int == 'i' as i32 { p = p.offset(1); } - if p < name_eq_value_end - && *p as ::core::ffi::c_int == 'B' as i32 - { + if p < name_eq_value_end && *p as c_int == 'B' as i32 { p = p.offset(1); } if p < name_eq_value_end { *str = multiplier_start; - return b"Invalid multiplier suffix (KiB, MiB, or GiB)\0" - as *const u8 as *const ::core::ffi::c_char; + return b"Invalid multiplier suffix (KiB, MiB, or GiB)\0" as *const u8 + as *const c_char; } - if v > UINT32_MAX as uint32_t >> shift { - return b"Value out of range\0" as *const u8 - as *const ::core::ffi::c_char; + if v > UINT32_MAX as u32 >> shift { + return b"Value out of range\0" as *const u8 as *const c_char; } v <<= shift; } if v < (*optmap.offset(i as isize)).u.range.min || v > (*optmap.offset(i as isize)).u.range.max { - return b"Value out of range\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Value out of range\0" as *const u8 as *const c_char; } } - let mut ptr: *mut ::core::ffi::c_void = (filter_options - as *mut ::core::ffi::c_char) - .offset( - (*optmap.offset(i as isize)).offset as ::core::ffi::c_int - as isize, - ) as *mut ::core::ffi::c_void; - match (*optmap.offset(i as isize)).type_0 as ::core::ffi::c_int { + let mut ptr: *mut c_void = (filter_options as *mut c_char) + .offset((*optmap.offset(i as isize)).offset as isize) + as *mut c_void; + match (*optmap.offset(i as isize)).type_0 as c_int { 1 => { *(ptr as *mut lzma_mode) = v as lzma_mode; } @@ -1009,39 +818,37 @@ unsafe extern "C" fn parse_options( *(ptr as *mut lzma_match_finder) = v as lzma_match_finder; } _ => { - *(ptr as *mut uint32_t) = v; + *(ptr as *mut u32) = v; } } *str = name_eq_value_end; } } } - return ::core::ptr::null::<::core::ffi::c_char>(); + return ::core::ptr::null::(); } unsafe extern "C" fn parse_filter( - str: *mut *const ::core::ffi::c_char, - mut str_end: *const ::core::ffi::c_char, + str: *mut *const c_char, + mut str_end: *const c_char, mut filter: *mut lzma_filter, mut allocator: *const lzma_allocator, mut only_xz: bool, -) -> *const ::core::ffi::c_char { - let mut name_end: *const ::core::ffi::c_char = str_end; - let mut opts_start: *const ::core::ffi::c_char = str_end; - let mut p: *const ::core::ffi::c_char = *str; +) -> *const c_char { + let mut name_end: *const c_char = str_end; + let mut opts_start: *const c_char = str_end; + let mut p: *const c_char = *str; while p < str_end { - if *p as ::core::ffi::c_int == ':' as i32 - || *p as ::core::ffi::c_int == '=' as i32 - { + if *p as c_int == ':' as i32 || *p as c_int == '=' as i32 { name_end = p; - opts_start = p.offset(1 as ::core::ffi::c_int as isize); + opts_start = p.offset(1 as isize); break; } else { p = p.offset(1); } } - let name_len: size_t = name_end.offset_from(*str) as ::core::ffi::c_long as size_t; + let name_len: size_t = name_end.offset_from(*str) as c_long as size_t; if name_len > NAME_LEN_MAX as size_t { - return b"Unknown filter name\0" as *const u8 as *const ::core::ffi::c_char; + return b"Unknown filter name\0" as *const u8 as *const c_char; } let mut i: size_t = 0 as size_t; while i @@ -1049,93 +856,79 @@ unsafe extern "C" fn parse_filter( .wrapping_div(::core::mem::size_of::() as usize) { if memcmp( - *str as *const ::core::ffi::c_void, - &raw const (*(&raw const filter_name_map as *const C2RustUnnamed) - .offset(i as isize)) - .name as *const ::core::ffi::c_char as *const ::core::ffi::c_void, + *str as *const c_void, + &raw const (*(&raw const filter_name_map as *const C2RustUnnamed).offset(i as isize)) + .name as *const c_char as *const c_void, name_len, - ) == 0 as ::core::ffi::c_int - && filter_name_map[i as usize].name[name_len as usize] as ::core::ffi::c_int - == '\0' as i32 + ) == 0 as c_int + && filter_name_map[i as usize].name[name_len as usize] as c_int == '\0' as i32 { - if only_xz as ::core::ffi::c_int != 0 - && filter_name_map[i as usize].id - >= LZMA_FILTER_RESERVED_START as lzma_vli + if only_xz as c_int != 0 + && filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START as lzma_vli { return b"This filter cannot be used in the .xz format\0" as *const u8 - as *const ::core::ffi::c_char; + as *const c_char; } - let mut options: *mut ::core::ffi::c_void = lzma_alloc_zero( - filter_name_map[i as usize].opts_size as size_t, - allocator, - ); + let mut options: *mut c_void = + lzma_alloc_zero(filter_name_map[i as usize].opts_size as size_t, allocator); if options.is_null() { - return b"Memory allocation failed\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Memory allocation failed\0" as *const u8 as *const c_char; } *str = opts_start; - let mut errmsg: *const ::core::ffi::c_char = filter_name_map[i as usize] - .parse - .expect("non-null function pointer")(str, str_end, options); + let mut errmsg: *const c_char = + filter_name_map[i as usize] + .parse + .expect("non-null function pointer")(str, str_end, options); if !errmsg.is_null() { lzma_free(options, allocator); return errmsg; } (*filter).id = filter_name_map[i as usize].id; (*filter).options = options; - return ::core::ptr::null::<::core::ffi::c_char>(); + return ::core::ptr::null::(); } i = i.wrapping_add(1); } - return b"Unknown filter name\0" as *const u8 as *const ::core::ffi::c_char; + return b"Unknown filter name\0" as *const u8 as *const c_char; } unsafe extern "C" fn str_to_filters( - str: *mut *const ::core::ffi::c_char, + str: *mut *const c_char, mut filters: *mut lzma_filter, - mut flags: uint32_t, + mut flags: u32, mut allocator: *const lzma_allocator, -) -> *const ::core::ffi::c_char { +) -> *const c_char { let mut current_block: u64; - let mut errmsg: *const ::core::ffi::c_char = ::core::ptr::null::< - ::core::ffi::c_char, - >(); - while **str as ::core::ffi::c_int == ' ' as i32 { + let mut errmsg: *const c_char = ::core::ptr::null::(); + while **str as c_int == ' ' as i32 { *str = (*str).offset(1); } - if **str as ::core::ffi::c_int == '\0' as i32 { - return b"Empty string is not allowed, try '6' if a default value is needed\0" - as *const u8 as *const ::core::ffi::c_char; + if **str as c_int == '\0' as i32 { + return b"Empty string is not allowed, try '6' if a default value is needed\0" as *const u8 + as *const c_char; } - if **str as ::core::ffi::c_int >= '0' as i32 - && **str as ::core::ffi::c_int <= '9' as i32 - || **str as ::core::ffi::c_int == '-' as i32 - && (*(*str).offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - >= '0' as i32 - && *(*str).offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - <= '9' as i32) + if **str as c_int >= '0' as i32 && **str as c_int <= '9' as i32 + || **str as c_int == '-' as i32 + && (*(*str).offset(1 as isize) as c_int >= '0' as i32 + && *(*str).offset(1 as isize) as c_int <= '9' as i32) { - if **str as ::core::ffi::c_int == '-' as i32 { + if **str as c_int == '-' as i32 { *str = (*str).offset(1); } let str_len: size_t = strlen(*str) as size_t; - let mut str_end: *const ::core::ffi::c_char = memchr( - *str as *const ::core::ffi::c_void, - ' ' as i32, - str_len, - ) as *const ::core::ffi::c_char; + let mut str_end: *const c_char = + memchr(*str as *const c_void, ' ' as i32, str_len) as *const c_char; if !str_end.is_null() { let mut i: size_t = 1 as size_t; - while *str_end.offset(i as isize) as ::core::ffi::c_int != '\0' as i32 { - if *str_end.offset(i as isize) as ::core::ffi::c_int != ' ' as i32 { - return b"Unsupported preset\0" as *const u8 - as *const ::core::ffi::c_char; + while *str_end.offset(i as isize) as c_int != '\0' as i32 { + if *str_end.offset(i as isize) as c_int != ' ' as i32 { + return b"Unsupported preset\0" as *const u8 as *const c_char; } i = i.wrapping_add(1); } } else { str_end = (*str).offset(str_len as isize); } - let mut preset: uint32_t = 0; + let mut preset: u32 = 0; errmsg = parse_lzma12_preset(str, str_end, &raw mut preset); if !errmsg.is_null() { return errmsg; @@ -1145,61 +938,49 @@ unsafe extern "C" fn str_to_filters( allocator, ) as *mut lzma_options_lzma; if opts.is_null() { - return b"Memory allocation failed\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Memory allocation failed\0" as *const u8 as *const c_char; } if lzma_lzma_preset(opts, preset) != 0 { - lzma_free(opts as *mut ::core::ffi::c_void, allocator); - return b"Unsupported preset\0" as *const u8 as *const ::core::ffi::c_char; + lzma_free(opts as *mut c_void, allocator); + return b"Unsupported preset\0" as *const u8 as *const c_char; } - (*filters.offset(0 as ::core::ffi::c_int as isize)).id = LZMA_FILTER_LZMA2 - as lzma_vli; - let ref mut fresh0 = (*filters.offset(0 as ::core::ffi::c_int as isize)).options; - *fresh0 = opts as *mut ::core::ffi::c_void; - (*filters.offset(1 as ::core::ffi::c_int as isize)).id = LZMA_VLI_UNKNOWN - as lzma_vli; - let ref mut fresh1 = (*filters.offset(1 as ::core::ffi::c_int as isize)).options; + (*filters.offset(0 as isize)).id = LZMA_FILTER_LZMA2 as lzma_vli; + let ref mut fresh0 = (*filters.offset(0 as isize)).options; + *fresh0 = opts as *mut c_void; + (*filters.offset(1 as isize)).id = LZMA_VLI_UNKNOWN as lzma_vli; + let ref mut fresh1 = (*filters.offset(1 as isize)).options; *fresh1 = NULL; - return ::core::ptr::null::<::core::ffi::c_char>(); + return ::core::ptr::null::(); } - let only_xz: bool = flags & LZMA_STR_ALL_FILTERS as uint32_t == 0 as uint32_t; + let only_xz: bool = flags & LZMA_STR_ALL_FILTERS as u32 == 0 as u32; let mut temp_filters: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::<::core::ffi::c_void>(), + options: ::core::ptr::null_mut::(), }; 5]; let mut i_0: size_t = 0 as size_t; loop { if i_0 == LZMA_FILTERS_MAX as size_t { - errmsg = b"The maximum number of filters is four\0" as *const u8 - as *const ::core::ffi::c_char; + errmsg = b"The maximum number of filters is four\0" as *const u8 as *const c_char; current_block = 6100283484465977373; break; } else { - if *(*str).offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - == '-' as i32 - && *(*str).offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - == '-' as i32 + if *(*str).offset(0 as isize) as c_int == '-' as i32 + && *(*str).offset(1 as isize) as c_int == '-' as i32 { - *str = (*str).offset(2 as ::core::ffi::c_int as isize); + *str = (*str).offset(2 as isize); } - let mut filter_end: *const ::core::ffi::c_char = *str; - while *filter_end.offset(0 as ::core::ffi::c_int as isize) - as ::core::ffi::c_int != '\0' as i32 - { - if *filter_end.offset(0 as ::core::ffi::c_int as isize) - as ::core::ffi::c_int == '-' as i32 - && *filter_end.offset(1 as ::core::ffi::c_int as isize) - as ::core::ffi::c_int == '-' as i32 - || *filter_end.offset(0 as ::core::ffi::c_int as isize) - as ::core::ffi::c_int == ' ' as i32 + let mut filter_end: *const c_char = *str; + while *filter_end.offset(0 as isize) as c_int != '\0' as i32 { + if *filter_end.offset(0 as isize) as c_int == '-' as i32 + && *filter_end.offset(1 as isize) as c_int == '-' as i32 + || *filter_end.offset(0 as isize) as c_int == ' ' as i32 { break; } filter_end = filter_end.offset(1); } if filter_end == *str { - errmsg = b"Filter name is missing\0" as *const u8 - as *const ::core::ffi::c_char; + errmsg = b"Filter name is missing\0" as *const u8 as *const c_char; current_block = 6100283484465977373; break; } else { @@ -1215,11 +996,11 @@ unsafe extern "C" fn str_to_filters( current_block = 6100283484465977373; break; } - while **str as ::core::ffi::c_int == ' ' as i32 { + while **str as c_int == ' ' as i32 { *str = (*str).offset(1); } i_0 = i_0.wrapping_add(1); - if !(**str as ::core::ffi::c_int != '\0' as i32) { + if !(**str as c_int != '\0' as i32) { current_block = 15090052786889560393; break; } @@ -1230,17 +1011,14 @@ unsafe extern "C" fn str_to_filters( 15090052786889560393 => { temp_filters[i_0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; temp_filters[i_0 as usize].options = NULL; - if flags & LZMA_STR_NO_VALIDATION as uint32_t == 0 as uint32_t { + if flags & LZMA_STR_NO_VALIDATION as u32 == 0 as u32 { let mut dummy: size_t = 0; - let ret: lzma_ret = lzma_validate_chain( - &raw mut temp_filters as *mut lzma_filter, - &raw mut dummy, - ) as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { - errmsg = b"Invalid filter chain ('lzma2' missing at the end?)\0" - as *const u8 as *const ::core::ffi::c_char; + let ret: lzma_ret = + lzma_validate_chain(&raw mut temp_filters as *mut lzma_filter, &raw mut dummy) + as lzma_ret; + if ret as c_uint != LZMA_OK as c_uint { + errmsg = b"Invalid filter chain ('lzma2' missing at the end?)\0" as *const u8 + as *const c_char; current_block = 6100283484465977373; } else { current_block = 12381812505308290051; @@ -1252,16 +1030,12 @@ unsafe extern "C" fn str_to_filters( 6100283484465977373 => {} _ => { memcpy( - filters as *mut ::core::ffi::c_void, - &raw mut temp_filters as *mut lzma_filter - as *const ::core::ffi::c_void, - i_0 - .wrapping_add(1 as size_t) - .wrapping_mul( - ::core::mem::size_of::() as size_t, - ), + filters as *mut c_void, + &raw mut temp_filters as *mut lzma_filter as *const c_void, + i_0.wrapping_add(1 as size_t) + .wrapping_mul(::core::mem::size_of::() as size_t), ); - return ::core::ptr::null::<::core::ffi::c_char>(); + return ::core::ptr::null::(); } } } @@ -1279,105 +1053,81 @@ unsafe extern "C" fn str_to_filters( } #[no_mangle] pub unsafe extern "C" fn lzma_str_to_filters( - mut str: *const ::core::ffi::c_char, - mut error_pos: *mut ::core::ffi::c_int, + mut str: *const c_char, + mut error_pos: *mut c_int, mut filters: *mut lzma_filter, - mut flags: uint32_t, + mut flags: u32, mut allocator: *const lzma_allocator, -) -> *const ::core::ffi::c_char { +) -> *const c_char { if !error_pos.is_null() { - *error_pos = 0 as ::core::ffi::c_int; + *error_pos = 0 as c_int; } if str.is_null() || filters.is_null() { - return b"Unexpected NULL pointer argument(s) to lzma_str_to_filters()\0" - as *const u8 as *const ::core::ffi::c_char; + return b"Unexpected NULL pointer argument(s) to lzma_str_to_filters()\0" as *const u8 + as *const c_char; } - let supported_flags: uint32_t = LZMA_STR_ALL_FILTERS as uint32_t - | LZMA_STR_NO_VALIDATION as uint32_t; + let supported_flags: u32 = LZMA_STR_ALL_FILTERS as u32 | LZMA_STR_NO_VALIDATION as u32; if flags & !supported_flags != 0 { - return b"Unsupported flags to lzma_str_to_filters()\0" as *const u8 - as *const ::core::ffi::c_char; + return b"Unsupported flags to lzma_str_to_filters()\0" as *const u8 as *const c_char; } - let mut used: *const ::core::ffi::c_char = str; - let mut errmsg: *const ::core::ffi::c_char = str_to_filters( - &raw mut used, - filters, - flags, - allocator, - ); + let mut used: *const c_char = str; + let mut errmsg: *const c_char = str_to_filters(&raw mut used, filters, flags, allocator); if !error_pos.is_null() { - let n: size_t = used.offset_from(str) as ::core::ffi::c_long as size_t; + let n: size_t = used.offset_from(str) as c_long as size_t; *error_pos = if n > INT_MAX as size_t { INT_MAX } else { - n as ::core::ffi::c_int + n as c_int }; } return errmsg; } unsafe extern "C" fn strfy_filter( mut dest: *mut lzma_str, - mut delimiter: *const ::core::ffi::c_char, + mut delimiter: *const c_char, mut optmap: *const option_map, mut optmap_count: size_t, - mut filter_options: *const ::core::ffi::c_void, + mut filter_options: *const c_void, ) { let mut i: size_t = 0 as size_t; while i < optmap_count { - if !((*optmap.offset(i as isize)).type_0 as ::core::ffi::c_int - == OPTMAP_TYPE_LZMA_PRESET as ::core::ffi::c_int) - { - let mut v: uint32_t = 0; - let mut ptr: *const ::core::ffi::c_void = (filter_options - as *const ::core::ffi::c_char) - .offset( - (*optmap.offset(i as isize)).offset as ::core::ffi::c_int as isize, - ) as *const ::core::ffi::c_void; - match (*optmap.offset(i as isize)).type_0 as ::core::ffi::c_int { + if !((*optmap.offset(i as isize)).type_0 as c_int == OPTMAP_TYPE_LZMA_PRESET as c_int) { + let mut v: u32 = 0; + let mut ptr: *const c_void = (filter_options as *const c_char) + .offset((*optmap.offset(i as isize)).offset as isize) + as *const c_void; + match (*optmap.offset(i as isize)).type_0 as c_int { 1 => { - v = *(ptr as *const lzma_mode) as uint32_t; + v = *(ptr as *const lzma_mode) as u32; } 2 => { - v = *(ptr as *const lzma_match_finder) as uint32_t; + v = *(ptr as *const lzma_match_finder) as u32; } _ => { - v = *(ptr as *const uint32_t); + v = *(ptr as *const u32); } } - if !(v == 0 as uint32_t - && (*optmap.offset(i as isize)).flags as ::core::ffi::c_int - & OPTMAP_NO_STRFY_ZERO != 0) + if !(v == 0 as u32 + && (*optmap.offset(i as isize)).flags as c_int & OPTMAP_NO_STRFY_ZERO != 0) { str_append_str(dest, delimiter); - delimiter = b",\0" as *const u8 as *const ::core::ffi::c_char; + delimiter = b",\0" as *const u8 as *const c_char; str_append_str( dest, - &raw const (*optmap.offset(i as isize)).name - as *const ::core::ffi::c_char, + &raw const (*optmap.offset(i as isize)).name as *const c_char, ); - str_append_str(dest, b"=\0" as *const u8 as *const ::core::ffi::c_char); - if (*optmap.offset(i as isize)).flags as ::core::ffi::c_int - & OPTMAP_USE_NAME_VALUE_MAP != 0 - { - let mut map: *const name_value_map = (*optmap.offset(i as isize)) - .u - .map; + str_append_str(dest, b"=\0" as *const u8 as *const c_char); + if (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_NAME_VALUE_MAP != 0 { + let mut map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0 as size_t; loop { - if (*map.offset(j as isize)) - .name[0 as ::core::ffi::c_int as usize] as ::core::ffi::c_int - == '\0' as i32 - { - str_append_str( - dest, - b"UNKNOWN\0" as *const u8 as *const ::core::ffi::c_char, - ); + if (*map.offset(j as isize)).name[0 as usize] as c_int == '\0' as i32 { + str_append_str(dest, b"UNKNOWN\0" as *const u8 as *const c_char); break; } else if (*map.offset(j as isize)).value == v { str_append_str( dest, - &raw const (*map.offset(j as isize)).name - as *const ::core::ffi::c_char, + &raw const (*map.offset(j as isize)).name as *const c_char, ); break; } else { @@ -1388,8 +1138,7 @@ unsafe extern "C" fn strfy_filter( str_append_u32( dest, v, - (*optmap.offset(i as isize)).flags as ::core::ffi::c_int - & OPTMAP_USE_BYTE_SUFFIX != 0, + (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_BYTE_SUFFIX != 0, ); } } @@ -1399,47 +1148,41 @@ unsafe extern "C" fn strfy_filter( } #[no_mangle] pub unsafe extern "C" fn lzma_str_from_filters( - mut output_str: *mut *mut ::core::ffi::c_char, + mut output_str: *mut *mut c_char, mut filters: *const lzma_filter, - mut flags: uint32_t, + mut flags: u32, mut allocator: *const lzma_allocator, ) -> lzma_ret { if output_str.is_null() { return LZMA_PROG_ERROR; } - *output_str = ::core::ptr::null_mut::<::core::ffi::c_char>(); + *output_str = ::core::ptr::null_mut::(); if filters.is_null() { return LZMA_PROG_ERROR; } - let supported_flags: uint32_t = LZMA_STR_ENCODER as uint32_t - | LZMA_STR_DECODER as uint32_t | LZMA_STR_GETOPT_LONG as uint32_t - | LZMA_STR_NO_SPACES as uint32_t; + let supported_flags: u32 = LZMA_STR_ENCODER as u32 + | LZMA_STR_DECODER as u32 + | LZMA_STR_GETOPT_LONG as u32 + | LZMA_STR_NO_SPACES as u32; if flags & !supported_flags != 0 { return LZMA_OPTIONS_ERROR; } - if (*filters.offset(0 as ::core::ffi::c_int as isize)).id - == LZMA_VLI_UNKNOWN as lzma_vli - { + if (*filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_OPTIONS_ERROR; } let mut dest: lzma_str = lzma_str { - buf: ::core::ptr::null_mut::<::core::ffi::c_char>(), + buf: ::core::ptr::null_mut::(), pos: 0, }; let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - let show_opts: bool = flags - & (LZMA_STR_ENCODER as uint32_t | LZMA_STR_DECODER as uint32_t) != 0; - let mut opt_delim: *const ::core::ffi::c_char = if flags - & LZMA_STR_GETOPT_LONG as uint32_t != 0 - { - b"=\0" as *const u8 as *const ::core::ffi::c_char + let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; + let mut opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { + b"=\0" as *const u8 as *const c_char } else { - b":\0" as *const u8 as *const ::core::ffi::c_char + b":\0" as *const u8 as *const c_char }; let mut i: size_t = 0 as size_t; while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { @@ -1447,25 +1190,18 @@ pub unsafe extern "C" fn lzma_str_from_filters( str_free(&raw mut dest, allocator); return LZMA_OPTIONS_ERROR; } - if i > 0 as size_t && flags & LZMA_STR_NO_SPACES as uint32_t == 0 { - str_append_str( - &raw mut dest, - b" \0" as *const u8 as *const ::core::ffi::c_char, - ); + if i > 0 as size_t && flags & LZMA_STR_NO_SPACES as u32 == 0 { + str_append_str(&raw mut dest, b" \0" as *const u8 as *const c_char); } - if flags & LZMA_STR_GETOPT_LONG as uint32_t != 0 - || i > 0 as size_t && flags & LZMA_STR_NO_SPACES as uint32_t != 0 + if flags & LZMA_STR_GETOPT_LONG as u32 != 0 + || i > 0 as size_t && flags & LZMA_STR_NO_SPACES as u32 != 0 { - str_append_str( - &raw mut dest, - b"--\0" as *const u8 as *const ::core::ffi::c_char, - ); + str_append_str(&raw mut dest, b"--\0" as *const u8 as *const c_char); } let mut j: size_t = 0 as size_t; loop { - if j - == (::core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) - .wrapping_div(::core::mem::size_of::() as usize) + if j == (::core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) + .wrapping_div(::core::mem::size_of::() as usize) { str_free(&raw mut dest, allocator); return LZMA_OPTIONS_ERROR; @@ -1475,7 +1211,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( &raw mut dest, &raw const (*(&raw const filter_name_map as *const C2RustUnnamed) .offset(j as isize)) - .name as *const ::core::ffi::c_char, + .name as *const c_char, ); if !show_opts { break; @@ -1487,12 +1223,10 @@ pub unsafe extern "C" fn lzma_str_from_filters( } break; } else { - let optmap_count: size_t = (if flags & LZMA_STR_ENCODER as uint32_t - != 0 - { - filter_name_map[j as usize].strfy_encoder as ::core::ffi::c_int + let optmap_count: size_t = (if flags & LZMA_STR_ENCODER as u32 != 0 { + filter_name_map[j as usize].strfy_encoder as c_int } else { - filter_name_map[j as usize].strfy_decoder as ::core::ffi::c_int + filter_name_map[j as usize].strfy_decoder as c_int }) as size_t; strfy_filter( &raw mut dest, @@ -1513,46 +1247,40 @@ pub unsafe extern "C" fn lzma_str_from_filters( } #[no_mangle] pub unsafe extern "C" fn lzma_str_list_filters( - mut output_str: *mut *mut ::core::ffi::c_char, + mut output_str: *mut *mut c_char, mut filter_id: lzma_vli, - mut flags: uint32_t, + mut flags: u32, mut allocator: *const lzma_allocator, ) -> lzma_ret { if output_str.is_null() { return LZMA_PROG_ERROR; } - *output_str = ::core::ptr::null_mut::<::core::ffi::c_char>(); - let supported_flags: uint32_t = LZMA_STR_ALL_FILTERS as uint32_t - | LZMA_STR_ENCODER as uint32_t | LZMA_STR_DECODER as uint32_t - | LZMA_STR_GETOPT_LONG as uint32_t; + *output_str = ::core::ptr::null_mut::(); + let supported_flags: u32 = LZMA_STR_ALL_FILTERS as u32 + | LZMA_STR_ENCODER as u32 + | LZMA_STR_DECODER as u32 + | LZMA_STR_GETOPT_LONG as u32; if flags & !supported_flags != 0 { return LZMA_OPTIONS_ERROR; } let mut dest: lzma_str = lzma_str { - buf: ::core::ptr::null_mut::<::core::ffi::c_char>(), + buf: ::core::ptr::null_mut::(), pos: 0, }; let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - let show_opts: bool = flags - & (LZMA_STR_ENCODER as uint32_t | LZMA_STR_DECODER as uint32_t) != 0; - let mut filter_delim: *const ::core::ffi::c_char = if show_opts as ::core::ffi::c_int - != 0 - { - b"\n\0" as *const u8 as *const ::core::ffi::c_char + let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; + let mut filter_delim: *const c_char = if show_opts as c_int != 0 { + b"\n\0" as *const u8 as *const c_char } else { - b" \0" as *const u8 as *const ::core::ffi::c_char + b" \0" as *const u8 as *const c_char }; - let mut opt_delim: *const ::core::ffi::c_char = if flags - & LZMA_STR_GETOPT_LONG as uint32_t != 0 - { - b"=\0" as *const u8 as *const ::core::ffi::c_char + let mut opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { + b"=\0" as *const u8 as *const c_char } else { - b":\0" as *const u8 as *const ::core::ffi::c_char + b":\0" as *const u8 as *const c_char }; let mut first_filter_printed: bool = false_0 != 0; let mut i: size_t = 0 as size_t; @@ -1564,98 +1292,79 @@ pub unsafe extern "C" fn lzma_str_list_filters( && filter_id != filter_name_map[i as usize].id) { if !(filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START as lzma_vli - && flags & LZMA_STR_ALL_FILTERS as uint32_t == 0 as uint32_t + && flags & LZMA_STR_ALL_FILTERS as u32 == 0 as u32 && filter_id == LZMA_VLI_UNKNOWN as lzma_vli) { if first_filter_printed { str_append_str(&raw mut dest, filter_delim); } first_filter_printed = true_0 != 0; - if flags & LZMA_STR_GETOPT_LONG as uint32_t != 0 { - str_append_str( - &raw mut dest, - b"--\0" as *const u8 as *const ::core::ffi::c_char, - ); + if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { + str_append_str(&raw mut dest, b"--\0" as *const u8 as *const c_char); } str_append_str( &raw mut dest, &raw const (*(&raw const filter_name_map as *const C2RustUnnamed) .offset(i as isize)) - .name as *const ::core::ffi::c_char, + .name as *const c_char, ); if show_opts { - let mut optmap: *const option_map = filter_name_map[i as usize] - .optmap; - let mut d: *const ::core::ffi::c_char = opt_delim; - let end: size_t = (if flags & LZMA_STR_ENCODER as uint32_t != 0 { - filter_name_map[i as usize].strfy_encoder as ::core::ffi::c_int + let mut optmap: *const option_map = filter_name_map[i as usize].optmap; + let mut d: *const c_char = opt_delim; + let end: size_t = (if flags & LZMA_STR_ENCODER as u32 != 0 { + filter_name_map[i as usize].strfy_encoder as c_int } else { - filter_name_map[i as usize].strfy_decoder as ::core::ffi::c_int + filter_name_map[i as usize].strfy_decoder as c_int }) as size_t; let mut j: size_t = 0 as size_t; while j < end { str_append_str(&raw mut dest, d); - d = b",\0" as *const u8 as *const ::core::ffi::c_char; + d = b",\0" as *const u8 as *const c_char; str_append_str( &raw mut dest, - &raw const (*optmap.offset(j as isize)).name - as *const ::core::ffi::c_char, + &raw const (*optmap.offset(j as isize)).name as *const c_char, ); - str_append_str( - &raw mut dest, - b"=<\0" as *const u8 as *const ::core::ffi::c_char, - ); - if (*optmap.offset(j as isize)).type_0 as ::core::ffi::c_int - == OPTMAP_TYPE_LZMA_PRESET as ::core::ffi::c_int + str_append_str(&raw mut dest, b"=<\0" as *const u8 as *const c_char); + if (*optmap.offset(j as isize)).type_0 as c_int + == OPTMAP_TYPE_LZMA_PRESET as c_int { str_append_str(&raw mut dest, LZMA12_PRESET_STR.as_ptr()); - } else if (*optmap.offset(j as isize)).flags - as ::core::ffi::c_int & OPTMAP_USE_NAME_VALUE_MAP != 0 + } else if (*optmap.offset(j as isize)).flags as c_int + & OPTMAP_USE_NAME_VALUE_MAP + != 0 { - let mut m: *const name_value_map = (*optmap - .offset(j as isize)) - .u - .map; + let mut m: *const name_value_map = (*optmap.offset(j as isize)).u.map; let mut k: size_t = 0 as size_t; - while (*m.offset(k as isize)) - .name[0 as ::core::ffi::c_int as usize] - as ::core::ffi::c_int != '\0' as i32 - { + while (*m.offset(k as isize)).name[0 as usize] as c_int != '\0' as i32 { if k > 0 as size_t { str_append_str( &raw mut dest, - b"|\0" as *const u8 as *const ::core::ffi::c_char, + b"|\0" as *const u8 as *const c_char, ); } str_append_str( &raw mut dest, - &raw const (*m.offset(k as isize)).name - as *const ::core::ffi::c_char, + &raw const (*m.offset(k as isize)).name as *const c_char, ); k = k.wrapping_add(1); } } else { - let use_byte_suffix: bool = (*optmap.offset(j as isize)) - .flags as ::core::ffi::c_int & OPTMAP_USE_BYTE_SUFFIX != 0; + let use_byte_suffix: bool = (*optmap.offset(j as isize)).flags as c_int + & OPTMAP_USE_BYTE_SUFFIX + != 0; str_append_u32( &raw mut dest, (*optmap.offset(j as isize)).u.range.min, use_byte_suffix, ); - str_append_str( - &raw mut dest, - b"-\0" as *const u8 as *const ::core::ffi::c_char, - ); + str_append_str(&raw mut dest, b"-\0" as *const u8 as *const c_char); str_append_u32( &raw mut dest, (*optmap.offset(j as isize)).u.range.max, use_byte_suffix, ); } - str_append_str( - &raw mut dest, - b">\0" as *const u8 as *const ::core::ffi::c_char, - ); + str_append_str(&raw mut dest, b">\0" as *const u8 as *const c_char); j = j.wrapping_add(1); } } @@ -1672,11 +1381,8 @@ pub unsafe extern "C" fn lzma_str_list_filters( unsafe extern "C" fn run_static_initializers() { lzma12_optmap = [ option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"preset\0\0\0\0\0\0"), - type_0: OPTMAP_TYPE_LZMA_PRESET as ::core::ffi::c_int as uint8_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"preset\0\0\0\0\0\0"), + type_0: OPTMAP_TYPE_LZMA_PRESET as u8, flags: 0, offset: 0, u: C2RustUnnamed_0 { @@ -1684,117 +1390,92 @@ unsafe extern "C" fn run_static_initializers() { }, }, option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"dict\0\0\0\0\0\0\0\0"), + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dict\0\0\0\0\0\0\0\0"), type_0: 0, - flags: OPTMAP_USE_BYTE_SUFFIX as uint8_t, - offset: 0 as ::core::ffi::c_ulong as uint16_t, + flags: OPTMAP_USE_BYTE_SUFFIX as u8, + offset: 0 as c_ulong as u16, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: LZMA_DICT_SIZE_MIN as uint32_t, - max: ((1 as uint32_t) << 30 as ::core::ffi::c_int) - .wrapping_add((1 as uint32_t) << 29 as ::core::ffi::c_int), + min: LZMA_DICT_SIZE_MIN as u32, + max: ((1 as u32) << 30 as c_int).wrapping_add((1 as u32) << 29 as c_int), }, }, }, option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"lc\0\0\0\0\0\0\0\0\0\0"), + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lc\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 20 as ::core::ffi::c_ulong as uint16_t, + offset: 20 as c_ulong as u16, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: LZMA_LCLP_MIN as uint32_t, - max: LZMA_LCLP_MAX as uint32_t, + min: LZMA_LCLP_MIN as u32, + max: LZMA_LCLP_MAX as u32, }, }, }, option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"lp\0\0\0\0\0\0\0\0\0\0"), + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lp\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 24 as ::core::ffi::c_ulong as uint16_t, + offset: 24 as c_ulong as u16, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: LZMA_LCLP_MIN as uint32_t, - max: LZMA_LCLP_MAX as uint32_t, + min: LZMA_LCLP_MIN as u32, + max: LZMA_LCLP_MAX as u32, }, }, }, option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"pb\0\0\0\0\0\0\0\0\0\0"), + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"pb\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 28 as ::core::ffi::c_ulong as uint16_t, + offset: 28 as c_ulong as u16, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: LZMA_PB_MIN as uint32_t, - max: LZMA_PB_MAX as uint32_t, + min: LZMA_PB_MIN as u32, + max: LZMA_PB_MAX as u32, }, }, }, option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"mode\0\0\0\0\0\0\0\0"), - type_0: OPTMAP_TYPE_LZMA_MODE as ::core::ffi::c_int as uint8_t, - flags: OPTMAP_USE_NAME_VALUE_MAP as uint8_t, - offset: 32 as ::core::ffi::c_ulong as uint16_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mode\0\0\0\0\0\0\0\0"), + type_0: OPTMAP_TYPE_LZMA_MODE as u8, + flags: OPTMAP_USE_NAME_VALUE_MAP as u8, + offset: 32 as c_ulong as u16, u: C2RustUnnamed_0 { map: &raw const lzma12_mode_map as *const name_value_map, }, }, option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"nice\0\0\0\0\0\0\0\0"), + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"nice\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 36 as ::core::ffi::c_ulong as uint16_t, + offset: 36 as c_ulong as u16, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: 2 as uint32_t, - max: 273 as uint32_t, + min: 2 as u32, + max: 273 as u32, }, }, }, option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"mf\0\0\0\0\0\0\0\0\0\0"), - type_0: OPTMAP_TYPE_LZMA_MATCH_FINDER as ::core::ffi::c_int as uint8_t, - flags: OPTMAP_USE_NAME_VALUE_MAP as uint8_t, - offset: 40 as ::core::ffi::c_ulong as uint16_t, + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mf\0\0\0\0\0\0\0\0\0\0"), + type_0: OPTMAP_TYPE_LZMA_MATCH_FINDER as u8, + flags: OPTMAP_USE_NAME_VALUE_MAP as u8, + offset: 40 as c_ulong as u16, u: C2RustUnnamed_0 { map: &raw const lzma12_mf_map as *const name_value_map, }, }, option_map { - name: ::core::mem::transmute::< - [u8; 12], - [::core::ffi::c_char; 12], - >(*b"depth\0\0\0\0\0\0\0"), + name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"depth\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 44 as ::core::ffi::c_ulong as uint16_t, + offset: 44 as c_ulong as u16, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: 0 as uint32_t, - max: UINT32_MAX as uint32_t, + min: 0 as u32, + max: UINT32_MAX as u32, }, }, }, diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index 0a85aecf..6dbddd8e 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -1,8 +1,5 @@ -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -24,17 +21,14 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_vli = uint64_t; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const LZMA_VLI_BYTES_MAX: ::core::ffi::c_int = 9 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_vli_decode( mut vli: *mut lzma_vli, mut vli_pos: *mut size_t, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, ) -> lzma_ret { @@ -59,26 +53,20 @@ pub unsafe extern "C" fn lzma_vli_decode( } } loop { - let byte: uint8_t = *in_0.offset(*in_pos as isize); + let byte: u8 = *in_0.offset(*in_pos as isize); *in_pos = (*in_pos).wrapping_add(1); - *vli = (*vli) - .wrapping_add( - ((byte as ::core::ffi::c_int & 0x7f as ::core::ffi::c_int) as lzma_vli) - << (*vli_pos).wrapping_mul(7 as size_t), - ); + *vli = (*vli).wrapping_add( + ((byte as c_int & 0x7f as c_int) as lzma_vli) << (*vli_pos).wrapping_mul(7 as size_t), + ); *vli_pos = (*vli_pos).wrapping_add(1); - if byte as ::core::ffi::c_int & 0x80 as ::core::ffi::c_int - == 0 as ::core::ffi::c_int - { - if byte as ::core::ffi::c_int == 0 as ::core::ffi::c_int - && *vli_pos > 1 as size_t - { + if byte as c_int & 0x80 as c_int == 0 as c_int { + if byte as c_int == 0 as c_int && *vli_pos > 1 as size_t { return LZMA_DATA_ERROR; } return (if vli_pos == &raw mut vli_pos_internal { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int } else { - LZMA_STREAM_END as ::core::ffi::c_int + LZMA_STREAM_END as c_int }) as lzma_ret; } if *vli_pos == LZMA_VLI_BYTES_MAX as size_t { @@ -89,8 +77,8 @@ pub unsafe extern "C" fn lzma_vli_decode( } } return (if vli_pos == &raw mut vli_pos_internal { - LZMA_DATA_ERROR as ::core::ffi::c_int + LZMA_DATA_ERROR as c_int } else { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int }) as lzma_ret; } diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index fc0b1861..c702963f 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -1,8 +1,5 @@ -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -24,21 +21,16 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_vli = uint64_t; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); -pub const LZMA_VLI_BYTES_MAX: ::core::ffi::c_int = 9 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_vli_encode( mut vli: lzma_vli, mut vli_pos: *mut size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { @@ -49,7 +41,7 @@ pub unsafe extern "C" fn lzma_vli_encode( return LZMA_PROG_ERROR; } } else if *out_pos >= out_size { - return LZMA_BUF_ERROR + return LZMA_BUF_ERROR; } if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || vli > LZMA_VLI_MAX as lzma_vli { return LZMA_PROG_ERROR; @@ -57,24 +49,23 @@ pub unsafe extern "C" fn lzma_vli_encode( vli >>= (*vli_pos).wrapping_mul(7 as size_t); while vli >= 0x80 as lzma_vli { *vli_pos = (*vli_pos).wrapping_add(1); - *out.offset(*out_pos as isize) = (vli as uint8_t as ::core::ffi::c_int - | 0x80 as ::core::ffi::c_int) as uint8_t; - vli >>= 7 as ::core::ffi::c_int; + *out.offset(*out_pos as isize) = (vli as u8 as c_int | 0x80 as c_int) as u8; + vli >>= 7 as c_int; *out_pos = (*out_pos).wrapping_add(1); if *out_pos == out_size { return (if vli_pos == &raw mut vli_pos_internal { - LZMA_PROG_ERROR as ::core::ffi::c_int + LZMA_PROG_ERROR as c_int } else { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int }) as lzma_ret; } } - *out.offset(*out_pos as isize) = vli as uint8_t; + *out.offset(*out_pos as isize) = vli as u8; *out_pos = (*out_pos).wrapping_add(1); *vli_pos = (*vli_pos).wrapping_add(1); return (if vli_pos == &raw mut vli_pos_internal { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int } else { - LZMA_STREAM_END as ::core::ffi::c_int + LZMA_STREAM_END as c_int }) as lzma_ret; } diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index 34de1ab3..c5ac22a4 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -1,18 +1,15 @@ -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_vli = uint64_t; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_MAX: ::core::ffi::c_ulonglong = UINT64_MAX - .wrapping_div(2 as ::core::ffi::c_ulonglong); +use crate::types::*; +use core::ffi::{c_int, c_ulonglong}; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); #[no_mangle] -pub unsafe extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> uint32_t { +pub unsafe extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { if vli > LZMA_VLI_MAX as lzma_vli { - return 0 as uint32_t; + return 0 as u32; } - let mut i: uint32_t = 0 as uint32_t; + let mut i: u32 = 0 as u32; loop { - vli >>= 7 as ::core::ffi::c_int; + vli >>= 7 as c_int; i = i.wrapping_add(1); if !(vli != 0 as lzma_vli) { break; diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index 879cec5f..6684aa08 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -1,14 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn memset( - __b: *mut ::core::ffi::c_void, - __c: ::core::ffi::c_int, - __len: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -16,13 +11,6 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -44,7 +32,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -53,109 +40,75 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_delta_type = ::core::ffi::c_uint; pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_delta { pub type_0: lzma_delta_type, - pub dist: uint32_t, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, - pub reserved_int3: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub dist: u32, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -170,25 +123,22 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_delta_coder { pub next: lzma_next_coder, pub distance: size_t, - pub pos: uint8_t, - pub history: [uint8_t; 256], + pub pos: u8, + pub history: [u8; 256], } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_DELTA_DIST_MIN: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const LZMA_DELTA_DIST_MAX: ::core::ffi::c_int = 256 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; +pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; unsafe extern "C" fn delta_coder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; lzma_next_end(&raw mut (*coder).next, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_delta_coder_init( @@ -205,18 +155,14 @@ pub unsafe extern "C" fn lzma_delta_coder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; - (*next).end = Some( - delta_coder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), - ) as lzma_end_function; + (*next).coder = coder as *mut c_void; + (*next).end = + Some(delta_coder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) + as lzma_end_function; (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -226,40 +172,33 @@ pub unsafe extern "C" fn lzma_delta_coder_init( set_out_limit: None, }; } - if lzma_delta_coder_memusage( - (*filters.offset(0 as ::core::ffi::c_int as isize)).options, - ) == UINT64_MAX as uint64_t - { + if lzma_delta_coder_memusage((*filters.offset(0 as isize)).options) == UINT64_MAX as u64 { return LZMA_OPTIONS_ERROR; } - let mut opt: *const lzma_options_delta = (*filters - .offset(0 as ::core::ffi::c_int as isize)) - .options as *const lzma_options_delta; + let mut opt: *const lzma_options_delta = + (*filters.offset(0 as isize)).options as *const lzma_options_delta; (*coder).distance = (*opt).dist as size_t; - (*coder).pos = 0 as uint8_t; + (*coder).pos = 0 as u8; memset( - &raw mut (*coder).history as *mut uint8_t as *mut ::core::ffi::c_void, - 0 as ::core::ffi::c_int, + &raw mut (*coder).history as *mut u8 as *mut c_void, + 0 as c_int, 256 as size_t, ); return lzma_next_filter_init( &raw mut (*coder).next, allocator, - filters.offset(1 as ::core::ffi::c_int as isize), + filters.offset(1 as isize), ); } #[no_mangle] -pub unsafe extern "C" fn lzma_delta_coder_memusage( - mut options: *const ::core::ffi::c_void, -) -> uint64_t { +pub unsafe extern "C" fn lzma_delta_coder_memusage(mut options: *const c_void) -> u64 { let mut opt: *const lzma_options_delta = options as *const lzma_options_delta; if opt.is_null() - || (*opt).type_0 as ::core::ffi::c_uint - != LZMA_DELTA_TYPE_BYTE as ::core::ffi::c_int as ::core::ffi::c_uint - || (*opt).dist < LZMA_DELTA_DIST_MIN as uint32_t - || (*opt).dist > LZMA_DELTA_DIST_MAX as uint32_t + || (*opt).type_0 as c_uint != LZMA_DELTA_TYPE_BYTE as c_uint + || (*opt).dist < LZMA_DELTA_DIST_MIN as u32 + || (*opt).dist > LZMA_DELTA_DIST_MAX as u32 { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } - return ::core::mem::size_of::() as uint64_t; + return ::core::mem::size_of::() as u64; } diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 4dda54d6..a53892de 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -1,21 +1,13 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; fn lzma_delta_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -37,7 +29,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -46,109 +37,75 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_delta_type = ::core::ffi::c_uint; pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_delta { pub type_0: lzma_delta_type, - pub dist: uint32_t, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, - pub reserved_int3: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub dist: u32, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -163,53 +120,44 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_delta_coder { pub next: lzma_next_coder, pub distance: size_t, - pub pos: uint8_t, - pub history: [uint8_t; 256], + pub pos: u8, + pub history: [u8; 256], } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; unsafe extern "C" fn decode_buffer( mut coder: *mut lzma_delta_coder, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) { let distance: size_t = (*coder).distance; let mut i: size_t = 0 as size_t; while i < size { let ref mut fresh0 = *buffer.offset(i as isize); - *fresh0 = (*fresh0 as ::core::ffi::c_int - + (*coder) - .history[(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) - as usize] as ::core::ffi::c_int) as uint8_t; + *fresh0 = (*fresh0 as c_int + + (*coder).history + [(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) as usize] + as c_int) as u8; let fresh1 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder) - .history[(fresh1 as ::core::ffi::c_int & 0xff as ::core::ffi::c_int) - as usize] = *buffer.offset(i as isize); + (*coder).history[(fresh1 as c_int & 0xff as c_int) as usize] = *buffer.offset(i as isize); i = i.wrapping_add(1); } } unsafe extern "C" fn delta_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; let out_start: size_t = *out_pos; - let ret: lzma_ret = (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -235,12 +183,12 @@ pub unsafe extern "C" fn lzma_delta_decoder_init( (*next).code = Some( delta_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -250,9 +198,9 @@ pub unsafe extern "C" fn lzma_delta_decoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_delta_props_decode( - mut options: *mut *mut ::core::ffi::c_void, + mut options: *mut *mut c_void, mut allocator: *const lzma_allocator, - mut props: *const uint8_t, + mut props: *const u8, mut props_size: size_t, ) -> lzma_ret { if props_size != 1 as size_t { @@ -266,9 +214,7 @@ pub unsafe extern "C" fn lzma_delta_props_decode( return LZMA_MEM_ERROR; } (*opt).type_0 = LZMA_DELTA_TYPE_BYTE; - (*opt).dist = (*props.offset(0 as ::core::ffi::c_int as isize) - as ::core::ffi::c_uint) - .wrapping_add(1 as ::core::ffi::c_uint) as uint32_t; - *options = opt as *mut ::core::ffi::c_void; + (*opt).dist = (*props.offset(0 as isize) as c_uint).wrapping_add(1 as c_uint) as u32; + *options = opt as *mut c_void; return LZMA_OK; } diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index 20a8c1e7..a12d5d64 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -1,23 +1,18 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_next_filter_update( next: *mut lzma_next_coder, allocator: *const lzma_allocator, reversed_filters: *const lzma_filter, ) -> lzma_ret; - fn lzma_delta_coder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; + fn lzma_delta_coder_memusage(options: *const c_void) -> u64; fn lzma_delta_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -39,7 +34,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -48,109 +42,75 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_delta_type = ::core::ffi::c_uint; pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_delta { pub type_0: lzma_delta_type, - pub dist: uint32_t, - pub reserved_int1: uint32_t, - pub reserved_int2: uint32_t, - pub reserved_int3: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub dist: u32, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -165,66 +125,56 @@ pub type lzma_filter_info = lzma_filter_info_s; pub struct lzma_delta_coder { pub next: lzma_next_coder, pub distance: size_t, - pub pos: uint8_t, - pub history: [uint8_t; 256], + pub pos: u8, + pub history: [u8; 256], } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const LZMA_DELTA_DIST_MIN: ::core::ffi::c_int = 1 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; unsafe extern "C" fn copy_and_encode( mut coder: *mut lzma_delta_coder, - mut in_0: *const uint8_t, - mut out: *mut uint8_t, + mut in_0: *const u8, + mut out: *mut u8, mut size: size_t, ) { let distance: size_t = (*coder).distance; let mut i: size_t = 0 as size_t; while i < size { - let tmp: uint8_t = (*coder) - .history[(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) - as usize]; + let tmp: u8 = (*coder).history + [(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) as usize]; let fresh2 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder) - .history[(fresh2 as ::core::ffi::c_int & 0xff as ::core::ffi::c_int) - as usize] = *in_0.offset(i as isize); - *out.offset(i as isize) = (*in_0.offset(i as isize) as ::core::ffi::c_int - - tmp as ::core::ffi::c_int) as uint8_t; + (*coder).history[(fresh2 as c_int & 0xff as c_int) as usize] = *in_0.offset(i as isize); + *out.offset(i as isize) = (*in_0.offset(i as isize) as c_int - tmp as c_int) as u8; i = i.wrapping_add(1); } } unsafe extern "C" fn encode_in_place( mut coder: *mut lzma_delta_coder, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) { let distance: size_t = (*coder).distance; let mut i: size_t = 0 as size_t; while i < size { - let tmp: uint8_t = (*coder) - .history[(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) - as usize]; + let tmp: u8 = (*coder).history + [(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) as usize]; let fresh0 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder) - .history[(fresh0 as ::core::ffi::c_int & 0xff as ::core::ffi::c_int) - as usize] = *buffer.offset(i as isize); + (*coder).history[(fresh0 as c_int & 0xff as c_int) as usize] = *buffer.offset(i as isize); let ref mut fresh1 = *buffer.offset(i as isize); - *fresh1 = (*fresh1 as ::core::ffi::c_int - tmp as ::core::ffi::c_int) as uint8_t; + *fresh1 = (*fresh1 as c_int - tmp as c_int) as u8; i = i.wrapping_add(1); } } unsafe extern "C" fn delta_encode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -234,7 +184,11 @@ unsafe extern "C" fn delta_encode( if (*coder).next.code.is_none() { let in_avail: size_t = in_size.wrapping_sub(*in_pos); let out_avail: size_t = out_size.wrapping_sub(*out_pos); - let size: size_t = if in_avail < out_avail { in_avail } else { out_avail }; + let size: size_t = if in_avail < out_avail { + in_avail + } else { + out_avail + }; if size > 0 as size_t { copy_and_encode( coder, @@ -245,22 +199,14 @@ unsafe extern "C" fn delta_encode( } *in_pos = (*in_pos).wrapping_add(size); *out_pos = (*out_pos).wrapping_add(size); - ret = (if action as ::core::ffi::c_uint - != LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint - && *in_pos == in_size - { - LZMA_STREAM_END as ::core::ffi::c_int + ret = (if action as c_uint != LZMA_RUN as c_uint && *in_pos == in_size { + LZMA_STREAM_END as c_int } else { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int }) as lzma_ret; } else { let out_start: size_t = *out_pos; - ret = (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -279,7 +225,7 @@ unsafe extern "C" fn delta_encode( return ret; } unsafe extern "C" fn delta_encoder_update( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, mut filters_null: *const lzma_filter, mut reversed_filters: *const lzma_filter, @@ -288,7 +234,7 @@ unsafe extern "C" fn delta_encoder_update( return lzma_next_filter_update( &raw mut (*coder).next, allocator, - reversed_filters.offset(1 as ::core::ffi::c_int as isize), + reversed_filters.offset(1 as isize), ); } #[no_mangle] @@ -300,12 +246,12 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( (*next).code = Some( delta_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -314,7 +260,7 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( (*next).update = Some( delta_encoder_update as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -322,7 +268,7 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -332,15 +278,13 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_delta_props_encode( - mut options: *const ::core::ffi::c_void, - mut out: *mut uint8_t, + mut options: *const c_void, + mut out: *mut u8, ) -> lzma_ret { - if lzma_delta_coder_memusage(options) == UINT64_MAX as uint64_t { + if lzma_delta_coder_memusage(options) == UINT64_MAX as u64 { return LZMA_PROG_ERROR; } let mut opt: *const lzma_options_delta = options as *const lzma_options_delta; - *out.offset(0 as ::core::ffi::c_int as isize) = (*opt) - .dist - .wrapping_sub(LZMA_DELTA_DIST_MIN as uint32_t) as uint8_t; + *out.offset(0 as isize) = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN as u32) as u8; return LZMA_OK; } diff --git a/liblzma-rs/src/lib.rs b/liblzma-rs/src/lib.rs index 4aff872f..555a5000 100644 --- a/liblzma-rs/src/lib.rs +++ b/liblzma-rs/src/lib.rs @@ -9,9 +9,11 @@ unused_parens, unused_variables, unused_imports, - clippy::all, + clippy::all )] +pub mod types; + pub mod check; pub mod common; pub mod delta; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 40230703..83f2a8fe 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -1,14 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulong, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -16,12 +11,6 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -43,7 +32,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -52,84 +40,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -140,7 +95,7 @@ pub type lzma_code_function = Option< pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -153,7 +108,7 @@ pub type lzma_filter_info = lzma_filter_info_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_dict { - pub buf: *mut uint8_t, + pub buf: *mut u8, pub pos: size_t, pub full: size_t, pub limit: size_t, @@ -165,31 +120,25 @@ pub struct lzma_dict { #[repr(C)] pub struct lzma_lz_options { pub dict_size: size_t, - pub preset_dict: *const uint8_t, + pub preset_dict: *const u8, pub preset_dict_size: size_t, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_decoder { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub code: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_dict, - *const uint8_t, + *const u8, *mut size_t, size_t, ) -> lzma_ret, >, - pub reset: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const ::core::ffi::c_void) -> (), - >, - pub set_uncompressed: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), - >, - pub end: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), - >, + pub reset: Option ()>, + pub set_uncompressed: Option ()>, + pub end: Option ()>, } #[derive(Copy, Clone)] #[repr(C)] @@ -206,25 +155,20 @@ pub struct lzma_coder { pub struct C2RustUnnamed { pub pos: size_t, pub size: size_t, - pub buffer: [uint8_t; 4096], + pub buffer: [u8; 4096], } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const UINTPTR_MAX: ::core::ffi::c_ulong = 18446744073709551615 - as ::core::ffi::c_ulong; -pub const SIZE_MAX: ::core::ffi::c_ulong = UINTPTR_MAX; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_BUFFER_SIZE: ::core::ffi::c_int = 4096 as ::core::ffi::c_int; -pub const LZ_DICT_EXTRA: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZ_DICT_REPEAT_MAX: ::core::ffi::c_int = 288 as ::core::ffi::c_int; -pub const LZ_DICT_INIT_POS: ::core::ffi::c_int = 2 as ::core::ffi::c_int - * LZ_DICT_REPEAT_MAX; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; +pub const SIZE_MAX: c_ulong = UINTPTR_MAX; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_BUFFER_SIZE: c_int = 4096 as c_int; +pub const LZ_DICT_EXTRA: c_int = 0 as c_int; +pub const LZ_DICT_REPEAT_MAX: c_int = 288 as c_int; +pub const LZ_DICT_INIT_POS: c_int = 2 as c_int * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { coder: NULL, code: None, @@ -235,17 +179,19 @@ pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { unsafe extern "C" fn lz_decoder_reset(mut coder: *mut lzma_coder) { (*coder).dict.pos = LZ_DICT_INIT_POS as size_t; (*coder).dict.full = 0 as size_t; - *(*coder).dict.buf.offset((LZ_DICT_INIT_POS - 1 as ::core::ffi::c_int) as isize) = '\0' - as i32 as uint8_t; + *(*coder) + .dict + .buf + .offset((LZ_DICT_INIT_POS - 1 as c_int) as isize) = '\0' as i32 as u8; (*coder).dict.has_wrapped = false_0 != 0; (*coder).dict.need_reset = false_0 != 0; } unsafe extern "C" fn decode_buffer( mut coder: *mut lzma_coder, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { @@ -254,69 +200,60 @@ unsafe extern "C" fn decode_buffer( (*coder).dict.pos = LZ_DICT_REPEAT_MAX as size_t; (*coder).dict.has_wrapped = true_0 != 0; memcpy( - (*coder).dict.buf as *mut ::core::ffi::c_void, + (*coder).dict.buf as *mut c_void, (*coder) .dict .buf .offset((*coder).dict.size as isize) - .offset(-(LZ_DICT_REPEAT_MAX as isize)) - as *const ::core::ffi::c_void, + .offset(-(LZ_DICT_REPEAT_MAX as isize)) as *const c_void, LZ_DICT_REPEAT_MAX as size_t, ); } let dict_start: size_t = (*coder).dict.pos; - (*coder).dict.limit = (*coder) - .dict - .pos - .wrapping_add( - (if out_size.wrapping_sub(*out_pos) - < (*coder).dict.size.wrapping_sub((*coder).dict.pos) - { - out_size.wrapping_sub(*out_pos) - } else { - (*coder).dict.size.wrapping_sub((*coder).dict.pos) - }), - ); - let ret: lzma_ret = (*coder) - .lz - .code - .expect( - "non-null function pointer", - )((*coder).lz.coder, &raw mut (*coder).dict, in_0, in_pos, in_size) - as lzma_ret; + (*coder).dict.limit = (*coder).dict.pos.wrapping_add( + (if out_size.wrapping_sub(*out_pos) < (*coder).dict.size.wrapping_sub((*coder).dict.pos) + { + out_size.wrapping_sub(*out_pos) + } else { + (*coder).dict.size.wrapping_sub((*coder).dict.pos) + }), + ); + let ret: lzma_ret = (*coder).lz.code.expect("non-null function pointer")( + (*coder).lz.coder, + &raw mut (*coder).dict, + in_0, + in_pos, + in_size, + ) as lzma_ret; let copy_size: size_t = (*coder).dict.pos.wrapping_sub(dict_start); if copy_size > 0 as size_t { memcpy( - out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, - (*coder).dict.buf.offset(dict_start as isize) - as *const ::core::ffi::c_void, + out.offset(*out_pos as isize) as *mut c_void, + (*coder).dict.buf.offset(dict_start as isize) as *const c_void, copy_size, ); } *out_pos = (*out_pos).wrapping_add(copy_size); if (*coder).dict.need_reset { lz_decoder_reset(coder); - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - || *out_pos == out_size - { + if ret as c_uint != LZMA_OK as c_uint || *out_pos == out_size { return ret; } - } else if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - || *out_pos == out_size || (*coder).dict.pos < (*coder).dict.size + } else if ret as c_uint != LZMA_OK as c_uint + || *out_pos == out_size + || (*coder).dict.pos < (*coder).dict.size { - return ret + return ret; } - }; + } } unsafe extern "C" fn lz_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, @@ -329,31 +266,21 @@ unsafe extern "C" fn lz_decode( if !(*coder).next_finished && (*coder).temp.pos == (*coder).temp.size { (*coder).temp.pos = 0 as size_t; (*coder).temp.size = 0 as size_t; - let ret: lzma_ret = (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, in_pos, in_size, - &raw mut (*coder).temp.buffer as *mut uint8_t, + &raw mut (*coder).temp.buffer as *mut u8, &raw mut (*coder).temp.size, LZMA_BUFFER_SIZE as size_t, action, ) as lzma_ret; - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { (*coder).next_finished = true_0 != 0; - } else if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - || (*coder).temp.size == 0 as size_t - { - return ret + } else if ret as c_uint != LZMA_OK as c_uint || (*coder).temp.size == 0 as size_t { + return ret; } } if (*coder).this_finished { @@ -367,45 +294,36 @@ unsafe extern "C" fn lz_decode( } let ret_0: lzma_ret = decode_buffer( coder, - &raw mut (*coder).temp.buffer as *mut uint8_t, + &raw mut (*coder).temp.buffer as *mut u8, &raw mut (*coder).temp.pos, (*coder).temp.size, out, out_pos, out_size, ) as lzma_ret; - if ret_0 as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_0 as c_uint == LZMA_STREAM_END as c_uint { (*coder).this_finished = true_0 != 0; - } else if ret_0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { - return ret_0 - } else if (*coder).next_finished as ::core::ffi::c_int != 0 - && *out_pos < out_size - { - return LZMA_DATA_ERROR + } else if ret_0 as c_uint != LZMA_OK as c_uint { + return ret_0; + } else if (*coder).next_finished as c_int != 0 && *out_pos < out_size { + return LZMA_DATA_ERROR; } } return LZMA_OK; } unsafe extern "C" fn lz_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; lzma_next_end(&raw mut (*coder).next, allocator); - lzma_free((*coder).dict.buf as *mut ::core::ffi::c_void, allocator); + lzma_free((*coder).dict.buf as *mut c_void, allocator); if (*coder).lz.end.is_some() { - (*coder) - .lz - .end - .expect("non-null function pointer")((*coder).lz.coder, allocator); + (*coder).lz.end.expect("non-null function pointer")((*coder).lz.coder, allocator); } else { lzma_free((*coder).lz.coder, allocator); } - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_lz_decoder_init( @@ -417,7 +335,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( *mut lzma_lz_decoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, >, @@ -429,35 +347,31 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( lz_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; - (*next).end = Some( - lz_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), - ) as lzma_end_function; - (*coder).dict.buf = ::core::ptr::null_mut::(); + (*next).end = + Some(lz_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) + as lzma_end_function; + (*coder).dict.buf = ::core::ptr::null_mut::(); (*coder).dict.size = 0 as size_t; (*coder).lz = LZMA_LZ_DECODER_INIT; (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -469,22 +383,17 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( } let mut lz_options: lzma_lz_options = lzma_lz_options { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: ::core::ptr::null::(), preset_dict_size: 0, }; - let ret_: lzma_ret = lz_init - .expect( - "non-null function pointer", - )( + let ret_: lzma_ret = lz_init.expect("non-null function pointer")( &raw mut (*coder).lz, allocator, - (*filters.offset(0 as ::core::ffi::c_int as isize)).id, - (*filters.offset(0 as ::core::ffi::c_int as isize)).options, + (*filters.offset(0 as isize)).id, + (*filters.offset(0 as isize)).options, &raw mut lz_options, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } if lz_options.dict_size < 4096 as size_t { @@ -493,22 +402,19 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( if lz_options.dict_size > (SIZE_MAX as size_t) .wrapping_sub(15 as size_t) - .wrapping_sub((2 as ::core::ffi::c_int * LZ_DICT_REPEAT_MAX) as size_t) + .wrapping_sub((2 as c_int * LZ_DICT_REPEAT_MAX) as size_t) .wrapping_sub(LZ_DICT_EXTRA as size_t) { return LZMA_MEM_ERROR; } - lz_options.dict_size = lz_options.dict_size.wrapping_add(15 as size_t) - & !(15 as ::core::ffi::c_int as size_t); + lz_options.dict_size = lz_options.dict_size.wrapping_add(15 as size_t) & !(15 as size_t); let alloc_size: size_t = lz_options .dict_size - .wrapping_add((2 as ::core::ffi::c_int * LZ_DICT_REPEAT_MAX) as size_t); + .wrapping_add((2 as c_int * LZ_DICT_REPEAT_MAX) as size_t); if (*coder).dict.size != alloc_size { - lzma_free((*coder).dict.buf as *mut ::core::ffi::c_void, allocator); - (*coder).dict.buf = lzma_alloc( - alloc_size.wrapping_add(LZ_DICT_EXTRA as size_t), - allocator, - ) as *mut uint8_t; + lzma_free((*coder).dict.buf as *mut c_void, allocator); + (*coder).dict.buf = + lzma_alloc(alloc_size.wrapping_add(LZ_DICT_EXTRA as size_t), allocator) as *mut u8; if (*coder).dict.buf.is_null() { return LZMA_MEM_ERROR; } @@ -523,9 +429,8 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( }; let offset: size_t = lz_options.preset_dict_size.wrapping_sub(copy_size); memcpy( - (*coder).dict.buf.offset((*coder).dict.pos as isize) - as *mut ::core::ffi::c_void, - lz_options.preset_dict.offset(offset as isize) as *const ::core::ffi::c_void, + (*coder).dict.buf.offset((*coder).dict.pos as isize) as *mut c_void, + lz_options.preset_dict.offset(offset as isize) as *const c_void, copy_size, ); (*coder).dict.pos = (*coder).dict.pos.wrapping_add(copy_size); @@ -538,15 +443,13 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( return lzma_next_filter_init( &raw mut (*coder).next, allocator, - filters.offset(1 as ::core::ffi::c_int as isize), + filters.offset(1 as isize), ); } #[no_mangle] -pub unsafe extern "C" fn lzma_lz_decoder_memusage( - mut dictionary_size: size_t, -) -> uint64_t { - return (::core::mem::size_of::() as uint64_t) - .wrapping_add(dictionary_size as uint64_t) - .wrapping_add((2 as ::core::ffi::c_int * LZ_DICT_REPEAT_MAX) as uint64_t) - .wrapping_add(LZ_DICT_EXTRA as uint64_t); +pub unsafe extern "C" fn lzma_lz_decoder_memusage(mut dictionary_size: size_t) -> u64 { + return (::core::mem::size_of::() as u64) + .wrapping_add(dictionary_size as u64) + .wrapping_add((2 as c_int * LZ_DICT_REPEAT_MAX) as u64) + .wrapping_add(LZ_DICT_EXTRA as u64); } diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index eecbaaf7..d132be4d 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -1,28 +1,12 @@ +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn memmove( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __len: size_t, - ) -> *mut ::core::ffi::c_void; - fn memset( - __b: *mut ::core::ffi::c_void, - __c: ::core::ffi::c_int, - __len: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc_zero( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn memmove(__dst: *mut c_void, __src: *const c_void, __len: size_t) -> *mut c_void; + fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -35,32 +19,24 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; - fn lzma_mf_hc3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; - fn lzma_mf_hc3_skip(dict: *mut lzma_mf, amount: uint32_t); - fn lzma_mf_hc4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; - fn lzma_mf_hc4_skip(dict: *mut lzma_mf, amount: uint32_t); - fn lzma_mf_bt2_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; - fn lzma_mf_bt2_skip(dict: *mut lzma_mf, amount: uint32_t); - fn lzma_mf_bt3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; - fn lzma_mf_bt3_skip(dict: *mut lzma_mf, amount: uint32_t); - fn lzma_mf_bt4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> uint32_t; - fn lzma_mf_bt4_skip(dict: *mut lzma_mf, amount: uint32_t); + fn lzma_mf_hc3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; + fn lzma_mf_hc3_skip(dict: *mut lzma_mf, amount: u32); + fn lzma_mf_hc4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; + fn lzma_mf_hc4_skip(dict: *mut lzma_mf, amount: u32); + fn lzma_mf_bt2_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; + fn lzma_mf_bt2_skip(dict: *mut lzma_mf, amount: u32); + fn lzma_mf_bt3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; + fn lzma_mf_bt3_skip(dict: *mut lzma_mf, amount: u32); + fn lzma_mf_bt4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; + fn lzma_mf_bt4_skip(dict: *mut lzma_mf, amount: u32); } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -82,7 +58,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -91,90 +66,56 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; @@ -185,7 +126,7 @@ pub const LZMA_MF_HC3: lzma_match_finder = 3; pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -198,35 +139,35 @@ pub type lzma_filter_info = lzma_filter_info_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_match { - pub len: uint32_t, - pub dist: uint32_t, + pub len: u32, + pub dist: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_mf_s { - pub buffer: *mut uint8_t, - pub size: uint32_t, - pub keep_size_before: uint32_t, - pub keep_size_after: uint32_t, - pub offset: uint32_t, - pub read_pos: uint32_t, - pub read_ahead: uint32_t, - pub read_limit: uint32_t, - pub write_pos: uint32_t, - pub pending: uint32_t, - pub find: Option uint32_t>, - pub skip: Option ()>, - pub hash: *mut uint32_t, - pub son: *mut uint32_t, - pub cyclic_pos: uint32_t, - pub cyclic_size: uint32_t, - pub hash_mask: uint32_t, - pub depth: uint32_t, - pub nice_len: uint32_t, - pub match_len_max: uint32_t, + pub buffer: *mut u8, + pub size: u32, + pub keep_size_before: u32, + pub keep_size_after: u32, + pub offset: u32, + pub read_pos: u32, + pub read_ahead: u32, + pub read_limit: u32, + pub write_pos: u32, + pub pending: u32, + pub find: Option u32>, + pub skip: Option ()>, + pub hash: *mut u32, + pub son: *mut u32, + pub cyclic_pos: u32, + pub cyclic_size: u32, + pub hash_mask: u32, + pub depth: u32, + pub nice_len: u32, + pub match_len_max: u32, pub action: lzma_action, - pub hash_count: uint32_t, - pub sons_count: uint32_t, + pub hash_count: u32, + pub sons_count: u32, } pub type lzma_mf = lzma_mf_s; #[derive(Copy, Clone)] @@ -238,36 +179,20 @@ pub struct lzma_lz_options { pub match_len_max: size_t, pub nice_len: size_t, pub match_finder: lzma_match_finder, - pub depth: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, + pub depth: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_encoder { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub code: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut lzma_mf, - *mut uint8_t, - *mut size_t, - size_t, - ) -> lzma_ret, - >, - pub end: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), - >, - pub options_update: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_filter) -> lzma_ret, - >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + unsafe extern "C" fn(*mut c_void, *mut lzma_mf, *mut u8, *mut size_t, size_t) -> lzma_ret, >, + pub end: Option ()>, + pub options_update: Option lzma_ret>, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] @@ -276,32 +201,26 @@ pub struct lzma_coder { pub mf: lzma_mf, pub next: lzma_next_coder, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; #[inline] -unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> uint32_t { - return match_finder as uint32_t & 0xf as uint32_t; +unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> u32 { + return match_finder as u32 & 0xf as u32; } -pub const HASH_2_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 10 as ::core::ffi::c_int; -pub const HASH_3_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 16 as ::core::ffi::c_int; -pub const LZMA_MEMCMPLEN_EXTRA: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const HASH_2_SIZE: c_uint = (1 as c_uint) << 10 as c_int; +pub const HASH_3_SIZE: c_uint = (1 as c_uint) << 16 as c_int; +pub const LZMA_MEMCMPLEN_EXTRA: c_int = 0 as c_int; unsafe extern "C" fn move_window(mut mf: *mut lzma_mf) { - let move_offset: uint32_t = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) - & !(15 as uint32_t); + let move_offset: u32 = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) & !(15 as u32); let move_size: size_t = (*mf).write_pos.wrapping_sub(move_offset) as size_t; memmove( - (*mf).buffer as *mut ::core::ffi::c_void, - (*mf).buffer.offset(move_offset as isize) as *const ::core::ffi::c_void, + (*mf).buffer as *mut c_void, + (*mf).buffer.offset(move_offset as isize) as *const c_void, move_size, ); (*mf).offset = (*mf).offset.wrapping_add(move_offset); @@ -312,13 +231,12 @@ unsafe extern "C" fn move_window(mut mf: *mut lzma_mf) { unsafe extern "C" fn fill_window( mut coder: *mut lzma_coder, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, mut action: lzma_action, ) -> lzma_ret { - if (*coder).mf.read_pos >= (*coder).mf.size.wrapping_sub((*coder).mf.keep_size_after) - { + if (*coder).mf.read_pos >= (*coder).mf.size.wrapping_sub((*coder).mf.keep_size_after) { move_window(&raw mut (*coder).mf); } let mut write_pos: size_t = (*coder).mf.write_pos as size_t; @@ -332,21 +250,13 @@ unsafe extern "C" fn fill_window( &raw mut write_pos, (*coder).mf.size as size_t, ); - ret = (if action as ::core::ffi::c_uint - != LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint - && *in_pos == in_size - { - LZMA_STREAM_END as ::core::ffi::c_int + ret = (if action as c_uint != LZMA_RUN as c_uint && *in_pos == in_size { + LZMA_STREAM_END as c_int } else { - LZMA_OK as ::core::ffi::c_int + LZMA_OK as c_int }) as lzma_ret; } else { - ret = (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -358,15 +268,13 @@ unsafe extern "C" fn fill_window( action, ); } - (*coder).mf.write_pos = write_pos as uint32_t; + (*coder).mf.write_pos = write_pos as u32; memset( - (*coder).mf.buffer.offset(write_pos as isize) as *mut ::core::ffi::c_void, - 0 as ::core::ffi::c_int, + (*coder).mf.buffer.offset(write_pos as isize) as *mut c_void, + 0 as c_int, 0 as size_t, ); - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { ret = LZMA_OK; (*coder).mf.action = action; (*coder).mf.read_limit = (*coder).mf.write_pos; @@ -376,64 +284,44 @@ unsafe extern "C" fn fill_window( .write_pos .wrapping_sub((*coder).mf.keep_size_after); } - if (*coder).mf.pending > 0 as uint32_t - && (*coder).mf.read_pos < (*coder).mf.read_limit - { - let pending: uint32_t = (*coder).mf.pending; - (*coder).mf.pending = 0 as uint32_t; + if (*coder).mf.pending > 0 as u32 && (*coder).mf.read_pos < (*coder).mf.read_limit { + let pending: u32 = (*coder).mf.pending; + (*coder).mf.pending = 0 as u32; (*coder).mf.read_pos = (*coder).mf.read_pos.wrapping_sub(pending); - (*coder) - .mf - .skip - .expect("non-null function pointer")(&raw mut (*coder).mf, pending); + (*coder).mf.skip.expect("non-null function pointer")(&raw mut (*coder).mf, pending); } return ret; } unsafe extern "C" fn lz_encode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; - while *out_pos < out_size - && (*in_pos < in_size - || action as ::core::ffi::c_uint - != LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint) - { - if (*coder).mf.action as ::core::ffi::c_uint - == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint + while *out_pos < out_size && (*in_pos < in_size || action as c_uint != LZMA_RUN as c_uint) { + if (*coder).mf.action as c_uint == LZMA_RUN as c_uint && (*coder).mf.read_pos >= (*coder).mf.read_limit { - let ret_: lzma_ret = fill_window( - coder, - allocator, - in_0, - in_pos, - in_size, - action, - ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret_: lzma_ret = + fill_window(coder, allocator, in_0, in_pos, in_size, action) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } } - let ret: lzma_ret = (*coder) - .lz - .code - .expect( - "non-null function pointer", - )((*coder).lz.coder, &raw mut (*coder).mf, out, out_pos, out_size) - as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret: lzma_ret = (*coder).lz.code.expect("non-null function pointer")( + (*coder).lz.coder, + &raw mut (*coder).mf, + out, + out_pos, + out_size, + ) as lzma_ret; + if ret as c_uint != LZMA_OK as c_uint { (*coder).mf.action = LZMA_RUN; return ret; } @@ -447,148 +335,132 @@ unsafe extern "C" fn lz_encoder_prepare( ) -> bool { if !((*lz_options).dict_size >= LZMA_DICT_SIZE_MIN as size_t && (*lz_options).dict_size - <= ((1 as ::core::ffi::c_uint) << 30 as ::core::ffi::c_int) - .wrapping_add((1 as ::core::ffi::c_uint) << 29 as ::core::ffi::c_int) - as size_t) || (*lz_options).nice_len > (*lz_options).match_len_max + <= ((1 as c_uint) << 30 as c_int).wrapping_add((1 as c_uint) << 29 as c_int) as size_t) + || (*lz_options).nice_len > (*lz_options).match_len_max { return true_0 != 0; } (*mf).keep_size_before = (*lz_options) .before_size - .wrapping_add((*lz_options).dict_size) as uint32_t; + .wrapping_add((*lz_options).dict_size) as u32; (*mf).keep_size_after = (*lz_options) .after_size - .wrapping_add((*lz_options).match_len_max) as uint32_t; - let mut reserve: uint32_t = (*lz_options).dict_size.wrapping_div(2 as size_t) - as uint32_t; - if reserve > (1 as uint32_t) << 30 as ::core::ffi::c_int { - reserve = reserve.wrapping_div(2 as uint32_t); + .wrapping_add((*lz_options).match_len_max) as u32; + let mut reserve: u32 = (*lz_options).dict_size.wrapping_div(2 as size_t) as u32; + if reserve > (1 as u32) << 30 as c_int { + reserve = reserve.wrapping_div(2 as u32); } - reserve = (reserve as size_t) - .wrapping_add( - (*lz_options) - .before_size - .wrapping_add((*lz_options).match_len_max) - .wrapping_add((*lz_options).after_size) - .wrapping_div(2 as size_t) - .wrapping_add( - ((1 as ::core::ffi::c_uint) << 19 as ::core::ffi::c_int) as size_t, - ), - ) as uint32_t as uint32_t; - let old_size: uint32_t = (*mf).size; + reserve = (reserve as size_t).wrapping_add( + (*lz_options) + .before_size + .wrapping_add((*lz_options).match_len_max) + .wrapping_add((*lz_options).after_size) + .wrapping_div(2 as size_t) + .wrapping_add(((1 as c_uint) << 19 as c_int) as size_t), + ) as u32 as u32; + let old_size: u32 = (*mf).size; (*mf).size = (*mf) .keep_size_before .wrapping_add(reserve) .wrapping_add((*mf).keep_size_after); if !(*mf).buffer.is_null() && old_size != (*mf).size { - lzma_free((*mf).buffer as *mut ::core::ffi::c_void, allocator); - (*mf).buffer = ::core::ptr::null_mut::(); + lzma_free((*mf).buffer as *mut c_void, allocator); + (*mf).buffer = ::core::ptr::null_mut::(); } - (*mf).match_len_max = (*lz_options).match_len_max as uint32_t; - (*mf).nice_len = (*lz_options).nice_len as uint32_t; - (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1 as size_t) as uint32_t; - match (*lz_options).match_finder as ::core::ffi::c_uint { + (*mf).match_len_max = (*lz_options).match_len_max as u32; + (*mf).nice_len = (*lz_options).nice_len as u32; + (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1 as size_t) as u32; + match (*lz_options).match_finder as c_uint { 3 => { (*mf).find = Some( - lzma_mf_hc3_find - as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, - ) as Option uint32_t>; - (*mf).skip = Some( - lzma_mf_hc3_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), - ) as Option ()>; + lzma_mf_hc3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ) + as Option u32>; + (*mf).skip = Some(lzma_mf_hc3_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) + as Option ()>; } 4 => { (*mf).find = Some( - lzma_mf_hc4_find - as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, - ) as Option uint32_t>; - (*mf).skip = Some( - lzma_mf_hc4_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), - ) as Option ()>; + lzma_mf_hc4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ) + as Option u32>; + (*mf).skip = Some(lzma_mf_hc4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) + as Option ()>; } 18 => { (*mf).find = Some( - lzma_mf_bt2_find - as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, - ) as Option uint32_t>; - (*mf).skip = Some( - lzma_mf_bt2_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), - ) as Option ()>; + lzma_mf_bt2_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ) + as Option u32>; + (*mf).skip = Some(lzma_mf_bt2_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) + as Option ()>; } 19 => { (*mf).find = Some( - lzma_mf_bt3_find - as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, - ) as Option uint32_t>; - (*mf).skip = Some( - lzma_mf_bt3_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), - ) as Option ()>; + lzma_mf_bt3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ) + as Option u32>; + (*mf).skip = Some(lzma_mf_bt3_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) + as Option ()>; } 20 => { (*mf).find = Some( - lzma_mf_bt4_find - as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> uint32_t, - ) as Option uint32_t>; - (*mf).skip = Some( - lzma_mf_bt4_skip as unsafe extern "C" fn(*mut lzma_mf, uint32_t) -> (), - ) as Option ()>; + lzma_mf_bt4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ) + as Option u32>; + (*mf).skip = Some(lzma_mf_bt4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) + as Option ()>; } _ => return true_0 != 0, } - let hash_bytes: uint32_t = mf_get_hash_bytes((*lz_options).match_finder) as uint32_t; - let is_bt: bool = (*lz_options).match_finder as ::core::ffi::c_uint - & 0x10 as ::core::ffi::c_uint != 0 as ::core::ffi::c_uint; - let mut hs: uint32_t = 0; - if hash_bytes == 2 as uint32_t { - hs = 0xffff as uint32_t; + let hash_bytes: u32 = mf_get_hash_bytes((*lz_options).match_finder) as u32; + let is_bt: bool = (*lz_options).match_finder as c_uint & 0x10 as c_uint != 0 as c_uint; + let mut hs: u32 = 0; + if hash_bytes == 2 as u32 { + hs = 0xffff as u32; } else { - hs = (*lz_options).dict_size.wrapping_sub(1 as size_t) as uint32_t; - hs |= hs >> 1 as ::core::ffi::c_int; - hs |= hs >> 2 as ::core::ffi::c_int; - hs |= hs >> 4 as ::core::ffi::c_int; - hs |= hs >> 8 as ::core::ffi::c_int; - hs >>= 1 as ::core::ffi::c_int; - hs |= 0xffff as uint32_t; - if hs > (1 as uint32_t) << 24 as ::core::ffi::c_int { - if hash_bytes == 3 as uint32_t { - hs = ((1 as ::core::ffi::c_uint) << 24 as ::core::ffi::c_int) - .wrapping_sub(1 as ::core::ffi::c_uint) as uint32_t; + hs = (*lz_options).dict_size.wrapping_sub(1 as size_t) as u32; + hs |= hs >> 1 as c_int; + hs |= hs >> 2 as c_int; + hs |= hs >> 4 as c_int; + hs |= hs >> 8 as c_int; + hs >>= 1 as c_int; + hs |= 0xffff as u32; + if hs > (1 as u32) << 24 as c_int { + if hash_bytes == 3 as u32 { + hs = ((1 as c_uint) << 24 as c_int).wrapping_sub(1 as c_uint) as u32; } else { - hs >>= 1 as ::core::ffi::c_int; + hs >>= 1 as c_int; } } } (*mf).hash_mask = hs; hs = hs.wrapping_add(1); - if hash_bytes > 2 as uint32_t { - hs = (hs as ::core::ffi::c_uint).wrapping_add(HASH_2_SIZE) as uint32_t - as uint32_t; + if hash_bytes > 2 as u32 { + hs = (hs as c_uint).wrapping_add(HASH_2_SIZE) as u32 as u32; } - if hash_bytes > 3 as uint32_t { - hs = (hs as ::core::ffi::c_uint).wrapping_add(HASH_3_SIZE) as uint32_t - as uint32_t; + if hash_bytes > 3 as u32 { + hs = (hs as c_uint).wrapping_add(HASH_3_SIZE) as u32 as u32; } - let old_hash_count: uint32_t = (*mf).hash_count; - let old_sons_count: uint32_t = (*mf).sons_count; + let old_hash_count: u32 = (*mf).hash_count; + let old_sons_count: u32 = (*mf).sons_count; (*mf).hash_count = hs; (*mf).sons_count = (*mf).cyclic_size; if is_bt { - (*mf).sons_count = (*mf).sons_count.wrapping_mul(2 as uint32_t); + (*mf).sons_count = (*mf).sons_count.wrapping_mul(2 as u32); } if old_hash_count != (*mf).hash_count || old_sons_count != (*mf).sons_count { - lzma_free((*mf).hash as *mut ::core::ffi::c_void, allocator); - (*mf).hash = ::core::ptr::null_mut::(); - lzma_free((*mf).son as *mut ::core::ffi::c_void, allocator); - (*mf).son = ::core::ptr::null_mut::(); + lzma_free((*mf).hash as *mut c_void, allocator); + (*mf).hash = ::core::ptr::null_mut::(); + lzma_free((*mf).son as *mut c_void, allocator); + (*mf).son = ::core::ptr::null_mut::(); } (*mf).depth = (*lz_options).depth; - if (*mf).depth == 0 as uint32_t { + if (*mf).depth == 0 as u32 { if is_bt { - (*mf).depth = (16 as uint32_t) - .wrapping_add((*mf).nice_len.wrapping_div(2 as uint32_t)); + (*mf).depth = (16 as u32).wrapping_add((*mf).nice_len.wrapping_div(2 as u32)); } else { - (*mf).depth = (4 as uint32_t) - .wrapping_add((*mf).nice_len.wrapping_div(4 as uint32_t)); + (*mf).depth = (4 as u32).wrapping_add((*mf).nice_len.wrapping_div(4 as u32)); } } return false_0 != 0; @@ -600,65 +472,60 @@ unsafe extern "C" fn lz_encoder_init( ) -> bool { if (*mf).buffer.is_null() { (*mf).buffer = lzma_alloc( - (*mf).size.wrapping_add(LZMA_MEMCMPLEN_EXTRA as uint32_t) as size_t, + (*mf).size.wrapping_add(LZMA_MEMCMPLEN_EXTRA as u32) as size_t, allocator, - ) as *mut uint8_t; + ) as *mut u8; if (*mf).buffer.is_null() { return true_0 != 0; } memset( - (*mf).buffer.offset((*mf).size as isize) as *mut ::core::ffi::c_void, - 0 as ::core::ffi::c_int, + (*mf).buffer.offset((*mf).size as isize) as *mut c_void, + 0 as c_int, 0 as size_t, ); } (*mf).offset = (*mf).cyclic_size; - (*mf).read_pos = 0 as uint32_t; - (*mf).read_ahead = 0 as uint32_t; - (*mf).read_limit = 0 as uint32_t; - (*mf).write_pos = 0 as uint32_t; - (*mf).pending = 0 as uint32_t; + (*mf).read_pos = 0 as u32; + (*mf).read_ahead = 0 as u32; + (*mf).read_limit = 0 as u32; + (*mf).write_pos = 0 as u32; + (*mf).pending = 0 as u32; if (*mf).hash.is_null() { (*mf).hash = lzma_alloc_zero( - ((*mf).hash_count as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + ((*mf).hash_count as size_t).wrapping_mul(::core::mem::size_of::() as size_t), allocator, - ) as *mut uint32_t; + ) as *mut u32; (*mf).son = lzma_alloc( - ((*mf).sons_count as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + ((*mf).sons_count as size_t).wrapping_mul(::core::mem::size_of::() as size_t), allocator, - ) as *mut uint32_t; + ) as *mut u32; if (*mf).hash.is_null() || (*mf).son.is_null() { - lzma_free((*mf).hash as *mut ::core::ffi::c_void, allocator); - (*mf).hash = ::core::ptr::null_mut::(); - lzma_free((*mf).son as *mut ::core::ffi::c_void, allocator); - (*mf).son = ::core::ptr::null_mut::(); + lzma_free((*mf).hash as *mut c_void, allocator); + (*mf).hash = ::core::ptr::null_mut::(); + lzma_free((*mf).son as *mut c_void, allocator); + (*mf).son = ::core::ptr::null_mut::(); return true_0 != 0; } } else { memset( - (*mf).hash as *mut ::core::ffi::c_void, - 0 as ::core::ffi::c_int, - ((*mf).hash_count as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + (*mf).hash as *mut c_void, + 0 as c_int, + ((*mf).hash_count as size_t).wrapping_mul(::core::mem::size_of::() as size_t), ); } - (*mf).cyclic_pos = 0 as uint32_t; - if !(*lz_options).preset_dict.is_null() - && (*lz_options).preset_dict_size > 0 as uint32_t - { + (*mf).cyclic_pos = 0 as u32; + if !(*lz_options).preset_dict.is_null() && (*lz_options).preset_dict_size > 0 as u32 { (*mf).write_pos = if (*lz_options).preset_dict_size < (*mf).size { (*lz_options).preset_dict_size } else { (*mf).size }; memcpy( - (*mf).buffer as *mut ::core::ffi::c_void, + (*mf).buffer as *mut c_void, (*lz_options) .preset_dict .offset((*lz_options).preset_dict_size as isize) - .offset(-((*mf).write_pos as isize)) as *const ::core::ffi::c_void, + .offset(-((*mf).write_pos as isize)) as *const c_void, (*mf).write_pos as size_t, ); (*mf).action = LZMA_SYNC_FLUSH; @@ -668,11 +535,9 @@ unsafe extern "C" fn lz_encoder_init( return false_0 != 0; } #[no_mangle] -pub unsafe extern "C" fn lzma_lz_encoder_memusage( - mut lz_options: *const lzma_lz_options, -) -> uint64_t { +pub unsafe extern "C" fn lzma_lz_encoder_memusage(mut lz_options: *const lzma_lz_options) -> u64 { let mut mf: lzma_mf = lzma_mf_s { - buffer: ::core::ptr::null_mut::(), + buffer: ::core::ptr::null_mut::(), size: 0, keep_size_before: 0, keep_size_after: 0, @@ -684,8 +549,8 @@ pub unsafe extern "C" fn lzma_lz_encoder_memusage( pending: 0, find: None, skip: None, - hash: ::core::ptr::null_mut::(), - son: ::core::ptr::null_mut::(), + hash: ::core::ptr::null_mut::(), + son: ::core::ptr::null_mut::(), cyclic_pos: 0, cyclic_size: 0, hash_mask: 0, @@ -693,43 +558,40 @@ pub unsafe extern "C" fn lzma_lz_encoder_memusage( nice_len: 0, match_len_max: 0, action: LZMA_RUN, - hash_count: 0 as uint32_t, - sons_count: 0 as uint32_t, + hash_count: 0 as u32, + sons_count: 0 as u32, }; if lz_encoder_prepare( &raw mut mf, ::core::ptr::null::(), lz_options, ) { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } - return (mf.hash_count as uint64_t) - .wrapping_add(mf.sons_count as uint64_t) - .wrapping_mul(::core::mem::size_of::() as uint64_t) - .wrapping_add(mf.size as uint64_t) - .wrapping_add(::core::mem::size_of::() as uint64_t); + return (mf.hash_count as u64) + .wrapping_add(mf.sons_count as u64) + .wrapping_mul(::core::mem::size_of::() as u64) + .wrapping_add(mf.size as u64) + .wrapping_add(::core::mem::size_of::() as u64); } unsafe extern "C" fn lz_encoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; lzma_next_end(&raw mut (*coder).next, allocator); - lzma_free((*coder).mf.son as *mut ::core::ffi::c_void, allocator); - lzma_free((*coder).mf.hash as *mut ::core::ffi::c_void, allocator); - lzma_free((*coder).mf.buffer as *mut ::core::ffi::c_void, allocator); + lzma_free((*coder).mf.son as *mut c_void, allocator); + lzma_free((*coder).mf.hash as *mut c_void, allocator); + lzma_free((*coder).mf.buffer as *mut c_void, allocator); if (*coder).lz.end.is_some() { - (*coder) - .lz - .end - .expect("non-null function pointer")((*coder).lz.coder, allocator); + (*coder).lz.end.expect("non-null function pointer")((*coder).lz.coder, allocator); } else { lzma_free((*coder).lz.coder, allocator); } - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lz_encoder_update( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, mut filters_null: *const lzma_filter, mut reversed_filters: *const lzma_filter, @@ -741,32 +603,31 @@ unsafe extern "C" fn lz_encoder_update( let ret_: lzma_ret = (*coder) .lz .options_update - .expect("non-null function pointer")((*coder).lz.coder, reversed_filters) - as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + .expect("non-null function pointer")( + (*coder).lz.coder, reversed_filters + ) as lzma_ret; + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } return lzma_next_filter_update( &raw mut (*coder).next, allocator, - reversed_filters.offset(1 as ::core::ffi::c_int as isize), + reversed_filters.offset(1 as isize), ); } unsafe extern "C" fn lz_encoder_set_out_limit( - mut coder_ptr: *mut ::core::ffi::c_void, - mut uncomp_size: *mut uint64_t, - mut out_limit: uint64_t, + mut coder_ptr: *mut c_void, + mut uncomp_size: *mut u64, + mut out_limit: u64, ) -> lzma_ret { let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; if (*coder).next.code.is_none() && (*coder).lz.set_out_limit.is_some() { return (*coder) .lz .set_out_limit - .expect( - "non-null function pointer", - )((*coder).lz.coder, uncomp_size, out_limit); + .expect("non-null function pointer")( + (*coder).lz.coder, uncomp_size, out_limit + ); } return LZMA_OPTIONS_ERROR; } @@ -780,7 +641,7 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( *mut lzma_lz_encoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, >, @@ -792,32 +653,28 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( lz_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; - (*next).end = Some( - lz_encoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), - ) as lzma_end_function; + (*next).end = + Some(lz_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) + as lzma_end_function; (*next).update = Some( lz_encoder_update as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -825,7 +682,7 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -833,34 +690,24 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( >; (*next).set_out_limit = Some( lz_encoder_set_out_limit - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >; + as Option lzma_ret>; (*coder).lz.coder = NULL; (*coder).lz.code = None; (*coder).lz.end = None; (*coder).lz.options_update = None; (*coder).lz.set_out_limit = None; - (*coder).mf.buffer = ::core::ptr::null_mut::(); - (*coder).mf.size = 0 as uint32_t; - (*coder).mf.hash = ::core::ptr::null_mut::(); - (*coder).mf.son = ::core::ptr::null_mut::(); - (*coder).mf.hash_count = 0 as uint32_t; - (*coder).mf.sons_count = 0 as uint32_t; + (*coder).mf.buffer = ::core::ptr::null_mut::(); + (*coder).mf.size = 0 as u32; + (*coder).mf.hash = ::core::ptr::null_mut::(); + (*coder).mf.son = ::core::ptr::null_mut::(); + (*coder).mf.hash_count = 0 as u32; + (*coder).mf.sons_count = 0 as u32; (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -878,22 +725,17 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( nice_len: 0, match_finder: 0 as lzma_match_finder, depth: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: ::core::ptr::null::(), preset_dict_size: 0, }; - let ret_: lzma_ret = lz_init - .expect( - "non-null function pointer", - )( + let ret_: lzma_ret = lz_init.expect("non-null function pointer")( &raw mut (*coder).lz, allocator, - (*filters.offset(0 as ::core::ffi::c_int as isize)).id, - (*filters.offset(0 as ::core::ffi::c_int as isize)).options, + (*filters.offset(0 as isize)).id, + (*filters.offset(0 as isize)).options, &raw mut lz_options, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } if lz_encoder_prepare(&raw mut (*coder).mf, allocator, &raw mut lz_options) { @@ -905,12 +747,12 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( return lzma_next_filter_init( &raw mut (*coder).next, allocator, - filters.offset(1 as ::core::ffi::c_int as isize), + filters.offset(1 as isize), ); } #[no_mangle] pub unsafe extern "C" fn lzma_mf_is_supported(mut mf: lzma_match_finder) -> lzma_bool { - match mf as ::core::ffi::c_uint { + match mf as c_uint { 3 => return true_0 as lzma_bool, 4 => return true_0 as lzma_bool, 18 => return true_0 as lzma_bool, diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index df1f12bc..3372db6d 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -1,9 +1,8 @@ +use crate::types::*; +use core::ffi::{c_int, c_long, c_uint}; extern "C" { - static lzma_crc32_table: [[uint32_t; 256]; 8]; + static lzma_crc32_table: [[u32; 256]; 8]; } -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -12,69 +11,62 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_match { - pub len: uint32_t, - pub dist: uint32_t, + pub len: u32, + pub dist: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_mf_s { - pub buffer: *mut uint8_t, - pub size: uint32_t, - pub keep_size_before: uint32_t, - pub keep_size_after: uint32_t, - pub offset: uint32_t, - pub read_pos: uint32_t, - pub read_ahead: uint32_t, - pub read_limit: uint32_t, - pub write_pos: uint32_t, - pub pending: uint32_t, - pub find: Option uint32_t>, - pub skip: Option ()>, - pub hash: *mut uint32_t, - pub son: *mut uint32_t, - pub cyclic_pos: uint32_t, - pub cyclic_size: uint32_t, - pub hash_mask: uint32_t, - pub depth: uint32_t, - pub nice_len: uint32_t, - pub match_len_max: uint32_t, + pub buffer: *mut u8, + pub size: u32, + pub keep_size_before: u32, + pub keep_size_after: u32, + pub offset: u32, + pub read_pos: u32, + pub read_ahead: u32, + pub read_limit: u32, + pub write_pos: u32, + pub pending: u32, + pub find: Option u32>, + pub skip: Option ()>, + pub hash: *mut u32, + pub son: *mut u32, + pub cyclic_pos: u32, + pub cyclic_size: u32, + pub hash_mask: u32, + pub depth: u32, + pub nice_len: u32, + pub match_len_max: u32, pub action: lzma_action, - pub hash_count: uint32_t, - pub sons_count: uint32_t, + pub hash_count: u32, + pub sons_count: u32, } pub type lzma_mf = lzma_mf_s; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const uint8_t { +unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); } #[inline] -unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> uint32_t { +unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> u32 { return (*mf).write_pos.wrapping_sub((*mf).read_pos); } -pub const HASH_2_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 10 as ::core::ffi::c_int; -pub const HASH_3_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 16 as ::core::ffi::c_int; -pub const HASH_2_MASK: ::core::ffi::c_uint = HASH_2_SIZE - .wrapping_sub(1 as ::core::ffi::c_uint); -pub const HASH_3_MASK: ::core::ffi::c_uint = HASH_3_SIZE - .wrapping_sub(1 as ::core::ffi::c_uint); -pub const FIX_3_HASH_SIZE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 10 as ::core::ffi::c_int; -pub const FIX_4_HASH_SIZE: ::core::ffi::c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); +pub const HASH_2_SIZE: c_uint = (1 as c_uint) << 10 as c_int; +pub const HASH_3_SIZE: c_uint = (1 as c_uint) << 16 as c_int; +pub const HASH_2_MASK: c_uint = HASH_2_SIZE.wrapping_sub(1 as c_uint); +pub const HASH_3_MASK: c_uint = HASH_3_SIZE.wrapping_sub(1 as c_uint); +pub const FIX_3_HASH_SIZE: c_uint = (1 as c_uint) << 10 as c_int; +pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); #[inline(always)] unsafe extern "C" fn lzma_memcmplen( - mut buf1: *const uint8_t, - mut buf2: *const uint8_t, - mut len: uint32_t, - mut limit: uint32_t, -) -> uint32_t { - while len < limit - && *buf1.offset(len as isize) as ::core::ffi::c_int - == *buf2.offset(len as isize) as ::core::ffi::c_int + mut buf1: *const u8, + mut buf2: *const u8, + mut len: u32, + mut limit: u32, +) -> u32 { + while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int { len = len.wrapping_add(1); } @@ -83,27 +75,22 @@ unsafe extern "C" fn lzma_memcmplen( #[no_mangle] pub unsafe extern "C" fn lzma_mf_find( mut mf: *mut lzma_mf, - mut count_ptr: *mut uint32_t, + mut count_ptr: *mut u32, mut matches: *mut lzma_match, -) -> uint32_t { - let count: uint32_t = (*mf).find.expect("non-null function pointer")(mf, matches) - as uint32_t; - let mut len_best: uint32_t = 0 as uint32_t; - if count > 0 as uint32_t { - len_best = (*matches.offset(count.wrapping_sub(1 as uint32_t) as isize)).len; +) -> u32 { + let count: u32 = (*mf).find.expect("non-null function pointer")(mf, matches) as u32; + let mut len_best: u32 = 0 as u32; + if count > 0 as u32 { + len_best = (*matches.offset(count.wrapping_sub(1 as u32) as isize)).len; if len_best == (*mf).nice_len { - let mut limit: uint32_t = mf_avail(mf).wrapping_add(1 as uint32_t); + let mut limit: u32 = mf_avail(mf).wrapping_add(1 as u32); if limit > (*mf).match_len_max { limit = (*mf).match_len_max; } - let mut p1: *const uint8_t = mf_ptr(mf) - .offset(-(1 as ::core::ffi::c_int as isize)); - let mut p2: *const uint8_t = p1 - .offset( - -((*matches.offset(count.wrapping_sub(1 as uint32_t) as isize)).dist - as isize), - ) - .offset(-(1 as ::core::ffi::c_int as isize)); + let mut p1: *const u8 = mf_ptr(mf).offset(-(1 as isize)); + let mut p2: *const u8 = p1 + .offset(-((*matches.offset(count.wrapping_sub(1 as u32) as isize)).dist as isize)) + .offset(-(1 as isize)); len_best = lzma_memcmplen(p1, p2, len_best, limit); } } @@ -111,25 +98,24 @@ pub unsafe extern "C" fn lzma_mf_find( (*mf).read_ahead = (*mf).read_ahead.wrapping_add(1); return len_best; } -pub const EMPTY_HASH_VALUE: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const MUST_NORMALIZE_POS: ::core::ffi::c_uint = UINT32_MAX; +pub const EMPTY_HASH_VALUE: c_int = 0 as c_int; +pub const MUST_NORMALIZE_POS: c_uint = UINT32_MAX; unsafe extern "C" fn normalize(mut mf: *mut lzma_mf) { - let subvalue: uint32_t = (MUST_NORMALIZE_POS as uint32_t) - .wrapping_sub((*mf).cyclic_size); - let mut i: uint32_t = 0 as uint32_t; + let subvalue: u32 = (MUST_NORMALIZE_POS as u32).wrapping_sub((*mf).cyclic_size); + let mut i: u32 = 0 as u32; while i < (*mf).hash_count { if *(*mf).hash.offset(i as isize) <= subvalue { - *(*mf).hash.offset(i as isize) = EMPTY_HASH_VALUE as uint32_t; + *(*mf).hash.offset(i as isize) = EMPTY_HASH_VALUE as u32; } else { let ref mut fresh0 = *(*mf).hash.offset(i as isize); *fresh0 = (*fresh0).wrapping_sub(subvalue); } i = i.wrapping_add(1); } - let mut i_0: uint32_t = 0 as uint32_t; + let mut i_0: u32 = 0 as u32; while i_0 < (*mf).sons_count { if *(*mf).son.offset(i_0 as isize) <= subvalue { - *(*mf).son.offset(i_0 as isize) = EMPTY_HASH_VALUE as uint32_t; + *(*mf).son.offset(i_0 as isize) = EMPTY_HASH_VALUE as u32; } else { let ref mut fresh1 = *(*mf).son.offset(i_0 as isize); *fresh1 = (*fresh1).wrapping_sub(subvalue); @@ -141,12 +127,10 @@ unsafe extern "C" fn normalize(mut mf: *mut lzma_mf) { unsafe extern "C" fn move_pos(mut mf: *mut lzma_mf) { (*mf).cyclic_pos = (*mf).cyclic_pos.wrapping_add(1); if (*mf).cyclic_pos == (*mf).cyclic_size { - (*mf).cyclic_pos = 0 as uint32_t; + (*mf).cyclic_pos = 0 as u32; } (*mf).read_pos = (*mf).read_pos.wrapping_add(1); - if ((*mf).read_pos.wrapping_add((*mf).offset) == 4294967295 as uint32_t) - as ::core::ffi::c_int as ::core::ffi::c_long != 0 - { + if ((*mf).read_pos.wrapping_add((*mf).offset) == 4294967295 as u32) as c_int as c_long != 0 { normalize(mf); } } @@ -155,365 +139,313 @@ unsafe extern "C" fn move_pending(mut mf: *mut lzma_mf) { (*mf).pending = (*mf).pending.wrapping_add(1); } unsafe extern "C" fn hc_find_func( - len_limit: uint32_t, - pos: uint32_t, - cur: *const uint8_t, - mut cur_match: uint32_t, - mut depth: uint32_t, - son: *mut uint32_t, - cyclic_pos: uint32_t, - cyclic_size: uint32_t, + len_limit: u32, + pos: u32, + cur: *const u8, + mut cur_match: u32, + mut depth: u32, + son: *mut u32, + cyclic_pos: u32, + cyclic_size: u32, mut matches: *mut lzma_match, - mut len_best: uint32_t, + mut len_best: u32, ) -> *mut lzma_match { *son.offset(cyclic_pos as isize) = cur_match; loop { - let delta: uint32_t = pos.wrapping_sub(cur_match); + let delta: u32 = pos.wrapping_sub(cur_match); let fresh2 = depth; depth = depth.wrapping_sub(1); - if fresh2 == 0 as uint32_t || delta >= cyclic_size { + if fresh2 == 0 as u32 || delta >= cyclic_size { return matches; } - let pb: *const uint8_t = cur.offset(-(delta as isize)); - cur_match = *son - .offset( - cyclic_pos - .wrapping_sub(delta) - .wrapping_add( - (if delta > cyclic_pos { cyclic_size } else { 0 as uint32_t }), - ) as isize, - ); - if *pb.offset(len_best as isize) as ::core::ffi::c_int - == *cur.offset(len_best as isize) as ::core::ffi::c_int - && *pb.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - == *cur.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + let pb: *const u8 = cur.offset(-(delta as isize)); + cur_match = *son.offset(cyclic_pos.wrapping_sub(delta).wrapping_add( + (if delta > cyclic_pos { + cyclic_size + } else { + 0 as u32 + }), + ) as isize); + if *pb.offset(len_best as isize) as c_int == *cur.offset(len_best as isize) as c_int + && *pb.offset(0 as isize) as c_int == *cur.offset(0 as isize) as c_int { - let mut len: uint32_t = lzma_memcmplen(pb, cur, 1 as uint32_t, len_limit); + let mut len: u32 = lzma_memcmplen(pb, cur, 1 as u32, len_limit); if len_best < len { len_best = len; (*matches).len = len; - (*matches).dist = delta.wrapping_sub(1 as uint32_t); + (*matches).dist = delta.wrapping_sub(1 as u32); matches = matches.offset(1); if len == len_limit { return matches; } } } - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_mf_hc3_find( mut mf: *mut lzma_mf, mut matches: *mut lzma_match, -) -> uint32_t { - let mut len_limit: uint32_t = mf_avail(mf); +) -> u32 { + let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 3 as uint32_t - || 0 as ::core::ffi::c_int != 0 - && (*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + } else if len_limit < 3 as u32 + || 0 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint { move_pending(mf); - return 0 as uint32_t; + return 0 as u32; } - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: uint32_t = 0 as uint32_t; - let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] - ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; - let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; - let hash_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int) & (*mf).hash_mask; - let delta2: uint32_t = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); - let cur_match: uint32_t = *(*mf) + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: u32 = 0 as u32; + let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] + ^ *cur.offset(1 as isize) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_value: u32 = (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & (*mf).hash_mask; + let delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); + let cur_match: u32 = *(*mf) .hash - .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize) = pos; - let mut len_best: uint32_t = 2 as uint32_t; - if delta2 < (*mf).cyclic_size - && *cur.offset(-(delta2 as isize)) as ::core::ffi::c_int - == *cur as ::core::ffi::c_int - { - len_best = lzma_memcmplen( - cur.offset(-(delta2 as isize)), - cur, - len_best, - len_limit, - ); - (*matches.offset(0 as ::core::ffi::c_int as isize)).len = len_best; - (*matches.offset(0 as ::core::ffi::c_int as isize)).dist = delta2 - .wrapping_sub(1 as uint32_t); - matches_count = 1 as uint32_t; + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + let mut len_best: u32 = 2 as u32; + if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { + len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); + (*matches.offset(0 as isize)).len = len_best; + (*matches.offset(0 as isize)).dist = delta2.wrapping_sub(1 as u32); + matches_count = 1 as u32; if len_best == len_limit { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); - return 1 as uint32_t; + return 1 as u32; } } matches_count = hc_find_func( - len_limit, - pos, - cur, - cur_match, - (*mf).depth, - (*mf).son, - (*mf).cyclic_pos, - (*mf).cyclic_size, - matches.offset(matches_count as isize), - len_best, - ) - .offset_from(matches) as ::core::ffi::c_long as uint32_t; + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + len_best, + ) + .offset_from(matches) as c_long as u32; move_pos(mf); return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_hc3_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { +pub unsafe extern "C" fn lzma_mf_hc3_skip(mut mf: *mut lzma_mf, mut amount: u32) { loop { - if mf_avail(mf) < 3 as uint32_t { + if mf_avail(mf) < 3 as u32 { move_pending(mf); } else { - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] - ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; - let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; - let hash_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int) & (*mf).hash_mask; - let cur_match: uint32_t = *(*mf) + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] + ^ *cur.offset(1 as isize) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_value: u32 = + (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & (*mf).hash_mask; + let cur_match: u32 = *(*mf) .hash - .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset( - (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, - ) = pos; + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); } amount = amount.wrapping_sub(1); - if !(amount != 0 as uint32_t) { + if !(amount != 0 as u32) { break; } - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_mf_hc4_find( mut mf: *mut lzma_mf, mut matches: *mut lzma_match, -) -> uint32_t { - let mut len_limit: uint32_t = mf_avail(mf); +) -> u32 { + let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 4 as uint32_t - || 0 as ::core::ffi::c_int != 0 - && (*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + } else if len_limit < 4 as u32 + || 0 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint { move_pending(mf); - return 0 as uint32_t; + return 0 as u32; } - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: uint32_t = 0 as uint32_t; - let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] - ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; - let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; - let hash_3_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int) & HASH_3_MASK as uint32_t; - let hash_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int - ^ lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(3 as ::core::ffi::c_int as isize) as usize] - << 5 as ::core::ffi::c_int) & (*mf).hash_mask; - let mut delta2: uint32_t = pos - .wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); - let delta3: uint32_t = pos - .wrapping_sub( - *(*mf) - .hash - .offset( - (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize, - ), - ); - let cur_match: uint32_t = *(*mf) + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: u32 = 0 as u32; + let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] + ^ *cur.offset(1 as isize) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_3_value: u32 = + (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & HASH_3_MASK as u32; + let hash_value: u32 = (temp + ^ (*cur.offset(2 as isize) as u32) << 8 as c_int + ^ lzma_crc32_table[0 as usize][*cur.offset(3 as isize) as usize] << 5 as c_int) + & (*mf).hash_mask; + let mut delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); + let delta3: u32 = pos.wrapping_sub( + *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize), + ); + let cur_match: u32 = *(*mf) .hash - .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize) = pos; + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize) = pos; *(*mf) .hash - .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize) = pos; - let mut len_best: uint32_t = 1 as uint32_t; - if delta2 < (*mf).cyclic_size - && *cur.offset(-(delta2 as isize)) as ::core::ffi::c_int - == *cur as ::core::ffi::c_int - { - len_best = 2 as uint32_t; - (*matches.offset(0 as ::core::ffi::c_int as isize)).len = 2 as uint32_t; - (*matches.offset(0 as ::core::ffi::c_int as isize)).dist = delta2 - .wrapping_sub(1 as uint32_t); - matches_count = 1 as uint32_t; + .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + let mut len_best: u32 = 1 as u32; + if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { + len_best = 2 as u32; + (*matches.offset(0 as isize)).len = 2 as u32; + (*matches.offset(0 as isize)).dist = delta2.wrapping_sub(1 as u32); + matches_count = 1 as u32; } - if delta2 != delta3 && delta3 < (*mf).cyclic_size - && *cur.offset(-(delta3 as isize)) as ::core::ffi::c_int - == *cur as ::core::ffi::c_int + if delta2 != delta3 + && delta3 < (*mf).cyclic_size + && *cur.offset(-(delta3 as isize)) as c_int == *cur as c_int { - len_best = 3 as uint32_t; + len_best = 3 as u32; let fresh3 = matches_count; matches_count = matches_count.wrapping_add(1); - (*matches.offset(fresh3 as isize)).dist = delta3.wrapping_sub(1 as uint32_t); + (*matches.offset(fresh3 as isize)).dist = delta3.wrapping_sub(1 as u32); delta2 = delta3; } - if matches_count != 0 as uint32_t { - len_best = lzma_memcmplen( - cur.offset(-(delta2 as isize)), - cur, - len_best, - len_limit, - ); - (*matches.offset(matches_count.wrapping_sub(1 as uint32_t) as isize)).len = len_best; + if matches_count != 0 as u32 { + len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); + (*matches.offset(matches_count.wrapping_sub(1 as u32) as isize)).len = len_best; if len_best == len_limit { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); return matches_count; } } - if len_best < 3 as uint32_t { - len_best = 3 as uint32_t; + if len_best < 3 as u32 { + len_best = 3 as u32; } matches_count = hc_find_func( - len_limit, - pos, - cur, - cur_match, - (*mf).depth, - (*mf).son, - (*mf).cyclic_pos, - (*mf).cyclic_size, - matches.offset(matches_count as isize), - len_best, - ) - .offset_from(matches) as ::core::ffi::c_long as uint32_t; + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + len_best, + ) + .offset_from(matches) as c_long as u32; move_pos(mf); return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_hc4_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { +pub unsafe extern "C" fn lzma_mf_hc4_skip(mut mf: *mut lzma_mf, mut amount: u32) { loop { - if mf_avail(mf) < 4 as uint32_t { + if mf_avail(mf) < 4 as u32 { move_pending(mf); } else { - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] - ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; - let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; - let hash_3_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int) & HASH_3_MASK as uint32_t; - let hash_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int - ^ lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(3 as ::core::ffi::c_int as isize) as usize] - << 5 as ::core::ffi::c_int) & (*mf).hash_mask; - let cur_match: uint32_t = *(*mf) + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] + ^ *cur.offset(1 as isize) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_3_value: u32 = + (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & HASH_3_MASK as u32; + let hash_value: u32 = (temp + ^ (*cur.offset(2 as isize) as u32) << 8 as c_int + ^ lzma_crc32_table[0 as usize][*cur.offset(3 as isize) as usize] << 5 as c_int) + & (*mf).hash_mask; + let cur_match: u32 = *(*mf) .hash - .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset( - (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize, - ) = pos; + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize) = pos; *(*mf) .hash - .offset( - (FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, - ) = pos; + .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); } amount = amount.wrapping_sub(1); - if !(amount != 0 as uint32_t) { + if !(amount != 0 as u32) { break; } - }; + } } unsafe extern "C" fn bt_find_func( - len_limit: uint32_t, - pos: uint32_t, - cur: *const uint8_t, - mut cur_match: uint32_t, - mut depth: uint32_t, - son: *mut uint32_t, - cyclic_pos: uint32_t, - cyclic_size: uint32_t, + len_limit: u32, + pos: u32, + cur: *const u8, + mut cur_match: u32, + mut depth: u32, + son: *mut u32, + cyclic_pos: u32, + cyclic_size: u32, mut matches: *mut lzma_match, - mut len_best: uint32_t, + mut len_best: u32, ) -> *mut lzma_match { - let mut ptr0: *mut uint32_t = son - .offset((cyclic_pos << 1 as ::core::ffi::c_int) as isize) - .offset(1 as ::core::ffi::c_int as isize); - let mut ptr1: *mut uint32_t = son - .offset((cyclic_pos << 1 as ::core::ffi::c_int) as isize); - let mut len0: uint32_t = 0 as uint32_t; - let mut len1: uint32_t = 0 as uint32_t; + let mut ptr0: *mut u32 = son + .offset((cyclic_pos << 1 as c_int) as isize) + .offset(1 as isize); + let mut ptr1: *mut u32 = son.offset((cyclic_pos << 1 as c_int) as isize); + let mut len0: u32 = 0 as u32; + let mut len1: u32 = 0 as u32; loop { - let delta: uint32_t = pos.wrapping_sub(cur_match); + let delta: u32 = pos.wrapping_sub(cur_match); let fresh4 = depth; depth = depth.wrapping_sub(1); - if fresh4 == 0 as uint32_t || delta >= cyclic_size { - *ptr0 = EMPTY_HASH_VALUE as uint32_t; - *ptr1 = EMPTY_HASH_VALUE as uint32_t; + if fresh4 == 0 as u32 || delta >= cyclic_size { + *ptr0 = EMPTY_HASH_VALUE as u32; + *ptr1 = EMPTY_HASH_VALUE as u32; return matches; } - let pair: *mut uint32_t = son - .offset( - (cyclic_pos - .wrapping_sub(delta) - .wrapping_add( - (if delta > cyclic_pos { cyclic_size } else { 0 as uint32_t }), - ) << 1 as ::core::ffi::c_int) as isize, - ); - let pb: *const uint8_t = cur.offset(-(delta as isize)); - let mut len: uint32_t = if len0 < len1 { len0 } else { len1 }; - if *pb.offset(len as isize) as ::core::ffi::c_int - == *cur.offset(len as isize) as ::core::ffi::c_int - { - len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as uint32_t), len_limit); + let pair: *mut u32 = son.offset( + (cyclic_pos.wrapping_sub(delta).wrapping_add( + (if delta > cyclic_pos { + cyclic_size + } else { + 0 as u32 + }), + ) << 1 as c_int) as isize, + ); + let pb: *const u8 = cur.offset(-(delta as isize)); + let mut len: u32 = if len0 < len1 { len0 } else { len1 }; + if *pb.offset(len as isize) as c_int == *cur.offset(len as isize) as c_int { + len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as u32), len_limit); if len_best < len { len_best = len; (*matches).len = len; - (*matches).dist = delta.wrapping_sub(1 as uint32_t); + (*matches).dist = delta.wrapping_sub(1 as u32); matches = matches.offset(1); if len == len_limit { - *ptr1 = *pair.offset(0 as ::core::ffi::c_int as isize); - *ptr0 = *pair.offset(1 as ::core::ffi::c_int as isize); + *ptr1 = *pair.offset(0 as isize); + *ptr0 = *pair.offset(1 as isize); return matches; } } } - if (*pb.offset(len as isize) as ::core::ffi::c_int) - < *cur.offset(len as isize) as ::core::ffi::c_int - { + if (*pb.offset(len as isize) as c_int) < *cur.offset(len as isize) as c_int { *ptr1 = cur_match; - ptr1 = pair.offset(1 as ::core::ffi::c_int as isize); + ptr1 = pair.offset(1 as isize); cur_match = *ptr1; len1 = len; } else { @@ -522,59 +454,55 @@ unsafe extern "C" fn bt_find_func( cur_match = *ptr0; len0 = len; } - }; + } } unsafe extern "C" fn bt_skip_func( - len_limit: uint32_t, - pos: uint32_t, - cur: *const uint8_t, - mut cur_match: uint32_t, - mut depth: uint32_t, - son: *mut uint32_t, - cyclic_pos: uint32_t, - cyclic_size: uint32_t, + len_limit: u32, + pos: u32, + cur: *const u8, + mut cur_match: u32, + mut depth: u32, + son: *mut u32, + cyclic_pos: u32, + cyclic_size: u32, ) { - let mut ptr0: *mut uint32_t = son - .offset((cyclic_pos << 1 as ::core::ffi::c_int) as isize) - .offset(1 as ::core::ffi::c_int as isize); - let mut ptr1: *mut uint32_t = son - .offset((cyclic_pos << 1 as ::core::ffi::c_int) as isize); - let mut len0: uint32_t = 0 as uint32_t; - let mut len1: uint32_t = 0 as uint32_t; + let mut ptr0: *mut u32 = son + .offset((cyclic_pos << 1 as c_int) as isize) + .offset(1 as isize); + let mut ptr1: *mut u32 = son.offset((cyclic_pos << 1 as c_int) as isize); + let mut len0: u32 = 0 as u32; + let mut len1: u32 = 0 as u32; loop { - let delta: uint32_t = pos.wrapping_sub(cur_match); + let delta: u32 = pos.wrapping_sub(cur_match); let fresh5 = depth; depth = depth.wrapping_sub(1); - if fresh5 == 0 as uint32_t || delta >= cyclic_size { - *ptr0 = EMPTY_HASH_VALUE as uint32_t; - *ptr1 = EMPTY_HASH_VALUE as uint32_t; + if fresh5 == 0 as u32 || delta >= cyclic_size { + *ptr0 = EMPTY_HASH_VALUE as u32; + *ptr1 = EMPTY_HASH_VALUE as u32; return; } - let mut pair: *mut uint32_t = son - .offset( - (cyclic_pos - .wrapping_sub(delta) - .wrapping_add( - (if delta > cyclic_pos { cyclic_size } else { 0 as uint32_t }), - ) << 1 as ::core::ffi::c_int) as isize, - ); - let mut pb: *const uint8_t = cur.offset(-(delta as isize)); - let mut len: uint32_t = if len0 < len1 { len0 } else { len1 }; - if *pb.offset(len as isize) as ::core::ffi::c_int - == *cur.offset(len as isize) as ::core::ffi::c_int - { - len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as uint32_t), len_limit); + let mut pair: *mut u32 = son.offset( + (cyclic_pos.wrapping_sub(delta).wrapping_add( + (if delta > cyclic_pos { + cyclic_size + } else { + 0 as u32 + }), + ) << 1 as c_int) as isize, + ); + let mut pb: *const u8 = cur.offset(-(delta as isize)); + let mut len: u32 = if len0 < len1 { len0 } else { len1 }; + if *pb.offset(len as isize) as c_int == *cur.offset(len as isize) as c_int { + len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as u32), len_limit); if len == len_limit { - *ptr1 = *pair.offset(0 as ::core::ffi::c_int as isize); - *ptr0 = *pair.offset(1 as ::core::ffi::c_int as isize); + *ptr1 = *pair.offset(0 as isize); + *ptr0 = *pair.offset(1 as isize); return; } } - if (*pb.offset(len as isize) as ::core::ffi::c_int) - < *cur.offset(len as isize) as ::core::ffi::c_int - { + if (*pb.offset(len as isize) as c_int) < *cur.offset(len as isize) as c_int { *ptr1 = cur_match; - ptr1 = pair.offset(1 as ::core::ffi::c_int as isize); + ptr1 = pair.offset(1 as isize); cur_match = *ptr1; len1 = len; } else { @@ -583,60 +511,55 @@ unsafe extern "C" fn bt_skip_func( cur_match = *ptr0; len0 = len; } - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_mf_bt2_find( mut mf: *mut lzma_mf, mut matches: *mut lzma_match, -) -> uint32_t { - let mut len_limit: uint32_t = mf_avail(mf); +) -> u32 { + let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 2 as uint32_t - || 1 as ::core::ffi::c_int != 0 - && (*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + } else if len_limit < 2 as u32 + || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint { move_pending(mf); - return 0 as uint32_t; + return 0 as u32; } - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: uint32_t = 0 as uint32_t; - let hash_value: uint32_t = *cur.offset(0 as ::core::ffi::c_int as isize) as uint32_t - | (*cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - let cur_match: uint32_t = *(*mf).hash.offset(hash_value as isize); + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: u32 = 0 as u32; + let hash_value: u32 = + *cur.offset(0 as isize) as u32 | (*cur.offset(1 as isize) as u32) << 8 as c_int; + let cur_match: u32 = *(*mf).hash.offset(hash_value as isize); *(*mf).hash.offset(hash_value as isize) = pos; matches_count = bt_find_func( - len_limit, - pos, - cur, - cur_match, - (*mf).depth, - (*mf).son, - (*mf).cyclic_pos, - (*mf).cyclic_size, - matches.offset(matches_count as isize), - 1 as uint32_t, - ) - .offset_from(matches) as ::core::ffi::c_long as uint32_t; + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + 1 as u32, + ) + .offset_from(matches) as c_long as u32; move_pos(mf); return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { +pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: u32) { let mut current_block_8: u64; loop { - let mut len_limit: uint32_t = mf_avail(mf); + let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_8 = 11875828834189669668; - } else if len_limit < 2 as uint32_t - || 1 as ::core::ffi::c_int != 0 - && (*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + } else if len_limit < 2 as u32 + || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint { move_pending(mf); current_block_8 = 18088007599891946824; @@ -645,13 +568,11 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: uint } match current_block_8 { 11875828834189669668 => { - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let hash_value: uint32_t = *cur.offset(0 as ::core::ffi::c_int as isize) - as uint32_t - | (*cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - let cur_match: uint32_t = *(*mf).hash.offset(hash_value as isize); + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let hash_value: u32 = + *cur.offset(0 as isize) as u32 | (*cur.offset(1 as isize) as u32) << 8 as c_int; + let cur_match: u32 = *(*mf).hash.offset(hash_value as isize); *(*mf).hash.offset(hash_value as isize) = pos; bt_skip_func( len_limit, @@ -668,60 +589,46 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: uint _ => {} } amount = amount.wrapping_sub(1); - if !(amount != 0 as uint32_t) { + if !(amount != 0 as u32) { break; } - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_mf_bt3_find( mut mf: *mut lzma_mf, mut matches: *mut lzma_match, -) -> uint32_t { - let mut len_limit: uint32_t = mf_avail(mf); +) -> u32 { + let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 3 as uint32_t - || 1 as ::core::ffi::c_int != 0 - && (*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + } else if len_limit < 3 as u32 + || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint { move_pending(mf); - return 0 as uint32_t; + return 0 as u32; } - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: uint32_t = 0 as uint32_t; - let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] - ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; - let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; - let hash_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int) & (*mf).hash_mask; - let delta2: uint32_t = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); - let cur_match: uint32_t = *(*mf) + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: u32 = 0 as u32; + let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] + ^ *cur.offset(1 as isize) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_value: u32 = (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & (*mf).hash_mask; + let delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); + let cur_match: u32 = *(*mf) .hash - .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize) = pos; - let mut len_best: uint32_t = 2 as uint32_t; - if delta2 < (*mf).cyclic_size - && *cur.offset(-(delta2 as isize)) as ::core::ffi::c_int - == *cur as ::core::ffi::c_int - { - len_best = lzma_memcmplen( - cur, - cur.offset(-(delta2 as isize)), - len_best, - len_limit, - ); - (*matches.offset(0 as ::core::ffi::c_int as isize)).len = len_best; - (*matches.offset(0 as ::core::ffi::c_int as isize)).dist = delta2 - .wrapping_sub(1 as uint32_t); - matches_count = 1 as uint32_t; + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + let mut len_best: u32 = 2 as u32; + if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { + len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); + (*matches.offset(0 as isize)).len = len_best; + (*matches.offset(0 as isize)).dist = delta2.wrapping_sub(1 as u32); + matches_count = 1 as u32; if len_best == len_limit { bt_skip_func( len_limit, @@ -734,37 +641,35 @@ pub unsafe extern "C" fn lzma_mf_bt3_find( (*mf).cyclic_size, ); move_pos(mf); - return 1 as uint32_t; + return 1 as u32; } } matches_count = bt_find_func( - len_limit, - pos, - cur, - cur_match, - (*mf).depth, - (*mf).son, - (*mf).cyclic_pos, - (*mf).cyclic_size, - matches.offset(matches_count as isize), - len_best, - ) - .offset_from(matches) as ::core::ffi::c_long as uint32_t; + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + len_best, + ) + .offset_from(matches) as c_long as u32; move_pos(mf); return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { +pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: u32) { let mut current_block_9: u64; loop { - let mut len_limit: uint32_t = mf_avail(mf); + let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_9 = 11875828834189669668; - } else if len_limit < 3 as uint32_t - || 1 as ::core::ffi::c_int != 0 - && (*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + } else if len_limit < 3 as u32 + || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint { move_pending(mf); current_block_9 = 18088007599891946824; @@ -773,26 +678,20 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: uint } match current_block_9 { 11875828834189669668 => { - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] - ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; - let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; - let hash_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int) & (*mf).hash_mask; - let cur_match: uint32_t = *(*mf) + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] + ^ *cur.offset(1 as isize) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_value: u32 = + (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & (*mf).hash_mask; + let cur_match: u32 = *(*mf) .hash - .offset( - (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, - ); + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset( - (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, - ) = pos; + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; bt_skip_func( len_limit, pos, @@ -808,92 +707,73 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: uint _ => {} } amount = amount.wrapping_sub(1); - if !(amount != 0 as uint32_t) { + if !(amount != 0 as u32) { break; } - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_mf_bt4_find( mut mf: *mut lzma_mf, mut matches: *mut lzma_match, -) -> uint32_t { - let mut len_limit: uint32_t = mf_avail(mf); +) -> u32 { + let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 4 as uint32_t - || 1 as ::core::ffi::c_int != 0 - && (*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + } else if len_limit < 4 as u32 + || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint { move_pending(mf); - return 0 as uint32_t; + return 0 as u32; } - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: uint32_t = 0 as uint32_t; - let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] - ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; - let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; - let hash_3_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int) & HASH_3_MASK as uint32_t; - let hash_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int - ^ lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(3 as ::core::ffi::c_int as isize) as usize] - << 5 as ::core::ffi::c_int) & (*mf).hash_mask; - let mut delta2: uint32_t = pos - .wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); - let delta3: uint32_t = pos - .wrapping_sub( - *(*mf) - .hash - .offset( - (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize, - ), - ); - let cur_match: uint32_t = *(*mf) + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let mut matches_count: u32 = 0 as u32; + let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] + ^ *cur.offset(1 as isize) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_3_value: u32 = + (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & HASH_3_MASK as u32; + let hash_value: u32 = (temp + ^ (*cur.offset(2 as isize) as u32) << 8 as c_int + ^ lzma_crc32_table[0 as usize][*cur.offset(3 as isize) as usize] << 5 as c_int) + & (*mf).hash_mask; + let mut delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); + let delta3: u32 = pos.wrapping_sub( + *(*mf) + .hash + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize), + ); + let cur_match: u32 = *(*mf) .hash - .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize); + .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize) = pos; + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize) = pos; *(*mf) .hash - .offset((FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize) = pos; - let mut len_best: uint32_t = 1 as uint32_t; - if delta2 < (*mf).cyclic_size - && *cur.offset(-(delta2 as isize)) as ::core::ffi::c_int - == *cur as ::core::ffi::c_int - { - len_best = 2 as uint32_t; - (*matches.offset(0 as ::core::ffi::c_int as isize)).len = 2 as uint32_t; - (*matches.offset(0 as ::core::ffi::c_int as isize)).dist = delta2 - .wrapping_sub(1 as uint32_t); - matches_count = 1 as uint32_t; + .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + let mut len_best: u32 = 1 as u32; + if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { + len_best = 2 as u32; + (*matches.offset(0 as isize)).len = 2 as u32; + (*matches.offset(0 as isize)).dist = delta2.wrapping_sub(1 as u32); + matches_count = 1 as u32; } - if delta2 != delta3 && delta3 < (*mf).cyclic_size - && *cur.offset(-(delta3 as isize)) as ::core::ffi::c_int - == *cur as ::core::ffi::c_int + if delta2 != delta3 + && delta3 < (*mf).cyclic_size + && *cur.offset(-(delta3 as isize)) as c_int == *cur as c_int { - len_best = 3 as uint32_t; + len_best = 3 as u32; let fresh6 = matches_count; matches_count = matches_count.wrapping_add(1); - (*matches.offset(fresh6 as isize)).dist = delta3.wrapping_sub(1 as uint32_t); + (*matches.offset(fresh6 as isize)).dist = delta3.wrapping_sub(1 as u32); delta2 = delta3; } - if matches_count != 0 as uint32_t { - len_best = lzma_memcmplen( - cur, - cur.offset(-(delta2 as isize)), - len_best, - len_limit, - ); - (*matches.offset(matches_count.wrapping_sub(1 as uint32_t) as isize)).len = len_best; + if matches_count != 0 as u32 { + len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); + (*matches.offset(matches_count.wrapping_sub(1 as u32) as isize)).len = len_best; if len_best == len_limit { bt_skip_func( len_limit, @@ -909,37 +789,35 @@ pub unsafe extern "C" fn lzma_mf_bt4_find( return matches_count; } } - if len_best < 3 as uint32_t { - len_best = 3 as uint32_t; + if len_best < 3 as u32 { + len_best = 3 as u32; } matches_count = bt_find_func( - len_limit, - pos, - cur, - cur_match, - (*mf).depth, - (*mf).son, - (*mf).cyclic_pos, - (*mf).cyclic_size, - matches.offset(matches_count as isize), - len_best, - ) - .offset_from(matches) as ::core::ffi::c_long as uint32_t; + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + matches.offset(matches_count as isize), + len_best, + ) + .offset_from(matches) as c_long as u32; move_pos(mf); return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { +pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: u32) { let mut current_block_10: u64; loop { - let mut len_limit: uint32_t = mf_avail(mf); + let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_10 = 11875828834189669668; - } else if len_limit < 4 as uint32_t - || 1 as ::core::ffi::c_int != 0 - && (*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint + } else if len_limit < 4 as u32 + || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint { move_pending(mf); current_block_10 = 18088007599891946824; @@ -948,37 +826,27 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: uint } match current_block_10 { 11875828834189669668 => { - let mut cur: *const uint8_t = mf_ptr(mf); - let pos: uint32_t = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: uint32_t = lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(0 as ::core::ffi::c_int as isize) as usize] - ^ *cur.offset(1 as ::core::ffi::c_int as isize) as uint32_t; - let hash_2_value: uint32_t = temp & HASH_2_MASK as uint32_t; - let hash_3_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int) & HASH_3_MASK as uint32_t; - let hash_value: uint32_t = (temp - ^ (*cur.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int - ^ lzma_crc32_table[0 as ::core::ffi::c_int - as usize][*cur.offset(3 as ::core::ffi::c_int as isize) as usize] - << 5 as ::core::ffi::c_int) & (*mf).hash_mask; - let cur_match: uint32_t = *(*mf) + let mut cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] + ^ *cur.offset(1 as isize) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_3_value: u32 = + (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & HASH_3_MASK as u32; + let hash_value: u32 = (temp + ^ (*cur.offset(2 as isize) as u32) << 8 as c_int + ^ lzma_crc32_table[0 as usize][*cur.offset(3 as isize) as usize] << 5 as c_int) + & (*mf).hash_mask; + let cur_match: u32 = *(*mf) .hash - .offset( - (FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, - ); + .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset( - (FIX_3_HASH_SIZE as uint32_t).wrapping_add(hash_3_value) as isize, - ) = pos; + .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize) = pos; *(*mf) .hash - .offset( - (FIX_4_HASH_SIZE as uint32_t).wrapping_add(hash_value) as isize, - ) = pos; + .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; bt_skip_func( len_limit, pos, @@ -994,8 +862,8 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: uint _ => {} } amount = amount.wrapping_sub(1); - if !(amount != 0 as uint32_t) { + if !(amount != 0 as u32) { break; } - }; + } } diff --git a/liblzma-rs/src/lzma/fastpos_table.rs b/liblzma-rs/src/lzma/fastpos_table.rs index c09ae003..e4d2f0a9 100644 --- a/liblzma-rs/src/lzma/fastpos_table.rs +++ b/liblzma-rs/src/lzma/fastpos_table.rs @@ -1,8196 +1,346 @@ -pub type uint8_t = u8; +use crate::types::*; +use core::ffi::c_int; #[no_mangle] -pub static mut lzma_fastpos: [uint8_t; 8192] = [ - 0 as ::core::ffi::c_int as uint8_t, - 1 as ::core::ffi::c_int as uint8_t, - 2 as ::core::ffi::c_int as uint8_t, - 3 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 5 as ::core::ffi::c_int as uint8_t, - 5 as ::core::ffi::c_int as uint8_t, - 6 as ::core::ffi::c_int as uint8_t, - 6 as ::core::ffi::c_int as uint8_t, - 6 as ::core::ffi::c_int as uint8_t, - 6 as ::core::ffi::c_int as uint8_t, - 7 as ::core::ffi::c_int as uint8_t, - 7 as ::core::ffi::c_int as uint8_t, - 7 as ::core::ffi::c_int as uint8_t, - 7 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, +pub static mut lzma_fastpos: [u8; 8192] = [ + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, ]; diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index f80d22f0..71f58bdb 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -1,14 +1,13 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -21,15 +20,13 @@ extern "C" { *mut lzma_lz_decoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, >, ) -> lzma_ret; - fn lzma_lzma_decoder_memusage_nocheck( - options: *const ::core::ffi::c_void, - ) -> uint64_t; - fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: uint8_t) -> bool; + fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; + fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; fn lzma_lzma_decoder_create( lz: *mut lzma_lz_decoder, allocator: *const lzma_allocator, @@ -37,15 +34,7 @@ extern "C" { lz_options: *mut lzma_lz_options, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -67,7 +56,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -76,132 +64,97 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -215,36 +168,30 @@ pub type lzma_filter_info = lzma_filter_info_s; #[repr(C)] pub struct lzma_lz_options { pub dict_size: size_t, - pub preset_dict: *const uint8_t, + pub preset_dict: *const u8, pub preset_dict_size: size_t, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_decoder { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub code: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_dict, - *const uint8_t, + *const u8, *mut size_t, size_t, ) -> lzma_ret, >, - pub reset: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const ::core::ffi::c_void) -> (), - >, - pub set_uncompressed: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), - >, - pub end: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), - >, + pub reset: Option ()>, + pub set_uncompressed: Option ()>, + pub end: Option ()>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_dict { - pub buf: *mut uint8_t, + pub buf: *mut u8, pub pos: size_t, pub full: size_t, pub limit: size_t, @@ -264,7 +211,7 @@ pub struct lzma_lzma2_coder { pub need_dictionary_reset: bool, pub options: lzma_options_lzma, } -pub type sequence = ::core::ffi::c_uint; +pub type sequence = c_uint; pub const SEQ_COPY: sequence = 7; pub const SEQ_LZMA: sequence = 6; pub const SEQ_PROPERTIES: sequence = 5; @@ -273,16 +220,13 @@ pub const SEQ_COMPRESSED_0: sequence = 3; pub const SEQ_UNCOMPRESSED_2: sequence = 2; pub const SEQ_UNCOMPRESSED_1: sequence = 1; pub const SEQ_CONTROL: sequence = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZ_DICT_REPEAT_MAX: ::core::ffi::c_int = 288 as ::core::ffi::c_int; -pub const LZ_DICT_INIT_POS: ::core::ffi::c_int = 2 as ::core::ffi::c_int - * LZ_DICT_REPEAT_MAX; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZ_DICT_REPEAT_MAX: c_int = 288 as c_int; +pub const LZ_DICT_INIT_POS: c_int = 2 as c_int * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { coder: NULL, code: None, @@ -293,7 +237,7 @@ pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { #[inline] unsafe extern "C" fn dict_write( mut dict: *mut lzma_dict, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, mut left: *mut size_t, @@ -301,17 +245,14 @@ unsafe extern "C" fn dict_write( if in_size.wrapping_sub(*in_pos) > *left { in_size = (*in_pos).wrapping_add(*left); } - *left = (*left) - .wrapping_sub( - lzma_bufcpy( - in_0, - in_pos, - in_size, - (*dict).buf, - &raw mut (*dict).pos, - (*dict).limit, - ), - ); + *left = (*left).wrapping_sub(lzma_bufcpy( + in_0, + in_pos, + in_size, + (*dict).buf, + &raw mut (*dict).pos, + (*dict).limit, + )); if !(*dict).has_wrapped { (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); } @@ -321,55 +262,46 @@ unsafe extern "C" fn dict_reset(mut dict: *mut lzma_dict) { (*dict).need_reset = true_0 != 0; } unsafe extern "C" fn lzma2_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut dict: *mut lzma_dict, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; - while *in_pos < in_size - || (*coder).sequence as ::core::ffi::c_uint - == SEQ_LZMA as ::core::ffi::c_int as ::core::ffi::c_uint - { - match (*coder).sequence as ::core::ffi::c_uint { + while *in_pos < in_size || (*coder).sequence as c_uint == SEQ_LZMA as c_uint { + match (*coder).sequence as c_uint { 0 => { - let control: uint32_t = *in_0.offset(*in_pos as isize) as uint32_t; + let control: u32 = *in_0.offset(*in_pos as isize) as u32; *in_pos = (*in_pos).wrapping_add(1); - if control == 0 as uint32_t { + if control == 0 as u32 { return LZMA_STREAM_END; } - if control >= 0xe0 as uint32_t || control == 1 as uint32_t { + if control >= 0xe0 as u32 || control == 1 as u32 { (*coder).need_properties = true_0 != 0; (*coder).need_dictionary_reset = true_0 != 0; } else if (*coder).need_dictionary_reset { - return LZMA_DATA_ERROR + return LZMA_DATA_ERROR; } - if control >= 0x80 as uint32_t { - (*coder).uncompressed_size = ((control & 0x1f as uint32_t) - << 16 as ::core::ffi::c_int) as size_t; + if control >= 0x80 as u32 { + (*coder).uncompressed_size = ((control & 0x1f as u32) << 16 as c_int) as size_t; (*coder).sequence = SEQ_UNCOMPRESSED_1; - if control >= 0xc0 as uint32_t { + if control >= 0xc0 as u32 { (*coder).need_properties = false_0 != 0; (*coder).next_sequence = SEQ_PROPERTIES; } else if (*coder).need_properties { - return LZMA_DATA_ERROR + return LZMA_DATA_ERROR; } else { (*coder).next_sequence = SEQ_LZMA; - if control >= 0xa0 as uint32_t { - (*coder) - .lzma - .reset - .expect( - "non-null function pointer", - )( + if control >= 0xa0 as u32 { + (*coder).lzma.reset.expect("non-null function pointer")( (*coder).lzma.coder, - &raw mut (*coder).options as *const ::core::ffi::c_void, + &raw mut (*coder).options as *const c_void, ); } } } else { - if control > 2 as uint32_t { + if control > 2 as u32 { return LZMA_DATA_ERROR; } (*coder).sequence = SEQ_COMPRESSED_0; @@ -386,28 +318,20 @@ unsafe extern "C" fn lzma2_decode( *in_pos = (*in_pos).wrapping_add(1); (*coder).uncompressed_size = (*coder) .uncompressed_size - .wrapping_add( - ((*in_0.offset(fresh0 as isize) as uint32_t) - << 8 as ::core::ffi::c_int) as size_t, - ); + .wrapping_add(((*in_0.offset(fresh0 as isize) as u32) << 8 as c_int) as size_t); (*coder).sequence = SEQ_UNCOMPRESSED_2; } 2 => { let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - (*coder).uncompressed_size = (*coder) - .uncompressed_size - .wrapping_add( - (*in_0.offset(fresh1 as isize) as ::core::ffi::c_uint) - .wrapping_add(1 as ::core::ffi::c_uint) as size_t, - ); + (*coder).uncompressed_size = (*coder).uncompressed_size.wrapping_add( + (*in_0.offset(fresh1 as isize) as c_uint).wrapping_add(1 as c_uint) as size_t, + ); (*coder).sequence = SEQ_COMPRESSED_0; (*coder) .lzma .set_uncompressed - .expect( - "non-null function pointer", - )( + .expect("non-null function pointer")( (*coder).lzma.coder, (*coder).uncompressed_size as lzma_vli, false_0 != 0, @@ -416,59 +340,46 @@ unsafe extern "C" fn lzma2_decode( 3 => { let fresh2 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - (*coder).compressed_size = ((*in_0.offset(fresh2 as isize) as uint32_t) - << 8 as ::core::ffi::c_int) as size_t; + (*coder).compressed_size = + ((*in_0.offset(fresh2 as isize) as u32) << 8 as c_int) as size_t; (*coder).sequence = SEQ_COMPRESSED_1; } 4 => { let fresh3 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - (*coder).compressed_size = (*coder) - .compressed_size - .wrapping_add( - (*in_0.offset(fresh3 as isize) as ::core::ffi::c_uint) - .wrapping_add(1 as ::core::ffi::c_uint) as size_t, - ); + (*coder).compressed_size = (*coder).compressed_size.wrapping_add( + (*in_0.offset(fresh3 as isize) as c_uint).wrapping_add(1 as c_uint) as size_t, + ); (*coder).sequence = (*coder).next_sequence as sequence; } 5 => { let fresh4 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if lzma_lzma_lclppb_decode( - &raw mut (*coder).options, - *in_0.offset(fresh4 as isize), - ) { + if lzma_lzma_lclppb_decode(&raw mut (*coder).options, *in_0.offset(fresh4 as isize)) + { return LZMA_DATA_ERROR; } - (*coder) - .lzma - .reset - .expect( - "non-null function pointer", - )( + (*coder).lzma.reset.expect("non-null function pointer")( (*coder).lzma.coder, - &raw mut (*coder).options as *const ::core::ffi::c_void, + &raw mut (*coder).options as *const c_void, ); (*coder).sequence = SEQ_LZMA; } 6 => { let in_start: size_t = *in_pos; - let ret: lzma_ret = (*coder) - .lzma - .code - .expect( - "non-null function pointer", - )((*coder).lzma.coder, dict, in_0, in_pos, in_size) as lzma_ret; + let ret: lzma_ret = (*coder).lzma.code.expect("non-null function pointer")( + (*coder).lzma.coder, + dict, + in_0, + in_pos, + in_size, + ) as lzma_ret; let in_used: size_t = (*in_pos).wrapping_sub(in_start); if in_used > (*coder).compressed_size { return LZMA_DATA_ERROR; } - (*coder).compressed_size = (*coder) - .compressed_size - .wrapping_sub(in_used); - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + (*coder).compressed_size = (*coder).compressed_size.wrapping_sub(in_used); + if ret as c_uint != LZMA_STREAM_END as c_uint { return ret; } if (*coder).compressed_size != 0 as size_t { @@ -495,18 +406,18 @@ unsafe extern "C" fn lzma2_decode( return LZMA_OK; } unsafe extern "C" fn lzma2_decoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; lzma_free((*coder).lzma.coder, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma2_decoder_init( mut lz: *mut lzma_lz_decoder, mut allocator: *const lzma_allocator, mut id: lzma_vli, - mut opt: *const ::core::ffi::c_void, + mut opt: *const c_void, mut lz_options: *mut lzma_lz_options, ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; @@ -518,52 +429,38 @@ unsafe extern "C" fn lzma2_decoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*lz).coder = coder as *mut ::core::ffi::c_void; + (*lz).coder = coder as *mut c_void; (*lz).code = Some( lzma2_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_dict, - *const uint8_t, + *const u8, *mut size_t, size_t, ) -> lzma_ret, ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_dict, - *const uint8_t, + *const u8, *mut size_t, size_t, ) -> lzma_ret, >; (*lz).end = Some( - lzma2_decoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + lzma2_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), - >; + as Option ()>; (*coder).lzma = LZMA_LZ_DECODER_INIT; } let mut options: *const lzma_options_lzma = opt as *const lzma_options_lzma; (*coder).sequence = SEQ_CONTROL; (*coder).need_properties = true_0 != 0; - (*coder).need_dictionary_reset = (*options).preset_dict.is_null() - || (*options).preset_dict_size == 0 as uint32_t; - return lzma_lzma_decoder_create( - &raw mut (*coder).lzma, - allocator, - options, - lz_options, - ); + (*coder).need_dictionary_reset = + (*options).preset_dict.is_null() || (*options).preset_dict_size == 0 as u32; + return lzma_lzma_decoder_create(&raw mut (*coder).lzma, allocator, options, lz_options); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_decoder_init( @@ -581,37 +478,31 @@ pub unsafe extern "C" fn lzma_lzma2_decoder_init( *mut lzma_lz_decoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, ), ); } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma2_decoder_memusage( - mut options: *const ::core::ffi::c_void, -) -> uint64_t { - return (::core::mem::size_of::() as uint64_t) +pub unsafe extern "C" fn lzma_lzma2_decoder_memusage(mut options: *const c_void) -> u64 { + return (::core::mem::size_of::() as u64) .wrapping_add(lzma_lzma_decoder_memusage_nocheck(options)); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_props_decode( - mut options: *mut *mut ::core::ffi::c_void, + mut options: *mut *mut c_void, mut allocator: *const lzma_allocator, - mut props: *const uint8_t, + mut props: *const u8, mut props_size: size_t, ) -> lzma_ret { if props_size != 1 as size_t { return LZMA_OPTIONS_ERROR; } - if *props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - & 0xc0 as ::core::ffi::c_int != 0 - { + if *props.offset(0 as isize) as c_int & 0xc0 as c_int != 0 { return LZMA_OPTIONS_ERROR; } - if *props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - > 40 as ::core::ffi::c_int - { + if *props.offset(0 as isize) as c_int > 40 as c_int { return LZMA_OPTIONS_ERROR; } let mut opt: *mut lzma_options_lzma = lzma_alloc( @@ -621,21 +512,16 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if opt.is_null() { return LZMA_MEM_ERROR; } - if *props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - == 40 as ::core::ffi::c_int - { - (*opt).dict_size = UINT32_MAX as uint32_t; + if *props.offset(0 as isize) as c_int == 40 as c_int { + (*opt).dict_size = UINT32_MAX as u32; } else { - (*opt).dict_size = (2 as ::core::ffi::c_uint - | *props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_uint - & 1 as ::core::ffi::c_uint) as uint32_t; - (*opt).dict_size - <<= (*props.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_uint) - .wrapping_div(2 as ::core::ffi::c_uint) - .wrapping_add(11 as ::core::ffi::c_uint); + (*opt).dict_size = (2 as c_uint | *props.offset(0 as isize) as c_uint & 1 as c_uint) as u32; + (*opt).dict_size <<= (*props.offset(0 as isize) as c_uint) + .wrapping_div(2 as c_uint) + .wrapping_add(11 as c_uint); } - (*opt).preset_dict = ::core::ptr::null::(); - (*opt).preset_dict_size = 0 as uint32_t; - *options = opt as *mut ::core::ffi::c_void; + (*opt).preset_dict = ::core::ptr::null::(); + (*opt).preset_dict_size = 0 as u32; + *options = opt as *mut c_void; return LZMA_OK; } diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index e3aaf046..86f99fa5 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -1,21 +1,18 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; #[repr(C)] -pub struct lzma_lzma1_encoder_s { _opaque: [u8; 0] } +pub struct lzma_lzma1_encoder_s { + _opaque: [u8; 0], +} extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; @@ -28,18 +25,15 @@ extern "C" { *mut lzma_lz_encoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, >, ) -> lzma_ret; - fn lzma_lzma_encoder_memusage(options: *const ::core::ffi::c_void) -> uint64_t; - fn lzma_lzma_lclppb_encode( - options: *const lzma_options_lzma, - byte: *mut uint8_t, - ) -> bool; + fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64; + fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; fn lzma_lzma_encoder_create( - coder_ptr: *mut *mut ::core::ffi::c_void, + coder_ptr: *mut *mut c_void, allocator: *const lzma_allocator, id: lzma_vli, options: *const lzma_options_lzma, @@ -52,22 +46,14 @@ extern "C" { fn lzma_lzma_encode( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, - read_limit: uint32_t, + read_limit: u32, ) -> lzma_ret; - static lzma_fastpos: [uint8_t; 8192]; + static lzma_fastpos: [u8; 8192]; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -89,7 +75,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -98,132 +83,97 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -236,35 +186,35 @@ pub type lzma_filter_info = lzma_filter_info_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_match { - pub len: uint32_t, - pub dist: uint32_t, + pub len: u32, + pub dist: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_mf_s { - pub buffer: *mut uint8_t, - pub size: uint32_t, - pub keep_size_before: uint32_t, - pub keep_size_after: uint32_t, - pub offset: uint32_t, - pub read_pos: uint32_t, - pub read_ahead: uint32_t, - pub read_limit: uint32_t, - pub write_pos: uint32_t, - pub pending: uint32_t, - pub find: Option uint32_t>, - pub skip: Option ()>, - pub hash: *mut uint32_t, - pub son: *mut uint32_t, - pub cyclic_pos: uint32_t, - pub cyclic_size: uint32_t, - pub hash_mask: uint32_t, - pub depth: uint32_t, - pub nice_len: uint32_t, - pub match_len_max: uint32_t, + pub buffer: *mut u8, + pub size: u32, + pub keep_size_before: u32, + pub keep_size_after: u32, + pub offset: u32, + pub read_pos: u32, + pub read_ahead: u32, + pub read_limit: u32, + pub write_pos: u32, + pub pending: u32, + pub find: Option u32>, + pub skip: Option ()>, + pub hash: *mut u32, + pub son: *mut u32, + pub cyclic_pos: u32, + pub cyclic_size: u32, + pub hash_mask: u32, + pub depth: u32, + pub nice_len: u32, + pub match_len_max: u32, pub action: lzma_action, - pub hash_count: uint32_t, - pub sons_count: uint32_t, + pub hash_count: u32, + pub sons_count: u32, } pub type lzma_mf = lzma_mf_s; #[derive(Copy, Clone)] @@ -276,43 +226,27 @@ pub struct lzma_lz_options { pub match_len_max: size_t, pub nice_len: size_t, pub match_finder: lzma_match_finder, - pub depth: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, + pub depth: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_encoder { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub code: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut lzma_mf, - *mut uint8_t, - *mut size_t, - size_t, - ) -> lzma_ret, - >, - pub end: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), - >, - pub options_update: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_filter) -> lzma_ret, - >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + unsafe extern "C" fn(*mut c_void, *mut lzma_mf, *mut u8, *mut size_t, size_t) -> lzma_ret, >, + pub end: Option ()>, + pub options_update: Option lzma_ret>, + pub set_out_limit: Option lzma_ret>, } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma2_coder { pub sequence: C2RustUnnamed, - pub lzma: *mut ::core::ffi::c_void, + pub lzma: *mut c_void, pub opt_cur: lzma_options_lzma, pub need_properties: bool, pub need_state_reset: bool, @@ -320,34 +254,34 @@ pub struct lzma_lzma2_coder { pub uncompressed_size: size_t, pub compressed_size: size_t, pub buf_pos: size_t, - pub buf: [uint8_t; 65542], + pub buf: [u8; 65542], } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const SEQ_UNCOMPRESSED_COPY: C2RustUnnamed = 4; pub const SEQ_UNCOMPRESSED_HEADER: C2RustUnnamed = 3; pub const SEQ_LZMA_COPY: C2RustUnnamed = 2; pub const SEQ_LZMA_ENCODE: C2RustUnnamed = 1; pub const SEQ_INIT: C2RustUnnamed = 0; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_DICT_SIZE_MIN: ::core::ffi::c_uint = 4096 as ::core::ffi::c_uint; -pub const LZMA_LCLP_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_PB_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; +pub const LZMA_LCLP_MAX: c_int = 4 as c_int; +pub const LZMA_PB_MAX: c_int = 4 as c_int; #[inline] -unsafe extern "C" fn mf_unencoded(mut mf: *const lzma_mf) -> uint32_t { - return (*mf).write_pos.wrapping_sub((*mf).read_pos).wrapping_add((*mf).read_ahead); +unsafe extern "C" fn mf_unencoded(mut mf: *const lzma_mf) -> u32 { + return (*mf) + .write_pos + .wrapping_sub((*mf).read_pos) + .wrapping_add((*mf).read_ahead); } #[inline] unsafe extern "C" fn mf_read( mut mf: *mut lzma_mf, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut left: *mut size_t, @@ -355,103 +289,80 @@ unsafe extern "C" fn mf_read( let out_avail: size_t = out_size.wrapping_sub(*out_pos); let copy_size: size_t = if out_avail < *left { out_avail } else { *left }; memcpy( - out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, - (*mf).buffer.offset((*mf).read_pos as isize).offset(-(*left as isize)) - as *const ::core::ffi::c_void, + out.offset(*out_pos as isize) as *mut c_void, + (*mf) + .buffer + .offset((*mf).read_pos as isize) + .offset(-(*left as isize)) as *const c_void, copy_size, ); *out_pos = (*out_pos).wrapping_add(copy_size); *left = (*left).wrapping_sub(copy_size); } -pub const FASTPOS_BITS: ::core::ffi::c_int = 13 as ::core::ffi::c_int; +pub const FASTPOS_BITS: c_int = 13 as c_int; #[inline] -unsafe extern "C" fn get_dist_slot(mut dist: uint32_t) -> uint32_t { - if dist - < (1 as uint32_t) - << FASTPOS_BITS - + (0 as ::core::ffi::c_int - + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - { - return lzma_fastpos[dist as usize] as uint32_t; +unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { + if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { + return lzma_fastpos[dist as usize] as u32; } - if dist - < (1 as uint32_t) - << FASTPOS_BITS - + (0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - { - return (lzma_fastpos[(dist - >> 0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { + return (lzma_fastpos + [(dist >> 0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } - return (lzma_fastpos[(dist - >> 0 as ::core::ffi::c_int - + 2 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + return (lzma_fastpos[(dist >> 0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (0 as ::core::ffi::c_int - + 2 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } -pub const LZMA2_CHUNK_MAX: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 16 as ::core::ffi::c_int; -pub const LZMA2_UNCOMPRESSED_MAX: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 21 as ::core::ffi::c_int; -pub const LZMA2_HEADER_MAX: ::core::ffi::c_int = 6 as ::core::ffi::c_int; -pub const LZMA2_HEADER_UNCOMPRESSED: ::core::ffi::c_int = 3 as ::core::ffi::c_int; +pub const LZMA2_CHUNK_MAX: c_uint = (1 as c_uint) << 16 as c_int; +pub const LZMA2_UNCOMPRESSED_MAX: c_uint = (1 as c_uint) << 21 as c_int; +pub const LZMA2_HEADER_MAX: c_int = 6 as c_int; +pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3 as c_int; unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { let mut pos: size_t = 0; if (*coder).need_properties { pos = 0 as size_t; if (*coder).need_dictionary_reset { - (*coder).buf[pos as usize] = (0x80 as ::core::ffi::c_int - + ((3 as ::core::ffi::c_int) << 5 as ::core::ffi::c_int)) as uint8_t; + (*coder).buf[pos as usize] = (0x80 as c_int + ((3 as c_int) << 5 as c_int)) as u8; } else { - (*coder).buf[pos as usize] = (0x80 as ::core::ffi::c_int - + ((2 as ::core::ffi::c_int) << 5 as ::core::ffi::c_int)) as uint8_t; + (*coder).buf[pos as usize] = (0x80 as c_int + ((2 as c_int) << 5 as c_int)) as u8; } } else { pos = 1 as size_t; if (*coder).need_state_reset { - (*coder).buf[pos as usize] = (0x80 as ::core::ffi::c_int - + ((1 as ::core::ffi::c_int) << 5 as ::core::ffi::c_int)) as uint8_t; + (*coder).buf[pos as usize] = (0x80 as c_int + ((1 as c_int) << 5 as c_int)) as u8; } else { - (*coder).buf[pos as usize] = 0x80 as uint8_t; + (*coder).buf[pos as usize] = 0x80 as u8; } } (*coder).buf_pos = pos; let mut size: size_t = (*coder).uncompressed_size.wrapping_sub(1 as size_t); let fresh1 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh1 as usize] = ((*coder).buf[fresh1 as usize] as size_t) - .wrapping_add(size >> 16 as ::core::ffi::c_int) as uint8_t as uint8_t; + (*coder).buf[fresh1 as usize] = + ((*coder).buf[fresh1 as usize] as size_t).wrapping_add(size >> 16 as c_int) as u8 as u8; let fresh2 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh2 as usize] = (size >> 8 as ::core::ffi::c_int & 0xff as size_t) - as uint8_t; + (*coder).buf[fresh2 as usize] = (size >> 8 as c_int & 0xff as size_t) as u8; let fresh3 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh3 as usize] = (size & 0xff as size_t) as uint8_t; + (*coder).buf[fresh3 as usize] = (size & 0xff as size_t) as u8; size = (*coder).compressed_size.wrapping_sub(1 as size_t); let fresh4 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh4 as usize] = (size >> 8 as ::core::ffi::c_int) as uint8_t; + (*coder).buf[fresh4 as usize] = (size >> 8 as c_int) as u8; let fresh5 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh5 as usize] = (size & 0xff as size_t) as uint8_t; + (*coder).buf[fresh5 as usize] = (size & 0xff as size_t) as u8; if (*coder).need_properties { lzma_lzma_lclppb_encode( &raw mut (*coder).opt_cur, - (&raw mut (*coder).buf as *mut uint8_t).offset(pos as isize), + (&raw mut (*coder).buf as *mut u8).offset(pos as isize), ); } (*coder).need_properties = false_0 != 0; @@ -463,45 +374,39 @@ unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { } unsafe extern "C" fn lzma2_header_uncompressed(mut coder: *mut lzma_lzma2_coder) { if (*coder).need_dictionary_reset { - (*coder).buf[0 as ::core::ffi::c_int as usize] = 1 as uint8_t; + (*coder).buf[0 as usize] = 1 as u8; } else { - (*coder).buf[0 as ::core::ffi::c_int as usize] = 2 as uint8_t; + (*coder).buf[0 as usize] = 2 as u8; } (*coder).need_dictionary_reset = false_0 != 0; - (*coder).buf[1 as ::core::ffi::c_int as usize] = ((*coder) - .uncompressed_size - .wrapping_sub(1 as size_t) >> 8 as ::core::ffi::c_int) as uint8_t; - (*coder).buf[2 as ::core::ffi::c_int as usize] = ((*coder) - .uncompressed_size - .wrapping_sub(1 as size_t) & 0xff as size_t) as uint8_t; + (*coder).buf[1 as usize] = + ((*coder).uncompressed_size.wrapping_sub(1 as size_t) >> 8 as c_int) as u8; + (*coder).buf[2 as usize] = + ((*coder).uncompressed_size.wrapping_sub(1 as size_t) & 0xff as size_t) as u8; (*coder).buf_pos = 0 as size_t; } unsafe extern "C" fn lzma2_encode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut mf: *mut lzma_mf, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; while *out_pos < out_size { let mut current_block_45: u64; - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 => { - if mf_unencoded(mf) == 0 as uint32_t { - if (*mf).action as ::core::ffi::c_uint - == LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint - { + if mf_unencoded(mf) == 0 as u32 { + if (*mf).action as c_uint == LZMA_FINISH as c_uint { let fresh0 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0 as uint8_t; + *out.offset(fresh0 as isize) = 0 as u8; } - return (if (*mf).action as ::core::ffi::c_uint - == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint - { - LZMA_OK as ::core::ffi::c_int + return (if (*mf).action as c_uint == LZMA_RUN as c_uint { + LZMA_OK as c_int } else { - LZMA_STREAM_END as ::core::ffi::c_int + LZMA_STREAM_END as c_int }) as lzma_ret; } if (*coder).need_state_reset { @@ -509,9 +414,7 @@ unsafe extern "C" fn lzma2_encode( (*coder).lzma as *mut lzma_lzma1_encoder, &raw mut (*coder).opt_cur, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } } @@ -528,7 +431,7 @@ unsafe extern "C" fn lzma2_encode( } 3 => { lzma_bufcpy( - &raw mut (*coder).buf as *mut uint8_t, + &raw mut (*coder).buf as *mut u8, &raw mut (*coder).buf_pos, LZMA2_HEADER_UNCOMPRESSED as size_t, out, @@ -550,7 +453,13 @@ unsafe extern "C" fn lzma2_encode( } match current_block_45 { 10903800704467975402 => { - mf_read(mf, out, out_pos, out_size, &raw mut (*coder).uncompressed_size); + mf_read( + mf, + out, + out_pos, + out_size, + &raw mut (*coder).uncompressed_size, + ); if (*coder).uncompressed_size != 0 as size_t { return LZMA_OK; } @@ -558,11 +467,12 @@ unsafe extern "C" fn lzma2_encode( current_block_45 = 11743904203796629665; } 2979737022853876585 => { - let left: uint32_t = (LZMA2_UNCOMPRESSED_MAX as size_t) - .wrapping_sub((*coder).uncompressed_size) as uint32_t; - let mut limit: uint32_t = 0; + let left: u32 = (LZMA2_UNCOMPRESSED_MAX as size_t) + .wrapping_sub((*coder).uncompressed_size) + as u32; + let mut limit: u32 = 0; if left < (*mf).match_len_max { - limit = 0 as uint32_t; + limit = 0 as u32; } else { limit = (*mf) .read_pos @@ -570,34 +480,29 @@ unsafe extern "C" fn lzma2_encode( .wrapping_add(left) .wrapping_sub((*mf).match_len_max); } - let read_start: uint32_t = (*mf).read_pos.wrapping_sub((*mf).read_ahead); + let read_start: u32 = (*mf).read_pos.wrapping_sub((*mf).read_ahead); let ret: lzma_ret = lzma_lzma_encode( (*coder).lzma as *mut lzma_lzma1_encoder, mf, - (&raw mut (*coder).buf as *mut uint8_t) - .offset(LZMA2_HEADER_MAX as isize), + (&raw mut (*coder).buf as *mut u8).offset(LZMA2_HEADER_MAX as isize), &raw mut (*coder).compressed_size, LZMA2_CHUNK_MAX as size_t, limit, ) as lzma_ret; - (*coder).uncompressed_size = (*coder) - .uncompressed_size - .wrapping_add( - (*mf) - .read_pos - .wrapping_sub((*mf).read_ahead) - .wrapping_sub(read_start) as size_t, - ); - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + (*coder).uncompressed_size = (*coder).uncompressed_size.wrapping_add( + (*mf) + .read_pos + .wrapping_sub((*mf).read_ahead) + .wrapping_sub(read_start) as size_t, + ); + if ret as c_uint != LZMA_STREAM_END as c_uint { return LZMA_OK; } if (*coder).compressed_size >= (*coder).uncompressed_size { (*coder).uncompressed_size = (*coder) .uncompressed_size .wrapping_add((*mf).read_ahead as size_t); - (*mf).read_ahead = 0 as uint32_t; + (*mf).read_ahead = 0 as u32; lzma2_header_uncompressed(coder); (*coder).need_state_reset = true_0 != 0; (*coder).sequence = SEQ_UNCOMPRESSED_HEADER; @@ -613,7 +518,7 @@ unsafe extern "C" fn lzma2_encode( match current_block_45 { 13410404938545238636 => { lzma_bufcpy( - &raw mut (*coder).buf as *mut uint8_t, + &raw mut (*coder).buf as *mut u8, &raw mut (*coder).buf_pos, (*coder).compressed_size, out, @@ -631,32 +536,30 @@ unsafe extern "C" fn lzma2_encode( return LZMA_OK; } unsafe extern "C" fn lzma2_encoder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; lzma_free((*coder).lzma, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma2_encoder_options_update( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut filter: *const lzma_filter, ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; - if (*filter).options.is_null() - || (*coder).sequence as ::core::ffi::c_uint - != SEQ_INIT as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*filter).options.is_null() || (*coder).sequence as c_uint != SEQ_INIT as c_uint { return LZMA_PROG_ERROR; } - let mut opt: *const lzma_options_lzma = (*filter).options - as *const lzma_options_lzma; - if (*coder).opt_cur.lc != (*opt).lc || (*coder).opt_cur.lp != (*opt).lp + let mut opt: *const lzma_options_lzma = (*filter).options as *const lzma_options_lzma; + if (*coder).opt_cur.lc != (*opt).lc + || (*coder).opt_cur.lp != (*opt).lp || (*coder).opt_cur.pb != (*opt).pb { - if (*opt).lc > LZMA_LCLP_MAX as uint32_t || (*opt).lp > LZMA_LCLP_MAX as uint32_t - || (*opt).lc.wrapping_add((*opt).lp) > LZMA_LCLP_MAX as uint32_t - || (*opt).pb > LZMA_PB_MAX as uint32_t + if (*opt).lc > LZMA_LCLP_MAX as u32 + || (*opt).lp > LZMA_LCLP_MAX as u32 + || (*opt).lc.wrapping_add((*opt).lp) > LZMA_LCLP_MAX as u32 + || (*opt).pb > LZMA_PB_MAX as u32 { return LZMA_OPTIONS_ERROR; } @@ -672,7 +575,7 @@ unsafe extern "C" fn lzma2_encoder_init( mut lz: *mut lzma_lz_encoder, mut allocator: *const lzma_allocator, mut id: lzma_vli, - mut options: *const ::core::ffi::c_void, + mut options: *const c_void, mut lz_options: *mut lzma_lz_options, ) -> lzma_ret { if options.is_null() { @@ -687,60 +590,43 @@ unsafe extern "C" fn lzma2_encoder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*lz).coder = coder as *mut ::core::ffi::c_void; + (*lz).coder = coder as *mut c_void; (*lz).code = Some( lzma2_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_mf, - *mut uint8_t, + *mut u8, *mut size_t, size_t, ) -> lzma_ret, ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_mf, - *mut uint8_t, + *mut u8, *mut size_t, size_t, ) -> lzma_ret, >; (*lz).end = Some( - lzma2_encoder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + lzma2_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), - >; + as Option ()>; (*lz).options_update = Some( lzma2_encoder_options_update - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_filter, - ) -> lzma_ret, + as unsafe extern "C" fn(*mut c_void, *const lzma_filter) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_filter, - ) -> lzma_ret, - >; + as Option lzma_ret>; (*coder).lzma = NULL; } (*coder).opt_cur = *(options as *const lzma_options_lzma); (*coder).sequence = SEQ_INIT; (*coder).need_properties = true_0 != 0; (*coder).need_state_reset = false_0 != 0; - (*coder).need_dictionary_reset = (*coder).opt_cur.preset_dict.is_null() - || (*coder).opt_cur.preset_dict_size == 0 as uint32_t; + (*coder).need_dictionary_reset = + (*coder).opt_cur.preset_dict.is_null() || (*coder).opt_cur.preset_dict_size == 0 as u32; let ret_: lzma_ret = lzma_lzma_encoder_create( &raw mut (*coder).lzma, allocator, @@ -748,16 +634,16 @@ unsafe extern "C" fn lzma2_encoder_init( &raw mut (*coder).opt_cur, lz_options, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } - if (*lz_options).before_size.wrapping_add((*lz_options).dict_size) + if (*lz_options) + .before_size + .wrapping_add((*lz_options).dict_size) < LZMA2_CHUNK_MAX as size_t { - (*lz_options).before_size = (LZMA2_CHUNK_MAX as size_t) - .wrapping_sub((*lz_options).dict_size); + (*lz_options).before_size = + (LZMA2_CHUNK_MAX as size_t).wrapping_sub((*lz_options).dict_size); } return LZMA_OK; } @@ -777,70 +663,59 @@ pub unsafe extern "C" fn lzma_lzma2_encoder_init( *mut lzma_lz_encoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, ), ); } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma2_encoder_memusage( - mut options: *const ::core::ffi::c_void, -) -> uint64_t { - let lzma_mem: uint64_t = lzma_lzma_encoder_memusage(options) as uint64_t; - if lzma_mem == UINT64_MAX as uint64_t { - return UINT64_MAX as uint64_t; +pub unsafe extern "C" fn lzma_lzma2_encoder_memusage(mut options: *const c_void) -> u64 { + let lzma_mem: u64 = lzma_lzma_encoder_memusage(options) as u64; + if lzma_mem == UINT64_MAX as u64 { + return UINT64_MAX as u64; } - return (::core::mem::size_of::() as uint64_t) - .wrapping_add(lzma_mem); + return (::core::mem::size_of::() as u64).wrapping_add(lzma_mem); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_props_encode( - mut options: *const ::core::ffi::c_void, - mut out: *mut uint8_t, + mut options: *const c_void, + mut out: *mut u8, ) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; } let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; - let mut d: uint32_t = if (*opt).dict_size > 4096 as uint32_t { + let mut d: u32 = if (*opt).dict_size > 4096 as u32 { (*opt).dict_size } else { - 4096 as uint32_t + 4096 as u32 }; d = d.wrapping_sub(1); - d |= d >> 2 as ::core::ffi::c_int; - d |= d >> 3 as ::core::ffi::c_int; - d |= d >> 4 as ::core::ffi::c_int; - d |= d >> 8 as ::core::ffi::c_int; - d |= d >> 16 as ::core::ffi::c_int; - if d == UINT32_MAX as uint32_t { - *out.offset(0 as ::core::ffi::c_int as isize) = 40 as uint8_t; + d |= d >> 2 as c_int; + d |= d >> 3 as c_int; + d |= d >> 4 as c_int; + d |= d >> 8 as c_int; + d |= d >> 16 as c_int; + if d == UINT32_MAX as u32 { + *out.offset(0 as isize) = 40 as u8; } else { - *out.offset(0 as ::core::ffi::c_int as isize) = get_dist_slot( - d.wrapping_add(1 as uint32_t), - ) - .wrapping_sub(24 as uint32_t) as uint8_t; + *out.offset(0 as isize) = + get_dist_slot(d.wrapping_add(1 as u32)).wrapping_sub(24 as u32) as u8; } return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma2_block_size( - mut options: *const ::core::ffi::c_void, -) -> uint64_t { +pub unsafe extern "C" fn lzma_lzma2_block_size(mut options: *const c_void) -> u64 { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; - if !((*opt).dict_size >= LZMA_DICT_SIZE_MIN as uint32_t - && (*opt).dict_size - <= ((1 as uint32_t) << 30 as ::core::ffi::c_int) - .wrapping_add((1 as uint32_t) << 29 as ::core::ffi::c_int)) + if !((*opt).dict_size >= LZMA_DICT_SIZE_MIN as u32 + && (*opt).dict_size <= ((1 as u32) << 30 as c_int).wrapping_add((1 as u32) << 29 as c_int)) { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } - return if ((*opt).dict_size as uint64_t).wrapping_mul(3 as uint64_t) - > (1 as uint64_t) << 20 as ::core::ffi::c_int - { - ((*opt).dict_size as uint64_t).wrapping_mul(3 as uint64_t) + return if ((*opt).dict_size as u64).wrapping_mul(3 as u64) > (1 as u64) << 20 as c_int { + ((*opt).dict_size as u64).wrapping_mul(3 as u64) } else { - (1 as uint64_t) << 20 as ::core::ffi::c_int + (1 as u64) << 20 as c_int }; } diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 820f24da..71347bab 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -1,14 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_long, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_lz_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -18,23 +13,14 @@ extern "C" { *mut lzma_lz_decoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, >, ) -> lzma_ret; - fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> uint64_t; + fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -56,7 +42,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -65,132 +50,97 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -203,7 +153,7 @@ pub type lzma_filter_info = lzma_filter_info_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_dict { - pub buf: *mut uint8_t, + pub buf: *mut u8, pub pos: size_t, pub full: size_t, pub limit: size_t, @@ -215,34 +165,26 @@ pub struct lzma_dict { #[repr(C)] pub struct lzma_lz_options { pub dict_size: size_t, - pub preset_dict: *const uint8_t, + pub preset_dict: *const u8, pub preset_dict_size: size_t, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_decoder { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub code: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_dict, - *const uint8_t, + *const u8, *mut size_t, size_t, ) -> lzma_ret, >, - pub reset: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const ::core::ffi::c_void) -> (), - >, - pub set_uncompressed: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), - >, - pub end: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), - >, + pub reset: Option ()>, + pub set_uncompressed: Option ()>, + pub end: Option ()>, } -pub type probability = uint16_t; -pub type lzma_lzma_state = ::core::ffi::c_uint; pub const STATE_NONLIT_REP: lzma_lzma_state = 11; pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; @@ -272,23 +214,23 @@ pub struct lzma_lzma1_decoder { pub rep_len_decoder: lzma_length_decoder, pub rc: lzma_range_decoder, pub state: lzma_lzma_state, - pub rep0: uint32_t, - pub rep1: uint32_t, - pub rep2: uint32_t, - pub rep3: uint32_t, - pub pos_mask: uint32_t, - pub literal_context_bits: uint32_t, - pub literal_mask: uint32_t, + pub rep0: u32, + pub rep1: u32, + pub rep2: u32, + pub rep3: u32, + pub pos_mask: u32, + pub literal_context_bits: u32, + pub literal_mask: u32, pub uncompressed_size: lzma_vli, pub allow_eopm: bool, pub sequence: C2RustUnnamed, pub probs: *mut probability, - pub symbol: uint32_t, - pub limit: uint32_t, - pub offset: uint32_t, - pub len: uint32_t, + pub symbol: u32, + pub limit: u32, + pub offset: u32, + pub len: u32, } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const SEQ_COPY: C2RustUnnamed = 22; pub const SEQ_REP_LEN_BITTREE: C2RustUnnamed = 21; pub const SEQ_REP_LEN_CHOICE2: C2RustUnnamed = 20; @@ -315,9 +257,9 @@ pub const SEQ_NORMALIZE: C2RustUnnamed = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_range_decoder { - pub range: uint32_t, - pub code: uint32_t, - pub init_bytes_left: uint32_t, + pub range: u32, + pub code: u32, + pub init_bytes_left: u32, } #[derive(Copy, Clone)] #[repr(C)] @@ -328,87 +270,72 @@ pub struct lzma_length_decoder { pub mid: [[probability; 8]; 16], pub high: [probability; 256], } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { - let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; - num - |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - num - |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 16 as ::core::ffi::c_int; - num - |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) - << 24 as ::core::ffi::c_int; +unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { + let mut num: u32 = *buf.offset(0 as isize) as u32; + num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; + num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; + num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; return num; } -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 - as ::core::ffi::c_ulonglong; -pub const LZMA_LCLP_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_PB_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_LZMA1EXT_ALLOW_EOPM: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; -pub const LZ_DICT_REPEAT_MAX: ::core::ffi::c_int = 288 as ::core::ffi::c_int; -pub const LZ_DICT_INIT_POS: ::core::ffi::c_int = 2 as ::core::ffi::c_int - * LZ_DICT_REPEAT_MAX; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_LCLP_MAX: c_int = 4 as c_int; +pub const LZMA_PB_MAX: c_int = 4 as c_int; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1 as c_uint; +pub const LZ_DICT_REPEAT_MAX: c_int = 288 as c_int; +pub const LZ_DICT_INIT_POS: c_int = 2 as c_int * LZ_DICT_REPEAT_MAX; #[inline] -unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: uint32_t) -> uint8_t { - return *(*dict) - .buf - .offset( - (*dict) - .pos - .wrapping_sub(distance as size_t) - .wrapping_sub(1 as size_t) - .wrapping_add( - (if (distance as size_t) < (*dict).pos { - 0 as size_t - } else { - (*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t) - }), - ) as isize, - ); +unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { + return *(*dict).buf.offset( + (*dict) + .pos + .wrapping_sub(distance as size_t) + .wrapping_sub(1 as size_t) + .wrapping_add( + (if (distance as size_t) < (*dict).pos { + 0 as size_t + } else { + (*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t) + }), + ) as isize, + ); } #[inline] -unsafe extern "C" fn dict_get0(dict: *const lzma_dict) -> uint8_t { - return *(*dict).buf.offset((*dict).pos.wrapping_sub(1 as size_t) as isize); +unsafe extern "C" fn dict_get0(dict: *const lzma_dict) -> u8 { + return *(*dict) + .buf + .offset((*dict).pos.wrapping_sub(1 as size_t) as isize); } #[inline] -unsafe extern "C" fn dict_is_distance_valid( - dict: *const lzma_dict, - distance: size_t, -) -> bool { +unsafe extern "C" fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bool { return (*dict).full > distance; } #[inline] unsafe extern "C" fn dict_repeat( mut dict: *mut lzma_dict, - mut distance: uint32_t, - mut len: *mut uint32_t, + mut distance: u32, + mut len: *mut u32, ) -> bool { let dict_avail: size_t = (*dict).limit.wrapping_sub((*dict).pos); - let mut left: uint32_t = (if dict_avail < *len as size_t { + let mut left: u32 = (if dict_avail < *len as size_t { dict_avail } else { *len as size_t - }) as uint32_t; + }) as u32; *len = (*len).wrapping_sub(left); let mut back: size_t = (*dict) .pos .wrapping_sub(distance as size_t) .wrapping_sub(1 as size_t); if distance as size_t >= (*dict).pos { - back = back - .wrapping_add((*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t)); + back = back.wrapping_add((*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t)); } if distance < left { loop { @@ -418,14 +345,14 @@ unsafe extern "C" fn dict_repeat( (*dict).pos = (*dict).pos.wrapping_add(1); *(*dict).buf.offset(fresh1 as isize) = *(*dict).buf.offset(fresh0 as isize); left = left.wrapping_sub(1); - if !(left > 0 as uint32_t) { + if !(left > 0 as u32) { break; } } } else { memcpy( - (*dict).buf.offset((*dict).pos as isize) as *mut ::core::ffi::c_void, - (*dict).buf.offset(back as isize) as *const ::core::ffi::c_void, + (*dict).buf.offset((*dict).pos as isize) as *mut c_void, + (*dict).buf.offset(back as isize) as *const c_void, left as size_t, ); (*dict).pos = (*dict).pos.wrapping_add(left as size_t); @@ -433,10 +360,10 @@ unsafe extern "C" fn dict_repeat( if !(*dict).has_wrapped { (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); } - return *len != 0 as uint32_t; + return *len != 0 as u32; } #[inline] -unsafe extern "C" fn dict_put(mut dict: *mut lzma_dict, mut byte: uint8_t) { +unsafe extern "C" fn dict_put(mut dict: *mut lzma_dict, mut byte: u8) { let fresh2 = (*dict).pos; (*dict).pos = (*dict).pos.wrapping_add(1); *(*dict).buf.offset(fresh2 as isize) = byte; @@ -445,135 +372,117 @@ unsafe extern "C" fn dict_put(mut dict: *mut lzma_dict, mut byte: uint8_t) { } } #[inline] -unsafe extern "C" fn dict_put_safe(mut dict: *mut lzma_dict, mut byte: uint8_t) -> bool { - if ((*dict).pos == (*dict).limit) as ::core::ffi::c_int as ::core::ffi::c_long != 0 { +unsafe extern "C" fn dict_put_safe(mut dict: *mut lzma_dict, mut byte: u8) -> bool { + if ((*dict).pos == (*dict).limit) as c_long != 0 { return true_0 != 0; } dict_put(dict, byte); return false_0 != 0; } -pub const RC_SHIFT_BITS: ::core::ffi::c_int = 8 as ::core::ffi::c_int; -pub const RC_TOP_BITS: ::core::ffi::c_int = 24 as ::core::ffi::c_int; -pub const RC_TOP_VALUE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) << RC_TOP_BITS; -pub const RC_BIT_MODEL_TOTAL_BITS: ::core::ffi::c_int = 11 as ::core::ffi::c_int; -pub const RC_BIT_MODEL_TOTAL: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_BITS: ::core::ffi::c_int = 5 as ::core::ffi::c_int; +pub const RC_SHIFT_BITS: c_int = 8 as c_int; +pub const RC_TOP_BITS: c_int = 24 as c_int; +pub const RC_TOP_VALUE: c_uint = (1 as c_uint) << RC_TOP_BITS; +pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; +pub const RC_BIT_MODEL_TOTAL: c_uint = (1 as c_uint) << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_MOVE_BITS: c_int = 5 as c_int; #[inline] unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> bool { - return (*options).lc <= LZMA_LCLP_MAX as uint32_t - && (*options).lp <= LZMA_LCLP_MAX as uint32_t - && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as uint32_t - && (*options).pb <= LZMA_PB_MAX as uint32_t; + return (*options).lc <= LZMA_LCLP_MAX as u32 + && (*options).lp <= LZMA_LCLP_MAX as u32 + && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as u32 + && (*options).pb <= LZMA_PB_MAX as u32; } -pub const STATES: ::core::ffi::c_int = 12 as ::core::ffi::c_int; -pub const LIT_STATES: ::core::ffi::c_int = 7 as ::core::ffi::c_int; -pub const LITERAL_CODER_SIZE: ::core::ffi::c_uint = 0x300 as ::core::ffi::c_uint; +pub const STATES: c_int = 12 as c_int; +pub const LIT_STATES: c_int = 7 as c_int; +pub const LITERAL_CODER_SIZE: c_uint = 0x300 as c_uint; #[inline] -unsafe extern "C" fn literal_init( - mut probs: *mut probability, - mut lc: uint32_t, - mut lp: uint32_t, -) { +unsafe extern "C" fn literal_init(mut probs: *mut probability, mut lc: u32, mut lp: u32) { let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; let mut i: size_t = 0 as size_t; while i < coders { - *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; + *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; i = i.wrapping_add(1); } } -pub const MATCH_LEN_MIN: ::core::ffi::c_int = 2 as ::core::ffi::c_int; -pub const LEN_LOW_BITS: ::core::ffi::c_int = 3 as ::core::ffi::c_int; -pub const LEN_LOW_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << LEN_LOW_BITS; -pub const LEN_MID_BITS: ::core::ffi::c_int = 3 as ::core::ffi::c_int; -pub const LEN_MID_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << LEN_MID_BITS; -pub const LEN_HIGH_BITS: ::core::ffi::c_int = 8 as ::core::ffi::c_int; -pub const LEN_HIGH_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << LEN_HIGH_BITS; -pub const DIST_STATES: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const DIST_SLOT_BITS: ::core::ffi::c_int = 6 as ::core::ffi::c_int; -pub const DIST_SLOTS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) << DIST_SLOT_BITS; -pub const DIST_MODEL_START: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const DIST_MODEL_END: ::core::ffi::c_int = 14 as ::core::ffi::c_int; -pub const FULL_DISTANCES_BITS: ::core::ffi::c_int = DIST_MODEL_END - / 2 as ::core::ffi::c_int; -pub const FULL_DISTANCES: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const ALIGN_SIZE: ::core::ffi::c_int = (1 as ::core::ffi::c_int) << ALIGN_BITS; +pub const MATCH_LEN_MIN: c_int = 2 as c_int; +pub const LEN_LOW_BITS: c_int = 3 as c_int; +pub const LEN_LOW_SYMBOLS: c_int = (1 as c_int) << LEN_LOW_BITS; +pub const LEN_MID_BITS: c_int = 3 as c_int; +pub const LEN_MID_SYMBOLS: c_int = (1 as c_int) << LEN_MID_BITS; +pub const LEN_HIGH_BITS: c_int = 8 as c_int; +pub const LEN_HIGH_SYMBOLS: c_int = (1 as c_int) << LEN_HIGH_BITS; +pub const DIST_STATES: c_int = 4 as c_int; +pub const DIST_SLOT_BITS: c_int = 6 as c_int; +pub const DIST_SLOTS: c_int = (1 as c_int) << DIST_SLOT_BITS; +pub const DIST_MODEL_START: c_int = 4 as c_int; +pub const DIST_MODEL_END: c_int = 14 as c_int; +pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2 as c_int; +pub const FULL_DISTANCES: c_int = (1 as c_int) << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: c_int = 4 as c_int; +pub const ALIGN_SIZE: c_int = (1 as c_int) << ALIGN_BITS; #[inline] unsafe extern "C" fn rc_read_init( mut rc: *mut lzma_range_decoder, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, ) -> lzma_ret { - while (*rc).init_bytes_left > 0 as uint32_t { + while (*rc).init_bytes_left > 0 as u32 { if *in_pos == in_size { return LZMA_OK; } - if (*rc).init_bytes_left == 5 as uint32_t - && *in_0.offset(*in_pos as isize) as ::core::ffi::c_int - != 0 as ::core::ffi::c_int + if (*rc).init_bytes_left == 5 as u32 + && *in_0.offset(*in_pos as isize) as c_int != 0 as c_int { return LZMA_DATA_ERROR; } - (*rc).code = (*rc).code << 8 as ::core::ffi::c_int - | *in_0.offset(*in_pos as isize) as uint32_t; + (*rc).code = (*rc).code << 8 as c_int | *in_0.offset(*in_pos as isize) as u32; *in_pos = (*in_pos).wrapping_add(1); (*rc).init_bytes_left = (*rc).init_bytes_left.wrapping_sub(1); } return LZMA_STREAM_END; } unsafe extern "C" fn lzma_decode( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut dictptr: *mut lzma_dict, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, ) -> lzma_ret { let mut current_block: u64; let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; - let ret: lzma_ret = rc_read_init(&raw mut (*coder).rc, in_0, in_pos, in_size) - as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + let ret: lzma_ret = rc_read_init(&raw mut (*coder).rc, in_0, in_pos, in_size) as lzma_ret; + if ret as c_uint != LZMA_STREAM_END as c_uint { return ret; } let mut dict: lzma_dict = *dictptr; let dict_start: size_t = dict.pos; let mut rc: lzma_range_decoder = (*coder).rc; - let mut rc_in_ptr: *const uint8_t = in_0.offset(*in_pos as isize); - let mut rc_in_end: *const uint8_t = in_0.offset(in_size as isize); - let mut rc_in_fast_end: *const uint8_t = if rc_in_end.offset_from(rc_in_ptr) - as ::core::ffi::c_long <= 20 as ::core::ffi::c_long - { - rc_in_ptr - } else { - rc_in_end.offset(-(20 as ::core::ffi::c_int as isize)) - }; - let mut rc_bound: uint32_t = 0; - let mut state: uint32_t = (*coder).state as uint32_t; - let mut rep0: uint32_t = (*coder).rep0; - let mut rep1: uint32_t = (*coder).rep1; - let mut rep2: uint32_t = (*coder).rep2; - let mut rep3: uint32_t = (*coder).rep3; - let pos_mask: uint32_t = (*coder).pos_mask; + let mut rc_in_ptr: *const u8 = in_0.offset(*in_pos as isize); + let mut rc_in_end: *const u8 = in_0.offset(in_size as isize); + let mut rc_in_fast_end: *const u8 = + if rc_in_end.offset_from(rc_in_ptr) as c_long <= 20 as c_long { + rc_in_ptr + } else { + rc_in_end.offset(-(20 as isize)) + }; + let mut rc_bound: u32 = 0; + let mut state: u32 = (*coder).state as u32; + let mut rep0: u32 = (*coder).rep0; + let mut rep1: u32 = (*coder).rep1; + let mut rep2: u32 = (*coder).rep2; + let mut rep3: u32 = (*coder).rep3; + let pos_mask: u32 = (*coder).pos_mask; let mut probs: *mut probability = (*coder).probs; - let mut symbol: uint32_t = (*coder).symbol; - let mut limit: uint32_t = (*coder).limit; - let mut offset: uint32_t = (*coder).offset; - let mut len: uint32_t = (*coder).len; - let literal_mask: uint32_t = (*coder).literal_mask; - let literal_context_bits: uint32_t = (*coder).literal_context_bits; - let mut pos_state: uint32_t = (dict.pos & pos_mask as size_t) as uint32_t; + let mut symbol: u32 = (*coder).symbol; + let mut limit: u32 = (*coder).limit; + let mut offset: u32 = (*coder).offset; + let mut len: u32 = (*coder).len; + let literal_mask: u32 = (*coder).literal_mask; + let literal_context_bits: u32 = (*coder).literal_context_bits; + let mut pos_state: u32 = (dict.pos & pos_mask as size_t) as u32; let mut ret_0: lzma_ret = LZMA_OK; - let mut eopm_is_valid: bool = (*coder).uncompressed_size - == LZMA_VLI_UNKNOWN as lzma_vli; + let mut eopm_is_valid: bool = (*coder).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli; let mut might_finish_without_eopm: bool = false_0 != 0; if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli && (*coder).uncompressed_size <= dict.limit.wrapping_sub(dict.pos) as lzma_vli @@ -581,7 +490,7 @@ unsafe extern "C" fn lzma_decode( dict.limit = dict.pos.wrapping_add((*coder).uncompressed_size as size_t); might_finish_without_eopm = true_0 != 0; } - match (*coder).sequence as ::core::ffi::c_uint { + match (*coder).sequence as c_uint { 0 | 1 => { current_block = 5979571030476392895; } @@ -659,7 +568,7 @@ unsafe extern "C" fn lzma_decode( break; } 12043352250568755004 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_REP_LEN_CHOICE; current_block = 4609795085482299213; @@ -668,40 +577,37 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh142 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh142 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh142 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).rep_len_decoder.choice as uint32_t); + .wrapping_mul((*coder).rep_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice - as ::core::ffi::c_uint) - .wrapping_add( + (*coder).rep_len_decoder.choice = + ((*coder).rep_len_decoder.choice as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.choice as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub((*coder).rep_len_decoder.choice as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; probs = &raw mut *(&raw mut (*coder).rep_len_decoder.low as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; - limit = LEN_LOW_SYMBOLS as uint32_t; - len = MATCH_LEN_MIN as uint32_t; + limit = LEN_LOW_SYMBOLS as u32; + len = MATCH_LEN_MIN as u32; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice - as ::core::ffi::c_int - - ((*coder).rep_len_decoder.choice as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; + (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice as c_int + - ((*coder).rep_len_decoder.choice as c_int >> RC_MOVE_BITS)) + as probability; current_block = 6834592846991627977; continue; } current_block = 16690975975023747857; } 3996983927318648760 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_IS_REP2; current_block = 4609795085482299213; @@ -710,33 +616,30 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh141 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh141 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh141 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep2[state as usize] as uint32_t); + .wrapping_mul((*coder).is_rep2[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] - as ::core::ffi::c_uint) - .wrapping_add( + (*coder).is_rep2[state as usize] = + ((*coder).is_rep2[state as usize] as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep2[state as usize] as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub((*coder).is_rep2[state as usize] as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; - let distance_3: uint32_t = rep2; + let distance_3: u32 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance_3; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] - as ::core::ffi::c_int - - ((*coder).is_rep2[state as usize] as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - let distance_4: uint32_t = rep3; + (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] as c_int + - ((*coder).is_rep2[state as usize] as c_int >> RC_MOVE_BITS)) + as probability; + let distance_4: u32 = rep3; rep3 = rep2; rep2 = rep1; rep1 = rep0; @@ -745,7 +648,7 @@ unsafe extern "C" fn lzma_decode( current_block = 15498320742470848828; } 11808118301119257848 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_IS_REP1; current_block = 4609795085482299213; @@ -754,31 +657,28 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh140 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh140 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh140 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep1[state as usize] as uint32_t); + .wrapping_mul((*coder).is_rep1[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] - as ::core::ffi::c_uint) - .wrapping_add( + (*coder).is_rep1[state as usize] = + ((*coder).is_rep1[state as usize] as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep1[state as usize] as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub((*coder).is_rep1[state as usize] as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; - let distance_2: uint32_t = rep1; + let distance_2: u32 = rep1; rep1 = rep0; rep0 = distance_2; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] - as ::core::ffi::c_int - - ((*coder).is_rep1[state as usize] as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; + (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] as c_int + - ((*coder).is_rep1[state as usize] as c_int >> RC_MOVE_BITS)) + as probability; current_block = 3996983927318648760; continue; } @@ -794,7 +694,7 @@ unsafe extern "C" fn lzma_decode( } } 1698084742280242340 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_IS_REP0_LONG; current_block = 4609795085482299213; @@ -803,46 +703,40 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh139 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh139 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh139 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).is_rep0_long[state as usize][pos_state as usize] - as uint32_t, - ); + .wrapping_mul((*coder).is_rep0_long[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder) - .is_rep0_long[state as usize][pos_state as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( + (*coder).is_rep0_long[state as usize][pos_state as usize] = + ((*coder).is_rep0_long[state as usize][pos_state as usize] as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_rep0_long[state as usize][pos_state as usize] - as ::core::ffi::c_uint, + as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; - state = (if state < LIT_STATES as uint32_t { - STATE_LIT_SHORTREP as ::core::ffi::c_int + ) as probability as probability; + state = (if state < LIT_STATES as u32 { + STATE_LIT_SHORTREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int - }) as uint32_t; + STATE_NONLIT_REP as c_int + }) as u32; current_block = 5341942013764523046; continue; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder) - .is_rep0_long[state as usize][pos_state as usize] - as ::core::ffi::c_int - - ((*coder).is_rep0_long[state as usize][pos_state as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + (*coder).is_rep0_long[state as usize][pos_state as usize] = + ((*coder).is_rep0_long[state as usize][pos_state as usize] as c_int + - ((*coder).is_rep0_long[state as usize][pos_state as usize] as c_int + >> RC_MOVE_BITS)) as probability; } current_block = 15498320742470848828; } 4420799852307653083 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_IS_REP0; current_block = 4609795085482299213; @@ -851,36 +745,33 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh138 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh138 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh138 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep0[state as usize] as uint32_t); + .wrapping_mul((*coder).is_rep0[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] - as ::core::ffi::c_uint) - .wrapping_add( + (*coder).is_rep0[state as usize] = + ((*coder).is_rep0[state as usize] as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep0[state as usize] as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub((*coder).is_rep0[state as usize] as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; current_block = 1698084742280242340; continue; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] - as ::core::ffi::c_int - - ((*coder).is_rep0[state as usize] as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; + (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] as c_int + - ((*coder).is_rep0[state as usize] as c_int >> RC_MOVE_BITS)) + as probability; current_block = 11808118301119257848; continue; } } 3469750012682708893 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_IS_REP; current_block = 4609795085482299213; @@ -889,26 +780,24 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh123 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh123 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh123 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep[state as usize] as uint32_t); + .wrapping_mul((*coder).is_rep[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] - as ::core::ffi::c_uint) - .wrapping_add( + (*coder).is_rep[state as usize] = + ((*coder).is_rep[state as usize] as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep[state as usize] as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub((*coder).is_rep[state as usize] as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; - state = (if state < LIT_STATES as uint32_t { - STATE_LIT_MATCH as ::core::ffi::c_int + state = (if state < LIT_STATES as u32 { + STATE_LIT_MATCH as c_int } else { - STATE_NONLIT_MATCH as ::core::ffi::c_int - }) as uint32_t; + STATE_NONLIT_MATCH as c_int + }) as u32; rep3 = rep2; rep2 = rep1; rep1 = rep0; @@ -917,12 +806,11 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] - as ::core::ffi::c_int - - ((*coder).is_rep[state as usize] as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - if !(!dict_is_distance_valid(&raw mut dict, 0 as size_t) - as ::core::ffi::c_int as ::core::ffi::c_long != 0) + (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as c_int + - ((*coder).is_rep[state as usize] as c_int >> RC_MOVE_BITS)) + as probability; + if !(!dict_is_distance_valid(&raw mut dict, 0 as size_t) as c_int as c_long + != 0) { current_block = 4420799852307653083; continue; @@ -933,7 +821,7 @@ unsafe extern "C" fn lzma_decode( } } 7073645523065812117 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_EOPM; current_block = 4609795085482299213; @@ -942,19 +830,19 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh137 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh137 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh137 as u32; } } - ret_0 = (if rc.code == 0 as uint32_t { - LZMA_STREAM_END as ::core::ffi::c_int + ret_0 = (if rc.code == 0 as u32 { + LZMA_STREAM_END as c_int } else { - LZMA_DATA_ERROR as ::core::ffi::c_int + LZMA_DATA_ERROR as c_int }) as lzma_ret; current_block = 4609795085482299213; continue; } 10510472849010538284 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_ALIGN; current_block = 4609795085482299213; @@ -963,50 +851,44 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh136 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh136 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh136 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).pos_align[offset.wrapping_add(symbol) as usize] - as uint32_t, - ); + .wrapping_mul((*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[offset.wrapping_add(symbol) as usize] = ((*coder) - .pos_align[offset.wrapping_add(symbol) as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( + (*coder).pos_align[offset.wrapping_add(symbol) as usize] = + ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).pos_align[offset.wrapping_add(symbol) as usize] - as ::core::ffi::c_uint, + as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[offset.wrapping_add(symbol) as usize] = ((*coder) - .pos_align[offset.wrapping_add(symbol) as usize] - as ::core::ffi::c_int - - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + (*coder).pos_align[offset.wrapping_add(symbol) as usize] = + ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as c_int + - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as c_int + >> RC_MOVE_BITS)) as probability; symbol = symbol.wrapping_add(offset); } - offset <<= 1 as ::core::ffi::c_int; - if offset < ALIGN_SIZE as uint32_t { + offset <<= 1 as c_int; + if offset < ALIGN_SIZE as u32 { current_block = 10510472849010538284; continue; } rep0 = rep0.wrapping_add(symbol); - if rep0 == UINT32_MAX as uint32_t { + if rep0 == UINT32_MAX as u32 { current_block = 12043253436139097694; } else { current_block = 13383302701878543647; } } 15418612220330286504 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_DIRECT; current_block = 4609795085482299213; @@ -1015,29 +897,27 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh135 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh135 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh135 as u32; } } - rc.range >>= 1 as ::core::ffi::c_int; + rc.range >>= 1 as c_int; rc.code = rc.code.wrapping_sub(rc.range); - rc_bound = (0 as uint32_t) - .wrapping_sub(rc.code >> 31 as ::core::ffi::c_int); + rc_bound = (0 as u32).wrapping_sub(rc.code >> 31 as c_int); rc.code = rc.code.wrapping_add(rc.range & rc_bound); - rep0 = (rep0 << 1 as ::core::ffi::c_int) - .wrapping_add(rc_bound.wrapping_add(1 as uint32_t)); + rep0 = (rep0 << 1 as c_int).wrapping_add(rc_bound.wrapping_add(1 as u32)); limit = limit.wrapping_sub(1); - if limit > 0 as uint32_t { + if limit > 0 as u32 { current_block = 15418612220330286504; continue; } rep0 <<= ALIGN_BITS; - symbol = 0 as uint32_t; - offset = 1 as uint32_t; + symbol = 0 as u32; + offset = 1 as u32; current_block = 10510472849010538284; continue; } 617447976488552541 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_DIST_MODEL; current_block = 4609795085482299213; @@ -1046,34 +926,28 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh132 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh132 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh132 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh133 = *probs.offset(symbol as isize); - *fresh133 = (*fresh133 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + *fresh133 = (*fresh133 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh134 = *probs.offset(symbol as isize); - *fresh134 = (*fresh134 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - rep0 = (rep0 as ::core::ffi::c_uint) - .wrapping_add((1 as ::core::ffi::c_uint) << offset) as uint32_t - as uint32_t; + *fresh134 = (*fresh134 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + rep0 = (rep0 as c_uint).wrapping_add((1 as c_uint) << offset) as u32 as u32; } offset = offset.wrapping_add(1); if offset < limit { @@ -1083,7 +957,7 @@ unsafe extern "C" fn lzma_decode( current_block = 13383302701878543647; } 4174862988780014241 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_DIST_SLOT; current_block = 4609795085482299213; @@ -1092,55 +966,50 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh129 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh129 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh129 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh130 = *probs.offset(symbol as isize); - *fresh130 = (*fresh130 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + *fresh130 = (*fresh130 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh131 = *probs.offset(symbol as isize); - *fresh131 = (*fresh131 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + *fresh131 = (*fresh131 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - if symbol < DIST_SLOTS as uint32_t { + if symbol < DIST_SLOTS as u32 { current_block = 4174862988780014241; continue; } - symbol = symbol.wrapping_sub(DIST_SLOTS as uint32_t); - if symbol < DIST_MODEL_START as uint32_t { + symbol = symbol.wrapping_sub(DIST_SLOTS as u32); + if symbol < DIST_MODEL_START as u32 { rep0 = symbol; } else { - limit = (symbol >> 1 as ::core::ffi::c_int) - .wrapping_sub(1 as uint32_t); - rep0 = (2 as uint32_t).wrapping_add(symbol & 1 as uint32_t); - if symbol < DIST_MODEL_END as uint32_t { + limit = (symbol >> 1 as c_int).wrapping_sub(1 as u32); + rep0 = (2 as u32).wrapping_add(symbol & 1 as u32); + if symbol < DIST_MODEL_END as u32 { rep0 <<= limit; probs = (&raw mut (*coder).pos_special as *mut probability) .offset(rep0 as isize) .offset(-(symbol as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - symbol = 1 as uint32_t; - offset = 0 as uint32_t; + .offset(-(1 as isize)); + symbol = 1 as u32; + offset = 0 as u32; current_block = 617447976488552541; continue; } else { - limit = limit.wrapping_sub(ALIGN_BITS as uint32_t); + limit = limit.wrapping_sub(ALIGN_BITS as u32); current_block = 15418612220330286504; continue; } @@ -1148,7 +1017,7 @@ unsafe extern "C" fn lzma_decode( current_block = 13383302701878543647; } 592696588731961849 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_MATCH_LEN_BITTREE; current_block = 4609795085482299213; @@ -1157,51 +1026,46 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh126 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh126 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh126 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh127 = *probs.offset(symbol as isize); - *fresh127 = (*fresh127 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + *fresh127 = (*fresh127 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh128 = *probs.offset(symbol as isize); - *fresh128 = (*fresh128 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + *fresh128 = (*fresh128 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } if symbol < limit { current_block = 592696588731961849; continue; } len = len.wrapping_add(symbol.wrapping_sub(limit)); - probs = &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) - .offset( - (if len < (DIST_STATES + MATCH_LEN_MIN) as uint32_t { - len.wrapping_sub(MATCH_LEN_MIN as uint32_t) - } else { - (DIST_STATES - 1 as ::core::ffi::c_int) as uint32_t - }) as isize, - ) as *mut probability; - symbol = 1 as uint32_t; + probs = &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]).offset( + (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { + len.wrapping_sub(MATCH_LEN_MIN as u32) + } else { + (DIST_STATES - 1 as c_int) as u32 + }) as isize, + ) as *mut probability; + symbol = 1 as u32; current_block = 4174862988780014241; continue; } 13912927785247575907 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_MATCH_LEN_CHOICE2; current_block = 4609795085482299213; @@ -1210,44 +1074,39 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh125 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh125 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh125 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).match_len_decoder.choice2 as uint32_t); + .wrapping_mul((*coder).match_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice2 = ((*coder) - .match_len_decoder - .choice2 as ::core::ffi::c_uint) - .wrapping_add( + (*coder).match_len_decoder.choice2 = + ((*coder).match_len_decoder.choice2 as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.choice2 as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub((*coder).match_len_decoder.choice2 as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; probs = &raw mut *(&raw mut (*coder).match_len_decoder.mid as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; - limit = LEN_MID_SYMBOLS as uint32_t; - len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as uint32_t; + limit = LEN_MID_SYMBOLS as u32; + len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.choice2 = ((*coder) - .match_len_decoder - .choice2 as ::core::ffi::c_int - - ((*coder).match_len_decoder.choice2 as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; + (*coder).match_len_decoder.choice2 = ((*coder).match_len_decoder.choice2 + as c_int + - ((*coder).match_len_decoder.choice2 as c_int >> RC_MOVE_BITS)) + as probability; probs = &raw mut (*coder).match_len_decoder.high as *mut probability; - limit = LEN_HIGH_SYMBOLS as uint32_t; - len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) - as uint32_t; + limit = LEN_HIGH_SYMBOLS as u32; + len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32; } current_block = 8485842003490715114; } 1138292997408115650 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_MATCH_LEN_CHOICE; current_block = 4609795085482299213; @@ -1256,42 +1115,37 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh124 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh124 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh124 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).match_len_decoder.choice as uint32_t); + .wrapping_mul((*coder).match_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice = ((*coder) - .match_len_decoder - .choice as ::core::ffi::c_uint) - .wrapping_add( + (*coder).match_len_decoder.choice = + ((*coder).match_len_decoder.choice as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.choice as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub((*coder).match_len_decoder.choice as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; probs = &raw mut *(&raw mut (*coder).match_len_decoder.low as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; - limit = LEN_LOW_SYMBOLS as uint32_t; - len = MATCH_LEN_MIN as uint32_t; + limit = LEN_LOW_SYMBOLS as u32; + len = MATCH_LEN_MIN as u32; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.choice = ((*coder) - .match_len_decoder - .choice as ::core::ffi::c_int - - ((*coder).match_len_decoder.choice as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; + (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice as c_int + - ((*coder).match_len_decoder.choice as c_int >> RC_MOVE_BITS)) + as probability; current_block = 13912927785247575907; continue; } current_block = 8485842003490715114; } 10535798129821001304 => { - if dict_put_safe(&raw mut dict, symbol as uint8_t) { + if dict_put_safe(&raw mut dict, symbol as u8) { (*coder).sequence = SEQ_LITERAL_WRITE; current_block = 4609795085482299213; continue; @@ -1300,11 +1154,9 @@ unsafe extern "C" fn lzma_decode( } } 18125716024132132232 => { - let match_bit: uint32_t = len & offset; - let subcoder_index: uint32_t = offset - .wrapping_add(match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { + let match_bit: u32 = len & offset; + let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_LITERAL_MATCHED; current_block = 4609795085482299213; @@ -1313,39 +1165,33 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh120 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh120 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh120 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(subcoder_index as isize) as uint32_t); + .wrapping_mul(*probs.offset(subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh121 = *probs.offset(subcoder_index as isize); - *fresh121 = (*fresh121 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(subcoder_index as isize) - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + *fresh121 = (*fresh121 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(subcoder_index as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; offset &= !match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh122 = *probs.offset(subcoder_index as isize); - *fresh122 = (*fresh122 as ::core::ffi::c_int - - (*probs.offset(subcoder_index as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + *fresh122 = (*fresh122 as c_int + - (*probs.offset(subcoder_index as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); offset &= match_bit; } - len <<= 1 as ::core::ffi::c_int; - if symbol - < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t - { + len <<= 1 as c_int; + if symbol < ((1 as c_int) << 8 as c_int) as u32 { current_block = 18125716024132132232; continue; } else { @@ -1354,11 +1200,10 @@ unsafe extern "C" fn lzma_decode( } } 5979571030476392895 => { - if (might_finish_without_eopm as ::core::ffi::c_int != 0 - && dict.pos == dict.limit) as ::core::ffi::c_int - as ::core::ffi::c_long != 0 + if (might_finish_without_eopm as c_int != 0 && dict.pos == dict.limit) as c_long + != 0 { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_NORMALIZE; current_block = 4609795085482299213; @@ -1367,10 +1212,10 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh115 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh115 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh115 as u32; } } - if rc.code == 0 as uint32_t { + if rc.code == 0 as u32 { ret_0 = LZMA_STREAM_END; current_block = 4609795085482299213; continue; @@ -1382,7 +1227,7 @@ unsafe extern "C" fn lzma_decode( eopm_is_valid = true_0 != 0; } } - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_IS_MATCH; current_block = 4609795085482299213; @@ -1391,73 +1236,61 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh116 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh116 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh116 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).is_match[state as usize][pos_state as usize] as uint32_t, - ); + .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_match[state as usize][pos_state as usize] = ((*coder) - .is_match[state as usize][pos_state as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_match[state as usize][pos_state as usize] - as ::core::ffi::c_uint, + (*coder).is_match[state as usize][pos_state as usize] = + ((*coder).is_match[state as usize][pos_state as usize] as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_match[state as usize][pos_state as usize] as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; - probs = (&raw mut (*coder).literal as *mut probability) - .offset( - (3 as size_t) - .wrapping_mul( - ((dict.pos << 8 as ::core::ffi::c_int) - .wrapping_add(dict_get0(&raw mut dict) as size_t) - & literal_mask as size_t) << literal_context_bits, - ) as isize, - ); - symbol = 1 as uint32_t; - if state < LIT_STATES as uint32_t { - state = if state - <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as uint32_t - { - STATE_LIT_LIT as ::core::ffi::c_int as uint32_t + ) as probability as probability; + probs = (&raw mut (*coder).literal as *mut probability).offset( + (3 as size_t).wrapping_mul( + ((dict.pos << 8 as c_int) + .wrapping_add(dict_get0(&raw mut dict) as size_t) + & literal_mask as size_t) + << literal_context_bits, + ) as isize, + ); + symbol = 1 as u32; + if state < LIT_STATES as u32 { + state = if state <= STATE_SHORTREP_LIT_LIT as u32 { + STATE_LIT_LIT as u32 } else { - state.wrapping_sub(3 as uint32_t) + state.wrapping_sub(3 as u32) }; current_block = 13844743919235296534; continue; } else { - state = if state - <= STATE_LIT_SHORTREP as ::core::ffi::c_int as uint32_t - { - state.wrapping_sub(3 as uint32_t) + state = if state <= STATE_LIT_SHORTREP as u32 { + state.wrapping_sub(3 as u32) } else { - state.wrapping_sub(6 as uint32_t) + state.wrapping_sub(6 as u32) }; - len = (dict_get(&raw mut dict, rep0) as uint32_t) - << 1 as ::core::ffi::c_int; - offset = 0x100 as uint32_t; + len = (dict_get(&raw mut dict, rep0) as u32) << 1 as c_int; + offset = 0x100 as u32; current_block = 18125716024132132232; continue; } } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_match[state as usize][pos_state as usize] = ((*coder) - .is_match[state as usize][pos_state as usize] - as ::core::ffi::c_int - - ((*coder).is_match[state as usize][pos_state as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + (*coder).is_match[state as usize][pos_state as usize] = + ((*coder).is_match[state as usize][pos_state as usize] as c_int + - ((*coder).is_match[state as usize][pos_state as usize] as c_int + >> RC_MOVE_BITS)) as probability; current_block = 3469750012682708893; continue; } } 13844743919235296534 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_LITERAL; current_block = 4609795085482299213; @@ -1466,35 +1299,29 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh117 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh117 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh117 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh118 = *probs.offset(symbol as isize); - *fresh118 = (*fresh118 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + *fresh118 = (*fresh118 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh119 = *probs.offset(symbol as isize); - *fresh119 = (*fresh119 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + *fresh119 = (*fresh119 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - if symbol - < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t - { + if symbol < ((1 as c_int) << 8 as c_int) as u32 { current_block = 13844743919235296534; continue; } else { @@ -1503,7 +1330,7 @@ unsafe extern "C" fn lzma_decode( } } 2467942631393454738 => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_REP_LEN_BITTREE; current_block = 4609795085482299213; @@ -1512,31 +1339,27 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh144 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh144 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh144 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh145 = *probs.offset(symbol as isize); - *fresh145 = (*fresh145 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + *fresh145 = (*fresh145 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh146 = *probs.offset(symbol as isize); - *fresh146 = (*fresh146 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + *fresh146 = (*fresh146 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } if symbol < limit { current_block = 2467942631393454738; @@ -1547,9 +1370,7 @@ unsafe extern "C" fn lzma_decode( continue; } 17340485688450593529 => { - if dict_repeat(&raw mut dict, rep0, &raw mut len) as ::core::ffi::c_long - != 0 - { + if dict_repeat(&raw mut dict, rep0, &raw mut len) as c_long != 0 { (*coder).sequence = SEQ_COPY; current_block = 4609795085482299213; continue; @@ -1558,7 +1379,7 @@ unsafe extern "C" fn lzma_decode( } } _ => { - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_REP_LEN_CHOICE2; current_block = 4609795085482299213; @@ -1567,45 +1388,40 @@ unsafe extern "C" fn lzma_decode( rc.range <<= RC_SHIFT_BITS; let fresh143 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh143 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh143 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).rep_len_decoder.choice2 as uint32_t); + .wrapping_mul((*coder).rep_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 - as ::core::ffi::c_uint) - .wrapping_add( + (*coder).rep_len_decoder.choice2 = + ((*coder).rep_len_decoder.choice2 as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.choice2 as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub((*coder).rep_len_decoder.choice2 as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; probs = &raw mut *(&raw mut (*coder).rep_len_decoder.mid as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; - limit = LEN_MID_SYMBOLS as uint32_t; - len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as uint32_t; + limit = LEN_MID_SYMBOLS as u32; + len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 - as ::core::ffi::c_int - - ((*coder).rep_len_decoder.choice2 as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; + (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 as c_int + - ((*coder).rep_len_decoder.choice2 as c_int >> RC_MOVE_BITS)) + as probability; probs = &raw mut (*coder).rep_len_decoder.high as *mut probability; - limit = LEN_HIGH_SYMBOLS as uint32_t; - len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) - as uint32_t; + limit = LEN_HIGH_SYMBOLS as u32; + len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32; } current_block = 16690975975023747857; } } match current_block { 13383302701878543647 => { - if !(!dict_is_distance_valid(&raw mut dict, rep0 as size_t) - as ::core::ffi::c_int as ::core::ffi::c_long != 0) + if !(!dict_is_distance_valid(&raw mut dict, rep0 as size_t) as c_int as c_long != 0) { current_block = 17340485688450593529; continue; @@ -1614,2542 +1430,2342 @@ unsafe extern "C" fn lzma_decode( current_block = 4609795085482299213; continue; } - 4956146061682418353 => { - loop { - pos_state = (dict.pos & pos_mask as size_t) as uint32_t; - if (!(rc_in_ptr < rc_in_fast_end) || dict.pos == dict.limit) - as ::core::ffi::c_int as ::core::ffi::c_long != 0 - { - current_block = 5979571030476392895; - continue 'c_9380; - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh3 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh3 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).is_match[state as usize][pos_state as usize] - as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).is_match[state as usize][pos_state as usize] = ((*coder) - .is_match[state as usize][pos_state as usize] - as ::core::ffi::c_uint) + 4956146061682418353 => loop { + pos_state = (dict.pos & pos_mask as size_t) as u32; + if (!(rc_in_ptr < rc_in_fast_end) || dict.pos == dict.limit) as c_int as c_long != 0 + { + current_block = 5979571030476392895; + continue 'c_9380; + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh3 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh3 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_match[state as usize][pos_state as usize] = + ((*coder).is_match[state as usize][pos_state as usize] as c_uint) .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_match[state as usize][pos_state as usize] as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + probs = (&raw mut (*coder).literal as *mut probability).offset( + (3 as size_t).wrapping_mul( + ((dict.pos << 8 as c_int) + .wrapping_add(dict_get0(&raw mut dict) as size_t) + & literal_mask as size_t) + << literal_context_bits, + ) as isize, + ); + if state < LIT_STATES as u32 { + state = if state <= STATE_SHORTREP_LIT_LIT as u32 { + STATE_LIT_LIT as u32 + } else { + state.wrapping_sub(3 as u32) + }; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh4 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh4 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh5 = *probs.offset(symbol as isize); + *fresh5 = (*fresh5 as c_uint).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_match[state as usize][pos_state as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, ) as probability as probability; - probs = (&raw mut (*coder).literal as *mut probability) - .offset( - (3 as size_t) - .wrapping_mul( - ((dict.pos << 8 as ::core::ffi::c_int) - .wrapping_add(dict_get0(&raw mut dict) as size_t) - & literal_mask as size_t) << literal_context_bits, - ) as isize, - ); - if state < LIT_STATES as uint32_t { - state = if state - <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as uint32_t - { - STATE_LIT_LIT as ::core::ffi::c_int as uint32_t - } else { - state.wrapping_sub(3 as uint32_t) - }; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh4 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh4 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh5 = *probs.offset(symbol as isize); - *fresh5 = (*fresh5 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh6 = *probs.offset(symbol as isize); - *fresh6 = (*fresh6 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh7 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh7 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh8 = *probs.offset(symbol as isize); - *fresh8 = (*fresh8 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh9 = *probs.offset(symbol as isize); - *fresh9 = (*fresh9 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh10 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh10 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh11 = *probs.offset(symbol as isize); - *fresh11 = (*fresh11 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh12 = *probs.offset(symbol as isize); - *fresh12 = (*fresh12 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh13 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh13 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh14 = *probs.offset(symbol as isize); - *fresh14 = (*fresh14 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh15 = *probs.offset(symbol as isize); - *fresh15 = (*fresh15 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh16 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh16 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh17 = *probs.offset(symbol as isize); - *fresh17 = (*fresh17 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh18 = *probs.offset(symbol as isize); - *fresh18 = (*fresh18 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh19 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh19 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh20 = *probs.offset(symbol as isize); - *fresh20 = (*fresh20 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh21 = *probs.offset(symbol as isize); - *fresh21 = (*fresh21 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh22 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh22 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh23 = *probs.offset(symbol as isize); - *fresh23 = (*fresh23 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh24 = *probs.offset(symbol as isize); - *fresh24 = (*fresh24 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh25 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh25 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh26 = *probs.offset(symbol as isize); - *fresh26 = (*fresh26 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh27 = *probs.offset(symbol as isize); - *fresh27 = (*fresh27 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - symbol = symbol - .wrapping_add(0 as ::core::ffi::c_int as uint32_t); + symbol <<= 1 as c_int; } else { - state = if state - <= STATE_LIT_SHORTREP as ::core::ffi::c_int as uint32_t - { - state.wrapping_sub(3 as uint32_t) - } else { - state.wrapping_sub(6 as uint32_t) - }; - let mut t_match_byte: uint32_t = dict_get( - &raw mut dict, - rep0, - ) as uint32_t; - let mut t_match_bit: uint32_t = 0; - let mut t_subcoder_index: uint32_t = 0; - let mut t_offset: uint32_t = 0x100 as uint32_t; - symbol = 1 as uint32_t; - t_match_byte <<= 1 as ::core::ffi::c_int; - t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset - .wrapping_add(t_match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh28 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh28 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - *probs.offset(t_subcoder_index as isize) as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh29 = *probs - .offset(t_subcoder_index as isize); - *fresh29 = (*fresh29 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - t_offset &= !t_match_bit; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh30 = *probs - .offset(t_subcoder_index as isize); - *fresh30 = (*fresh30 as ::core::ffi::c_int - - (*probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - t_offset &= t_match_bit; - } - t_match_byte <<= 1 as ::core::ffi::c_int; - t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset - .wrapping_add(t_match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh31 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh31 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - *probs.offset(t_subcoder_index as isize) as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh32 = *probs - .offset(t_subcoder_index as isize); - *fresh32 = (*fresh32 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - t_offset &= !t_match_bit; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh33 = *probs - .offset(t_subcoder_index as isize); - *fresh33 = (*fresh33 as ::core::ffi::c_int - - (*probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - t_offset &= t_match_bit; - } - t_match_byte <<= 1 as ::core::ffi::c_int; - t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset - .wrapping_add(t_match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh34 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh34 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - *probs.offset(t_subcoder_index as isize) as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh35 = *probs - .offset(t_subcoder_index as isize); - *fresh35 = (*fresh35 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - t_offset &= !t_match_bit; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh36 = *probs - .offset(t_subcoder_index as isize); - *fresh36 = (*fresh36 as ::core::ffi::c_int - - (*probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - t_offset &= t_match_bit; - } - t_match_byte <<= 1 as ::core::ffi::c_int; - t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset - .wrapping_add(t_match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh37 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh37 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - *probs.offset(t_subcoder_index as isize) as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh38 = *probs - .offset(t_subcoder_index as isize); - *fresh38 = (*fresh38 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - t_offset &= !t_match_bit; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh39 = *probs - .offset(t_subcoder_index as isize); - *fresh39 = (*fresh39 as ::core::ffi::c_int - - (*probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - t_offset &= t_match_bit; - } - t_match_byte <<= 1 as ::core::ffi::c_int; - t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset - .wrapping_add(t_match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh6 = *probs.offset(symbol as isize); + *fresh6 = (*fresh6 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh7 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh7 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh8 = *probs.offset(symbol as isize); + *fresh8 = (*fresh8 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh9 = *probs.offset(symbol as isize); + *fresh9 = (*fresh9 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh10 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh10 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh11 = *probs.offset(symbol as isize); + *fresh11 = (*fresh11 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh12 = *probs.offset(symbol as isize); + *fresh12 = (*fresh12 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh13 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh13 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh14 = *probs.offset(symbol as isize); + *fresh14 = (*fresh14 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh15 = *probs.offset(symbol as isize); + *fresh15 = (*fresh15 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh16 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh16 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh17 = *probs.offset(symbol as isize); + *fresh17 = (*fresh17 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh18 = *probs.offset(symbol as isize); + *fresh18 = (*fresh18 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh19 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh19 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh20 = *probs.offset(symbol as isize); + *fresh20 = (*fresh20 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh21 = *probs.offset(symbol as isize); + *fresh21 = (*fresh21 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh22 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh22 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh23 = *probs.offset(symbol as isize); + *fresh23 = (*fresh23 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh24 = *probs.offset(symbol as isize); + *fresh24 = (*fresh24 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh25 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh25 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh26 = *probs.offset(symbol as isize); + *fresh26 = (*fresh26 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh27 = *probs.offset(symbol as isize); + *fresh27 = (*fresh27 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + symbol = symbol.wrapping_add(0 as u32); + } else { + state = if state <= STATE_LIT_SHORTREP as u32 { + state.wrapping_sub(3 as u32) + } else { + state.wrapping_sub(6 as u32) + }; + let mut t_match_byte: u32 = dict_get(&raw mut dict, rep0) as u32; + let mut t_match_bit: u32 = 0; + let mut t_subcoder_index: u32 = 0; + let mut t_offset: u32 = 0x100 as u32; + symbol = 1 as u32; + t_match_byte <<= 1 as c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh28 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh28 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh29 = *probs.offset(t_subcoder_index as isize); + *fresh29 = (*fresh29 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh30 = *probs.offset(t_subcoder_index as isize); + *fresh30 = (*fresh30 as c_int + - (*probs.offset(t_subcoder_index as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh31 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh31 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh32 = *probs.offset(t_subcoder_index as isize); + *fresh32 = (*fresh32 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh33 = *probs.offset(t_subcoder_index as isize); + *fresh33 = (*fresh33 as c_int + - (*probs.offset(t_subcoder_index as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh34 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh34 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh35 = *probs.offset(t_subcoder_index as isize); + *fresh35 = (*fresh35 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh36 = *probs.offset(t_subcoder_index as isize); + *fresh36 = (*fresh36 as c_int + - (*probs.offset(t_subcoder_index as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh37 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh37 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh38 = *probs.offset(t_subcoder_index as isize); + *fresh38 = (*fresh38 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh39 = *probs.offset(t_subcoder_index as isize); + *fresh39 = (*fresh39 as c_int + - (*probs.offset(t_subcoder_index as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh40 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh40 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh41 = *probs.offset(t_subcoder_index as isize); + *fresh41 = (*fresh41 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh42 = *probs.offset(t_subcoder_index as isize); + *fresh42 = (*fresh42 as c_int + - (*probs.offset(t_subcoder_index as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh43 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh43 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh44 = *probs.offset(t_subcoder_index as isize); + *fresh44 = (*fresh44 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh45 = *probs.offset(t_subcoder_index as isize); + *fresh45 = (*fresh45 as c_int + - (*probs.offset(t_subcoder_index as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh46 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh46 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh47 = *probs.offset(t_subcoder_index as isize); + *fresh47 = (*fresh47 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh48 = *probs.offset(t_subcoder_index as isize); + *fresh48 = (*fresh48 as c_int + - (*probs.offset(t_subcoder_index as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + t_offset &= t_match_bit; + } + t_match_byte <<= 1 as c_int; + t_match_bit = t_match_byte & t_offset; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh49 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh49 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh50 = *probs.offset(t_subcoder_index as isize); + *fresh50 = (*fresh50 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as c_uint, + ) >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + t_offset &= !t_match_bit; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh51 = *probs.offset(t_subcoder_index as isize); + *fresh51 = (*fresh51 as c_int + - (*probs.offset(t_subcoder_index as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + t_offset &= t_match_bit; + } + } + dict_put(&raw mut dict, symbol as u8); + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_match[state as usize][pos_state as usize] = + ((*coder).is_match[state as usize][pos_state as usize] as c_int + - ((*coder).is_match[state as usize][pos_state as usize] as c_int + >> RC_MOVE_BITS)) as probability; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh52 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh52 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep[state as usize] as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep[state as usize] = + ((*coder).is_rep[state as usize] as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).is_rep[state as usize] as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + state = (if state < LIT_STATES as u32 { + STATE_LIT_MATCH as c_int + } else { + STATE_NONLIT_MATCH as c_int + }) as u32; + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh53 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh53 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).match_len_decoder.choice as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.choice = + ((*coder).match_len_decoder.choice as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).match_len_decoder.choice as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh40 = rc_in_ptr; + let fresh54 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh40 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh54 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - *probs.offset(t_subcoder_index as isize) as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh41 = *probs - .offset(t_subcoder_index as isize); - *fresh41 = (*fresh41 as ::core::ffi::c_uint) + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.low + [pos_state as usize][symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - t_offset &= !t_match_bit; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh42 = *probs - .offset(t_subcoder_index as isize); - *fresh42 = (*fresh42 as ::core::ffi::c_int - - (*probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - t_offset &= t_match_bit; + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.low + [pos_state as usize][symbol as usize] + as c_int + - ((*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - t_match_byte <<= 1 as ::core::ffi::c_int; - t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset - .wrapping_add(t_match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh43 = rc_in_ptr; + let fresh55 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh43 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh55 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - *probs.offset(t_subcoder_index as isize) as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh44 = *probs - .offset(t_subcoder_index as isize); - *fresh44 = (*fresh44 as ::core::ffi::c_uint) + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.low + [pos_state as usize][symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - t_offset &= !t_match_bit; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh45 = *probs - .offset(t_subcoder_index as isize); - *fresh45 = (*fresh45 as ::core::ffi::c_int - - (*probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - t_offset &= t_match_bit; + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.low + [pos_state as usize][symbol as usize] + as c_int + - ((*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - t_match_byte <<= 1 as ::core::ffi::c_int; - t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset - .wrapping_add(t_match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh46 = rc_in_ptr; + let fresh56 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh46 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh56 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - *probs.offset(t_subcoder_index as isize) as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh47 = *probs - .offset(t_subcoder_index as isize); - *fresh47 = (*fresh47 as ::core::ffi::c_uint) + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.low + [pos_state as usize][symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - t_offset &= !t_match_bit; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh48 = *probs - .offset(t_subcoder_index as isize); - *fresh48 = (*fresh48 as ::core::ffi::c_int - - (*probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - t_offset &= t_match_bit; + (*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.low + [pos_state as usize][symbol as usize] + as c_int + - ((*coder).match_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - t_match_byte <<= 1 as ::core::ffi::c_int; - t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset - .wrapping_add(t_match_bit) - .wrapping_add(symbol); - if rc.range < RC_TOP_VALUE as uint32_t { + symbol = symbol + .wrapping_add((-((1 as c_int) << 3 as c_int) + 2 as c_int) as u32); + len = symbol; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice + as c_int + - ((*coder).match_len_decoder.choice as c_int >> RC_MOVE_BITS)) + as probability; + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh49 = rc_in_ptr; + let fresh57 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh49 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh57 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - *probs.offset(t_subcoder_index as isize) as uint32_t, - ); + .wrapping_mul((*coder).match_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh50 = *probs - .offset(t_subcoder_index as isize); - *fresh50 = (*fresh50 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_uint, + (*coder).match_len_decoder.choice2 = + ((*coder).match_len_decoder.choice2 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.choice2 as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh58 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh58 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh59 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh59 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - t_offset &= !t_match_bit; + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh60 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh60 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).match_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).match_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + symbol = symbol.wrapping_add( + (-((1 as c_int) << 3 as c_int) + + 2 as c_int + + ((1 as c_int) << 3 as c_int)) + as u32, + ); + len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh51 = *probs - .offset(t_subcoder_index as isize); - *fresh51 = (*fresh51 as ::core::ffi::c_int - - (*probs.offset(t_subcoder_index as isize) - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - t_offset &= t_match_bit; + (*coder).match_len_decoder.choice2 = + ((*coder).match_len_decoder.choice2 as c_int + - ((*coder).match_len_decoder.choice2 as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh61 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh61 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh62 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh62 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh63 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh63 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh64 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh64 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh65 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh65 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh66 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh66 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh67 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh67 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh68 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh68 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).match_len_decoder.high[symbol as usize] = ((*coder) + .match_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as c_int + - ((*coder).match_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + symbol = symbol.wrapping_add( + (-((1 as c_int) << 8 as c_int) + + 2 as c_int + + ((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 3 as c_int)) + as u32, + ); + len = symbol; } } - dict_put(&raw mut dict, symbol as uint8_t); - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_match[state as usize][pos_state as usize] = ((*coder) - .is_match[state as usize][pos_state as usize] - as ::core::ffi::c_int - - ((*coder).is_match[state as usize][pos_state as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - if rc.range < RC_TOP_VALUE as uint32_t { + probs = &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) + .offset( + (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { + len.wrapping_sub(MATCH_LEN_MIN as u32) + } else { + (DIST_STATES - 1 as c_int) as u32 + }) as isize, + ) as *mut probability; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh52 = rc_in_ptr; + let fresh69 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh52 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh69 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep[state as usize] as uint32_t); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep[state as usize] = ((*coder) - .is_rep[state as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep[state as usize] as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - state = (if state < LIT_STATES as uint32_t { - STATE_LIT_MATCH as ::core::ffi::c_int - } else { - STATE_NONLIT_MATCH as ::core::ffi::c_int - }) as uint32_t; - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh53 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh53 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.choice as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.choice = ((*coder) - .match_len_decoder - .choice as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.choice as ::core::ffi::c_uint, + let ref mut fresh70 = *probs.offset(symbol as isize); + *fresh70 = (*fresh70 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh71 = *probs.offset(symbol as isize); + *fresh71 = (*fresh71 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh72 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh72 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh73 = *probs.offset(symbol as isize); + *fresh73 = (*fresh73 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh74 = *probs.offset(symbol as isize); + *fresh74 = (*fresh74 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh75 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh75 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh76 = *probs.offset(symbol as isize); + *fresh76 = (*fresh76 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh77 = *probs.offset(symbol as isize); + *fresh77 = (*fresh77 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh78 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh78 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh79 = *probs.offset(symbol as isize); + *fresh79 = (*fresh79 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh80 = *probs.offset(symbol as isize); + *fresh80 = (*fresh80 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh81 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh81 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh82 = *probs.offset(symbol as isize); + *fresh82 = (*fresh82 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh83 = *probs.offset(symbol as isize); + *fresh83 = (*fresh83 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh84 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh84 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh85 = *probs.offset(symbol as isize); + *fresh85 = (*fresh85 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + >> RC_MOVE_BITS, + ) as probability as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh86 = *probs.offset(symbol as isize); + *fresh86 = (*fresh86 as c_int + - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + symbol = symbol.wrapping_add(-((1 as c_int) << 6 as c_int) as u32); + if symbol < DIST_MODEL_START as u32 { + rep0 = symbol; + } else { + limit = (symbol >> 1 as c_int).wrapping_sub(1 as u32); + rep0 = (2 as u32).wrapping_add(symbol & 1 as u32); + if symbol < DIST_MODEL_END as u32 { + rep0 <<= limit; + probs = (&raw mut (*coder).pos_special as *mut probability) + .offset(rep0 as isize) + .offset(-(symbol as isize)) + .offset(-(1 as isize)); + symbol = 1 as u32; + offset = 1 as u32; + loop { + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh87 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh87 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul(*probs.offset(symbol as isize) as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + let ref mut fresh88 = *probs.offset(symbol as isize); + *fresh88 = (*fresh88 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(symbol as isize) as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + let ref mut fresh89 = *probs.offset(symbol as isize); + *fresh89 = (*fresh89 as c_int + - (*probs.offset(symbol as isize) as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + rep0 = rep0.wrapping_add(offset); + } + offset <<= 1 as c_int; + limit = limit.wrapping_sub(1); + if !(limit > 0 as u32) { + break; + } + } + } else { + limit = limit.wrapping_sub(ALIGN_BITS as u32); + loop { + rep0 = (rep0 << 1 as c_int).wrapping_add(1 as u32); + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh90 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh90 as u32; + } + rc.range >>= 1 as c_int; + rc.code = rc.code.wrapping_sub(rc.range); + rc_bound = (0 as u32).wrapping_sub(rc.code >> 31 as c_int); + rep0 = rep0.wrapping_add(rc_bound); + rc.code = rc.code.wrapping_add(rc.range & rc_bound); + limit = limit.wrapping_sub(1); + if !(limit > 0 as u32) { + break; + } + } + rep0 <<= ALIGN_BITS; + symbol = 0 as u32; + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh54 = rc_in_ptr; + let fresh91 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh54 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh91 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, + (*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] = + ((*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align + [symbol.wrapping_add(1 as u32) as usize] + as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + ) as probability + as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + (*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] = + ((*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] + as c_int + - ((*coder).pos_align + [symbol.wrapping_add(1 as u32) as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = symbol.wrapping_add(1 as u32); } - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh55 = rc_in_ptr; + let fresh92 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh55 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh92 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, + (*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] = + ((*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align + [symbol.wrapping_add(2 as u32) as usize] + as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + ) as probability + as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + (*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] = + ((*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] + as c_int + - ((*coder).pos_align + [symbol.wrapping_add(2 as u32) as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = symbol.wrapping_add(2 as u32); } - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh56 = rc_in_ptr; + let fresh93 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh56 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh93 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, + (*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] = + ((*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align + [symbol.wrapping_add(4 as u32) as usize] + as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + ) as probability + as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .match_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + (*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] = + ((*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] + as c_int + - ((*coder).pos_align + [symbol.wrapping_add(4 as u32) as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = symbol.wrapping_add(4 as u32); } - symbol = symbol - .wrapping_add( - (-((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + 2 as ::core::ffi::c_int) as uint32_t, - ); - len = symbol; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.choice = ((*coder) - .match_len_decoder - .choice as ::core::ffi::c_int - - ((*coder).match_len_decoder.choice as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh57 = rc_in_ptr; + let fresh94 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh57 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh94 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.choice2 as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice2 = ((*coder) - .match_len_decoder - .choice2 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.choice2 as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh58 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh58 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh59 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh59 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh60 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh60 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) + (*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] = + ((*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .match_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - symbol = symbol - .wrapping_add( - (-((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + 2 as ::core::ffi::c_int - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int)) - as uint32_t, - ); - len = symbol; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align + [symbol.wrapping_add(8 as u32) as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.choice2 = ((*coder) - .match_len_decoder - .choice2 as ::core::ffi::c_int - - ((*coder).match_len_decoder.choice2 as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh61 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh61 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh62 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh62 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh63 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh63 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh64 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh64 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh65 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh65 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh66 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh66 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh67 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh67 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh68 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh68 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).match_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - symbol = symbol - .wrapping_add( - (-((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) - + 2 as ::core::ffi::c_int - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int)) - as uint32_t, - ); - len = symbol; + (*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] = + ((*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] + as c_int + - ((*coder).pos_align + [symbol.wrapping_add(8 as u32) as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = symbol.wrapping_add(8 as u32); + } + rep0 = rep0.wrapping_add(symbol); + if rep0 == UINT32_MAX as u32 { + break; } } - probs = &raw mut *(&raw mut (*coder).dist_slot - as *mut [probability; 64]) - .offset( - (if len < (DIST_STATES + MATCH_LEN_MIN) as uint32_t { - len.wrapping_sub(MATCH_LEN_MIN as uint32_t) - } else { - (DIST_STATES - 1 as ::core::ffi::c_int) as uint32_t - }) as isize, - ) as *mut probability; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh69 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh69 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh70 = *probs.offset(symbol as isize); - *fresh70 = (*fresh70 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh71 = *probs.offset(symbol as isize); - *fresh71 = (*fresh71 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh72 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh72 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh73 = *probs.offset(symbol as isize); - *fresh73 = (*fresh73 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh74 = *probs.offset(symbol as isize); - *fresh74 = (*fresh74 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh75 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh75 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh76 = *probs.offset(symbol as isize); - *fresh76 = (*fresh76 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh77 = *probs.offset(symbol as isize); - *fresh77 = (*fresh77 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh78 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh78 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh79 = *probs.offset(symbol as isize); - *fresh79 = (*fresh79 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh80 = *probs.offset(symbol as isize); - *fresh80 = (*fresh80 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { + } + if !dict_is_distance_valid(&raw mut dict, rep0 as size_t) as c_long != 0 { + ret_0 = LZMA_DATA_ERROR; + current_block = 4609795085482299213; + continue 'c_9380; + } + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as c_int + - ((*coder).is_rep[state as usize] as c_int >> RC_MOVE_BITS)) + as probability; + if !dict_is_distance_valid(&raw mut dict, 0 as size_t) as c_int as c_long + != 0 + { + ret_0 = LZMA_DATA_ERROR; + current_block = 4609795085482299213; + continue 'c_9380; + } else { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh81 = rc_in_ptr; + let fresh95 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh81 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh95 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + .wrapping_mul((*coder).is_rep0[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh82 = *probs.offset(symbol as isize); - *fresh82 = (*fresh82 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + (*coder).is_rep0[state as usize] = + ((*coder).is_rep0[state as usize] as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_rep0[state as usize] as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh96 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh96 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).is_rep0_long[state as usize][pos_state as usize] + as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep0_long[state as usize][pos_state as usize] = + ((*coder).is_rep0_long[state as usize][pos_state as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_rep0_long[state as usize] + [pos_state as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + state = (if state < LIT_STATES as u32 { + STATE_LIT_SHORTREP as c_int + } else { + STATE_NONLIT_REP as c_int + }) as u32; + dict_put(&raw mut dict, dict_get(&raw mut dict, rep0)); + continue; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep0_long[state as usize][pos_state as usize] = + ((*coder).is_rep0_long[state as usize][pos_state as usize] + as c_int + - ((*coder).is_rep0_long[state as usize] + [pos_state as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + } } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh83 = *probs.offset(symbol as isize); - *fresh83 = (*fresh83 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] + as c_int + - ((*coder).is_rep0[state as usize] as c_int >> RC_MOVE_BITS)) + as probability; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh97 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh97 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep1[state as usize] as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep1[state as usize] = + ((*coder).is_rep1[state as usize] as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_rep1[state as usize] as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + let distance: u32 = rep1; + rep1 = rep0; + rep0 = distance; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep1[state as usize] = + ((*coder).is_rep1[state as usize] as c_int + - ((*coder).is_rep1[state as usize] as c_int + >> RC_MOVE_BITS)) + as probability; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh98 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh98 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).is_rep2[state as usize] as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).is_rep2[state as usize] = + ((*coder).is_rep2[state as usize] as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_rep2[state as usize] as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + let distance_0: u32 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance_0; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).is_rep2[state as usize] = + ((*coder).is_rep2[state as usize] as c_int + - ((*coder).is_rep2[state as usize] as c_int + >> RC_MOVE_BITS)) + as probability; + let distance_1: u32 = rep3; + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance_1; + } + } } - if rc.range < RC_TOP_VALUE as uint32_t { + state = (if state < LIT_STATES as u32 { + STATE_LIT_LONGREP as c_int + } else { + STATE_NONLIT_REP as c_int + }) as u32; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh84 = rc_in_ptr; + let fresh99 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh84 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh99 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); + .wrapping_mul((*coder).rep_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh85 = *probs.offset(symbol as isize); - *fresh85 = (*fresh85 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + (*coder).rep_len_decoder.choice = + ((*coder).rep_len_decoder.choice as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.choice as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh100 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh100 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] = + ((*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.low + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh101 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh101 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] = + ((*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.low + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh102 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh102 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] = + ((*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.low + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).rep_len_decoder.low[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + symbol = symbol.wrapping_add( + (-((1 as c_int) << 3 as c_int) + 2 as c_int) as u32, + ); + len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh86 = *probs.offset(symbol as isize); - *fresh86 = (*fresh86 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - symbol = symbol - .wrapping_add( - -((1 as ::core::ffi::c_int) << 6 as ::core::ffi::c_int) - as uint32_t, - ); - if symbol < DIST_MODEL_START as uint32_t { - rep0 = symbol; - } else { - limit = (symbol >> 1 as ::core::ffi::c_int) - .wrapping_sub(1 as uint32_t); - rep0 = (2 as uint32_t).wrapping_add(symbol & 1 as uint32_t); - if symbol < DIST_MODEL_END as uint32_t { - rep0 <<= limit; - probs = (&raw mut (*coder).pos_special as *mut probability) - .offset(rep0 as isize) - .offset(-(symbol as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - symbol = 1 as uint32_t; - offset = 1 as uint32_t; - loop { - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh87 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh87 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - let ref mut fresh88 = *probs.offset(symbol as isize); - *fresh88 = (*fresh88 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - *probs.offset(symbol as isize) as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh89 = *probs.offset(symbol as isize); - *fresh89 = (*fresh89 as ::core::ffi::c_int - - (*probs.offset(symbol as isize) as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - rep0 = rep0.wrapping_add(offset); - } - offset <<= 1 as ::core::ffi::c_int; - limit = limit.wrapping_sub(1); - if !(limit > 0 as uint32_t) { - break; - } - } - } else { - limit = limit.wrapping_sub(ALIGN_BITS as uint32_t); - loop { - rep0 = (rep0 << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh90 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh90 as uint32_t; - } - rc.range >>= 1 as ::core::ffi::c_int; - rc.code = rc.code.wrapping_sub(rc.range); - rc_bound = (0 as uint32_t) - .wrapping_sub(rc.code >> 31 as ::core::ffi::c_int); - rep0 = rep0.wrapping_add(rc_bound); - rc.code = rc.code.wrapping_add(rc.range & rc_bound); - limit = limit.wrapping_sub(1); - if !(limit > 0 as uint32_t) { - break; - } - } - rep0 <<= ALIGN_BITS; - symbol = 0 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { + (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice + as c_int + - ((*coder).rep_len_decoder.choice as c_int >> RC_MOVE_BITS)) + as probability; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh103 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh103 as u32; + } + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) + .wrapping_mul((*coder).rep_len_decoder.choice2 as u32); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.choice2 = + ((*coder).rep_len_decoder.choice2 as c_uint).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.choice2 as c_uint, + ) >> RC_MOVE_BITS, + ) as probability + as probability; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh91 = rc_in_ptr; + let fresh104 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh91 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh104 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] - as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) - .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] = ((*coder) - .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] - as ::core::ffi::c_uint) + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] = ((*coder) - .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] - as ::core::ffi::c_int - - ((*coder) - .pos_align[symbol.wrapping_add(1 as uint32_t) as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = symbol.wrapping_add(1 as uint32_t); + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh92 = rc_in_ptr; + let fresh105 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh92 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh105 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] - as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) - .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] = ((*coder) - .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] - as ::core::ffi::c_uint) + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] = ((*coder) - .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] - as ::core::ffi::c_int - - ((*coder) - .pos_align[symbol.wrapping_add(2 as uint32_t) as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = symbol.wrapping_add(2 as uint32_t); + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh93 = rc_in_ptr; + let fresh106 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh93 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh106 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] - as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) - .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] = ((*coder) - .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] - as ::core::ffi::c_uint) + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] = ((*coder) - .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] - as ::core::ffi::c_int - - ((*coder) - .pos_align[symbol.wrapping_add(4 as uint32_t) as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = symbol.wrapping_add(4 as uint32_t); + (*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] = ((*coder).rep_len_decoder.mid + [pos_state as usize] + [symbol as usize] + as c_int + - ((*coder).rep_len_decoder.mid[pos_state as usize] + [symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - if rc.range < RC_TOP_VALUE as uint32_t { + symbol = symbol.wrapping_add( + (-((1 as c_int) << 3 as c_int) + + 2 as c_int + + ((1 as c_int) << 3 as c_int)) + as u32, + ); + len = symbol; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.choice2 = + ((*coder).rep_len_decoder.choice2 as c_int + - ((*coder).rep_len_decoder.choice2 as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = 1 as u32; + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh94 = rc_in_ptr; + let fresh107 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh94 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh107 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] - as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) - .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] = ((*coder) - .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] - as ::core::ffi::c_uint) + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] = ((*coder) - .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] - as ::core::ffi::c_int - - ((*coder) - .pos_align[symbol.wrapping_add(8 as uint32_t) as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = symbol.wrapping_add(8 as uint32_t); + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - rep0 = rep0.wrapping_add(symbol); - if rep0 == UINT32_MAX as uint32_t { - break; + if rc.range < RC_TOP_VALUE as u32 { + rc.range <<= RC_SHIFT_BITS; + let fresh108 = rc_in_ptr; + rc_in_ptr = rc_in_ptr.offset(1); + rc.code = rc.code << RC_SHIFT_BITS | *fresh108 as u32; } - } - } - if !dict_is_distance_valid(&raw mut dict, rep0 as size_t) - as ::core::ffi::c_int as ::core::ffi::c_long != 0 - { - ret_0 = LZMA_DATA_ERROR; - current_block = 4609795085482299213; - continue 'c_9380; - } - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep[state as usize] = ((*coder) - .is_rep[state as usize] as ::core::ffi::c_int - - ((*coder).is_rep[state as usize] as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - if !dict_is_distance_valid(&raw mut dict, 0 as size_t) - as ::core::ffi::c_int as ::core::ffi::c_long != 0 - { - ret_0 = LZMA_DATA_ERROR; - current_block = 4609795085482299213; - continue 'c_9380; - } else { - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh95 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh95 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep0[state as usize] as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).is_rep0[state as usize] = ((*coder) - .is_rep0[state as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep0[state as usize] as ::core::ffi::c_uint, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, + ); + if rc.code < rc_bound { + rc.range = rc_bound; + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] + as c_uint) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as c_uint, ) >> RC_MOVE_BITS, - ) as probability as probability; - if rc.range < RC_TOP_VALUE as uint32_t { + ) + as probability + as probability; + symbol <<= 1 as c_int; + } else { + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + } + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh96 = rc_in_ptr; + let fresh109 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh96 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh109 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).is_rep0_long[state as usize][pos_state as usize] - as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder) - .is_rep0_long[state as usize][pos_state as usize] - as ::core::ffi::c_uint) + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep0_long[state as usize][pos_state as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - state = (if state < LIT_STATES as uint32_t { - STATE_LIT_SHORTREP as ::core::ffi::c_int - } else { - STATE_NONLIT_REP as ::core::ffi::c_int - }) as uint32_t; - dict_put(&raw mut dict, dict_get(&raw mut dict, rep0)); - continue; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder) - .is_rep0_long[state as usize][pos_state as usize] - as ::core::ffi::c_int - - ((*coder).is_rep0_long[state as usize][pos_state as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep0[state as usize] = ((*coder) - .is_rep0[state as usize] as ::core::ffi::c_int - - ((*coder).is_rep0[state as usize] as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh97 = rc_in_ptr; + let fresh110 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh97 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh110 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep1[state as usize] as uint32_t); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep1[state as usize] = ((*coder) - .is_rep1[state as usize] as ::core::ffi::c_uint) + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) + .rep_len_decoder + .high[symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep1[state as usize] as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - let distance: uint32_t = rep1; - rep1 = rep0; - rep0 = distance; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep1[state as usize] = ((*coder) - .is_rep1[state as usize] as ::core::ffi::c_int - - ((*coder).is_rep1[state as usize] as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh98 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh98 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep2[state as usize] as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).is_rep2[state as usize] = ((*coder) - .is_rep2[state as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).is_rep2[state as usize] as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - let distance_0: uint32_t = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance_0; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep2[state as usize] = ((*coder) - .is_rep2[state as usize] as ::core::ffi::c_int - - ((*coder).is_rep2[state as usize] as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - let distance_1: uint32_t = rep3; - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance_1; - } + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - } - state = (if state < LIT_STATES as uint32_t { - STATE_LIT_LONGREP as ::core::ffi::c_int - } else { - STATE_NONLIT_REP as ::core::ffi::c_int - }) as uint32_t; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh99 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh99 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).rep_len_decoder.choice as uint32_t); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.choice = ((*coder) - .rep_len_decoder - .choice as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.choice as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh100 = rc_in_ptr; + let fresh111 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh100 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh111 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) .rep_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) + .high[symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh101 = rc_in_ptr; + let fresh112 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh101 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh112 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) .rep_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) + .high[symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh102 = rc_in_ptr; + let fresh113 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh102 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh113 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] as uint32_t, - ); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder) + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) .rep_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) + .high[symbol as usize] + as c_uint) .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .rep_len_decoder - .low[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + - ((*coder).rep_len_decoder.high[symbol as usize] + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } - symbol = symbol - .wrapping_add( - (-((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + 2 as ::core::ffi::c_int) as uint32_t, - ); - len = symbol; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.choice = ((*coder) - .rep_len_decoder - .choice as ::core::ffi::c_int - - ((*coder).rep_len_decoder.choice as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - if rc.range < RC_TOP_VALUE as uint32_t { + if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh103 = rc_in_ptr; + let fresh114 = rc_in_ptr; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh103 as uint32_t; + rc.code = rc.code << RC_SHIFT_BITS | *fresh114 as u32; } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).rep_len_decoder.choice2 as uint32_t); + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, + ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice2 = ((*coder) + (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) .rep_len_decoder - .choice2 as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.choice2 as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh104 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh104 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh105 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh105 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh106 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh106 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] = ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int - - ((*coder) - .rep_len_decoder - .mid[pos_state as usize][symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - symbol = symbol + .high[symbol as usize] + as c_uint) .wrapping_add( - (-((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + 2 as ::core::ffi::c_int - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int)) - as uint32_t, - ); - len = symbol; + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high[symbol as usize] + as c_uint, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; + symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.choice2 = ((*coder) - .rep_len_decoder - .choice2 as ::core::ffi::c_int - - ((*coder).rep_len_decoder.choice2 as ::core::ffi::c_int - >> RC_MOVE_BITS)) as probability; - symbol = 1 as uint32_t; - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh107 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh107 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh108 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh108 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh109 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh109 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh110 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh110 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh111 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh111 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh112 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh112 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh113 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh113 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_int - - ((*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - if rc.range < RC_TOP_VALUE as uint32_t { - rc.range <<= RC_SHIFT_BITS; - let fresh114 = rc_in_ptr; - rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh114 as uint32_t; - } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as uint32_t, - ); - if rc.code < rc_bound { - rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as ::core::ffi::c_int; - } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] as ::core::ffi::c_int + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] + as c_int - ((*coder).rep_len_decoder.high[symbol as usize] - as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as ::core::ffi::c_int) - .wrapping_add(1 as uint32_t); - } - symbol = symbol - .wrapping_add( - (-((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) - + 2 as ::core::ffi::c_int - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int)) - as uint32_t, - ); - len = symbol; + as c_int + >> RC_MOVE_BITS)) + as probability; + symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); } + symbol = symbol.wrapping_add( + (-((1 as c_int) << 8 as c_int) + + 2 as c_int + + ((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 3 as c_int)) + as u32, + ); + len = symbol; } } } - if !(dict_repeat(&raw mut dict, rep0, &raw mut len) - as ::core::ffi::c_long != 0) - { - continue; - } - (*coder).sequence = SEQ_COPY; - current_block = 4609795085482299213; - continue 'c_9380; } + if !(dict_repeat(&raw mut dict, rep0, &raw mut len) as c_long != 0) { + continue; + } + (*coder).sequence = SEQ_COPY; + current_block = 4609795085482299213; + continue 'c_9380; } - } + }, 16690975975023747857 => { - symbol = 1 as uint32_t; + symbol = 1 as u32; current_block = 2467942631393454738; continue; } 15498320742470848828 => { - state = (if state < LIT_STATES as uint32_t { - STATE_LIT_LONGREP as ::core::ffi::c_int + state = (if state < LIT_STATES as u32 { + STATE_LIT_LONGREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int - }) as uint32_t; + STATE_NONLIT_REP as c_int + }) as u32; current_block = 12043352250568755004; continue; } 8485842003490715114 => { - symbol = 1 as uint32_t; + symbol = 1 as u32; current_block = 592696588731961849; continue; } @@ -4164,7 +3780,7 @@ unsafe extern "C" fn lzma_decode( } (*dictptr).full = dict.full; (*coder).rc = rc; - *in_pos = rc_in_ptr.offset_from(in_0) as ::core::ffi::c_long as size_t; + *in_pos = rc_in_ptr.offset_from(in_0) as c_long as size_t; (*coder).state = state as lzma_lzma_state; (*coder).rep0 = rep0; (*coder).rep1 = rep1; @@ -4180,30 +3796,24 @@ unsafe extern "C" fn lzma_decode( .uncompressed_size .wrapping_sub(dict.pos.wrapping_sub(dict_start) as lzma_vli); if (*coder).uncompressed_size == 0 as lzma_vli - && ret_0 as ::core::ffi::c_uint - == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - && ((*coder).sequence as ::core::ffi::c_uint - == SEQ_LITERAL_WRITE as ::core::ffi::c_int as ::core::ffi::c_uint - || (*coder).sequence as ::core::ffi::c_uint - == SEQ_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint - || (*coder).sequence as ::core::ffi::c_uint - == SEQ_COPY as ::core::ffi::c_int as ::core::ffi::c_uint) + && ret_0 as c_uint == LZMA_OK as c_uint + && ((*coder).sequence as c_uint == SEQ_LITERAL_WRITE as c_uint + || (*coder).sequence as c_uint == SEQ_SHORTREP as c_uint + || (*coder).sequence as c_uint == SEQ_COPY as c_uint) { ret_0 = LZMA_DATA_ERROR; } } - if ret_0 as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { - (*coder).rc.range = UINT32_MAX as uint32_t; - (*coder).rc.code = 0 as uint32_t; - (*coder).rc.init_bytes_left = 5 as uint32_t; + if ret_0 as c_uint == LZMA_STREAM_END as c_uint { + (*coder).rc.range = UINT32_MAX as u32; + (*coder).rc.code = 0 as u32; + (*coder).rc.init_bytes_left = 5 as u32; (*coder).sequence = SEQ_IS_MATCH; } return ret_0; } unsafe extern "C" fn lzma_decoder_uncompressed( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut uncompressed_size: lzma_vli, mut allow_eopm: bool, ) { @@ -4211,133 +3821,114 @@ unsafe extern "C" fn lzma_decoder_uncompressed( (*coder).uncompressed_size = uncompressed_size; (*coder).allow_eopm = allow_eopm; } -unsafe extern "C" fn lzma_decoder_reset( - mut coder_ptr: *mut ::core::ffi::c_void, - mut opt: *const ::core::ffi::c_void, -) { +unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *const c_void) { let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; let mut options: *const lzma_options_lzma = opt as *const lzma_options_lzma; - (*coder).pos_mask = ((1 as ::core::ffi::c_uint) << (*options).pb) - .wrapping_sub(1 as ::core::ffi::c_uint) as uint32_t; + (*coder).pos_mask = ((1 as c_uint) << (*options).pb).wrapping_sub(1 as c_uint) as u32; literal_init( &raw mut (*coder).literal as *mut probability, (*options).lc, (*options).lp, ); (*coder).literal_context_bits = (*options).lc; - (*coder).literal_mask = ((0x100 as ::core::ffi::c_uint) << (*options).lp) - .wrapping_sub(0x100 as ::core::ffi::c_uint >> (*options).lc) as uint32_t; + (*coder).literal_mask = + ((0x100 as c_uint) << (*options).lp).wrapping_sub(0x100 as c_uint >> (*options).lc) as u32; (*coder).state = STATE_LIT_LIT; - (*coder).rep0 = 0 as uint32_t; - (*coder).rep1 = 0 as uint32_t; - (*coder).rep2 = 0 as uint32_t; - (*coder).rep3 = 0 as uint32_t; - (*coder).pos_mask = ((1 as ::core::ffi::c_uint) << (*options).pb) - .wrapping_sub(1 as ::core::ffi::c_uint) as uint32_t; - (*coder).rc.range = UINT32_MAX as uint32_t; - (*coder).rc.code = 0 as uint32_t; - (*coder).rc.init_bytes_left = 5 as uint32_t; - let mut i: uint32_t = 0 as uint32_t; - while i < STATES as uint32_t { - let mut j: uint32_t = 0 as uint32_t; + (*coder).rep0 = 0 as u32; + (*coder).rep1 = 0 as u32; + (*coder).rep2 = 0 as u32; + (*coder).rep3 = 0 as u32; + (*coder).pos_mask = ((1 as c_uint) << (*options).pb).wrapping_sub(1 as c_uint) as u32; + (*coder).rc.range = UINT32_MAX as u32; + (*coder).rc.code = 0 as u32; + (*coder).rc.init_bytes_left = 5 as u32; + let mut i: u32 = 0 as u32; + while i < STATES as u32 { + let mut j: u32 = 0 as u32; while j <= (*coder).pos_mask { - (*coder).is_match[i as usize][j as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; - (*coder).is_rep0_long[i as usize][j as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + (*coder).is_match[i as usize][j as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep0_long[i as usize][j as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; j = j.wrapping_add(1); } - (*coder).is_rep[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).is_rep0[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).is_rep1[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).is_rep2[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; + (*coder).is_rep[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep0[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep1[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep2[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; i = i.wrapping_add(1); } - let mut i_0: uint32_t = 0 as uint32_t; - while i_0 < DIST_STATES as uint32_t { - let mut bt_i: uint32_t = 0 as uint32_t; - while bt_i < ((1 as ::core::ffi::c_int) << 6 as ::core::ffi::c_int) as uint32_t { - (*coder).dist_slot[i_0 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut i_0: u32 = 0 as u32; + while i_0 < DIST_STATES as u32 { + let mut bt_i: u32 = 0 as u32; + while bt_i < ((1 as c_int) << 6 as c_int) as u32 { + (*coder).dist_slot[i_0 as usize][bt_i as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i = bt_i.wrapping_add(1); } i_0 = i_0.wrapping_add(1); } - let mut i_1: uint32_t = 0 as uint32_t; - while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as uint32_t { - (*coder).pos_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut i_1: u32 = 0 as u32; + while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as u32 { + (*coder).pos_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; i_1 = i_1.wrapping_add(1); } - let mut bt_i_0: uint32_t = 0 as uint32_t; - while bt_i_0 < ((1 as ::core::ffi::c_int) << 4 as ::core::ffi::c_int) as uint32_t { - (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_0: u32 = 0 as u32; + while bt_i_0 < ((1 as c_int) << 4 as c_int) as u32 { + (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } - let num_pos_states: uint32_t = (1 as uint32_t) << (*options).pb; - (*coder).match_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).match_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).rep_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).rep_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - let mut pos_state: uint32_t = 0 as uint32_t; + let num_pos_states: u32 = (1 as u32) << (*options).pb; + (*coder).match_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).match_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).rep_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).rep_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + let mut pos_state: u32 = 0 as u32; while pos_state < num_pos_states { - let mut bt_i_1: uint32_t = 0 as uint32_t; - while bt_i_1 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t - { - (*coder).match_len_decoder.low[pos_state as usize][bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_1: u32 = 0 as u32; + while bt_i_1 < ((1 as c_int) << 3 as c_int) as u32 { + (*coder).match_len_decoder.low[pos_state as usize][bt_i_1 as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_1 = bt_i_1.wrapping_add(1); } - let mut bt_i_2: uint32_t = 0 as uint32_t; - while bt_i_2 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t - { - (*coder).match_len_decoder.mid[pos_state as usize][bt_i_2 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_2: u32 = 0 as u32; + while bt_i_2 < ((1 as c_int) << 3 as c_int) as u32 { + (*coder).match_len_decoder.mid[pos_state as usize][bt_i_2 as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_2 = bt_i_2.wrapping_add(1); } - let mut bt_i_3: uint32_t = 0 as uint32_t; - while bt_i_3 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t - { - (*coder).rep_len_decoder.low[pos_state as usize][bt_i_3 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_3: u32 = 0 as u32; + while bt_i_3 < ((1 as c_int) << 3 as c_int) as u32 { + (*coder).rep_len_decoder.low[pos_state as usize][bt_i_3 as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_3 = bt_i_3.wrapping_add(1); } - let mut bt_i_4: uint32_t = 0 as uint32_t; - while bt_i_4 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t - { - (*coder).rep_len_decoder.mid[pos_state as usize][bt_i_4 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_4: u32 = 0 as u32; + while bt_i_4 < ((1 as c_int) << 3 as c_int) as u32 { + (*coder).rep_len_decoder.mid[pos_state as usize][bt_i_4 as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_4 = bt_i_4.wrapping_add(1); } pos_state = pos_state.wrapping_add(1); } - let mut bt_i_5: uint32_t = 0 as uint32_t; - while bt_i_5 < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t { - (*coder).match_len_decoder.high[bt_i_5 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_5: u32 = 0 as u32; + while bt_i_5 < ((1 as c_int) << 8 as c_int) as u32 { + (*coder).match_len_decoder.high[bt_i_5 as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_5 = bt_i_5.wrapping_add(1); } - let mut bt_i_6: uint32_t = 0 as uint32_t; - while bt_i_6 < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t { - (*coder).rep_len_decoder.high[bt_i_6 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_6: u32 = 0 as u32; + while bt_i_6 < ((1 as c_int) << 8 as c_int) as u32 { + (*coder).rep_len_decoder.high[bt_i_6 as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_6 = bt_i_6.wrapping_add(1); } (*coder).sequence = SEQ_IS_MATCH; (*coder).probs = ::core::ptr::null_mut::(); - (*coder).symbol = 0 as uint32_t; - (*coder).limit = 0 as uint32_t; - (*coder).offset = 0 as uint32_t; - (*coder).len = 0 as uint32_t; + (*coder).symbol = 0 as u32; + (*coder).limit = 0 as u32; + (*coder).offset = 0 as u32; + (*coder).len = 0 as u32; } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_decoder_create( @@ -4357,42 +3948,29 @@ pub unsafe extern "C" fn lzma_lzma_decoder_create( (*lz).code = Some( lzma_decode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_dict, - *const uint8_t, + *const u8, *mut size_t, size_t, ) -> lzma_ret, ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_dict, - *const uint8_t, + *const u8, *mut size_t, size_t, ) -> lzma_ret, >; - (*lz).reset = Some( - lzma_decoder_reset - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const ::core::ffi::c_void, - ) -> (), - ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const ::core::ffi::c_void, - ) -> (), - >; + (*lz).reset = + Some(lzma_decoder_reset as unsafe extern "C" fn(*mut c_void, *const c_void) -> ()) + as Option ()>; (*lz).set_uncompressed = Some( - lzma_decoder_uncompressed - as unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), + lzma_decoder_uncompressed as unsafe extern "C" fn(*mut c_void, lzma_vli, bool) -> (), ) - as Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, lzma_vli, bool) -> (), - >; + as Option ()>; } (*lz_options).dict_size = (*options).dict_size as size_t; (*lz_options).preset_dict = (*options).preset_dict; @@ -4403,7 +3981,7 @@ unsafe extern "C" fn lzma_decoder_init( mut lz: *mut lzma_lz_decoder, mut allocator: *const lzma_allocator, mut id: lzma_vli, - mut options: *const ::core::ffi::c_void, + mut options: *const c_void, mut lz_options: *mut lzma_lz_options, ) -> lzma_ret { if !is_lclppb_valid(options as *const lzma_options_lzma) { @@ -4413,14 +3991,14 @@ unsafe extern "C" fn lzma_decoder_init( let mut allow_eopm: bool = true_0 != 0; if id == LZMA_FILTER_LZMA1EXT as lzma_vli { let mut opt: *const lzma_options_lzma = options as *const lzma_options_lzma; - if (*opt).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t) != 0 { + if (*opt).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; } - uncomp_size = ((*opt).ext_size_low as uint64_t) - .wrapping_add(((*opt).ext_size_high as uint64_t) << 32 as ::core::ffi::c_int) + uncomp_size = ((*opt).ext_size_low as u64) + .wrapping_add(((*opt).ext_size_high as u64) << 32 as c_int) as lzma_vli; - allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t - != 0 as uint32_t || uncomp_size == LZMA_VLI_UNKNOWN as lzma_vli; + allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 as u32 + || uncomp_size == LZMA_VLI_UNKNOWN as lzma_vli; } let ret_: lzma_ret = lzma_lzma_decoder_create( lz, @@ -4428,9 +4006,7 @@ unsafe extern "C" fn lzma_decoder_init( options as *const lzma_options_lzma, lz_options, ) as lzma_ret; - if ret_ as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_ as c_uint != LZMA_OK as c_uint { return ret_; } lzma_decoder_reset((*lz).coder, options); @@ -4453,7 +4029,7 @@ pub unsafe extern "C" fn lzma_lzma_decoder_init( *mut lzma_lz_decoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, ), @@ -4462,47 +4038,36 @@ pub unsafe extern "C" fn lzma_lzma_decoder_init( #[no_mangle] pub unsafe extern "C" fn lzma_lzma_lclppb_decode( mut options: *mut lzma_options_lzma, - mut byte: uint8_t, + mut byte: u8, ) -> bool { - if byte as ::core::ffi::c_int - > (4 as ::core::ffi::c_int * 5 as ::core::ffi::c_int + 4 as ::core::ffi::c_int) - * 9 as ::core::ffi::c_int + 8 as ::core::ffi::c_int - { + if byte as c_int > (4 as c_int * 5 as c_int + 4 as c_int) * 9 as c_int + 8 as c_int { return true_0 != 0; } - (*options).pb = (byte as ::core::ffi::c_int - / (9 as ::core::ffi::c_int * 5 as ::core::ffi::c_int)) as uint32_t; - byte = (byte as uint32_t) - .wrapping_sub( - (*options).pb.wrapping_mul(9 as uint32_t).wrapping_mul(5 as uint32_t), - ) as uint8_t as uint8_t; - (*options).lp = (byte as ::core::ffi::c_int / 9 as ::core::ffi::c_int) as uint32_t; - (*options).lc = (byte as uint32_t) - .wrapping_sub((*options).lp.wrapping_mul(9 as uint32_t)); - return (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX as uint32_t; + (*options).pb = (byte as c_int / (9 as c_int * 5 as c_int)) as u32; + byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9 as u32).wrapping_mul(5 as u32)) + as u8 as u8; + (*options).lp = (byte as c_int / 9 as c_int) as u32; + (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9 as u32)); + return (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX as u32; } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma_decoder_memusage_nocheck( - mut options: *const ::core::ffi::c_void, -) -> uint64_t { +pub unsafe extern "C" fn lzma_lzma_decoder_memusage_nocheck(mut options: *const c_void) -> u64 { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; - return (::core::mem::size_of::() as uint64_t) + return (::core::mem::size_of::() as u64) .wrapping_add(lzma_lz_decoder_memusage((*opt).dict_size as size_t)); } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma_decoder_memusage( - mut options: *const ::core::ffi::c_void, -) -> uint64_t { +pub unsafe extern "C" fn lzma_lzma_decoder_memusage(mut options: *const c_void) -> u64 { if !is_lclppb_valid(options as *const lzma_options_lzma) { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } return lzma_lzma_decoder_memusage_nocheck(options); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_props_decode( - mut options: *mut *mut ::core::ffi::c_void, + mut options: *mut *mut c_void, mut allocator: *const lzma_allocator, - mut props: *const uint8_t, + mut props: *const u8, mut props_size: size_t, ) -> lzma_ret { if props_size != 5 as size_t { @@ -4515,14 +4080,14 @@ pub unsafe extern "C" fn lzma_lzma_props_decode( if opt.is_null() { return LZMA_MEM_ERROR; } - if lzma_lzma_lclppb_decode(opt, *props.offset(0 as ::core::ffi::c_int as isize)) { - lzma_free(opt as *mut ::core::ffi::c_void, allocator); + if lzma_lzma_lclppb_decode(opt, *props.offset(0 as isize)) { + lzma_free(opt as *mut c_void, allocator); return LZMA_OPTIONS_ERROR; } else { - (*opt).dict_size = read32le(props.offset(1 as ::core::ffi::c_int as isize)); - (*opt).preset_dict = ::core::ptr::null::(); - (*opt).preset_dict_size = 0 as uint32_t; - *options = opt as *mut ::core::ffi::c_void; + (*opt).dict_size = read32le(props.offset(1 as isize)); + (*opt).preset_dict = ::core::ptr::null::(); + (*opt).preset_dict_size = 0 as u32; + *options = opt as *mut c_void; return LZMA_OK; }; } diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index ddc80950..7e5a94b7 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,8 +1,7 @@ +use crate::types::*; +use core::ffi::{c_int, c_long, c_uchar, c_uint, c_ulonglong, c_void}; extern "C" { - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; fn lzma_lz_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -12,39 +11,29 @@ extern "C" { *mut lzma_lz_encoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, >, ) -> lzma_ret; - fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> uint64_t; - static lzma_rc_prices: [uint8_t; 128]; + fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> u64; + static lzma_rc_prices: [u8; 128]; fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, - back_res: *mut uint32_t, - len_res: *mut uint32_t, + back_res: *mut u32, + len_res: *mut u32, ); fn lzma_lzma_optimum_normal( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, - back_res: *mut uint32_t, - len_res: *mut uint32_t, - position: uint32_t, + back_res: *mut u32, + len_res: *mut u32, + position: u32, ); - static lzma_fastpos: [uint8_t; 8192]; + static lzma_fastpos: [u8; 8192]; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -66,7 +55,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -75,132 +63,97 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, >; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -213,35 +166,35 @@ pub type lzma_filter_info = lzma_filter_info_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_match { - pub len: uint32_t, - pub dist: uint32_t, + pub len: u32, + pub dist: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_mf_s { - pub buffer: *mut uint8_t, - pub size: uint32_t, - pub keep_size_before: uint32_t, - pub keep_size_after: uint32_t, - pub offset: uint32_t, - pub read_pos: uint32_t, - pub read_ahead: uint32_t, - pub read_limit: uint32_t, - pub write_pos: uint32_t, - pub pending: uint32_t, - pub find: Option uint32_t>, - pub skip: Option ()>, - pub hash: *mut uint32_t, - pub son: *mut uint32_t, - pub cyclic_pos: uint32_t, - pub cyclic_size: uint32_t, - pub hash_mask: uint32_t, - pub depth: uint32_t, - pub nice_len: uint32_t, - pub match_len_max: uint32_t, + pub buffer: *mut u8, + pub size: u32, + pub keep_size_before: u32, + pub keep_size_after: u32, + pub offset: u32, + pub read_pos: u32, + pub read_ahead: u32, + pub read_limit: u32, + pub write_pos: u32, + pub pending: u32, + pub find: Option u32>, + pub skip: Option ()>, + pub hash: *mut u32, + pub son: *mut u32, + pub cyclic_pos: u32, + pub cyclic_size: u32, + pub hash_mask: u32, + pub depth: u32, + pub nice_len: u32, + pub match_len_max: u32, pub action: lzma_action, - pub hash_count: uint32_t, - pub sons_count: uint32_t, + pub hash_count: u32, + pub sons_count: u32, } pub type lzma_mf = lzma_mf_s; #[derive(Copy, Clone)] @@ -253,58 +206,40 @@ pub struct lzma_lz_options { pub match_len_max: size_t, pub nice_len: size_t, pub match_finder: lzma_match_finder, - pub depth: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, + pub depth: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_encoder { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub code: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut lzma_mf, - *mut uint8_t, - *mut size_t, - size_t, - ) -> lzma_ret, - >, - pub end: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), - >, - pub options_update: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_filter) -> lzma_ret, - >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + unsafe extern "C" fn(*mut c_void, *mut lzma_mf, *mut u8, *mut size_t, size_t) -> lzma_ret, >, + pub end: Option ()>, + pub options_update: Option lzma_ret>, + pub set_out_limit: Option lzma_ret>, } -pub type probability = uint16_t; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_range_encoder { - pub low: uint64_t, - pub cache_size: uint64_t, - pub range: uint32_t, - pub cache: uint8_t, - pub out_total: uint64_t, + pub low: u64, + pub cache_size: u64, + pub range: u32, + pub cache: u8, + pub out_total: u64, pub count: size_t, pub pos: size_t, pub symbols: [C2RustUnnamed; 53], pub probs: [*mut probability; 53], } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const RC_FLUSH: C2RustUnnamed = 4; pub const RC_DIRECT_1: C2RustUnnamed = 3; pub const RC_DIRECT_0: C2RustUnnamed = 2; pub const RC_BIT_1: C2RustUnnamed = 1; pub const RC_BIT_0: C2RustUnnamed = 0; -pub type lzma_lzma_state = ::core::ffi::c_uint; pub const STATE_NONLIT_REP: lzma_lzma_state = 11; pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; @@ -321,21 +256,21 @@ pub const STATE_LIT_LIT: lzma_lzma_state = 0; #[repr(C)] pub struct lzma_lzma1_encoder_s { pub rc: lzma_range_encoder, - pub uncomp_size: uint64_t, - pub out_limit: uint64_t, - pub uncomp_size_ptr: *mut uint64_t, + pub uncomp_size: u64, + pub out_limit: u64, + pub uncomp_size_ptr: *mut u64, pub state: lzma_lzma_state, - pub reps: [uint32_t; 4], + pub reps: [u32; 4], pub matches: [lzma_match; 274], - pub matches_count: uint32_t, - pub longest_match_length: uint32_t, + pub matches_count: u32, + pub longest_match_length: u32, pub fast_mode: bool, pub is_initialized: bool, pub is_flushed: bool, pub use_eopm: bool, - pub pos_mask: uint32_t, - pub literal_context_bits: uint32_t, - pub literal_mask: uint32_t, + pub pos_mask: u32, + pub literal_context_bits: u32, + pub literal_mask: u32, pub literal: [probability; 12288], pub is_match: [[probability; 16]; 12], pub is_rep: [probability; 12], @@ -348,14 +283,14 @@ pub struct lzma_lzma1_encoder_s { pub dist_align: [probability; 16], pub match_len_encoder: lzma_length_encoder, pub rep_len_encoder: lzma_length_encoder, - pub dist_slot_prices: [[uint32_t; 64]; 4], - pub dist_prices: [[uint32_t; 128]; 4], - pub dist_table_size: uint32_t, - pub match_price_count: uint32_t, - pub align_prices: [uint32_t; 16], - pub align_price_count: uint32_t, - pub opts_end_index: uint32_t, - pub opts_current_index: uint32_t, + pub dist_slot_prices: [[u32; 64]; 4], + pub dist_prices: [[u32; 128]; 4], + pub dist_table_size: u32, + pub match_price_count: u32, + pub align_prices: [u32; 16], + pub align_price_count: u32, + pub opts_end_index: u32, + pub opts_current_index: u32, pub opts: [lzma_optimal; 4096], } #[derive(Copy, Clone)] @@ -364,12 +299,12 @@ pub struct lzma_optimal { pub state: lzma_lzma_state, pub prev_1_is_literal: bool, pub prev_2: bool, - pub pos_prev_2: uint32_t, - pub back_prev_2: uint32_t, - pub price: uint32_t, - pub pos_prev: uint32_t, - pub back_prev: uint32_t, - pub backs: [uint32_t; 4], + pub pos_prev_2: u32, + pub back_prev_2: u32, + pub price: u32, + pub pos_prev: u32, + pub back_prev: u32, + pub backs: [u32; 4], } #[derive(Copy, Clone)] #[repr(C)] @@ -379,90 +314,76 @@ pub struct lzma_length_encoder { pub low: [[probability; 8]; 16], pub mid: [[probability; 8]; 16], pub high: [probability; 256], - pub prices: [[uint32_t; 272]; 16], - pub table_size: uint32_t, - pub counters: [uint32_t; 16], + pub prices: [[u32; 272]; 16], + pub table_size: u32, + pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { - *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; - *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) - as uint8_t; +unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { + *buf.offset(0 as isize) = num as u8; + *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; + *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; + *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; } -pub const LZMA_FILTER_LZMA1: ::core::ffi::c_ulonglong = 0x4000000000000001 - as ::core::ffi::c_ulonglong; -pub const LZMA_FILTER_LZMA1EXT: ::core::ffi::c_ulonglong = 0x4000000000000002 - as ::core::ffi::c_ulonglong; -pub const LZMA_LCLP_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_PB_MAX: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const LZMA_LZMA1EXT_ALLOW_EOPM: ::core::ffi::c_uint = 0x1 as ::core::ffi::c_uint; -pub const LZMA2_CHUNK_MAX: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 16 as ::core::ffi::c_int; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_LCLP_MAX: c_int = 4 as c_int; +pub const LZMA_PB_MAX: c_int = 4 as c_int; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1 as c_uint; +pub const LZMA2_CHUNK_MAX: c_uint = (1 as c_uint) << 16 as c_int; #[inline] -unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> uint32_t { - return match_finder as uint32_t & 0xf as uint32_t; +unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> u32 { + return match_finder as u32 & 0xf as u32; } #[inline] -unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { - if amount != 0 as uint32_t { +unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: u32) { + if amount != 0 as u32 { (*mf).skip.expect("non-null function pointer")(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const RC_SHIFT_BITS: ::core::ffi::c_int = 8 as ::core::ffi::c_int; -pub const RC_TOP_BITS: ::core::ffi::c_int = 24 as ::core::ffi::c_int; -pub const RC_TOP_VALUE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) << RC_TOP_BITS; -pub const RC_BIT_MODEL_TOTAL_BITS: ::core::ffi::c_int = 11 as ::core::ffi::c_int; -pub const RC_BIT_MODEL_TOTAL: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_BITS: ::core::ffi::c_int = 5 as ::core::ffi::c_int; -pub const RC_MOVE_REDUCING_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const RC_SHIFT_BITS: c_int = 8 as c_int; +pub const RC_TOP_BITS: c_int = 24 as c_int; +pub const RC_TOP_VALUE: c_uint = (1 as c_uint) << RC_TOP_BITS; +pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; +pub const RC_BIT_MODEL_TOTAL: c_uint = (1 as c_uint) << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_MOVE_BITS: c_int = 5 as c_int; +pub const RC_MOVE_REDUCING_BITS: c_int = 4 as c_int; #[inline] -unsafe extern "C" fn rc_bit_price(prob: probability, bit: uint32_t) -> uint32_t { - return lzma_rc_prices[((prob as uint32_t - ^ (0 as uint32_t).wrapping_sub(bit) - & (RC_BIT_MODEL_TOTAL as uint32_t).wrapping_sub(1 as uint32_t)) - >> RC_MOVE_REDUCING_BITS) as usize] as uint32_t; +unsafe extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { + return lzma_rc_prices[((prob as u32 + ^ (0 as u32).wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1 as u32)) + >> RC_MOVE_REDUCING_BITS) as usize] as u32; } #[inline] -unsafe extern "C" fn rc_bit_0_price(prob: probability) -> uint32_t { - return lzma_rc_prices[(prob as ::core::ffi::c_int >> RC_MOVE_REDUCING_BITS) as usize] - as uint32_t; +unsafe extern "C" fn rc_bit_0_price(prob: probability) -> u32 { + return lzma_rc_prices[(prob as c_int >> RC_MOVE_REDUCING_BITS) as usize] as u32; } #[inline] -unsafe extern "C" fn rc_bit_1_price(prob: probability) -> uint32_t { - return lzma_rc_prices[((prob as ::core::ffi::c_uint - ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1 as ::core::ffi::c_uint)) - >> RC_MOVE_REDUCING_BITS) as usize] as uint32_t; +unsafe extern "C" fn rc_bit_1_price(prob: probability) -> u32 { + return lzma_rc_prices[((prob as c_uint ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1 as c_uint)) + >> RC_MOVE_REDUCING_BITS) as usize] as u32; } #[inline] unsafe extern "C" fn rc_bittree_price( probs: *const probability, - bit_levels: uint32_t, - mut symbol: uint32_t, -) -> uint32_t { - let mut price: uint32_t = 0 as uint32_t; - symbol = (symbol as ::core::ffi::c_uint) - .wrapping_add((1 as ::core::ffi::c_uint) << bit_levels) as uint32_t as uint32_t; + bit_levels: u32, + mut symbol: u32, +) -> u32 { + let mut price: u32 = 0 as u32; + symbol = (symbol as c_uint).wrapping_add((1 as c_uint) << bit_levels) as u32 as u32; loop { - let bit: uint32_t = symbol & 1 as uint32_t; - symbol >>= 1 as ::core::ffi::c_int; + let bit: u32 = symbol & 1 as u32; + symbol >>= 1 as c_int; price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); - if !(symbol != 1 as uint32_t) { + if !(symbol != 1 as u32) { break; } } @@ -470,11 +391,11 @@ unsafe extern "C" fn rc_bittree_price( } #[inline] unsafe extern "C" fn rc_reset(mut rc: *mut lzma_range_encoder) { - (*rc).low = 0 as uint64_t; - (*rc).cache_size = 1 as uint64_t; - (*rc).range = UINT32_MAX as uint32_t; - (*rc).cache = 0 as uint8_t; - (*rc).out_total = 0 as uint64_t; + (*rc).low = 0 as u64; + (*rc).cache_size = 1 as u64; + (*rc).range = UINT32_MAX as u32; + (*rc).cache = 0 as u8; + (*rc).out_total = 0 as u64; (*rc).count = 0 as size_t; (*rc).pos = 0 as size_t; } @@ -486,7 +407,7 @@ unsafe extern "C" fn rc_forget(mut rc: *mut lzma_range_encoder) { unsafe extern "C" fn rc_bit( mut rc: *mut lzma_range_encoder, mut prob: *mut probability, - mut bit: uint32_t, + mut bit: u32, ) { (*rc).symbols[(*rc).count as usize] = bit as C2RustUnnamed; (*rc).probs[(*rc).count as usize] = prob; @@ -496,55 +417,63 @@ unsafe extern "C" fn rc_bit( unsafe extern "C" fn rc_bittree( mut rc: *mut lzma_range_encoder, mut probs: *mut probability, - mut bit_count: uint32_t, - mut symbol: uint32_t, + mut bit_count: u32, + mut symbol: u32, ) { - let mut model_index: uint32_t = 1 as uint32_t; + let mut model_index: u32 = 1 as u32; loop { bit_count = bit_count.wrapping_sub(1); - let bit: uint32_t = symbol >> bit_count & 1 as uint32_t; - rc_bit(rc, probs.offset(model_index as isize) as *mut probability, bit); - model_index = (model_index << 1 as ::core::ffi::c_int).wrapping_add(bit); - if !(bit_count != 0 as uint32_t) { + let bit: u32 = symbol >> bit_count & 1 as u32; + rc_bit( + rc, + probs.offset(model_index as isize) as *mut probability, + bit, + ); + model_index = (model_index << 1 as c_int).wrapping_add(bit); + if !(bit_count != 0 as u32) { break; } - }; + } } #[inline] unsafe extern "C" fn rc_bittree_reverse( mut rc: *mut lzma_range_encoder, mut probs: *mut probability, - mut bit_count: uint32_t, - mut symbol: uint32_t, + mut bit_count: u32, + mut symbol: u32, ) { - let mut model_index: uint32_t = 1 as uint32_t; + let mut model_index: u32 = 1 as u32; loop { - let bit: uint32_t = symbol & 1 as uint32_t; - symbol >>= 1 as ::core::ffi::c_int; - rc_bit(rc, probs.offset(model_index as isize) as *mut probability, bit); - model_index = (model_index << 1 as ::core::ffi::c_int).wrapping_add(bit); + let bit: u32 = symbol & 1 as u32; + symbol >>= 1 as c_int; + rc_bit( + rc, + probs.offset(model_index as isize) as *mut probability, + bit, + ); + model_index = (model_index << 1 as c_int).wrapping_add(bit); bit_count = bit_count.wrapping_sub(1); - if !(bit_count != 0 as uint32_t) { + if !(bit_count != 0 as u32) { break; } - }; + } } #[inline] unsafe extern "C" fn rc_direct( mut rc: *mut lzma_range_encoder, - mut value: uint32_t, - mut bit_count: uint32_t, + mut value: u32, + mut bit_count: u32, ) { loop { bit_count = bit_count.wrapping_sub(1); let fresh0 = (*rc).count; (*rc).count = (*rc).count.wrapping_add(1); - (*rc).symbols[fresh0 as usize] = (RC_DIRECT_0 as ::core::ffi::c_int as uint32_t) - .wrapping_add(value >> bit_count & 1 as uint32_t) as C2RustUnnamed; - if !(bit_count != 0 as uint32_t) { + (*rc).symbols[fresh0 as usize] = + (RC_DIRECT_0 as u32).wrapping_add(value >> bit_count & 1 as u32) as C2RustUnnamed; + if !(bit_count != 0 as u32) { break; } - }; + } } #[inline] unsafe extern "C" fn rc_flush(mut rc: *mut lzma_range_encoder) { @@ -559,108 +488,100 @@ unsafe extern "C" fn rc_flush(mut rc: *mut lzma_range_encoder) { #[inline] unsafe extern "C" fn rc_shift_low( mut rc: *mut lzma_range_encoder, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> bool { - if ((*rc).low as uint32_t) < 0xff000000 as ::core::ffi::c_uint as uint32_t - || ((*rc).low >> 32 as ::core::ffi::c_int) as uint32_t != 0 as uint32_t + if ((*rc).low as u32) < 0xff000000 as c_uint as u32 + || ((*rc).low >> 32 as c_int) as u32 != 0 as u32 { loop { if *out_pos == out_size { return true_0 != 0; } - *out.offset(*out_pos as isize) = ((*rc).cache as ::core::ffi::c_int - + ((*rc).low >> 32 as ::core::ffi::c_int) as uint8_t - as ::core::ffi::c_int) as uint8_t; + *out.offset(*out_pos as isize) = + ((*rc).cache as c_int + ((*rc).low >> 32 as c_int) as u8 as c_int) as u8; *out_pos = (*out_pos).wrapping_add(1); (*rc).out_total = (*rc).out_total.wrapping_add(1); - (*rc).cache = 0xff as uint8_t; + (*rc).cache = 0xff as u8; (*rc).cache_size = (*rc).cache_size.wrapping_sub(1); - if !((*rc).cache_size != 0 as uint64_t) { + if !((*rc).cache_size != 0 as u64) { break; } } - (*rc).cache = ((*rc).low >> 24 as ::core::ffi::c_int & 0xff as uint64_t) - as uint8_t; + (*rc).cache = ((*rc).low >> 24 as c_int & 0xff as u64) as u8; } (*rc).cache_size = (*rc).cache_size.wrapping_add(1); - (*rc).low = ((*rc).low & 0xffffff as uint64_t) << RC_SHIFT_BITS; + (*rc).low = ((*rc).low & 0xffffff as u64) << RC_SHIFT_BITS; return false_0 != 0; } #[inline] unsafe extern "C" fn rc_shift_low_dummy( - mut low: *mut uint64_t, - mut cache_size: *mut uint64_t, - mut cache: *mut uint8_t, - mut out_pos: *mut uint64_t, - mut out_size: uint64_t, + mut low: *mut u64, + mut cache_size: *mut u64, + mut cache: *mut u8, + mut out_pos: *mut u64, + mut out_size: u64, ) -> bool { - if (*low as uint32_t) < 0xff000000 as ::core::ffi::c_uint as uint32_t - || (*low >> 32 as ::core::ffi::c_int) as uint32_t != 0 as uint32_t - { + if (*low as u32) < 0xff000000 as c_uint as u32 || (*low >> 32 as c_int) as u32 != 0 as u32 { loop { if *out_pos == out_size { return true_0 != 0; } *out_pos = (*out_pos).wrapping_add(1); - *cache = 0xff as uint8_t; + *cache = 0xff as u8; *cache_size = (*cache_size).wrapping_sub(1); - if !(*cache_size != 0 as uint64_t) { + if !(*cache_size != 0 as u64) { break; } } - *cache = (*low >> 24 as ::core::ffi::c_int & 0xff as uint64_t) as uint8_t; + *cache = (*low >> 24 as c_int & 0xff as u64) as u8; } *cache_size = (*cache_size).wrapping_add(1); - *low = (*low & 0xffffff as uint64_t) << RC_SHIFT_BITS; + *low = (*low & 0xffffff as u64) << RC_SHIFT_BITS; return false_0 != 0; } #[inline] unsafe extern "C" fn rc_encode( mut rc: *mut lzma_range_encoder, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> bool { while (*rc).pos < (*rc).count { - if (*rc).range < RC_TOP_VALUE as uint32_t { + if (*rc).range < RC_TOP_VALUE as u32 { if rc_shift_low(rc, out, out_pos, out_size) { return true_0 != 0; } (*rc).range <<= RC_SHIFT_BITS; } - match (*rc).symbols[(*rc).pos as usize] as ::core::ffi::c_uint { + match (*rc).symbols[(*rc).pos as usize] as c_uint { 0 => { let mut prob: probability = *(*rc).probs[(*rc).pos as usize]; - (*rc).range = ((*rc).range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(prob as uint32_t); - prob = (prob as ::core::ffi::c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(prob as ::core::ffi::c_uint) - >> RC_MOVE_BITS, - ) as probability as probability; + (*rc).range = ((*rc).range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul(prob as u32); + prob = (prob as c_uint) + .wrapping_add(RC_BIT_MODEL_TOTAL.wrapping_sub(prob as c_uint) >> RC_MOVE_BITS) + as probability as probability; *(*rc).probs[(*rc).pos as usize] = prob; } 1 => { let mut prob_0: probability = *(*rc).probs[(*rc).pos as usize]; - let bound: uint32_t = (prob_0 as uint32_t) - .wrapping_mul((*rc).range >> RC_BIT_MODEL_TOTAL_BITS); - (*rc).low = (*rc).low.wrapping_add(bound as uint64_t); + let bound: u32 = + (prob_0 as u32).wrapping_mul((*rc).range >> RC_BIT_MODEL_TOTAL_BITS); + (*rc).low = (*rc).low.wrapping_add(bound as u64); (*rc).range = (*rc).range.wrapping_sub(bound); - prob_0 = (prob_0 as ::core::ffi::c_int - - (prob_0 as ::core::ffi::c_int >> RC_MOVE_BITS)) as probability; + prob_0 = (prob_0 as c_int - (prob_0 as c_int >> RC_MOVE_BITS)) as probability; *(*rc).probs[(*rc).pos as usize] = prob_0; } 2 => { - (*rc).range >>= 1 as ::core::ffi::c_int; + (*rc).range >>= 1 as c_int; } 3 => { - (*rc).range >>= 1 as ::core::ffi::c_int; - (*rc).low = (*rc).low.wrapping_add((*rc).range as uint64_t); + (*rc).range >>= 1 as c_int; + (*rc).low = (*rc).low.wrapping_add((*rc).range as u64); } 4 => { - (*rc).range = UINT32_MAX as uint32_t; + (*rc).range = UINT32_MAX as u32; loop { if rc_shift_low(rc, out, out_pos, out_size) { return true_0 != 0; @@ -684,16 +605,16 @@ unsafe extern "C" fn rc_encode( #[inline] unsafe extern "C" fn rc_encode_dummy( mut rc: *const lzma_range_encoder, - mut out_limit: uint64_t, + mut out_limit: u64, ) -> bool { - let mut low: uint64_t = (*rc).low; - let mut cache_size: uint64_t = (*rc).cache_size; - let mut range: uint32_t = (*rc).range; - let mut cache: uint8_t = (*rc).cache; - let mut out_pos: uint64_t = (*rc).out_total; + let mut low: u64 = (*rc).low; + let mut cache_size: u64 = (*rc).cache_size; + let mut range: u32 = (*rc).range; + let mut cache: u8 = (*rc).cache; + let mut out_pos: u64 = (*rc).out_total; let mut pos: size_t = (*rc).pos; loop { - if range < RC_TOP_VALUE as uint32_t { + if range < RC_TOP_VALUE as u32 { if rc_shift_low_dummy( &raw mut low, &raw mut cache_size, @@ -708,25 +629,23 @@ unsafe extern "C" fn rc_encode_dummy( if pos == (*rc).count { break; } - match (*rc).symbols[pos as usize] as ::core::ffi::c_uint { + match (*rc).symbols[pos as usize] as c_uint { 0 => { let mut prob: probability = *(*rc).probs[pos as usize]; - range = (range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(prob as uint32_t); + range = (range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul(prob as u32); } 1 => { let mut prob_0: probability = *(*rc).probs[pos as usize]; - let bound: uint32_t = (prob_0 as uint32_t) - .wrapping_mul(range >> RC_BIT_MODEL_TOTAL_BITS); - low = low.wrapping_add(bound as uint64_t); + let bound: u32 = (prob_0 as u32).wrapping_mul(range >> RC_BIT_MODEL_TOTAL_BITS); + low = low.wrapping_add(bound as u64); range = range.wrapping_sub(bound); } 2 => { - range >>= 1 as ::core::ffi::c_int; + range >>= 1 as c_int; } 3 => { - range >>= 1 as ::core::ffi::c_int; - low = low.wrapping_add(range as uint64_t); + range >>= 1 as c_int; + low = low.wrapping_add(range as u64); } 4 | _ => {} } @@ -748,238 +667,185 @@ unsafe extern "C" fn rc_encode_dummy( return false_0 != 0; } #[inline] -unsafe extern "C" fn rc_pending(mut rc: *const lzma_range_encoder) -> uint64_t { - return (*rc).cache_size.wrapping_add(5 as uint64_t).wrapping_sub(1 as uint64_t); +unsafe extern "C" fn rc_pending(mut rc: *const lzma_range_encoder) -> u64 { + return (*rc) + .cache_size + .wrapping_add(5 as u64) + .wrapping_sub(1 as u64); } #[inline] unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> bool { - return (*options).lc <= LZMA_LCLP_MAX as uint32_t - && (*options).lp <= LZMA_LCLP_MAX as uint32_t - && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as uint32_t - && (*options).pb <= LZMA_PB_MAX as uint32_t; + return (*options).lc <= LZMA_LCLP_MAX as u32 + && (*options).lp <= LZMA_LCLP_MAX as u32 + && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as u32 + && (*options).pb <= LZMA_PB_MAX as u32; } -pub const STATES: ::core::ffi::c_int = 12 as ::core::ffi::c_int; -pub const LIT_STATES: ::core::ffi::c_int = 7 as ::core::ffi::c_int; -pub const LITERAL_CODER_SIZE: ::core::ffi::c_uint = 0x300 as ::core::ffi::c_uint; +pub const STATES: c_int = 12 as c_int; +pub const LIT_STATES: c_int = 7 as c_int; +pub const LITERAL_CODER_SIZE: c_uint = 0x300 as c_uint; #[inline] -unsafe extern "C" fn literal_init( - mut probs: *mut probability, - mut lc: uint32_t, - mut lp: uint32_t, -) { +unsafe extern "C" fn literal_init(mut probs: *mut probability, mut lc: u32, mut lp: u32) { let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; let mut i: size_t = 0 as size_t; while i < coders { - *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; + *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; i = i.wrapping_add(1); } } -pub const MATCH_LEN_MIN: ::core::ffi::c_int = 2 as ::core::ffi::c_int; -pub const LEN_LOW_BITS: ::core::ffi::c_int = 3 as ::core::ffi::c_int; -pub const LEN_LOW_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << LEN_LOW_BITS; -pub const LEN_MID_BITS: ::core::ffi::c_int = 3 as ::core::ffi::c_int; -pub const LEN_MID_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << LEN_MID_BITS; -pub const LEN_HIGH_BITS: ::core::ffi::c_int = 8 as ::core::ffi::c_int; -pub const LEN_HIGH_SYMBOLS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << LEN_HIGH_BITS; -pub const LEN_SYMBOLS: ::core::ffi::c_int = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS - + LEN_HIGH_SYMBOLS; -pub const MATCH_LEN_MAX: ::core::ffi::c_int = MATCH_LEN_MIN + LEN_SYMBOLS - - 1 as ::core::ffi::c_int; -pub const DIST_STATES: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const DIST_SLOT_BITS: ::core::ffi::c_int = 6 as ::core::ffi::c_int; -pub const DIST_MODEL_START: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const DIST_MODEL_END: ::core::ffi::c_int = 14 as ::core::ffi::c_int; -pub const FULL_DISTANCES_BITS: ::core::ffi::c_int = DIST_MODEL_END - / 2 as ::core::ffi::c_int; -pub const FULL_DISTANCES: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const ALIGN_SIZE: ::core::ffi::c_int = (1 as ::core::ffi::c_int) << ALIGN_BITS; -pub const ALIGN_MASK: ::core::ffi::c_int = ALIGN_SIZE - 1 as ::core::ffi::c_int; -pub const REPS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const OPTS: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << 12 as ::core::ffi::c_int; -pub const FASTPOS_BITS: ::core::ffi::c_int = 13 as ::core::ffi::c_int; +pub const MATCH_LEN_MIN: c_int = 2 as c_int; +pub const LEN_LOW_BITS: c_int = 3 as c_int; +pub const LEN_LOW_SYMBOLS: c_int = (1 as c_int) << LEN_LOW_BITS; +pub const LEN_MID_BITS: c_int = 3 as c_int; +pub const LEN_MID_SYMBOLS: c_int = (1 as c_int) << LEN_MID_BITS; +pub const LEN_HIGH_BITS: c_int = 8 as c_int; +pub const LEN_HIGH_SYMBOLS: c_int = (1 as c_int) << LEN_HIGH_BITS; +pub const LEN_SYMBOLS: c_int = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS; +pub const MATCH_LEN_MAX: c_int = MATCH_LEN_MIN + LEN_SYMBOLS - 1 as c_int; +pub const DIST_STATES: c_int = 4 as c_int; +pub const DIST_SLOT_BITS: c_int = 6 as c_int; +pub const DIST_MODEL_START: c_int = 4 as c_int; +pub const DIST_MODEL_END: c_int = 14 as c_int; +pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2 as c_int; +pub const FULL_DISTANCES: c_int = (1 as c_int) << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: c_int = 4 as c_int; +pub const ALIGN_SIZE: c_int = (1 as c_int) << ALIGN_BITS; +pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1 as c_int; +pub const REPS: c_int = 4 as c_int; +pub const OPTS: c_int = (1 as c_int) << 12 as c_int; +pub const FASTPOS_BITS: c_int = 13 as c_int; #[inline] -unsafe extern "C" fn get_dist_slot(mut dist: uint32_t) -> uint32_t { - if dist - < (1 as uint32_t) - << FASTPOS_BITS - + (0 as ::core::ffi::c_int - + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - { - return lzma_fastpos[dist as usize] as uint32_t; +unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { + if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { + return lzma_fastpos[dist as usize] as u32; } - if dist - < (1 as uint32_t) - << FASTPOS_BITS - + (0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - { - return (lzma_fastpos[(dist - >> 0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { + return (lzma_fastpos + [(dist >> 0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } - return (lzma_fastpos[(dist - >> 0 as ::core::ffi::c_int - + 2 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + return (lzma_fastpos[(dist >> 0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (0 as ::core::ffi::c_int - + 2 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } #[inline] unsafe extern "C" fn literal_matched( mut rc: *mut lzma_range_encoder, mut subcoder: *mut probability, - mut match_byte: uint32_t, - mut symbol: uint32_t, + mut match_byte: u32, + mut symbol: u32, ) { - let mut offset: uint32_t = 0x100 as uint32_t; - symbol = (symbol as ::core::ffi::c_uint) - .wrapping_add((1 as ::core::ffi::c_uint) << 8 as ::core::ffi::c_int) as uint32_t - as uint32_t; + let mut offset: u32 = 0x100 as u32; + symbol = (symbol as c_uint).wrapping_add((1 as c_uint) << 8 as c_int) as u32 as u32; loop { - match_byte <<= 1 as ::core::ffi::c_int; - let match_bit: uint32_t = match_byte & offset; - let subcoder_index: uint32_t = offset + match_byte <<= 1 as c_int; + let match_bit: u32 = match_byte & offset; + let subcoder_index: u32 = offset .wrapping_add(match_bit) - .wrapping_add(symbol >> 8 as ::core::ffi::c_int); - let bit: uint32_t = symbol >> 7 as ::core::ffi::c_int & 1 as uint32_t; - rc_bit(rc, subcoder.offset(subcoder_index as isize) as *mut probability, bit); - symbol <<= 1 as ::core::ffi::c_int; + .wrapping_add(symbol >> 8 as c_int); + let bit: u32 = symbol >> 7 as c_int & 1 as u32; + rc_bit( + rc, + subcoder.offset(subcoder_index as isize) as *mut probability, + bit, + ); + symbol <<= 1 as c_int; offset &= !(match_byte ^ symbol); - if !(symbol < (1 as uint32_t) << 16 as ::core::ffi::c_int) { + if !(symbol < (1 as u32) << 16 as c_int) { break; } - }; + } } #[inline] unsafe extern "C" fn literal( mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf, - mut position: uint32_t, + mut position: u32, ) { - let cur_byte: uint8_t = *(*mf) + let cur_byte: u8 = *(*mf) .buffer .offset((*mf).read_pos.wrapping_sub((*mf).read_ahead) as isize); - let mut subcoder: *mut probability = (&raw mut (*coder).literal as *mut probability) - .offset( - (3 as uint32_t) - .wrapping_mul( - ((position << 8 as ::core::ffi::c_int) - .wrapping_add( - *(*mf) - .buffer - .offset( - (*mf) - .read_pos - .wrapping_sub((*mf).read_ahead) - .wrapping_sub(1 as uint32_t) as isize, - ) as uint32_t, - ) & (*coder).literal_mask) << (*coder).literal_context_bits, - ) as isize, - ); - if ((*coder).state as ::core::ffi::c_uint) < LIT_STATES as ::core::ffi::c_uint { - (*coder).state = (if (*coder).state as ::core::ffi::c_uint - <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - { - STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint + let mut subcoder: *mut probability = (&raw mut (*coder).literal as *mut probability).offset( + (3 as u32).wrapping_mul( + ((position << 8 as c_int).wrapping_add( + *(*mf).buffer.offset( + (*mf) + .read_pos + .wrapping_sub((*mf).read_ahead) + .wrapping_sub(1 as u32) as isize, + ) as u32, + ) & (*coder).literal_mask) + << (*coder).literal_context_bits, + ) as isize, + ); + if ((*coder).state as c_uint) < LIT_STATES as c_uint { + (*coder).state = (if (*coder).state as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { + STATE_LIT_LIT as c_uint } else { - ((*coder).state as ::core::ffi::c_uint) - .wrapping_sub(3 as ::core::ffi::c_uint) + ((*coder).state as c_uint).wrapping_sub(3 as c_uint) }) as lzma_lzma_state; - rc_bittree(&raw mut (*coder).rc, subcoder, 8 as uint32_t, cur_byte as uint32_t); + rc_bittree(&raw mut (*coder).rc, subcoder, 8 as u32, cur_byte as u32); } else { - (*coder).state = (if (*coder).state as ::core::ffi::c_uint - <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint - { - ((*coder).state as ::core::ffi::c_uint) - .wrapping_sub(3 as ::core::ffi::c_uint) + (*coder).state = (if (*coder).state as c_uint <= STATE_LIT_SHORTREP as c_uint { + ((*coder).state as c_uint).wrapping_sub(3 as c_uint) } else { - ((*coder).state as ::core::ffi::c_uint) - .wrapping_sub(6 as ::core::ffi::c_uint) + ((*coder).state as c_uint).wrapping_sub(6 as c_uint) }) as lzma_lzma_state; - let match_byte: uint8_t = *(*mf) - .buffer - .offset( - (*mf) - .read_pos - .wrapping_sub((*coder).reps[0 as ::core::ffi::c_int as usize]) - .wrapping_sub(1 as uint32_t) - .wrapping_sub((*mf).read_ahead) as isize, - ); + let match_byte: u8 = *(*mf).buffer.offset( + (*mf) + .read_pos + .wrapping_sub((*coder).reps[0 as usize]) + .wrapping_sub(1 as u32) + .wrapping_sub((*mf).read_ahead) as isize, + ); literal_matched( &raw mut (*coder).rc, subcoder, - match_byte as uint32_t, - cur_byte as uint32_t, + match_byte as u32, + cur_byte as u32, ); }; } -unsafe extern "C" fn length_update_prices( - mut lc: *mut lzma_length_encoder, - pos_state: uint32_t, -) { - let table_size: uint32_t = (*lc).table_size; +unsafe extern "C" fn length_update_prices(mut lc: *mut lzma_length_encoder, pos_state: u32) { + let table_size: u32 = (*lc).table_size; (*lc).counters[pos_state as usize] = table_size; - let a0: uint32_t = rc_bit_0_price((*lc).choice) as uint32_t; - let a1: uint32_t = rc_bit_1_price((*lc).choice) as uint32_t; - let b0: uint32_t = a1.wrapping_add(rc_bit_0_price((*lc).choice2) as uint32_t); - let b1: uint32_t = a1.wrapping_add(rc_bit_1_price((*lc).choice2) as uint32_t); - let prices: *mut uint32_t = &raw mut *(&raw mut (*lc).prices as *mut [uint32_t; 272]) - .offset(pos_state as isize) as *mut uint32_t; - let mut i: uint32_t = 0; - i = 0 as uint32_t; - while i < table_size && i < LEN_LOW_SYMBOLS as uint32_t { - *prices.offset(i as isize) = a0 - .wrapping_add( - rc_bittree_price( - &raw mut *(&raw mut (*lc).low as *mut [probability; 8]) - .offset(pos_state as isize) as *mut probability, - LEN_LOW_BITS as uint32_t, - i, - ), - ); + let a0: u32 = rc_bit_0_price((*lc).choice) as u32; + let a1: u32 = rc_bit_1_price((*lc).choice) as u32; + let b0: u32 = a1.wrapping_add(rc_bit_0_price((*lc).choice2) as u32); + let b1: u32 = a1.wrapping_add(rc_bit_1_price((*lc).choice2) as u32); + let prices: *mut u32 = + &raw mut *(&raw mut (*lc).prices as *mut [u32; 272]).offset(pos_state as isize) as *mut u32; + let mut i: u32 = 0; + i = 0 as u32; + while i < table_size && i < LEN_LOW_SYMBOLS as u32 { + *prices.offset(i as isize) = a0.wrapping_add(rc_bittree_price( + &raw mut *(&raw mut (*lc).low as *mut [probability; 8]).offset(pos_state as isize) + as *mut probability, + LEN_LOW_BITS as u32, + i, + )); i = i.wrapping_add(1); } - while i < table_size && i < (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as uint32_t { - *prices.offset(i as isize) = b0 - .wrapping_add( - rc_bittree_price( - &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]) - .offset(pos_state as isize) as *mut probability, - LEN_MID_BITS as uint32_t, - i.wrapping_sub(LEN_LOW_SYMBOLS as uint32_t), - ), - ); + while i < table_size && i < (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32 { + *prices.offset(i as isize) = b0.wrapping_add(rc_bittree_price( + &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]).offset(pos_state as isize) + as *mut probability, + LEN_MID_BITS as u32, + i.wrapping_sub(LEN_LOW_SYMBOLS as u32), + )); i = i.wrapping_add(1); } while i < table_size { - *prices.offset(i as isize) = b1 - .wrapping_add( - rc_bittree_price( - &raw mut (*lc).high as *mut probability, - LEN_HIGH_BITS as uint32_t, - i - .wrapping_sub(LEN_LOW_SYMBOLS as uint32_t) - .wrapping_sub(LEN_MID_SYMBOLS as uint32_t), - ), - ); + *prices.offset(i as isize) = b1.wrapping_add(rc_bittree_price( + &raw mut (*lc).high as *mut probability, + LEN_HIGH_BITS as u32, + i.wrapping_sub(LEN_LOW_SYMBOLS as u32) + .wrapping_sub(LEN_MID_SYMBOLS as u32), + )); i = i.wrapping_add(1); } } @@ -987,48 +853,46 @@ unsafe extern "C" fn length_update_prices( unsafe extern "C" fn length( mut rc: *mut lzma_range_encoder, mut lc: *mut lzma_length_encoder, - pos_state: uint32_t, - mut len: uint32_t, + pos_state: u32, + mut len: u32, fast_mode: bool, ) { - len = len.wrapping_sub(MATCH_LEN_MIN as uint32_t); - if len < LEN_LOW_SYMBOLS as uint32_t { - rc_bit(rc, &raw mut (*lc).choice, 0 as uint32_t); + len = len.wrapping_sub(MATCH_LEN_MIN as u32); + if len < LEN_LOW_SYMBOLS as u32 { + rc_bit(rc, &raw mut (*lc).choice, 0 as u32); rc_bittree( rc, - &raw mut *(&raw mut (*lc).low as *mut [probability; 8]) - .offset(pos_state as isize) as *mut probability, - LEN_LOW_BITS as uint32_t, + &raw mut *(&raw mut (*lc).low as *mut [probability; 8]).offset(pos_state as isize) + as *mut probability, + LEN_LOW_BITS as u32, len, ); } else { - rc_bit(rc, &raw mut (*lc).choice, 1 as uint32_t); - len = len.wrapping_sub(LEN_LOW_SYMBOLS as uint32_t); - if len < LEN_MID_SYMBOLS as uint32_t { - rc_bit(rc, &raw mut (*lc).choice2, 0 as uint32_t); + rc_bit(rc, &raw mut (*lc).choice, 1 as u32); + len = len.wrapping_sub(LEN_LOW_SYMBOLS as u32); + if len < LEN_MID_SYMBOLS as u32 { + rc_bit(rc, &raw mut (*lc).choice2, 0 as u32); rc_bittree( rc, - &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]) - .offset(pos_state as isize) as *mut probability, - LEN_MID_BITS as uint32_t, + &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]).offset(pos_state as isize) + as *mut probability, + LEN_MID_BITS as u32, len, ); } else { - rc_bit(rc, &raw mut (*lc).choice2, 1 as uint32_t); - len = len.wrapping_sub(LEN_MID_SYMBOLS as uint32_t); + rc_bit(rc, &raw mut (*lc).choice2, 1 as u32); + len = len.wrapping_sub(LEN_MID_SYMBOLS as u32); rc_bittree( rc, &raw mut (*lc).high as *mut probability, - LEN_HIGH_BITS as uint32_t, + LEN_HIGH_BITS as u32, len, ); } } if !fast_mode { - (*lc).counters[pos_state as usize] = (*lc) - .counters[pos_state as usize] - .wrapping_sub(1); - if (*lc).counters[pos_state as usize] == 0 as uint32_t { + (*lc).counters[pos_state as usize] = (*lc).counters[pos_state as usize].wrapping_sub(1); + if (*lc).counters[pos_state as usize] == 0 as u32 { length_update_prices(lc, pos_state); } } @@ -1036,16 +900,14 @@ unsafe extern "C" fn length( #[inline] unsafe extern "C" fn match_0( mut coder: *mut lzma_lzma1_encoder, - pos_state: uint32_t, - distance: uint32_t, - len: uint32_t, + pos_state: u32, + distance: u32, + len: u32, ) { - (*coder).state = (if ((*coder).state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_MATCH as ::core::ffi::c_int + (*coder).state = (if ((*coder).state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_MATCH as c_int } else { - STATE_NONLIT_MATCH as ::core::ffi::c_int + STATE_NONLIT_MATCH as c_int }) as lzma_lzma_state; length( &raw mut (*coder).rc, @@ -1054,31 +916,30 @@ unsafe extern "C" fn match_0( len, (*coder).fast_mode, ); - let dist_slot: uint32_t = get_dist_slot(distance) as uint32_t; - let dist_state: uint32_t = if len < (DIST_STATES + MATCH_LEN_MIN) as uint32_t { - len.wrapping_sub(MATCH_LEN_MIN as uint32_t) + let dist_slot: u32 = get_dist_slot(distance) as u32; + let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { + len.wrapping_sub(MATCH_LEN_MIN as u32) } else { - (DIST_STATES - 1 as ::core::ffi::c_int) as uint32_t + (DIST_STATES - 1 as c_int) as u32 }; rc_bittree( &raw mut (*coder).rc, &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) .offset(dist_state as isize) as *mut probability, - DIST_SLOT_BITS as uint32_t, + DIST_SLOT_BITS as u32, dist_slot, ); - if dist_slot >= DIST_MODEL_START as uint32_t { - let footer_bits: uint32_t = (dist_slot >> 1 as ::core::ffi::c_int) - .wrapping_sub(1 as uint32_t); - let base: uint32_t = (2 as uint32_t | dist_slot & 1 as uint32_t) << footer_bits; - let dist_reduced: uint32_t = distance.wrapping_sub(base); - if dist_slot < DIST_MODEL_END as uint32_t { + if dist_slot >= DIST_MODEL_START as u32 { + let footer_bits: u32 = (dist_slot >> 1 as c_int).wrapping_sub(1 as u32); + let base: u32 = (2 as u32 | dist_slot & 1 as u32) << footer_bits; + let dist_reduced: u32 = distance.wrapping_sub(base); + if dist_slot < DIST_MODEL_END as u32 { rc_bittree_reverse( &raw mut (*coder).rc, (&raw mut (*coder).dist_special as *mut probability) .offset(base as isize) .offset(-(dist_slot as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)), + .offset(-(1 as isize)), footer_bits, dist_reduced, ); @@ -1086,93 +947,85 @@ unsafe extern "C" fn match_0( rc_direct( &raw mut (*coder).rc, dist_reduced >> ALIGN_BITS, - footer_bits.wrapping_sub(ALIGN_BITS as uint32_t), + footer_bits.wrapping_sub(ALIGN_BITS as u32), ); rc_bittree_reverse( &raw mut (*coder).rc, &raw mut (*coder).dist_align as *mut probability, - ALIGN_BITS as uint32_t, - dist_reduced & ALIGN_MASK as uint32_t, + ALIGN_BITS as u32, + dist_reduced & ALIGN_MASK as u32, ); (*coder).align_price_count = (*coder).align_price_count.wrapping_add(1); } } - (*coder).reps[3 as ::core::ffi::c_int as usize] = (*coder) - .reps[2 as ::core::ffi::c_int as usize]; - (*coder).reps[2 as ::core::ffi::c_int as usize] = (*coder) - .reps[1 as ::core::ffi::c_int as usize]; - (*coder).reps[1 as ::core::ffi::c_int as usize] = (*coder) - .reps[0 as ::core::ffi::c_int as usize]; - (*coder).reps[0 as ::core::ffi::c_int as usize] = distance; + (*coder).reps[3 as usize] = (*coder).reps[2 as usize]; + (*coder).reps[2 as usize] = (*coder).reps[1 as usize]; + (*coder).reps[1 as usize] = (*coder).reps[0 as usize]; + (*coder).reps[0 as usize] = distance; (*coder).match_price_count = (*coder).match_price_count.wrapping_add(1); } #[inline] unsafe extern "C" fn rep_match( mut coder: *mut lzma_lzma1_encoder, - pos_state: uint32_t, - rep: uint32_t, - len: uint32_t, + pos_state: u32, + rep: u32, + len: u32, ) { - if rep == 0 as uint32_t { + if rep == 0 as u32 { rc_bit( &raw mut (*coder).rc, - (&raw mut (*coder).is_rep0 as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 0 as uint32_t, + (&raw mut (*coder).is_rep0 as *mut probability).offset((*coder).state as isize) + as *mut probability, + 0 as u32, ); rc_bit( &raw mut (*coder).rc, (&raw mut *(&raw mut (*coder).is_rep0_long as *mut [probability; 16]) .offset((*coder).state as isize) as *mut probability) .offset(pos_state as isize) as *mut probability, - (len != 1 as uint32_t) as ::core::ffi::c_int as uint32_t, + (len != 1 as u32) as u32, ); } else { - let distance: uint32_t = (*coder).reps[rep as usize]; + let distance: u32 = (*coder).reps[rep as usize]; rc_bit( &raw mut (*coder).rc, - (&raw mut (*coder).is_rep0 as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 1 as uint32_t, + (&raw mut (*coder).is_rep0 as *mut probability).offset((*coder).state as isize) + as *mut probability, + 1 as u32, ); - if rep == 1 as uint32_t { + if rep == 1 as u32 { rc_bit( &raw mut (*coder).rc, - (&raw mut (*coder).is_rep1 as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 0 as uint32_t, + (&raw mut (*coder).is_rep1 as *mut probability).offset((*coder).state as isize) + as *mut probability, + 0 as u32, ); } else { rc_bit( &raw mut (*coder).rc, - (&raw mut (*coder).is_rep1 as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 1 as uint32_t, + (&raw mut (*coder).is_rep1 as *mut probability).offset((*coder).state as isize) + as *mut probability, + 1 as u32, ); rc_bit( &raw mut (*coder).rc, - (&raw mut (*coder).is_rep2 as *mut probability) - .offset((*coder).state as isize) as *mut probability, - rep.wrapping_sub(2 as uint32_t), + (&raw mut (*coder).is_rep2 as *mut probability).offset((*coder).state as isize) + as *mut probability, + rep.wrapping_sub(2 as u32), ); - if rep == 3 as uint32_t { - (*coder).reps[3 as ::core::ffi::c_int as usize] = (*coder) - .reps[2 as ::core::ffi::c_int as usize]; + if rep == 3 as u32 { + (*coder).reps[3 as usize] = (*coder).reps[2 as usize]; } - (*coder).reps[2 as ::core::ffi::c_int as usize] = (*coder) - .reps[1 as ::core::ffi::c_int as usize]; + (*coder).reps[2 as usize] = (*coder).reps[1 as usize]; } - (*coder).reps[1 as ::core::ffi::c_int as usize] = (*coder) - .reps[0 as ::core::ffi::c_int as usize]; - (*coder).reps[0 as ::core::ffi::c_int as usize] = distance; + (*coder).reps[1 as usize] = (*coder).reps[0 as usize]; + (*coder).reps[0 as usize] = distance; } - if len == 1 as uint32_t { - (*coder).state = (if ((*coder).state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_SHORTREP as ::core::ffi::c_int + if len == 1 as u32 { + (*coder).state = (if ((*coder).state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_SHORTREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int + STATE_NONLIT_REP as c_int }) as lzma_lzma_state; } else { length( @@ -1182,30 +1035,28 @@ unsafe extern "C" fn rep_match( len, (*coder).fast_mode, ); - (*coder).state = (if ((*coder).state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_LONGREP as ::core::ffi::c_int + (*coder).state = (if ((*coder).state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_LONGREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int + STATE_NONLIT_REP as c_int }) as lzma_lzma_state; }; } unsafe extern "C" fn encode_symbol( mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf, - mut back: uint32_t, - mut len: uint32_t, - mut position: uint32_t, + mut back: u32, + mut len: u32, + mut position: u32, ) { - let pos_state: uint32_t = position & (*coder).pos_mask; - if back == UINT32_MAX as uint32_t { + let pos_state: u32 = position & (*coder).pos_mask; + if back == UINT32_MAX as u32 { rc_bit( &raw mut (*coder).rc, (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) .offset((*coder).state as isize) as *mut probability) .offset(pos_state as isize) as *mut probability, - 0 as uint32_t, + 0 as u32, ); literal(coder, mf, position); } else { @@ -1214,89 +1065,80 @@ unsafe extern "C" fn encode_symbol( (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) .offset((*coder).state as isize) as *mut probability) .offset(pos_state as isize) as *mut probability, - 1 as uint32_t, + 1 as u32, ); - if back < REPS as uint32_t { + if back < REPS as u32 { rc_bit( &raw mut (*coder).rc, - (&raw mut (*coder).is_rep as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 1 as uint32_t, + (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) + as *mut probability, + 1 as u32, ); rep_match(coder, pos_state, back, len); } else { rc_bit( &raw mut (*coder).rc, - (&raw mut (*coder).is_rep as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 0 as uint32_t, + (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) + as *mut probability, + 0 as u32, ); - match_0(coder, pos_state, back.wrapping_sub(REPS as uint32_t), len); + match_0(coder, pos_state, back.wrapping_sub(REPS as u32), len); } } (*mf).read_ahead = (*mf).read_ahead.wrapping_sub(len); } -unsafe extern "C" fn encode_init( - mut coder: *mut lzma_lzma1_encoder, - mut mf: *mut lzma_mf, -) -> bool { +unsafe extern "C" fn encode_init(mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf) -> bool { if (*mf).read_pos == (*mf).read_limit { - if (*mf).action as ::core::ffi::c_uint - == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*mf).action as c_uint == LZMA_RUN as c_uint { return false_0 != 0; } } else { - mf_skip(mf, 1 as uint32_t); - (*mf).read_ahead = 0 as uint32_t; + mf_skip(mf, 1 as u32); + (*mf).read_ahead = 0 as u32; rc_bit( &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) - .offset(0 as ::core::ffi::c_int as isize) as *mut probability) - .offset(0 as ::core::ffi::c_int as isize) as *mut probability, - 0 as uint32_t, + (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]).offset(0 as isize) + as *mut probability) + .offset(0 as isize) as *mut probability, + 0 as u32, ); rc_bittree( &raw mut (*coder).rc, - (&raw mut (*coder).literal as *mut probability) - .offset(0 as ::core::ffi::c_int as isize), - 8 as uint32_t, - *(*mf).buffer.offset(0 as ::core::ffi::c_int as isize) as uint32_t, + (&raw mut (*coder).literal as *mut probability).offset(0 as isize), + 8 as u32, + *(*mf).buffer.offset(0 as isize) as u32, ); (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(1); } (*coder).is_initialized = true_0 != 0; return true_0 != 0; } -unsafe extern "C" fn encode_eopm( - mut coder: *mut lzma_lzma1_encoder, - mut position: uint32_t, -) { - let pos_state: uint32_t = position & (*coder).pos_mask; +unsafe extern "C" fn encode_eopm(mut coder: *mut lzma_lzma1_encoder, mut position: u32) { + let pos_state: u32 = position & (*coder).pos_mask; rc_bit( &raw mut (*coder).rc, (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) .offset((*coder).state as isize) as *mut probability) .offset(pos_state as isize) as *mut probability, - 1 as uint32_t, + 1 as u32, ); rc_bit( &raw mut (*coder).rc, (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) as *mut probability, - 0 as uint32_t, + 0 as u32, ); - match_0(coder, pos_state, UINT32_MAX as uint32_t, MATCH_LEN_MIN as uint32_t); + match_0(coder, pos_state, UINT32_MAX as u32, MATCH_LEN_MIN as u32); } -pub const LOOP_INPUT_MAX: ::core::ffi::c_int = OPTS + 1 as ::core::ffi::c_int; +pub const LOOP_INPUT_MAX: c_int = OPTS + 1 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encode( mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, - mut limit: uint32_t, + mut limit: u32, ) -> lzma_ret { if !(*coder).is_initialized && !encode_init(coder, mf) { return LZMA_OK; @@ -1307,24 +1149,21 @@ pub unsafe extern "C" fn lzma_lzma_encode( if (*coder).is_flushed { return LZMA_STREAM_END; } - while !(limit != UINT32_MAX as uint32_t + while !(limit != UINT32_MAX as u32 && ((*mf).read_pos.wrapping_sub((*mf).read_ahead) >= limit - || (*out_pos as uint64_t).wrapping_add(rc_pending(&raw mut (*coder).rc)) - >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX as ::core::ffi::c_uint) - as uint64_t)) + || (*out_pos as u64).wrapping_add(rc_pending(&raw mut (*coder).rc)) + >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX as c_uint) as u64)) { if (*mf).read_pos >= (*mf).read_limit { - if (*mf).action as ::core::ffi::c_uint - == LZMA_RUN as ::core::ffi::c_int as ::core::ffi::c_uint - { + if (*mf).action as c_uint == LZMA_RUN as c_uint { return LZMA_OK; } - if (*mf).read_ahead == 0 as uint32_t { + if (*mf).read_ahead == 0 as u32 { break; } } - let mut len: uint32_t = 0; - let mut back: uint32_t = 0; + let mut len: u32 = 0; + let mut back: u32 = 0; if (*coder).fast_mode { lzma_lzma_optimum_fast(coder, mf, &raw mut back, &raw mut len); } else { @@ -1333,18 +1172,17 @@ pub unsafe extern "C" fn lzma_lzma_encode( mf, &raw mut back, &raw mut len, - (*coder).uncomp_size as uint32_t, + (*coder).uncomp_size as u32, ); } - encode_symbol(coder, mf, back, len, (*coder).uncomp_size as uint32_t); - if (*coder).out_limit != 0 as uint64_t - && rc_encode_dummy(&raw mut (*coder).rc, (*coder).out_limit) - as ::core::ffi::c_int != 0 + encode_symbol(coder, mf, back, len, (*coder).uncomp_size as u32); + if (*coder).out_limit != 0 as u64 + && rc_encode_dummy(&raw mut (*coder).rc, (*coder).out_limit) as c_int != 0 { rc_forget(&raw mut (*coder).rc); break; } else { - (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(len as uint64_t); + (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(len as u64); if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { return LZMA_OK; } @@ -1354,7 +1192,7 @@ pub unsafe extern "C" fn lzma_lzma_encode( *(*coder).uncomp_size_ptr = (*coder).uncomp_size; } if (*coder).use_eopm { - encode_eopm(coder, (*coder).uncomp_size as uint32_t); + encode_eopm(coder, (*coder).uncomp_size as u32); } rc_flush(&raw mut (*coder).rc); if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { @@ -1364,16 +1202,13 @@ pub unsafe extern "C" fn lzma_lzma_encode( return LZMA_STREAM_END; } unsafe extern "C" fn lzma_encode( - mut coder: *mut ::core::ffi::c_void, + mut coder: *mut c_void, mut mf: *mut lzma_mf, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { - if ((*mf).action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint) - as ::core::ffi::c_int as ::core::ffi::c_long != 0 - { + if ((*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint) as c_long != 0 { return LZMA_OPTIONS_ERROR; } return lzma_lzma_encode( @@ -1382,15 +1217,15 @@ unsafe extern "C" fn lzma_encode( out, out_pos, out_size, - UINT32_MAX as uint32_t, + UINT32_MAX as u32, ); } unsafe extern "C" fn lzma_lzma_set_out_limit( - mut coder_ptr: *mut ::core::ffi::c_void, - mut uncomp_size: *mut uint64_t, - mut out_limit: uint64_t, + mut coder_ptr: *mut c_void, + mut uncomp_size: *mut u64, + mut out_limit: u64, ) -> lzma_ret { - if out_limit < 6 as uint64_t { + if out_limit < 6 as u64 { return LZMA_BUF_ERROR; } let mut coder: *mut lzma_lzma1_encoder = coder_ptr as *mut lzma_lzma1_encoder; @@ -1400,13 +1235,11 @@ unsafe extern "C" fn lzma_lzma_set_out_limit( return LZMA_OK; } unsafe extern "C" fn is_options_valid(mut options: *const lzma_options_lzma) -> bool { - return is_lclppb_valid(options) as ::core::ffi::c_int != 0 - && (*options).nice_len >= MATCH_LEN_MIN as uint32_t - && (*options).nice_len <= MATCH_LEN_MAX as uint32_t - && ((*options).mode as ::core::ffi::c_uint - == LZMA_MODE_FAST as ::core::ffi::c_int as ::core::ffi::c_uint - || (*options).mode as ::core::ffi::c_uint - == LZMA_MODE_NORMAL as ::core::ffi::c_int as ::core::ffi::c_uint); + return is_lclppb_valid(options) as c_int != 0 + && (*options).nice_len >= MATCH_LEN_MIN as u32 + && (*options).nice_len <= MATCH_LEN_MAX as u32 + && ((*options).mode as c_uint == LZMA_MODE_FAST as c_uint + || (*options).mode as c_uint == LZMA_MODE_NORMAL as c_uint); } unsafe extern "C" fn set_lz_options( mut lz_options: *mut lzma_lz_options, @@ -1428,36 +1261,34 @@ unsafe extern "C" fn set_lz_options( } unsafe extern "C" fn length_encoder_reset( mut lencoder: *mut lzma_length_encoder, - num_pos_states: uint32_t, + num_pos_states: u32, fast_mode: bool, ) { - (*lencoder).choice = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) as probability; - (*lencoder).choice2 = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) as probability; + (*lencoder).choice = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*lencoder).choice2 = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; let mut pos_state: size_t = 0 as size_t; while pos_state < num_pos_states as size_t { - let mut bt_i: uint32_t = 0 as uint32_t; - while bt_i < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t { - (*lencoder).low[pos_state as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i: u32 = 0 as u32; + while bt_i < ((1 as c_int) << 3 as c_int) as u32 { + (*lencoder).low[pos_state as usize][bt_i as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i = bt_i.wrapping_add(1); } - let mut bt_i_0: uint32_t = 0 as uint32_t; - while bt_i_0 < ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) as uint32_t - { - (*lencoder).mid[pos_state as usize][bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_0: u32 = 0 as u32; + while bt_i_0 < ((1 as c_int) << 3 as c_int) as u32 { + (*lencoder).mid[pos_state as usize][bt_i_0 as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } pos_state = pos_state.wrapping_add(1); } - let mut bt_i_1: uint32_t = 0 as uint32_t; - while bt_i_1 < ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int) as uint32_t { - (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_1: u32 = 0 as u32; + while bt_i_1 < ((1 as c_int) << 8 as c_int) as u32 { + (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_1 = bt_i_1.wrapping_add(1); } if !fast_mode { - let mut pos_state_0: uint32_t = 0 as uint32_t; + let mut pos_state_0: u32 = 0 as u32; while pos_state_0 < num_pos_states { length_update_prices(lencoder, pos_state_0); pos_state_0 = pos_state_0.wrapping_add(1); @@ -1472,16 +1303,15 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( if !is_options_valid(options) { return LZMA_OPTIONS_ERROR; } - (*coder).pos_mask = ((1 as ::core::ffi::c_uint) << (*options).pb) - .wrapping_sub(1 as ::core::ffi::c_uint) as uint32_t; + (*coder).pos_mask = ((1 as c_uint) << (*options).pb).wrapping_sub(1 as c_uint) as u32; (*coder).literal_context_bits = (*options).lc; - (*coder).literal_mask = ((0x100 as ::core::ffi::c_uint) << (*options).lp) - .wrapping_sub(0x100 as ::core::ffi::c_uint >> (*options).lc) as uint32_t; + (*coder).literal_mask = + ((0x100 as c_uint) << (*options).lp).wrapping_sub(0x100 as c_uint >> (*options).lc) as u32; rc_reset(&raw mut (*coder).rc); (*coder).state = STATE_LIT_LIT; let mut i: size_t = 0 as size_t; while i < REPS as size_t { - (*coder).reps[i as usize] = 0 as uint32_t; + (*coder).reps[i as usize] = 0 as u32; i = i.wrapping_add(1); } literal_init( @@ -1493,65 +1323,57 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( while i_0 < STATES as size_t { let mut j: size_t = 0 as size_t; while j <= (*coder).pos_mask as size_t { - (*coder).is_match[i_0 as usize][j as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; - (*coder).is_rep0_long[i_0 as usize][j as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + (*coder).is_match[i_0 as usize][j as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep0_long[i_0 as usize][j as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; j = j.wrapping_add(1); } - (*coder).is_rep[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).is_rep0[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).is_rep1[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; - (*coder).is_rep2[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as ::core::ffi::c_int) - as probability; + (*coder).is_rep[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep0[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep1[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep2[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; i_0 = i_0.wrapping_add(1); } let mut i_1: size_t = 0 as size_t; while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as size_t { - (*coder).dist_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + (*coder).dist_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; i_1 = i_1.wrapping_add(1); } let mut i_2: size_t = 0 as size_t; while i_2 < DIST_STATES as size_t { - let mut bt_i: uint32_t = 0 as uint32_t; - while bt_i < ((1 as ::core::ffi::c_int) << 6 as ::core::ffi::c_int) as uint32_t { - (*coder).dist_slot[i_2 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i: u32 = 0 as u32; + while bt_i < ((1 as c_int) << 6 as c_int) as u32 { + (*coder).dist_slot[i_2 as usize][bt_i as usize] = + (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i = bt_i.wrapping_add(1); } i_2 = i_2.wrapping_add(1); } - let mut bt_i_0: uint32_t = 0 as uint32_t; - while bt_i_0 < ((1 as ::core::ffi::c_int) << 4 as ::core::ffi::c_int) as uint32_t { - (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL - >> 1 as ::core::ffi::c_int) as probability; + let mut bt_i_0: u32 = 0 as u32; + while bt_i_0 < ((1 as c_int) << 4 as c_int) as u32 { + (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } length_encoder_reset( &raw mut (*coder).match_len_encoder, - (1 as uint32_t) << (*options).pb, + (1 as u32) << (*options).pb, (*coder).fast_mode, ); length_encoder_reset( &raw mut (*coder).rep_len_encoder, - (1 as uint32_t) << (*options).pb, + (1 as u32) << (*options).pb, (*coder).fast_mode, ); - (*coder).match_price_count = UINT32_MAX.wrapping_div(2 as ::core::ffi::c_uint) - as uint32_t; - (*coder).align_price_count = UINT32_MAX.wrapping_div(2 as ::core::ffi::c_uint) - as uint32_t; - (*coder).opts_end_index = 0 as uint32_t; - (*coder).opts_current_index = 0 as uint32_t; + (*coder).match_price_count = UINT32_MAX.wrapping_div(2 as c_uint) as u32; + (*coder).align_price_count = UINT32_MAX.wrapping_div(2 as c_uint) as u32; + (*coder).opts_end_index = 0 as u32; + (*coder).opts_current_index = 0 as u32; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_create( - mut coder_ptr: *mut *mut ::core::ffi::c_void, + mut coder_ptr: *mut *mut c_void, mut allocator: *const lzma_allocator, mut id: lzma_vli, mut options: *const lzma_options_lzma, @@ -1567,52 +1389,48 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( } } let mut coder: *mut lzma_lzma1_encoder = *coder_ptr as *mut lzma_lzma1_encoder; - match (*options).mode as ::core::ffi::c_uint { + match (*options).mode as c_uint { 1 => { (*coder).fast_mode = true_0 != 0; } 2 => { (*coder).fast_mode = false_0 != 0; if (*options).dict_size - > ((1 as uint32_t) << 30 as ::core::ffi::c_int) - .wrapping_add((1 as uint32_t) << 29 as ::core::ffi::c_int) + > ((1 as u32) << 30 as c_int).wrapping_add((1 as u32) << 29 as c_int) { return LZMA_OPTIONS_ERROR; } - let mut log_size: uint32_t = 0 as uint32_t; - while (1 as uint32_t) << log_size < (*options).dict_size { + let mut log_size: u32 = 0 as u32; + while (1 as u32) << log_size < (*options).dict_size { log_size = log_size.wrapping_add(1); } - (*coder).dist_table_size = log_size.wrapping_mul(2 as uint32_t); - let nice_len: uint32_t = if mf_get_hash_bytes((*options).mf) - > (*options).nice_len - { - mf_get_hash_bytes((*options).mf) as uint32_t + (*coder).dist_table_size = log_size.wrapping_mul(2 as u32); + let nice_len: u32 = if mf_get_hash_bytes((*options).mf) > (*options).nice_len { + mf_get_hash_bytes((*options).mf) as u32 } else { (*options).nice_len }; (*coder).match_len_encoder.table_size = nice_len - .wrapping_add(1 as uint32_t) - .wrapping_sub(MATCH_LEN_MIN as uint32_t); + .wrapping_add(1 as u32) + .wrapping_sub(MATCH_LEN_MIN as u32); (*coder).rep_len_encoder.table_size = nice_len - .wrapping_add(1 as uint32_t) - .wrapping_sub(MATCH_LEN_MIN as uint32_t); + .wrapping_add(1 as u32) + .wrapping_sub(MATCH_LEN_MIN as u32); } _ => return LZMA_OPTIONS_ERROR, } - (*coder).is_initialized = !(*options).preset_dict.is_null() - && (*options).preset_dict_size > 0 as uint32_t; + (*coder).is_initialized = + !(*options).preset_dict.is_null() && (*options).preset_dict_size > 0 as u32; (*coder).is_flushed = false_0 != 0; - (*coder).uncomp_size = 0 as uint64_t; - (*coder).uncomp_size_ptr = ::core::ptr::null_mut::(); - (*coder).out_limit = 0 as uint64_t; + (*coder).uncomp_size = 0 as u64; + (*coder).uncomp_size_ptr = ::core::ptr::null_mut::(); + (*coder).out_limit = 0 as u64; (*coder).use_eopm = id == LZMA_FILTER_LZMA1 as lzma_vli; if id == LZMA_FILTER_LZMA1EXT as lzma_vli { - if (*options).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t) != 0 { + if (*options).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; } - (*coder).use_eopm = (*options).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as uint32_t - != 0 as uint32_t; + (*coder).use_eopm = (*options).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 as u32; } set_lz_options(lz_options, options); return lzma_lzma_encoder_reset(coder, options); @@ -1621,7 +1439,7 @@ unsafe extern "C" fn lzma_encoder_init( mut lz: *mut lzma_lz_encoder, mut allocator: *const lzma_allocator, mut id: lzma_vli, - mut options: *const ::core::ffi::c_void, + mut options: *const c_void, mut lz_options: *mut lzma_lz_options, ) -> lzma_ret { if options.is_null() { @@ -1630,37 +1448,26 @@ unsafe extern "C" fn lzma_encoder_init( (*lz).code = Some( lzma_encode as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_mf, - *mut uint8_t, + *mut u8, *mut size_t, size_t, ) -> lzma_ret, ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *mut lzma_mf, - *mut uint8_t, + *mut u8, *mut size_t, size_t, ) -> lzma_ret, >; (*lz).set_out_limit = Some( - lzma_lzma_set_out_limit - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, + lzma_lzma_set_out_limit as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret, ) - as Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >; + as Option lzma_ret>; return lzma_lzma_encoder_create( &raw mut (*lz).coder, allocator, @@ -1685,18 +1492,16 @@ pub unsafe extern "C" fn lzma_lzma_encoder_init( *mut lzma_lz_encoder, *const lzma_allocator, lzma_vli, - *const ::core::ffi::c_void, + *const c_void, *mut lzma_lz_options, ) -> lzma_ret, ), ); } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma_encoder_memusage( - mut options: *const ::core::ffi::c_void, -) -> uint64_t { +pub unsafe extern "C" fn lzma_lzma_encoder_memusage(mut options: *const c_void) -> u64 { if !is_options_valid(options as *const lzma_options_lzma) { - return UINT64_MAX as uint64_t; + return UINT64_MAX as u64; } let mut lz_options: lzma_lz_options = lzma_lz_options { before_size: 0, @@ -1706,38 +1511,36 @@ pub unsafe extern "C" fn lzma_lzma_encoder_memusage( nice_len: 0, match_finder: 0 as lzma_match_finder, depth: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: ::core::ptr::null::(), preset_dict_size: 0, }; set_lz_options(&raw mut lz_options, options as *const lzma_options_lzma); - let lz_memusage: uint64_t = lzma_lz_encoder_memusage(&raw mut lz_options) - as uint64_t; - if lz_memusage == UINT64_MAX as uint64_t { - return UINT64_MAX as uint64_t; + let lz_memusage: u64 = lzma_lz_encoder_memusage(&raw mut lz_options) as u64; + if lz_memusage == UINT64_MAX as u64 { + return UINT64_MAX as u64; } - return (::core::mem::size_of::() as uint64_t) - .wrapping_add(lz_memusage); + return (::core::mem::size_of::() as u64).wrapping_add(lz_memusage); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_lclppb_encode( mut options: *const lzma_options_lzma, - mut byte: *mut uint8_t, + mut byte: *mut u8, ) -> bool { if !is_lclppb_valid(options) { return true_0 != 0; } *byte = (*options) .pb - .wrapping_mul(5 as uint32_t) + .wrapping_mul(5 as u32) .wrapping_add((*options).lp) - .wrapping_mul(9 as uint32_t) - .wrapping_add((*options).lc) as uint8_t; + .wrapping_mul(9 as u32) + .wrapping_add((*options).lc) as u8; return false_0 != 0; } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_props_encode( - mut options: *const ::core::ffi::c_void, - mut out: *mut uint8_t, + mut options: *const c_void, + mut out: *mut u8, ) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; @@ -1746,14 +1549,11 @@ pub unsafe extern "C" fn lzma_lzma_props_encode( if lzma_lzma_lclppb_encode(opt, out) { return LZMA_PROG_ERROR; } - write32le(out.offset(1 as ::core::ffi::c_int as isize), (*opt).dict_size); + write32le(out.offset(1 as isize), (*opt).dict_size); return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_mode_is_supported(mut mode: lzma_mode) -> lzma_bool { - return (mode as ::core::ffi::c_uint - == LZMA_MODE_FAST as ::core::ffi::c_int as ::core::ffi::c_uint - || mode as ::core::ffi::c_uint - == LZMA_MODE_NORMAL as ::core::ffi::c_int as ::core::ffi::c_uint) - as ::core::ffi::c_int as lzma_bool; + return (mode as c_uint == LZMA_MODE_FAST as c_uint + || mode as c_uint == LZMA_MODE_NORMAL as c_uint) as lzma_bool; } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 19037dfd..9bc8c29a 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -1,22 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn memcmp( - __s1: *const ::core::ffi::c_void, - __s2: *const ::core::ffi::c_void, - __n: size_t, - ) -> ::core::ffi::c_int; - fn lzma_mf_find( - mf: *mut lzma_mf, - count: *mut uint32_t, - matches: *mut lzma_match, - ) -> uint32_t; + fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; + fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -25,58 +12,56 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_match { - pub len: uint32_t, - pub dist: uint32_t, + pub len: u32, + pub dist: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_mf_s { - pub buffer: *mut uint8_t, - pub size: uint32_t, - pub keep_size_before: uint32_t, - pub keep_size_after: uint32_t, - pub offset: uint32_t, - pub read_pos: uint32_t, - pub read_ahead: uint32_t, - pub read_limit: uint32_t, - pub write_pos: uint32_t, - pub pending: uint32_t, - pub find: Option uint32_t>, - pub skip: Option ()>, - pub hash: *mut uint32_t, - pub son: *mut uint32_t, - pub cyclic_pos: uint32_t, - pub cyclic_size: uint32_t, - pub hash_mask: uint32_t, - pub depth: uint32_t, - pub nice_len: uint32_t, - pub match_len_max: uint32_t, + pub buffer: *mut u8, + pub size: u32, + pub keep_size_before: u32, + pub keep_size_after: u32, + pub offset: u32, + pub read_pos: u32, + pub read_ahead: u32, + pub read_limit: u32, + pub write_pos: u32, + pub pending: u32, + pub find: Option u32>, + pub skip: Option ()>, + pub hash: *mut u32, + pub son: *mut u32, + pub cyclic_pos: u32, + pub cyclic_size: u32, + pub hash_mask: u32, + pub depth: u32, + pub nice_len: u32, + pub match_len_max: u32, pub action: lzma_action, - pub hash_count: uint32_t, - pub sons_count: uint32_t, + pub hash_count: u32, + pub sons_count: u32, } pub type lzma_mf = lzma_mf_s; -pub type probability = uint16_t; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_range_encoder { - pub low: uint64_t, - pub cache_size: uint64_t, - pub range: uint32_t, - pub cache: uint8_t, - pub out_total: uint64_t, + pub low: u64, + pub cache_size: u64, + pub range: u32, + pub cache: u8, + pub out_total: u64, pub count: size_t, pub pos: size_t, pub symbols: [C2RustUnnamed; 53], pub probs: [*mut probability; 53], } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const RC_FLUSH: C2RustUnnamed = 4; pub const RC_DIRECT_1: C2RustUnnamed = 3; pub const RC_DIRECT_0: C2RustUnnamed = 2; pub const RC_BIT_1: C2RustUnnamed = 1; pub const RC_BIT_0: C2RustUnnamed = 0; -pub type lzma_lzma_state = ::core::ffi::c_uint; pub const STATE_NONLIT_REP: lzma_lzma_state = 11; pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; @@ -93,21 +78,21 @@ pub const STATE_LIT_LIT: lzma_lzma_state = 0; #[repr(C)] pub struct lzma_lzma1_encoder_s { pub rc: lzma_range_encoder, - pub uncomp_size: uint64_t, - pub out_limit: uint64_t, - pub uncomp_size_ptr: *mut uint64_t, + pub uncomp_size: u64, + pub out_limit: u64, + pub uncomp_size_ptr: *mut u64, pub state: lzma_lzma_state, - pub reps: [uint32_t; 4], + pub reps: [u32; 4], pub matches: [lzma_match; 274], - pub matches_count: uint32_t, - pub longest_match_length: uint32_t, + pub matches_count: u32, + pub longest_match_length: u32, pub fast_mode: bool, pub is_initialized: bool, pub is_flushed: bool, pub use_eopm: bool, - pub pos_mask: uint32_t, - pub literal_context_bits: uint32_t, - pub literal_mask: uint32_t, + pub pos_mask: u32, + pub literal_context_bits: u32, + pub literal_mask: u32, pub literal: [probability; 12288], pub is_match: [[probability; 16]; 12], pub is_rep: [probability; 12], @@ -120,14 +105,14 @@ pub struct lzma_lzma1_encoder_s { pub dist_align: [probability; 16], pub match_len_encoder: lzma_length_encoder, pub rep_len_encoder: lzma_length_encoder, - pub dist_slot_prices: [[uint32_t; 64]; 4], - pub dist_prices: [[uint32_t; 128]; 4], - pub dist_table_size: uint32_t, - pub match_price_count: uint32_t, - pub align_prices: [uint32_t; 16], - pub align_price_count: uint32_t, - pub opts_end_index: uint32_t, - pub opts_current_index: uint32_t, + pub dist_slot_prices: [[u32; 64]; 4], + pub dist_prices: [[u32; 128]; 4], + pub dist_table_size: u32, + pub match_price_count: u32, + pub align_prices: [u32; 16], + pub align_price_count: u32, + pub opts_end_index: u32, + pub opts_current_index: u32, pub opts: [lzma_optimal; 4096], } #[derive(Copy, Clone)] @@ -136,12 +121,12 @@ pub struct lzma_optimal { pub state: lzma_lzma_state, pub prev_1_is_literal: bool, pub prev_2: bool, - pub pos_prev_2: uint32_t, - pub back_prev_2: uint32_t, - pub price: uint32_t, - pub pos_prev: uint32_t, - pub back_prev: uint32_t, - pub backs: [uint32_t; 4], + pub pos_prev_2: u32, + pub back_prev_2: u32, + pub price: u32, + pub pos_prev: u32, + pub back_prev: u32, + pub backs: [u32; 4], } #[derive(Copy, Clone)] #[repr(C)] @@ -151,38 +136,36 @@ pub struct lzma_length_encoder { pub low: [[probability; 8]; 16], pub mid: [[probability; 8]; 16], pub high: [probability; 256], - pub prices: [[uint32_t; 272]; 16], - pub table_size: uint32_t, - pub counters: [uint32_t; 16], + pub prices: [[u32; 272]; 16], + pub table_size: u32, + pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; #[inline] -unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const uint8_t { +unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); } #[inline] -unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> uint32_t { +unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> u32 { return (*mf).write_pos.wrapping_sub((*mf).read_pos); } #[inline] -unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { - if amount != 0 as uint32_t { +unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: u32) { + if amount != 0 as u32 { (*mf).skip.expect("non-null function pointer")(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const REPS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; +pub const REPS: c_int = 4 as c_int; #[inline(always)] unsafe extern "C" fn lzma_memcmplen( - mut buf1: *const uint8_t, - mut buf2: *const uint8_t, - mut len: uint32_t, - mut limit: uint32_t, -) -> uint32_t { - while len < limit - && *buf1.offset(len as isize) as ::core::ffi::c_int - == *buf2.offset(len as isize) as ::core::ffi::c_int + mut buf1: *const u8, + mut buf2: *const u8, + mut len: u32, + mut limit: u32, +) -> u32 { + while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int { len = len.wrapping_add(1); } @@ -192,13 +175,13 @@ unsafe extern "C" fn lzma_memcmplen( pub unsafe extern "C" fn lzma_lzma_optimum_fast( mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf, - mut back_res: *mut uint32_t, - mut len_res: *mut uint32_t, + mut back_res: *mut u32, + mut len_res: *mut u32, ) { - let nice_len: uint32_t = (*mf).nice_len; - let mut len_main: uint32_t = 0; - let mut matches_count: uint32_t = 0; - if (*mf).read_ahead == 0 as uint32_t { + let nice_len: u32 = (*mf).nice_len; + let mut len_main: u32 = 0; + let mut matches_count: u32 = 0; + if (*mf).read_ahead == 0 as u32 { len_main = lzma_mf_find( mf, &raw mut matches_count, @@ -208,46 +191,42 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( len_main = (*coder).longest_match_length; matches_count = (*coder).matches_count; } - let mut buf: *const uint8_t = mf_ptr(mf).offset(-(1 as ::core::ffi::c_int as isize)); - let buf_avail: uint32_t = if mf_avail(mf).wrapping_add(1 as uint32_t) - < (2 as ::core::ffi::c_int - + (((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int)) - - 1 as ::core::ffi::c_int) as uint32_t + let mut buf: *const u8 = mf_ptr(mf).offset(-(1 as isize)); + let buf_avail: u32 = if mf_avail(mf).wrapping_add(1 as u32) + < (2 as c_int + + (((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 8 as c_int)) + - 1 as c_int) as u32 { - (mf_avail(mf) as uint32_t).wrapping_add(1 as uint32_t) + (mf_avail(mf) as u32).wrapping_add(1 as u32) } else { - (2 as ::core::ffi::c_int - + (((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int)) - - 1 as ::core::ffi::c_int) as uint32_t + (2 as c_int + + (((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 8 as c_int)) + - 1 as c_int) as u32 }; - if buf_avail < 2 as uint32_t { - *back_res = UINT32_MAX as uint32_t; - *len_res = 1 as uint32_t; + if buf_avail < 2 as u32 { + *back_res = UINT32_MAX as u32; + *len_res = 1 as u32; return; } - let mut rep_len: uint32_t = 0 as uint32_t; - let mut rep_index: uint32_t = 0 as uint32_t; - let mut i: uint32_t = 0 as uint32_t; - while i < REPS as uint32_t { - let buf_back: *const uint8_t = buf + let mut rep_len: u32 = 0 as u32; + let mut rep_index: u32 = 0 as u32; + let mut i: u32 = 0 as u32; + while i < REPS as u32 { + let buf_back: *const u8 = buf .offset(-((*coder).reps[i as usize] as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - if !(*buf.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - != *buf_back.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - || *buf.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - != *buf_back.offset(1 as ::core::ffi::c_int as isize) - as ::core::ffi::c_int) + .offset(-(1 as isize)); + if !(*buf.offset(0 as isize) as c_int != *buf_back.offset(0 as isize) as c_int + || *buf.offset(1 as isize) as c_int != *buf_back.offset(1 as isize) as c_int) { - let len: uint32_t = lzma_memcmplen(buf, buf_back, 2 as uint32_t, buf_avail) - as uint32_t; + let len: u32 = lzma_memcmplen(buf, buf_back, 2 as u32, buf_avail) as u32; if len >= nice_len { *back_res = i; *len_res = len; - mf_skip(mf, len.wrapping_sub(1 as uint32_t)); + mf_skip(mf, len.wrapping_sub(1 as u32)); return; } if len > rep_len { @@ -258,61 +237,49 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( i = i.wrapping_add(1); } if len_main >= nice_len { - *back_res = (*coder) - .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] + *back_res = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize] .dist - .wrapping_add(REPS as uint32_t); + .wrapping_add(REPS as u32); *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(1 as uint32_t)); + mf_skip(mf, len_main.wrapping_sub(1 as u32)); return; } - let mut back_main: uint32_t = 0 as uint32_t; - if len_main >= 2 as uint32_t { - back_main = (*coder) - .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] - .dist; - while matches_count > 1 as uint32_t + let mut back_main: u32 = 0 as u32; + if len_main >= 2 as u32 { + back_main = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize].dist; + while matches_count > 1 as u32 && len_main - == (*coder) - .matches[matches_count.wrapping_sub(2 as uint32_t) as usize] + == (*coder).matches[matches_count.wrapping_sub(2 as u32) as usize] .len - .wrapping_add(1 as uint32_t) + .wrapping_add(1 as u32) { - if !(back_main >> 7 as ::core::ffi::c_int - > (*coder) - .matches[matches_count.wrapping_sub(2 as uint32_t) as usize] - .dist) + if !(back_main >> 7 as c_int + > (*coder).matches[matches_count.wrapping_sub(2 as u32) as usize].dist) { break; } matches_count = matches_count.wrapping_sub(1); - len_main = (*coder) - .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] - .len; - back_main = (*coder) - .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] - .dist; + len_main = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize].len; + back_main = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize].dist; } - if len_main == 2 as uint32_t && back_main >= 0x80 as uint32_t { - len_main = 1 as uint32_t; + if len_main == 2 as u32 && back_main >= 0x80 as u32 { + len_main = 1 as u32; } } - if rep_len >= 2 as uint32_t { - if rep_len.wrapping_add(1 as uint32_t) >= len_main - || rep_len.wrapping_add(2 as uint32_t) >= len_main - && back_main > (1 as uint32_t) << 9 as ::core::ffi::c_int - || rep_len.wrapping_add(3 as uint32_t) >= len_main - && back_main > (1 as uint32_t) << 15 as ::core::ffi::c_int + if rep_len >= 2 as u32 { + if rep_len.wrapping_add(1 as u32) >= len_main + || rep_len.wrapping_add(2 as u32) >= len_main && back_main > (1 as u32) << 9 as c_int + || rep_len.wrapping_add(3 as u32) >= len_main && back_main > (1 as u32) << 15 as c_int { *back_res = rep_index; *len_res = rep_len; - mf_skip(mf, rep_len.wrapping_sub(1 as uint32_t)); + mf_skip(mf, rep_len.wrapping_sub(1 as u32)); return; } } - if len_main < 2 as uint32_t || buf_avail <= 2 as uint32_t { - *back_res = UINT32_MAX as uint32_t; - *len_res = 1 as uint32_t; + if len_main < 2 as u32 || buf_avail <= 2 as u32 { + *back_res = UINT32_MAX as u32; + *len_res = 1 as u32; return; } (*coder).longest_match_length = lzma_mf_find( @@ -320,47 +287,44 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( &raw mut (*coder).matches_count, &raw mut (*coder).matches as *mut lzma_match, ); - if (*coder).longest_match_length >= 2 as uint32_t { - let new_dist: uint32_t = (*coder) - .matches[(*coder).matches_count.wrapping_sub(1 as uint32_t) as usize] - .dist; + if (*coder).longest_match_length >= 2 as u32 { + let new_dist: u32 = + (*coder).matches[(*coder).matches_count.wrapping_sub(1 as u32) as usize].dist; if (*coder).longest_match_length >= len_main && new_dist < back_main - || (*coder).longest_match_length == len_main.wrapping_add(1 as uint32_t) - && !(new_dist >> 7 as ::core::ffi::c_int > back_main) - || (*coder).longest_match_length > len_main.wrapping_add(1 as uint32_t) - || (*coder).longest_match_length.wrapping_add(1 as uint32_t) >= len_main - && len_main >= 3 as uint32_t - && back_main >> 7 as ::core::ffi::c_int > new_dist + || (*coder).longest_match_length == len_main.wrapping_add(1 as u32) + && !(new_dist >> 7 as c_int > back_main) + || (*coder).longest_match_length > len_main.wrapping_add(1 as u32) + || (*coder).longest_match_length.wrapping_add(1 as u32) >= len_main + && len_main >= 3 as u32 + && back_main >> 7 as c_int > new_dist { - *back_res = UINT32_MAX as uint32_t; - *len_res = 1 as uint32_t; + *back_res = UINT32_MAX as u32; + *len_res = 1 as u32; return; } } buf = buf.offset(1); - let limit: uint32_t = if 2 as uint32_t > len_main.wrapping_sub(1 as uint32_t) { - 2 as uint32_t + let limit: u32 = if 2 as u32 > len_main.wrapping_sub(1 as u32) { + 2 as u32 } else { - len_main.wrapping_sub(1 as uint32_t) + len_main.wrapping_sub(1 as u32) }; - let mut i_0: uint32_t = 0 as uint32_t; - while i_0 < REPS as uint32_t { + let mut i_0: u32 = 0 as u32; + while i_0 < REPS as u32 { if memcmp( - buf as *const ::core::ffi::c_void, - buf - .offset(-((*coder).reps[i_0 as usize] as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)) - as *const ::core::ffi::c_void, + buf as *const c_void, + buf.offset(-((*coder).reps[i_0 as usize] as isize)) + .offset(-(1 as isize)) as *const c_void, limit as size_t, - ) == 0 as ::core::ffi::c_int + ) == 0 as c_int { - *back_res = UINT32_MAX as uint32_t; - *len_res = 1 as uint32_t; + *back_res = UINT32_MAX as u32; + *len_res = 1 as u32; return; } i_0 = i_0.wrapping_add(1); } - *back_res = back_main.wrapping_add(REPS as uint32_t); + *back_res = back_main.wrapping_add(REPS as u32); *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(2 as uint32_t)); + mf_skip(mf, len_main.wrapping_sub(2 as u32)); } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index ed2fbb45..b1707f70 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -1,24 +1,11 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_mf_find( - mf: *mut lzma_mf, - count: *mut uint32_t, - matches: *mut lzma_match, - ) -> uint32_t; - static lzma_rc_prices: [uint8_t; 128]; - static lzma_fastpos: [uint8_t; 8192]; + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; + static lzma_rc_prices: [u8; 128]; + static lzma_fastpos: [u8; 8192]; } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -27,58 +14,56 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_match { - pub len: uint32_t, - pub dist: uint32_t, + pub len: u32, + pub dist: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_mf_s { - pub buffer: *mut uint8_t, - pub size: uint32_t, - pub keep_size_before: uint32_t, - pub keep_size_after: uint32_t, - pub offset: uint32_t, - pub read_pos: uint32_t, - pub read_ahead: uint32_t, - pub read_limit: uint32_t, - pub write_pos: uint32_t, - pub pending: uint32_t, - pub find: Option uint32_t>, - pub skip: Option ()>, - pub hash: *mut uint32_t, - pub son: *mut uint32_t, - pub cyclic_pos: uint32_t, - pub cyclic_size: uint32_t, - pub hash_mask: uint32_t, - pub depth: uint32_t, - pub nice_len: uint32_t, - pub match_len_max: uint32_t, + pub buffer: *mut u8, + pub size: u32, + pub keep_size_before: u32, + pub keep_size_after: u32, + pub offset: u32, + pub read_pos: u32, + pub read_ahead: u32, + pub read_limit: u32, + pub write_pos: u32, + pub pending: u32, + pub find: Option u32>, + pub skip: Option ()>, + pub hash: *mut u32, + pub son: *mut u32, + pub cyclic_pos: u32, + pub cyclic_size: u32, + pub hash_mask: u32, + pub depth: u32, + pub nice_len: u32, + pub match_len_max: u32, pub action: lzma_action, - pub hash_count: uint32_t, - pub sons_count: uint32_t, + pub hash_count: u32, + pub sons_count: u32, } pub type lzma_mf = lzma_mf_s; -pub type probability = uint16_t; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_range_encoder { - pub low: uint64_t, - pub cache_size: uint64_t, - pub range: uint32_t, - pub cache: uint8_t, - pub out_total: uint64_t, + pub low: u64, + pub cache_size: u64, + pub range: u32, + pub cache: u8, + pub out_total: u64, pub count: size_t, pub pos: size_t, pub symbols: [C2RustUnnamed; 53], pub probs: [*mut probability; 53], } -pub type C2RustUnnamed = ::core::ffi::c_uint; +pub type C2RustUnnamed = c_uint; pub const RC_FLUSH: C2RustUnnamed = 4; pub const RC_DIRECT_1: C2RustUnnamed = 3; pub const RC_DIRECT_0: C2RustUnnamed = 2; pub const RC_BIT_1: C2RustUnnamed = 1; pub const RC_BIT_0: C2RustUnnamed = 0; -pub type lzma_lzma_state = ::core::ffi::c_uint; pub const STATE_NONLIT_REP: lzma_lzma_state = 11; pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; @@ -95,21 +80,21 @@ pub const STATE_LIT_LIT: lzma_lzma_state = 0; #[repr(C)] pub struct lzma_lzma1_encoder_s { pub rc: lzma_range_encoder, - pub uncomp_size: uint64_t, - pub out_limit: uint64_t, - pub uncomp_size_ptr: *mut uint64_t, + pub uncomp_size: u64, + pub out_limit: u64, + pub uncomp_size_ptr: *mut u64, pub state: lzma_lzma_state, - pub reps: [uint32_t; 4], + pub reps: [u32; 4], pub matches: [lzma_match; 274], - pub matches_count: uint32_t, - pub longest_match_length: uint32_t, + pub matches_count: u32, + pub longest_match_length: u32, pub fast_mode: bool, pub is_initialized: bool, pub is_flushed: bool, pub use_eopm: bool, - pub pos_mask: uint32_t, - pub literal_context_bits: uint32_t, - pub literal_mask: uint32_t, + pub pos_mask: u32, + pub literal_context_bits: u32, + pub literal_mask: u32, pub literal: [probability; 12288], pub is_match: [[probability; 16]; 12], pub is_rep: [probability; 12], @@ -122,14 +107,14 @@ pub struct lzma_lzma1_encoder_s { pub dist_align: [probability; 16], pub match_len_encoder: lzma_length_encoder, pub rep_len_encoder: lzma_length_encoder, - pub dist_slot_prices: [[uint32_t; 64]; 4], - pub dist_prices: [[uint32_t; 128]; 4], - pub dist_table_size: uint32_t, - pub match_price_count: uint32_t, - pub align_prices: [uint32_t; 16], - pub align_price_count: uint32_t, - pub opts_end_index: uint32_t, - pub opts_current_index: uint32_t, + pub dist_slot_prices: [[u32; 64]; 4], + pub dist_prices: [[u32; 128]; 4], + pub dist_table_size: u32, + pub match_price_count: u32, + pub align_prices: [u32; 16], + pub align_price_count: u32, + pub opts_end_index: u32, + pub opts_current_index: u32, pub opts: [lzma_optimal; 4096], } #[derive(Copy, Clone)] @@ -138,12 +123,12 @@ pub struct lzma_optimal { pub state: lzma_lzma_state, pub prev_1_is_literal: bool, pub prev_2: bool, - pub pos_prev_2: uint32_t, - pub back_prev_2: uint32_t, - pub price: uint32_t, - pub pos_prev: uint32_t, - pub back_prev: uint32_t, - pub backs: [uint32_t; 4], + pub pos_prev_2: u32, + pub back_prev_2: u32, + pub price: u32, + pub pos_prev: u32, + pub back_prev: u32, + pub backs: [u32; 4], } #[derive(Copy, Clone)] #[repr(C)] @@ -153,68 +138,62 @@ pub struct lzma_length_encoder { pub low: [[probability; 8]; 16], pub mid: [[probability; 8]; 16], pub high: [probability; 256], - pub prices: [[uint32_t; 272]; 16], - pub table_size: uint32_t, - pub counters: [uint32_t; 16], + pub prices: [[u32; 272]; 16], + pub table_size: u32, + pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const UINT32_MAX: ::core::ffi::c_uint = 4294967295 as ::core::ffi::c_uint; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const uint8_t { +unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); } #[inline] -unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> uint32_t { +unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> u32 { return (*mf).write_pos.wrapping_sub((*mf).read_pos); } #[inline] -unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: uint32_t) { - if amount != 0 as uint32_t { +unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: u32) { + if amount != 0 as u32 { (*mf).skip.expect("non-null function pointer")(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const RC_BIT_MODEL_TOTAL_BITS: ::core::ffi::c_int = 11 as ::core::ffi::c_int; -pub const RC_BIT_MODEL_TOTAL: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_REDUCING_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const RC_BIT_PRICE_SHIFT_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const RC_INFINITY_PRICE: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 30 as ::core::ffi::c_int; +pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; +pub const RC_BIT_MODEL_TOTAL: c_uint = (1 as c_uint) << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_MOVE_REDUCING_BITS: c_int = 4 as c_int; +pub const RC_BIT_PRICE_SHIFT_BITS: c_int = 4 as c_int; +pub const RC_INFINITY_PRICE: c_uint = (1 as c_uint) << 30 as c_int; #[inline] -unsafe extern "C" fn rc_bit_price(prob: probability, bit: uint32_t) -> uint32_t { - return lzma_rc_prices[((prob as uint32_t - ^ (0 as uint32_t).wrapping_sub(bit) - & (RC_BIT_MODEL_TOTAL as uint32_t).wrapping_sub(1 as uint32_t)) - >> RC_MOVE_REDUCING_BITS) as usize] as uint32_t; +unsafe extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { + return lzma_rc_prices[((prob as u32 + ^ (0 as u32).wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1 as u32)) + >> RC_MOVE_REDUCING_BITS) as usize] as u32; } #[inline] -unsafe extern "C" fn rc_bit_0_price(prob: probability) -> uint32_t { - return lzma_rc_prices[(prob as ::core::ffi::c_int >> RC_MOVE_REDUCING_BITS) as usize] - as uint32_t; +unsafe extern "C" fn rc_bit_0_price(prob: probability) -> u32 { + return lzma_rc_prices[(prob as c_int >> RC_MOVE_REDUCING_BITS) as usize] as u32; } #[inline] -unsafe extern "C" fn rc_bit_1_price(prob: probability) -> uint32_t { - return lzma_rc_prices[((prob as ::core::ffi::c_uint - ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1 as ::core::ffi::c_uint)) - >> RC_MOVE_REDUCING_BITS) as usize] as uint32_t; +unsafe extern "C" fn rc_bit_1_price(prob: probability) -> u32 { + return lzma_rc_prices[((prob as c_uint ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1 as c_uint)) + >> RC_MOVE_REDUCING_BITS) as usize] as u32; } #[inline] unsafe extern "C" fn rc_bittree_price( probs: *const probability, - bit_levels: uint32_t, - mut symbol: uint32_t, -) -> uint32_t { - let mut price: uint32_t = 0 as uint32_t; - symbol = (symbol as ::core::ffi::c_uint) - .wrapping_add((1 as ::core::ffi::c_uint) << bit_levels) as uint32_t as uint32_t; + bit_levels: u32, + mut symbol: u32, +) -> u32 { + let mut price: u32 = 0 as u32; + symbol = (symbol as c_uint).wrapping_add((1 as c_uint) << bit_levels) as u32 as u32; loop { - let bit: uint32_t = symbol & 1 as uint32_t; - symbol >>= 1 as ::core::ffi::c_int; + let bit: u32 = symbol & 1 as u32; + symbol >>= 1 as c_int; price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); - if !(symbol != 1 as uint32_t) { + if !(symbol != 1 as u32) { break; } } @@ -223,145 +202,106 @@ unsafe extern "C" fn rc_bittree_price( #[inline] unsafe extern "C" fn rc_bittree_reverse_price( probs: *const probability, - mut bit_levels: uint32_t, - mut symbol: uint32_t, -) -> uint32_t { - let mut price: uint32_t = 0 as uint32_t; - let mut model_index: uint32_t = 1 as uint32_t; + mut bit_levels: u32, + mut symbol: u32, +) -> u32 { + let mut price: u32 = 0 as u32; + let mut model_index: u32 = 1 as u32; loop { - let bit: uint32_t = symbol & 1 as uint32_t; - symbol >>= 1 as ::core::ffi::c_int; - price = price - .wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); - model_index = (model_index << 1 as ::core::ffi::c_int).wrapping_add(bit); + let bit: u32 = symbol & 1 as u32; + symbol >>= 1 as c_int; + price = price.wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); + model_index = (model_index << 1 as c_int).wrapping_add(bit); bit_levels = bit_levels.wrapping_sub(1); - if !(bit_levels != 0 as uint32_t) { + if !(bit_levels != 0 as u32) { break; } } return price; } #[inline] -unsafe extern "C" fn rc_direct_price(bits: uint32_t) -> uint32_t { +unsafe extern "C" fn rc_direct_price(bits: u32) -> u32 { return bits << RC_BIT_PRICE_SHIFT_BITS; } -pub const LIT_STATES: ::core::ffi::c_int = 7 as ::core::ffi::c_int; -pub const MATCH_LEN_MIN: ::core::ffi::c_int = 2 as ::core::ffi::c_int; -pub const DIST_STATES: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const DIST_SLOT_BITS: ::core::ffi::c_int = 6 as ::core::ffi::c_int; -pub const DIST_MODEL_START: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const DIST_MODEL_END: ::core::ffi::c_int = 14 as ::core::ffi::c_int; -pub const FULL_DISTANCES_BITS: ::core::ffi::c_int = DIST_MODEL_END - / 2 as ::core::ffi::c_int; -pub const FULL_DISTANCES: ::core::ffi::c_int = (1 as ::core::ffi::c_int) - << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const ALIGN_SIZE: ::core::ffi::c_int = (1 as ::core::ffi::c_int) << ALIGN_BITS; -pub const ALIGN_MASK: ::core::ffi::c_int = ALIGN_SIZE - 1 as ::core::ffi::c_int; -pub const REPS: ::core::ffi::c_int = 4 as ::core::ffi::c_int; -pub const FASTPOS_BITS: ::core::ffi::c_int = 13 as ::core::ffi::c_int; +pub const LIT_STATES: c_int = 7 as c_int; +pub const MATCH_LEN_MIN: c_int = 2 as c_int; +pub const DIST_STATES: c_int = 4 as c_int; +pub const DIST_SLOT_BITS: c_int = 6 as c_int; +pub const DIST_MODEL_START: c_int = 4 as c_int; +pub const DIST_MODEL_END: c_int = 14 as c_int; +pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2 as c_int; +pub const FULL_DISTANCES: c_int = (1 as c_int) << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: c_int = 4 as c_int; +pub const ALIGN_SIZE: c_int = (1 as c_int) << ALIGN_BITS; +pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1 as c_int; +pub const REPS: c_int = 4 as c_int; +pub const FASTPOS_BITS: c_int = 13 as c_int; #[inline] -unsafe extern "C" fn get_dist_slot(mut dist: uint32_t) -> uint32_t { - if dist - < (1 as uint32_t) - << FASTPOS_BITS - + (0 as ::core::ffi::c_int - + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - { - return lzma_fastpos[dist as usize] as uint32_t; +unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { + if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { + return lzma_fastpos[dist as usize] as u32; } - if dist - < (1 as uint32_t) - << FASTPOS_BITS - + (0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - { - return (lzma_fastpos[(dist - >> 0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { + return (lzma_fastpos + [(dist >> 0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (0 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } - return (lzma_fastpos[(dist - >> 0 as ::core::ffi::c_int - + 2 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + return (lzma_fastpos[(dist >> 0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (0 as ::core::ffi::c_int - + 2 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } #[inline] -unsafe extern "C" fn get_dist_slot_2(mut dist: uint32_t) -> uint32_t { +unsafe extern "C" fn get_dist_slot_2(mut dist: u32) -> u32 { if dist - < (1 as uint32_t) + < (1 as u32) << FASTPOS_BITS - + (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - - 1 as ::core::ffi::c_int - + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + + (14 as c_int / 2 as c_int - 1 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { return (lzma_fastpos[(dist - >> 14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - - 1 as ::core::ffi::c_int - + 0 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + >> 14 as c_int / 2 as c_int - 1 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) + as usize] as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - - 1 as ::core::ffi::c_int - + 0 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int + * (14 as c_int / 2 as c_int - 1 as c_int + + 0 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } if dist - < (1 as uint32_t) + < (1 as u32) << FASTPOS_BITS - + (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - - 1 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) + + (14 as c_int / 2 as c_int - 1 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { return (lzma_fastpos[(dist - >> 14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - - 1 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + >> 14 as c_int / 2 as c_int - 1 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) + as usize] as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - - 1 as ::core::ffi::c_int - + 1 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int + * (14 as c_int / 2 as c_int - 1 as c_int + + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } return (lzma_fastpos[(dist - >> 14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - 1 as ::core::ffi::c_int - + 2 as ::core::ffi::c_int * (FASTPOS_BITS - 1 as ::core::ffi::c_int)) - as usize] as uint32_t) + >> 14 as c_int / 2 as c_int - 1 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) + as usize] as u32) .wrapping_add( - (2 as ::core::ffi::c_int - * (14 as ::core::ffi::c_int / 2 as ::core::ffi::c_int - - 1 as ::core::ffi::c_int - + 2 as ::core::ffi::c_int - * (FASTPOS_BITS - 1 as ::core::ffi::c_int))) as uint32_t, + (2 as c_int + * (14 as c_int / 2 as c_int - 1 as c_int + + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } #[inline(always)] unsafe extern "C" fn lzma_memcmplen( - mut buf1: *const uint8_t, - mut buf2: *const uint8_t, - mut len: uint32_t, - mut limit: uint32_t, -) -> uint32_t { - while len < limit - && *buf1.offset(len as isize) as ::core::ffi::c_int - == *buf2.offset(len as isize) as ::core::ffi::c_int + mut buf1: *const u8, + mut buf2: *const u8, + mut len: u32, + mut limit: u32, +) -> u32 { + while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int { len = len.wrapping_add(1); } @@ -369,43 +309,35 @@ unsafe extern "C" fn lzma_memcmplen( } unsafe extern "C" fn get_literal_price( coder: *const lzma_lzma1_encoder, - pos: uint32_t, - prev_byte: uint32_t, + pos: u32, + prev_byte: u32, match_mode: bool, - mut match_byte: uint32_t, - mut symbol: uint32_t, -) -> uint32_t { - let subcoder: *const probability = (&raw const (*coder).literal - as *const probability) - .offset( - (3 as uint32_t) - .wrapping_mul( - ((pos << 8 as ::core::ffi::c_int).wrapping_add(prev_byte) - & (*coder).literal_mask) << (*coder).literal_context_bits, - ) as isize, - ); - let mut price: uint32_t = 0 as uint32_t; + mut match_byte: u32, + mut symbol: u32, +) -> u32 { + let subcoder: *const probability = + (&raw const (*coder).literal as *const probability).offset((3 as u32).wrapping_mul( + ((pos << 8 as c_int).wrapping_add(prev_byte) & (*coder).literal_mask) + << (*coder).literal_context_bits, + ) as isize); + let mut price: u32 = 0 as u32; if !match_mode { - price = rc_bittree_price(subcoder, 8 as uint32_t, symbol); + price = rc_bittree_price(subcoder, 8 as u32, symbol); } else { - let mut offset: uint32_t = 0x100 as uint32_t; - symbol = (symbol as ::core::ffi::c_uint) - .wrapping_add((1 as ::core::ffi::c_uint) << 8 as ::core::ffi::c_int) - as uint32_t as uint32_t; + let mut offset: u32 = 0x100 as u32; + symbol = (symbol as c_uint).wrapping_add((1 as c_uint) << 8 as c_int) as u32 as u32; loop { - match_byte <<= 1 as ::core::ffi::c_int; - let match_bit: uint32_t = match_byte & offset; - let subcoder_index: uint32_t = offset + match_byte <<= 1 as c_int; + let match_bit: u32 = match_byte & offset; + let subcoder_index: u32 = offset .wrapping_add(match_bit) - .wrapping_add(symbol >> 8 as ::core::ffi::c_int); - let bit: uint32_t = symbol >> 7 as ::core::ffi::c_int & 1 as uint32_t; - price = price - .wrapping_add( - rc_bit_price(*subcoder.offset(subcoder_index as isize), bit), - ); - symbol <<= 1 as ::core::ffi::c_int; + .wrapping_add(symbol >> 8 as c_int); + let bit: u32 = symbol >> 7 as c_int & 1 as u32; + price = + price.wrapping_add(rc_bit_price(*subcoder.offset(subcoder_index as isize), bit)); + symbol <<= 1 as c_int; offset &= !(match_byte ^ symbol); - if !(symbol < (1 as uint32_t) << 16 as ::core::ffi::c_int) { + if !(symbol < (1 as u32) << 16 as c_int) { break; } } @@ -415,51 +347,44 @@ unsafe extern "C" fn get_literal_price( #[inline] unsafe extern "C" fn get_len_price( lencoder: *const lzma_length_encoder, - len: uint32_t, - pos_state: uint32_t, -) -> uint32_t { - return (*lencoder) - .prices[pos_state - as usize][len.wrapping_sub(MATCH_LEN_MIN as uint32_t) as usize]; + len: u32, + pos_state: u32, +) -> u32 { + return (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN as u32) as usize]; } #[inline] unsafe extern "C" fn get_short_rep_price( coder: *const lzma_lzma1_encoder, state: lzma_lzma_state, - pos_state: uint32_t, -) -> uint32_t { - return rc_bit_0_price((*coder).is_rep0[state as usize]) - .wrapping_add( - rc_bit_0_price((*coder).is_rep0_long[state as usize][pos_state as usize]), - ); + pos_state: u32, +) -> u32 { + return rc_bit_0_price((*coder).is_rep0[state as usize]).wrapping_add(rc_bit_0_price( + (*coder).is_rep0_long[state as usize][pos_state as usize], + )); } #[inline] unsafe extern "C" fn get_pure_rep_price( coder: *const lzma_lzma1_encoder, - rep_index: uint32_t, + rep_index: u32, state: lzma_lzma_state, - mut pos_state: uint32_t, -) -> uint32_t { - let mut price: uint32_t = 0; - if rep_index == 0 as uint32_t { + mut pos_state: u32, +) -> u32 { + let mut price: u32 = 0; + if rep_index == 0 as u32 { price = rc_bit_0_price((*coder).is_rep0[state as usize]); - price = price - .wrapping_add( - rc_bit_1_price((*coder).is_rep0_long[state as usize][pos_state as usize]), - ); + price = price.wrapping_add(rc_bit_1_price( + (*coder).is_rep0_long[state as usize][pos_state as usize], + )); } else { price = rc_bit_1_price((*coder).is_rep0[state as usize]); - if rep_index == 1 as uint32_t { + if rep_index == 1 as u32 { price = price.wrapping_add(rc_bit_0_price((*coder).is_rep1[state as usize])); } else { price = price.wrapping_add(rc_bit_1_price((*coder).is_rep1[state as usize])); - price = price - .wrapping_add( - rc_bit_price( - (*coder).is_rep2[state as usize], - rep_index.wrapping_sub(2 as uint32_t), - ), - ); + price = price.wrapping_add(rc_bit_price( + (*coder).is_rep2[state as usize], + rep_index.wrapping_sub(2 as u32), + )); } } return price; @@ -467,188 +392,173 @@ unsafe extern "C" fn get_pure_rep_price( #[inline] unsafe extern "C" fn get_rep_price( coder: *const lzma_lzma1_encoder, - rep_index: uint32_t, - len: uint32_t, + rep_index: u32, + len: u32, state: lzma_lzma_state, - pos_state: uint32_t, -) -> uint32_t { + pos_state: u32, +) -> u32 { return get_len_price(&raw const (*coder).rep_len_encoder, len, pos_state) .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state)); } #[inline] unsafe extern "C" fn get_dist_len_price( coder: *const lzma_lzma1_encoder, - dist: uint32_t, - len: uint32_t, - pos_state: uint32_t, -) -> uint32_t { - let dist_state: uint32_t = if len < (DIST_STATES + MATCH_LEN_MIN) as uint32_t { - len.wrapping_sub(MATCH_LEN_MIN as uint32_t) + dist: u32, + len: u32, + pos_state: u32, +) -> u32 { + let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { + len.wrapping_sub(MATCH_LEN_MIN as u32) } else { - (DIST_STATES - 1 as ::core::ffi::c_int) as uint32_t + (DIST_STATES - 1 as c_int) as u32 }; - let mut price: uint32_t = 0; - if dist < FULL_DISTANCES as uint32_t { + let mut price: u32 = 0; + if dist < FULL_DISTANCES as u32 { price = (*coder).dist_prices[dist_state as usize][dist as usize]; } else { - let dist_slot: uint32_t = get_dist_slot_2(dist) as uint32_t; - price = (*coder) - .dist_slot_prices[dist_state as usize][dist_slot as usize] - .wrapping_add( - (*coder).align_prices[(dist & ALIGN_MASK as uint32_t) as usize], - ); + let dist_slot: u32 = get_dist_slot_2(dist) as u32; + price = (*coder).dist_slot_prices[dist_state as usize][dist_slot as usize] + .wrapping_add((*coder).align_prices[(dist & ALIGN_MASK as u32) as usize]); } - price = price - .wrapping_add( - get_len_price(&raw const (*coder).match_len_encoder, len, pos_state), - ); + price = price.wrapping_add(get_len_price( + &raw const (*coder).match_len_encoder, + len, + pos_state, + )); return price; } unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { - let mut dist_state: uint32_t = 0 as uint32_t; - while dist_state < DIST_STATES as uint32_t { - let dist_slot_prices: *mut uint32_t = &raw mut *(&raw mut (*coder) - .dist_slot_prices as *mut [uint32_t; 64]) - .offset(dist_state as isize) as *mut uint32_t; - let mut dist_slot: uint32_t = 0 as uint32_t; + let mut dist_state: u32 = 0 as u32; + while dist_state < DIST_STATES as u32 { + let dist_slot_prices: *mut u32 = &raw mut *(&raw mut (*coder).dist_slot_prices + as *mut [u32; 64]) + .offset(dist_state as isize) as *mut u32; + let mut dist_slot: u32 = 0 as u32; while dist_slot < (*coder).dist_table_size { *dist_slot_prices.offset(dist_slot as isize) = rc_bittree_price( &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) .offset(dist_state as isize) as *mut probability, - DIST_SLOT_BITS as uint32_t, + DIST_SLOT_BITS as u32, dist_slot, ); dist_slot = dist_slot.wrapping_add(1); } - let mut dist_slot_0: uint32_t = DIST_MODEL_END as uint32_t; + let mut dist_slot_0: u32 = DIST_MODEL_END as u32; while dist_slot_0 < (*coder).dist_table_size { let ref mut fresh1 = *dist_slot_prices.offset(dist_slot_0 as isize); - *fresh1 = (*fresh1) - .wrapping_add( - rc_direct_price( - (dist_slot_0 >> 1 as ::core::ffi::c_int) - .wrapping_sub(1 as uint32_t) - .wrapping_sub(ALIGN_BITS as uint32_t), - ), - ); + *fresh1 = (*fresh1).wrapping_add(rc_direct_price( + (dist_slot_0 >> 1 as c_int) + .wrapping_sub(1 as u32) + .wrapping_sub(ALIGN_BITS as u32), + )); dist_slot_0 = dist_slot_0.wrapping_add(1); } - let mut i: uint32_t = 0 as uint32_t; - while i < DIST_MODEL_START as uint32_t { - (*coder).dist_prices[dist_state as usize][i as usize] = *dist_slot_prices - .offset(i as isize); + let mut i: u32 = 0 as u32; + while i < DIST_MODEL_START as u32 { + (*coder).dist_prices[dist_state as usize][i as usize] = + *dist_slot_prices.offset(i as isize); i = i.wrapping_add(1); } dist_state = dist_state.wrapping_add(1); } - let mut i_0: uint32_t = DIST_MODEL_START as uint32_t; - while i_0 < FULL_DISTANCES as uint32_t { - let dist_slot_1: uint32_t = get_dist_slot(i_0) as uint32_t; - let footer_bits: uint32_t = (dist_slot_1 >> 1 as ::core::ffi::c_int) - .wrapping_sub(1 as uint32_t); - let base: uint32_t = (2 as uint32_t | dist_slot_1 & 1 as uint32_t) - << footer_bits; - let price: uint32_t = rc_bittree_reverse_price( + let mut i_0: u32 = DIST_MODEL_START as u32; + while i_0 < FULL_DISTANCES as u32 { + let dist_slot_1: u32 = get_dist_slot(i_0) as u32; + let footer_bits: u32 = (dist_slot_1 >> 1 as c_int).wrapping_sub(1 as u32); + let base: u32 = (2 as u32 | dist_slot_1 & 1 as u32) << footer_bits; + let price: u32 = rc_bittree_reverse_price( (&raw mut (*coder).dist_special as *mut probability) .offset(base as isize) .offset(-(dist_slot_1 as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)), + .offset(-(1 as isize)), footer_bits, i_0.wrapping_sub(base), - ) as uint32_t; - let mut dist_state_0: uint32_t = 0 as uint32_t; - while dist_state_0 < DIST_STATES as uint32_t { - (*coder).dist_prices[dist_state_0 as usize][i_0 as usize] = price - .wrapping_add( - (*coder) - .dist_slot_prices[dist_state_0 as usize][dist_slot_1 as usize], - ); + ) as u32; + let mut dist_state_0: u32 = 0 as u32; + while dist_state_0 < DIST_STATES as u32 { + (*coder).dist_prices[dist_state_0 as usize][i_0 as usize] = price.wrapping_add( + (*coder).dist_slot_prices[dist_state_0 as usize][dist_slot_1 as usize], + ); dist_state_0 = dist_state_0.wrapping_add(1); } i_0 = i_0.wrapping_add(1); } - (*coder).match_price_count = 0 as uint32_t; + (*coder).match_price_count = 0 as u32; } unsafe extern "C" fn fill_align_prices(mut coder: *mut lzma_lzma1_encoder) { - let mut i: uint32_t = 0 as uint32_t; - while i < ALIGN_SIZE as uint32_t { + let mut i: u32 = 0 as u32; + while i < ALIGN_SIZE as u32 { (*coder).align_prices[i as usize] = rc_bittree_reverse_price( &raw mut (*coder).dist_align as *mut probability, - ALIGN_BITS as uint32_t, + ALIGN_BITS as u32, i, ); i = i.wrapping_add(1); } - (*coder).align_price_count = 0 as uint32_t; + (*coder).align_price_count = 0 as u32; } #[inline] unsafe extern "C" fn make_literal(mut optimal: *mut lzma_optimal) { - (*optimal).back_prev = UINT32_MAX as uint32_t; + (*optimal).back_prev = UINT32_MAX as u32; (*optimal).prev_1_is_literal = false_0 != 0; } #[inline] unsafe extern "C" fn make_short_rep(mut optimal: *mut lzma_optimal) { - (*optimal).back_prev = 0 as uint32_t; + (*optimal).back_prev = 0 as u32; (*optimal).prev_1_is_literal = false_0 != 0; } unsafe extern "C" fn backward( mut coder: *mut lzma_lzma1_encoder, - mut len_res: *mut uint32_t, - mut back_res: *mut uint32_t, - mut cur: uint32_t, + mut len_res: *mut u32, + mut back_res: *mut u32, + mut cur: u32, ) { (*coder).opts_end_index = cur; - let mut pos_mem: uint32_t = (*coder).opts[cur as usize].pos_prev; - let mut back_mem: uint32_t = (*coder).opts[cur as usize].back_prev; + let mut pos_mem: u32 = (*coder).opts[cur as usize].pos_prev; + let mut back_mem: u32 = (*coder).opts[cur as usize].back_prev; loop { if (*coder).opts[cur as usize].prev_1_is_literal { make_literal( (&raw mut (*coder).opts as *mut lzma_optimal).offset(pos_mem as isize) as *mut lzma_optimal, ); - (*coder).opts[pos_mem as usize].pos_prev = pos_mem - .wrapping_sub(1 as uint32_t); + (*coder).opts[pos_mem as usize].pos_prev = pos_mem.wrapping_sub(1 as u32); if (*coder).opts[cur as usize].prev_2 { - (*coder) - .opts[pos_mem.wrapping_sub(1 as uint32_t) as usize] - .prev_1_is_literal = false_0 != 0; - (*coder).opts[pos_mem.wrapping_sub(1 as uint32_t) as usize].pos_prev = (*coder) - .opts[cur as usize] - .pos_prev_2; - (*coder).opts[pos_mem.wrapping_sub(1 as uint32_t) as usize].back_prev = (*coder) - .opts[cur as usize] - .back_prev_2; + (*coder).opts[pos_mem.wrapping_sub(1 as u32) as usize].prev_1_is_literal = + false_0 != 0; + (*coder).opts[pos_mem.wrapping_sub(1 as u32) as usize].pos_prev = + (*coder).opts[cur as usize].pos_prev_2; + (*coder).opts[pos_mem.wrapping_sub(1 as u32) as usize].back_prev = + (*coder).opts[cur as usize].back_prev_2; } } - let pos_prev: uint32_t = pos_mem; - let back_cur: uint32_t = back_mem; + let pos_prev: u32 = pos_mem; + let back_cur: u32 = back_mem; back_mem = (*coder).opts[pos_prev as usize].back_prev; pos_mem = (*coder).opts[pos_prev as usize].pos_prev; (*coder).opts[pos_prev as usize].back_prev = back_cur; (*coder).opts[pos_prev as usize].pos_prev = cur; cur = pos_prev; - if !(cur != 0 as uint32_t) { + if !(cur != 0 as u32) { break; } } - (*coder).opts_current_index = (*coder) - .opts[0 as ::core::ffi::c_int as usize] - .pos_prev; - *len_res = (*coder).opts[0 as ::core::ffi::c_int as usize].pos_prev; - *back_res = (*coder).opts[0 as ::core::ffi::c_int as usize].back_prev; + (*coder).opts_current_index = (*coder).opts[0 as usize].pos_prev; + *len_res = (*coder).opts[0 as usize].pos_prev; + *back_res = (*coder).opts[0 as usize].back_prev; } #[inline] unsafe extern "C" fn helper1( mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf, - mut back_res: *mut uint32_t, - mut len_res: *mut uint32_t, - mut position: uint32_t, -) -> uint32_t { - let nice_len: uint32_t = (*mf).nice_len; - let mut len_main: uint32_t = 0; - let mut matches_count: uint32_t = 0; - if (*mf).read_ahead == 0 as uint32_t { + mut back_res: *mut u32, + mut len_res: *mut u32, + mut position: u32, +) -> u32 { + let nice_len: u32 = (*mf).nice_len; + let mut len_main: u32 = 0; + let mut matches_count: u32 = 0; + if (*mf).read_ahead == 0 as u32 { len_main = lzma_mf_find( mf, &raw mut matches_count, @@ -658,48 +568,40 @@ unsafe extern "C" fn helper1( len_main = (*coder).longest_match_length; matches_count = (*coder).matches_count; } - let buf_avail: uint32_t = if mf_avail(mf).wrapping_add(1 as uint32_t) - < (2 as ::core::ffi::c_int - + (((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int)) - - 1 as ::core::ffi::c_int) as uint32_t + let buf_avail: u32 = if mf_avail(mf).wrapping_add(1 as u32) + < (2 as c_int + + (((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 8 as c_int)) + - 1 as c_int) as u32 { - (mf_avail(mf) as uint32_t).wrapping_add(1 as uint32_t) + (mf_avail(mf) as u32).wrapping_add(1 as u32) } else { - (2 as ::core::ffi::c_int - + (((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 3 as ::core::ffi::c_int) - + ((1 as ::core::ffi::c_int) << 8 as ::core::ffi::c_int)) - - 1 as ::core::ffi::c_int) as uint32_t + (2 as c_int + + (((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 3 as c_int) + + ((1 as c_int) << 8 as c_int)) + - 1 as c_int) as u32 }; - if buf_avail < 2 as uint32_t { - *back_res = UINT32_MAX as uint32_t; - *len_res = 1 as uint32_t; - return UINT32_MAX as uint32_t; + if buf_avail < 2 as u32 { + *back_res = UINT32_MAX as u32; + *len_res = 1 as u32; + return UINT32_MAX as u32; } - let buf: *const uint8_t = mf_ptr(mf).offset(-(1 as ::core::ffi::c_int as isize)); - let mut rep_lens: [uint32_t; 4] = [0; 4]; - let mut rep_max_index: uint32_t = 0 as uint32_t; - let mut i: uint32_t = 0 as uint32_t; - while i < REPS as uint32_t { - let buf_back: *const uint8_t = buf + let buf: *const u8 = mf_ptr(mf).offset(-(1 as isize)); + let mut rep_lens: [u32; 4] = [0; 4]; + let mut rep_max_index: u32 = 0 as u32; + let mut i: u32 = 0 as u32; + while i < REPS as u32 { + let buf_back: *const u8 = buf .offset(-((*coder).reps[i as usize] as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - if *buf.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - != *buf_back.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - || *buf.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - != *buf_back.offset(1 as ::core::ffi::c_int as isize) - as ::core::ffi::c_int + .offset(-(1 as isize)); + if *buf.offset(0 as isize) as c_int != *buf_back.offset(0 as isize) as c_int + || *buf.offset(1 as isize) as c_int != *buf_back.offset(1 as isize) as c_int { - rep_lens[i as usize] = 0 as uint32_t; + rep_lens[i as usize] = 0 as u32; } else { - rep_lens[i as usize] = lzma_memcmplen( - buf, - buf_back, - 2 as uint32_t, - buf_avail, - ); + rep_lens[i as usize] = lzma_memcmplen(buf, buf_back, 2 as u32, buf_avail); if rep_lens[i as usize] > rep_lens[rep_max_index as usize] { rep_max_index = i; } @@ -709,151 +611,134 @@ unsafe extern "C" fn helper1( if rep_lens[rep_max_index as usize] >= nice_len { *back_res = rep_max_index; *len_res = rep_lens[rep_max_index as usize]; - mf_skip(mf, (*len_res).wrapping_sub(1 as uint32_t)); - return UINT32_MAX as uint32_t; + mf_skip(mf, (*len_res).wrapping_sub(1 as u32)); + return UINT32_MAX as u32; } if len_main >= nice_len { - *back_res = (*coder) - .matches[matches_count.wrapping_sub(1 as uint32_t) as usize] + *back_res = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize] .dist - .wrapping_add(REPS as uint32_t); + .wrapping_add(REPS as u32); *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(1 as uint32_t)); - return UINT32_MAX as uint32_t; + mf_skip(mf, len_main.wrapping_sub(1 as u32)); + return UINT32_MAX as u32; } - let current_byte: uint8_t = *buf; - let match_byte: uint8_t = *buf - .offset(-((*coder).reps[0 as ::core::ffi::c_int as usize] as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - if len_main < 2 as uint32_t - && current_byte as ::core::ffi::c_int != match_byte as ::core::ffi::c_int - && rep_lens[rep_max_index as usize] < 2 as uint32_t + let current_byte: u8 = *buf; + let match_byte: u8 = *buf + .offset(-((*coder).reps[0 as usize] as isize)) + .offset(-(1 as isize)); + if len_main < 2 as u32 + && current_byte as c_int != match_byte as c_int + && rep_lens[rep_max_index as usize] < 2 as u32 { - *back_res = UINT32_MAX as uint32_t; - *len_res = 1 as uint32_t; - return UINT32_MAX as uint32_t; + *back_res = UINT32_MAX as u32; + *len_res = 1 as u32; + return UINT32_MAX as u32; } - (*coder).opts[0 as ::core::ffi::c_int as usize].state = (*coder).state; - let pos_state: uint32_t = position & (*coder).pos_mask; - (*coder).opts[1 as ::core::ffi::c_int as usize].price = rc_bit_0_price( - (*coder).is_match[(*coder).state as usize][pos_state as usize], - ) - .wrapping_add( - get_literal_price( + (*coder).opts[0 as usize].state = (*coder).state; + let pos_state: u32 = position & (*coder).pos_mask; + (*coder).opts[1 as usize].price = + rc_bit_0_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) + .wrapping_add(get_literal_price( coder, position, - *buf.offset(-(1 as ::core::ffi::c_int) as isize) as uint32_t, - !(((*coder).state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint), - match_byte as uint32_t, - current_byte as uint32_t, - ), - ); + *buf.offset(-(1 as c_int) as isize) as u32, + !(((*coder).state as c_uint) < LIT_STATES as c_uint), + match_byte as u32, + current_byte as u32, + )); make_literal( - (&raw mut (*coder).opts as *mut lzma_optimal) - .offset(1 as ::core::ffi::c_int as isize) as *mut lzma_optimal, + (&raw mut (*coder).opts as *mut lzma_optimal).offset(1 as isize) as *mut lzma_optimal, ); - let match_price: uint32_t = rc_bit_1_price( - (*coder).is_match[(*coder).state as usize][pos_state as usize], - ) as uint32_t; - let rep_match_price: uint32_t = match_price - .wrapping_add( - rc_bit_1_price((*coder).is_rep[(*coder).state as usize]) as uint32_t, - ); - if match_byte as ::core::ffi::c_int == current_byte as ::core::ffi::c_int { - let short_rep_price: uint32_t = rep_match_price - .wrapping_add( - get_short_rep_price(coder, (*coder).state, pos_state) as uint32_t, - ); - if short_rep_price < (*coder).opts[1 as ::core::ffi::c_int as usize].price { - (*coder).opts[1 as ::core::ffi::c_int as usize].price = short_rep_price; + let match_price: u32 = + rc_bit_1_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) as u32; + let rep_match_price: u32 = + match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[(*coder).state as usize]) as u32); + if match_byte as c_int == current_byte as c_int { + let short_rep_price: u32 = + rep_match_price + .wrapping_add(get_short_rep_price(coder, (*coder).state, pos_state) as u32); + if short_rep_price < (*coder).opts[1 as usize].price { + (*coder).opts[1 as usize].price = short_rep_price; make_short_rep( - (&raw mut (*coder).opts as *mut lzma_optimal) - .offset(1 as ::core::ffi::c_int as isize) as *mut lzma_optimal, + (&raw mut (*coder).opts as *mut lzma_optimal).offset(1 as isize) + as *mut lzma_optimal, ); } } - let len_end: uint32_t = if len_main > rep_lens[rep_max_index as usize] { + let len_end: u32 = if len_main > rep_lens[rep_max_index as usize] { len_main } else { rep_lens[rep_max_index as usize] }; - if len_end < 2 as uint32_t { - *back_res = (*coder).opts[1 as ::core::ffi::c_int as usize].back_prev; - *len_res = 1 as uint32_t; - return UINT32_MAX as uint32_t; + if len_end < 2 as u32 { + *back_res = (*coder).opts[1 as usize].back_prev; + *len_res = 1 as u32; + return UINT32_MAX as u32; } - (*coder).opts[1 as ::core::ffi::c_int as usize].pos_prev = 0 as uint32_t; - let mut i_0: uint32_t = 0 as uint32_t; - while i_0 < REPS as uint32_t { - (*coder).opts[0 as ::core::ffi::c_int as usize].backs[i_0 as usize] = (*coder) - .reps[i_0 as usize]; + (*coder).opts[1 as usize].pos_prev = 0 as u32; + let mut i_0: u32 = 0 as u32; + while i_0 < REPS as u32 { + (*coder).opts[0 as usize].backs[i_0 as usize] = (*coder).reps[i_0 as usize]; i_0 = i_0.wrapping_add(1); } - let mut len: uint32_t = len_end; + let mut len: u32 = len_end; loop { - (*coder).opts[len as usize].price = RC_INFINITY_PRICE as uint32_t; + (*coder).opts[len as usize].price = RC_INFINITY_PRICE as u32; len = len.wrapping_sub(1); - if !(len >= 2 as uint32_t) { + if !(len >= 2 as u32) { break; } } - let mut i_1: uint32_t = 0 as uint32_t; - while i_1 < REPS as uint32_t { - let mut rep_len: uint32_t = rep_lens[i_1 as usize]; - if !(rep_len < 2 as uint32_t) { - let price: uint32_t = rep_match_price - .wrapping_add( - get_pure_rep_price(coder, i_1, (*coder).state, pos_state) as uint32_t, - ); + let mut i_1: u32 = 0 as u32; + while i_1 < REPS as u32 { + let mut rep_len: u32 = rep_lens[i_1 as usize]; + if !(rep_len < 2 as u32) { + let price: u32 = rep_match_price.wrapping_add(get_pure_rep_price( + coder, + i_1, + (*coder).state, + pos_state, + ) as u32); loop { - let cur_and_len_price: uint32_t = price - .wrapping_add( - get_len_price( - &raw mut (*coder).rep_len_encoder, - rep_len, - pos_state, - ) as uint32_t, - ); + let cur_and_len_price: u32 = price.wrapping_add(get_len_price( + &raw mut (*coder).rep_len_encoder, + rep_len, + pos_state, + ) as u32); if cur_and_len_price < (*coder).opts[rep_len as usize].price { (*coder).opts[rep_len as usize].price = cur_and_len_price; - (*coder).opts[rep_len as usize].pos_prev = 0 as uint32_t; + (*coder).opts[rep_len as usize].pos_prev = 0 as u32; (*coder).opts[rep_len as usize].back_prev = i_1; (*coder).opts[rep_len as usize].prev_1_is_literal = false_0 != 0; } rep_len = rep_len.wrapping_sub(1); - if !(rep_len >= 2 as uint32_t) { + if !(rep_len >= 2 as u32) { break; } } } i_1 = i_1.wrapping_add(1); } - let normal_match_price: uint32_t = match_price - .wrapping_add( - rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as uint32_t, - ); - len = if rep_lens[0 as ::core::ffi::c_int as usize] >= 2 as uint32_t { - rep_lens[0 as ::core::ffi::c_int as usize].wrapping_add(1 as uint32_t) + let normal_match_price: u32 = + match_price.wrapping_add(rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as u32); + len = if rep_lens[0 as usize] >= 2 as u32 { + rep_lens[0 as usize].wrapping_add(1 as u32) } else { - 2 as uint32_t + 2 as u32 }; if len <= len_main { - let mut i_2: uint32_t = 0 as uint32_t; + let mut i_2: u32 = 0 as u32; while len > (*coder).matches[i_2 as usize].len { i_2 = i_2.wrapping_add(1); } loop { - let dist: uint32_t = (*coder).matches[i_2 as usize].dist; - let cur_and_len_price_0: uint32_t = normal_match_price - .wrapping_add( - get_dist_len_price(coder, dist, len, pos_state) as uint32_t, - ); + let dist: u32 = (*coder).matches[i_2 as usize].dist; + let cur_and_len_price_0: u32 = normal_match_price + .wrapping_add(get_dist_len_price(coder, dist, len, pos_state) as u32); if cur_and_len_price_0 < (*coder).opts[len as usize].price { (*coder).opts[len as usize].price = cur_and_len_price_0; - (*coder).opts[len as usize].pos_prev = 0 as uint32_t; - (*coder).opts[len as usize].back_prev = dist - .wrapping_add(REPS as uint32_t); + (*coder).opts[len as usize].pos_prev = 0 as u32; + (*coder).opts[len as usize].back_prev = dist.wrapping_add(REPS as u32); (*coder).opts[len as usize].prev_1_is_literal = false_0 != 0; } if len == (*coder).matches[i_2 as usize].len { @@ -870,337 +755,266 @@ unsafe extern "C" fn helper1( #[inline] unsafe extern "C" fn helper2( mut coder: *mut lzma_lzma1_encoder, - mut reps: *mut uint32_t, - mut buf: *const uint8_t, - mut len_end: uint32_t, - mut position: uint32_t, - cur: uint32_t, - nice_len: uint32_t, - buf_avail_full: uint32_t, -) -> uint32_t { - let mut matches_count: uint32_t = (*coder).matches_count; - let mut new_len: uint32_t = (*coder).longest_match_length; - let mut pos_prev: uint32_t = (*coder).opts[cur as usize].pos_prev; + mut reps: *mut u32, + mut buf: *const u8, + mut len_end: u32, + mut position: u32, + cur: u32, + nice_len: u32, + buf_avail_full: u32, +) -> u32 { + let mut matches_count: u32 = (*coder).matches_count; + let mut new_len: u32 = (*coder).longest_match_length; + let mut pos_prev: u32 = (*coder).opts[cur as usize].pos_prev; let mut state: lzma_lzma_state = STATE_LIT_LIT; if (*coder).opts[cur as usize].prev_1_is_literal { pos_prev = pos_prev.wrapping_sub(1); if (*coder).opts[cur as usize].prev_2 { state = (*coder).opts[(*coder).opts[cur as usize].pos_prev_2 as usize].state; - if (*coder).opts[cur as usize].back_prev_2 < REPS as uint32_t { - state = (if (state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_LONGREP as ::core::ffi::c_int + if (*coder).opts[cur as usize].back_prev_2 < REPS as u32 { + state = (if (state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_LONGREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int + STATE_NONLIT_REP as c_int }) as lzma_lzma_state; } else { - state = (if (state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_MATCH as ::core::ffi::c_int + state = (if (state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_MATCH as c_int } else { - STATE_NONLIT_MATCH as ::core::ffi::c_int + STATE_NONLIT_MATCH as c_int }) as lzma_lzma_state; } } else { state = (*coder).opts[pos_prev as usize].state; } - state = (if state as ::core::ffi::c_uint - <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - { - STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - } else if state as ::core::ffi::c_uint - <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint - { - (state as ::core::ffi::c_uint).wrapping_sub(3 as ::core::ffi::c_uint) + state = (if state as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { + STATE_LIT_LIT as c_uint + } else if state as c_uint <= STATE_LIT_SHORTREP as c_uint { + (state as c_uint).wrapping_sub(3 as c_uint) } else { - (state as ::core::ffi::c_uint).wrapping_sub(6 as ::core::ffi::c_uint) + (state as c_uint).wrapping_sub(6 as c_uint) }) as lzma_lzma_state; } else { state = (*coder).opts[pos_prev as usize].state; } - if pos_prev == cur.wrapping_sub(1 as uint32_t) { - if (*coder).opts[cur as usize].back_prev == 0 as uint32_t { - state = (if (state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_SHORTREP as ::core::ffi::c_int + if pos_prev == cur.wrapping_sub(1 as u32) { + if (*coder).opts[cur as usize].back_prev == 0 as u32 { + state = (if (state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_SHORTREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int + STATE_NONLIT_REP as c_int }) as lzma_lzma_state; } else { - state = (if state as ::core::ffi::c_uint - <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - { - STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - } else if state as ::core::ffi::c_uint - <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint - { - (state as ::core::ffi::c_uint).wrapping_sub(3 as ::core::ffi::c_uint) + state = (if state as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { + STATE_LIT_LIT as c_uint + } else if state as c_uint <= STATE_LIT_SHORTREP as c_uint { + (state as c_uint).wrapping_sub(3 as c_uint) } else { - (state as ::core::ffi::c_uint).wrapping_sub(6 as ::core::ffi::c_uint) + (state as c_uint).wrapping_sub(6 as c_uint) }) as lzma_lzma_state; } } else { - let mut pos: uint32_t = 0; - if (*coder).opts[cur as usize].prev_1_is_literal as ::core::ffi::c_int != 0 - && (*coder).opts[cur as usize].prev_2 as ::core::ffi::c_int != 0 + let mut pos: u32 = 0; + if (*coder).opts[cur as usize].prev_1_is_literal as c_int != 0 + && (*coder).opts[cur as usize].prev_2 as c_int != 0 { pos_prev = (*coder).opts[cur as usize].pos_prev_2; pos = (*coder).opts[cur as usize].back_prev_2; - state = (if (state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_LONGREP as ::core::ffi::c_int + state = (if (state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_LONGREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int + STATE_NONLIT_REP as c_int }) as lzma_lzma_state; } else { pos = (*coder).opts[cur as usize].back_prev; - if pos < REPS as uint32_t { - state = (if (state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_LONGREP as ::core::ffi::c_int + if pos < REPS as u32 { + state = (if (state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_LONGREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int + STATE_NONLIT_REP as c_int }) as lzma_lzma_state; } else { - state = (if (state as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_MATCH as ::core::ffi::c_int + state = (if (state as c_uint) < LIT_STATES as c_uint { + STATE_LIT_MATCH as c_int } else { - STATE_NONLIT_MATCH as ::core::ffi::c_int + STATE_NONLIT_MATCH as c_int }) as lzma_lzma_state; } } - if pos < REPS as uint32_t { - *reps.offset(0 as ::core::ffi::c_int as isize) = (*coder) - .opts[pos_prev as usize] - .backs[pos as usize]; - let mut i: uint32_t = 0; - i = 1 as uint32_t; + if pos < REPS as u32 { + *reps.offset(0 as isize) = (*coder).opts[pos_prev as usize].backs[pos as usize]; + let mut i: u32 = 0; + i = 1 as u32; while i <= pos { - *reps.offset(i as isize) = (*coder) - .opts[pos_prev as usize] - .backs[i.wrapping_sub(1 as uint32_t) as usize]; + *reps.offset(i as isize) = + (*coder).opts[pos_prev as usize].backs[i.wrapping_sub(1 as u32) as usize]; i = i.wrapping_add(1); } - while i < REPS as uint32_t { - *reps.offset(i as isize) = (*coder) - .opts[pos_prev as usize] - .backs[i as usize]; + while i < REPS as u32 { + *reps.offset(i as isize) = (*coder).opts[pos_prev as usize].backs[i as usize]; i = i.wrapping_add(1); } } else { - *reps.offset(0 as ::core::ffi::c_int as isize) = pos - .wrapping_sub(REPS as uint32_t); - let mut i_0: uint32_t = 1 as uint32_t; - while i_0 < REPS as uint32_t { - *reps.offset(i_0 as isize) = (*coder) - .opts[pos_prev as usize] - .backs[i_0.wrapping_sub(1 as uint32_t) as usize]; + *reps.offset(0 as isize) = pos.wrapping_sub(REPS as u32); + let mut i_0: u32 = 1 as u32; + while i_0 < REPS as u32 { + *reps.offset(i_0 as isize) = + (*coder).opts[pos_prev as usize].backs[i_0.wrapping_sub(1 as u32) as usize]; i_0 = i_0.wrapping_add(1); } } } (*coder).opts[cur as usize].state = state; - let mut i_1: uint32_t = 0 as uint32_t; - while i_1 < REPS as uint32_t { + let mut i_1: u32 = 0 as u32; + while i_1 < REPS as u32 { (*coder).opts[cur as usize].backs[i_1 as usize] = *reps.offset(i_1 as isize); i_1 = i_1.wrapping_add(1); } - let cur_price: uint32_t = (*coder).opts[cur as usize].price; - let current_byte: uint8_t = *buf; - let match_byte: uint8_t = *buf - .offset(-(*reps.offset(0 as ::core::ffi::c_int as isize) as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - let pos_state: uint32_t = position & (*coder).pos_mask; - let cur_and_1_price: uint32_t = cur_price - .wrapping_add( - rc_bit_0_price((*coder).is_match[state as usize][pos_state as usize]) - as uint32_t, - ) - .wrapping_add( - get_literal_price( - coder, - position, - *buf.offset(-(1 as ::core::ffi::c_int) as isize) as uint32_t, - !((state as ::core::ffi::c_uint) < LIT_STATES as ::core::ffi::c_uint), - match_byte as uint32_t, - current_byte as uint32_t, - ) as uint32_t, - ); + let cur_price: u32 = (*coder).opts[cur as usize].price; + let current_byte: u8 = *buf; + let match_byte: u8 = *buf + .offset(-(*reps.offset(0 as isize) as isize)) + .offset(-(1 as isize)); + let pos_state: u32 = position & (*coder).pos_mask; + let cur_and_1_price: u32 = cur_price + .wrapping_add(rc_bit_0_price((*coder).is_match[state as usize][pos_state as usize]) as u32) + .wrapping_add(get_literal_price( + coder, + position, + *buf.offset(-(1 as c_int) as isize) as u32, + !((state as c_uint) < LIT_STATES as c_uint), + match_byte as u32, + current_byte as u32, + ) as u32); let mut next_is_literal: bool = false_0 != 0; - if cur_and_1_price < (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].price { - (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].price = cur_and_1_price; - (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].pos_prev = cur; + if cur_and_1_price < (*coder).opts[cur.wrapping_add(1 as u32) as usize].price { + (*coder).opts[cur.wrapping_add(1 as u32) as usize].price = cur_and_1_price; + (*coder).opts[cur.wrapping_add(1 as u32) as usize].pos_prev = cur; make_literal( (&raw mut (*coder).opts as *mut lzma_optimal) - .offset(cur.wrapping_add(1 as uint32_t) as isize) as *mut lzma_optimal, + .offset(cur.wrapping_add(1 as u32) as isize) as *mut lzma_optimal, ); next_is_literal = true_0 != 0; } - let match_price: uint32_t = cur_price - .wrapping_add( - rc_bit_1_price((*coder).is_match[state as usize][pos_state as usize]) - as uint32_t, - ); - let rep_match_price: uint32_t = match_price - .wrapping_add(rc_bit_1_price((*coder).is_rep[state as usize]) as uint32_t); - if match_byte as ::core::ffi::c_int == current_byte as ::core::ffi::c_int - && !((*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].pos_prev < cur - && (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].back_prev - == 0 as uint32_t) + let match_price: u32 = cur_price + .wrapping_add(rc_bit_1_price((*coder).is_match[state as usize][pos_state as usize]) as u32); + let rep_match_price: u32 = + match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[state as usize]) as u32); + if match_byte as c_int == current_byte as c_int + && !((*coder).opts[cur.wrapping_add(1 as u32) as usize].pos_prev < cur + && (*coder).opts[cur.wrapping_add(1 as u32) as usize].back_prev == 0 as u32) { - let short_rep_price: uint32_t = rep_match_price - .wrapping_add(get_short_rep_price(coder, state, pos_state) as uint32_t); - if short_rep_price - <= (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].price - { - (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].price = short_rep_price; - (*coder).opts[cur.wrapping_add(1 as uint32_t) as usize].pos_prev = cur; + let short_rep_price: u32 = + rep_match_price.wrapping_add(get_short_rep_price(coder, state, pos_state) as u32); + if short_rep_price <= (*coder).opts[cur.wrapping_add(1 as u32) as usize].price { + (*coder).opts[cur.wrapping_add(1 as u32) as usize].price = short_rep_price; + (*coder).opts[cur.wrapping_add(1 as u32) as usize].pos_prev = cur; make_short_rep( (&raw mut (*coder).opts as *mut lzma_optimal) - .offset(cur.wrapping_add(1 as uint32_t) as isize) + .offset(cur.wrapping_add(1 as u32) as isize) as *mut lzma_optimal, ); next_is_literal = true_0 != 0; } } - if buf_avail_full < 2 as uint32_t { + if buf_avail_full < 2 as u32 { return len_end; } - let buf_avail: uint32_t = if buf_avail_full < nice_len { + let buf_avail: u32 = if buf_avail_full < nice_len { buf_avail_full } else { nice_len }; - if !next_is_literal - && match_byte as ::core::ffi::c_int != current_byte as ::core::ffi::c_int - { - let buf_back: *const uint8_t = buf - .offset(-(*reps.offset(0 as ::core::ffi::c_int as isize) as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - let limit: uint32_t = if buf_avail_full < nice_len.wrapping_add(1 as uint32_t) { + if !next_is_literal && match_byte as c_int != current_byte as c_int { + let buf_back: *const u8 = buf + .offset(-(*reps.offset(0 as isize) as isize)) + .offset(-(1 as isize)); + let limit: u32 = if buf_avail_full < nice_len.wrapping_add(1 as u32) { buf_avail_full } else { - nice_len.wrapping_add(1 as uint32_t) + nice_len.wrapping_add(1 as u32) }; - let len_test: uint32_t = (lzma_memcmplen(buf, buf_back, 1 as uint32_t, limit) - as uint32_t) - .wrapping_sub(1 as uint32_t); - if len_test >= 2 as uint32_t { + let len_test: u32 = + (lzma_memcmplen(buf, buf_back, 1 as u32, limit) as u32).wrapping_sub(1 as u32); + if len_test >= 2 as u32 { let mut state_2: lzma_lzma_state = state; - state_2 = (if state_2 as ::core::ffi::c_uint - <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - { - STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - } else if state_2 as ::core::ffi::c_uint - <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint - { - (state_2 as ::core::ffi::c_uint).wrapping_sub(3 as ::core::ffi::c_uint) + state_2 = (if state_2 as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { + STATE_LIT_LIT as c_uint + } else if state_2 as c_uint <= STATE_LIT_SHORTREP as c_uint { + (state_2 as c_uint).wrapping_sub(3 as c_uint) } else { - (state_2 as ::core::ffi::c_uint).wrapping_sub(6 as ::core::ffi::c_uint) + (state_2 as c_uint).wrapping_sub(6 as c_uint) }) as lzma_lzma_state; - let pos_state_next: uint32_t = position.wrapping_add(1 as uint32_t) - & (*coder).pos_mask; - let next_rep_match_price: uint32_t = cur_and_1_price - .wrapping_add( - rc_bit_1_price( - (*coder).is_match[state_2 as usize][pos_state_next as usize], - ) as uint32_t, - ) - .wrapping_add( - rc_bit_1_price((*coder).is_rep[state_2 as usize]) as uint32_t, - ); - let offset: uint32_t = cur - .wrapping_add(1 as uint32_t) - .wrapping_add(len_test); + let pos_state_next: u32 = position.wrapping_add(1 as u32) & (*coder).pos_mask; + let next_rep_match_price: u32 = cur_and_1_price + .wrapping_add(rc_bit_1_price( + (*coder).is_match[state_2 as usize][pos_state_next as usize], + ) as u32) + .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2 as usize]) as u32); + let offset: u32 = cur.wrapping_add(1 as u32).wrapping_add(len_test); while len_end < offset { len_end = len_end.wrapping_add(1); - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as uint32_t; + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } - let cur_and_len_price: uint32_t = next_rep_match_price - .wrapping_add( - get_rep_price( - coder, - 0 as uint32_t, - len_test, - state_2, - pos_state_next, - ) as uint32_t, - ); + let cur_and_len_price: u32 = next_rep_match_price.wrapping_add(get_rep_price( + coder, + 0 as u32, + len_test, + state_2, + pos_state_next, + ) as u32); if cur_and_len_price < (*coder).opts[offset as usize].price { (*coder).opts[offset as usize].price = cur_and_len_price; - (*coder).opts[offset as usize].pos_prev = cur - .wrapping_add(1 as uint32_t); - (*coder).opts[offset as usize].back_prev = 0 as uint32_t; + (*coder).opts[offset as usize].pos_prev = cur.wrapping_add(1 as u32); + (*coder).opts[offset as usize].back_prev = 0 as u32; (*coder).opts[offset as usize].prev_1_is_literal = true_0 != 0; (*coder).opts[offset as usize].prev_2 = false_0 != 0; } } } - let mut start_len: uint32_t = 2 as uint32_t; - let mut rep_index: uint32_t = 0 as uint32_t; - while rep_index < REPS as uint32_t { - let buf_back_0: *const uint8_t = buf + let mut start_len: u32 = 2 as u32; + let mut rep_index: u32 = 0 as u32; + while rep_index < REPS as u32 { + let buf_back_0: *const u8 = buf .offset(-(*reps.offset(rep_index as isize) as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - if !(*buf.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - != *buf_back_0.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - || *buf.offset(1 as ::core::ffi::c_int as isize) as ::core::ffi::c_int - != *buf_back_0.offset(1 as ::core::ffi::c_int as isize) - as ::core::ffi::c_int) + .offset(-(1 as isize)); + if !(*buf.offset(0 as isize) as c_int != *buf_back_0.offset(0 as isize) as c_int + || *buf.offset(1 as isize) as c_int != *buf_back_0.offset(1 as isize) as c_int) { - let mut len_test_0: uint32_t = lzma_memcmplen( - buf, - buf_back_0, - 2 as uint32_t, - buf_avail, - ); + let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2 as u32, buf_avail); while len_end < cur.wrapping_add(len_test_0) { len_end = len_end.wrapping_add(1); - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as uint32_t; + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } - let len_test_temp: uint32_t = len_test_0; - let price: uint32_t = rep_match_price - .wrapping_add( - get_pure_rep_price(coder, rep_index, state, pos_state) as uint32_t, - ); + let len_test_temp: u32 = len_test_0; + let price: u32 = rep_match_price + .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state) as u32); loop { - let cur_and_len_price_0: uint32_t = price - .wrapping_add( - get_len_price( - &raw mut (*coder).rep_len_encoder, - len_test_0, - pos_state, - ) as uint32_t, - ); - if cur_and_len_price_0 - < (*coder).opts[cur.wrapping_add(len_test_0) as usize].price + let cur_and_len_price_0: u32 = price.wrapping_add(get_len_price( + &raw mut (*coder).rep_len_encoder, + len_test_0, + pos_state, + ) as u32); + if cur_and_len_price_0 < (*coder).opts[cur.wrapping_add(len_test_0) as usize].price { - (*coder).opts[cur.wrapping_add(len_test_0) as usize].price = cur_and_len_price_0; + (*coder).opts[cur.wrapping_add(len_test_0) as usize].price = + cur_and_len_price_0; (*coder).opts[cur.wrapping_add(len_test_0) as usize].pos_prev = cur; (*coder).opts[cur.wrapping_add(len_test_0) as usize].back_prev = rep_index; - (*coder) - .opts[cur.wrapping_add(len_test_0) as usize] - .prev_1_is_literal = false_0 != 0; + (*coder).opts[cur.wrapping_add(len_test_0) as usize].prev_1_is_literal = + false_0 != 0; } len_test_0 = len_test_0.wrapping_sub(1); - if !(len_test_0 >= 2 as uint32_t) { + if !(len_test_0 >= 2 as u32) { break; } } len_test_0 = len_test_temp; - if rep_index == 0 as uint32_t { - start_len = len_test_0.wrapping_add(1 as uint32_t); + if rep_index == 0 as u32 { + start_len = len_test_0.wrapping_add(1 as u32); } - let mut len_test_2: uint32_t = len_test_0.wrapping_add(1 as uint32_t); - let limit_0: uint32_t = if buf_avail_full < len_test_2.wrapping_add(nice_len) - { + let mut len_test_2: u32 = len_test_0.wrapping_add(1 as u32); + let limit_0: u32 = if buf_avail_full < len_test_2.wrapping_add(nice_len) { buf_avail_full } else { len_test_2.wrapping_add(nice_len) @@ -1208,95 +1022,68 @@ unsafe extern "C" fn helper2( if len_test_2 < limit_0 { len_test_2 = lzma_memcmplen(buf, buf_back_0, len_test_2, limit_0); } - len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1 as uint32_t)); - if len_test_2 >= 2 as uint32_t { + len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1 as u32)); + if len_test_2 >= 2 as u32 { let mut state_2_0: lzma_lzma_state = state; - state_2_0 = (if (state_2_0 as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_LONGREP as ::core::ffi::c_int + state_2_0 = (if (state_2_0 as c_uint) < LIT_STATES as c_uint { + STATE_LIT_LONGREP as c_int } else { - STATE_NONLIT_REP as ::core::ffi::c_int + STATE_NONLIT_REP as c_int }) as lzma_lzma_state; - let mut pos_state_next_0: uint32_t = position.wrapping_add(len_test_0) - & (*coder).pos_mask; - let cur_and_len_literal_price: uint32_t = price - .wrapping_add( - get_len_price( - &raw mut (*coder).rep_len_encoder, - len_test_0, - pos_state, - ) as uint32_t, - ) - .wrapping_add( - rc_bit_0_price( - (*coder) - .is_match[state_2_0 as usize][pos_state_next_0 as usize], - ) as uint32_t, - ) - .wrapping_add( - get_literal_price( - coder, - position.wrapping_add(len_test_0), - *buf.offset(len_test_0.wrapping_sub(1 as uint32_t) as isize) - as uint32_t, - true_0 != 0, - *buf_back_0.offset(len_test_0 as isize) as uint32_t, - *buf.offset(len_test_0 as isize) as uint32_t, - ) as uint32_t, - ); - state_2_0 = (if state_2_0 as ::core::ffi::c_uint - <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int - as ::core::ffi::c_uint - { - STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - } else if state_2_0 as ::core::ffi::c_uint - <= STATE_LIT_SHORTREP as ::core::ffi::c_int as ::core::ffi::c_uint - { - (state_2_0 as ::core::ffi::c_uint) - .wrapping_sub(3 as ::core::ffi::c_uint) + let mut pos_state_next_0: u32 = + position.wrapping_add(len_test_0) & (*coder).pos_mask; + let cur_and_len_literal_price: u32 = price + .wrapping_add(get_len_price( + &raw mut (*coder).rep_len_encoder, + len_test_0, + pos_state, + ) as u32) + .wrapping_add(rc_bit_0_price( + (*coder).is_match[state_2_0 as usize][pos_state_next_0 as usize], + ) as u32) + .wrapping_add(get_literal_price( + coder, + position.wrapping_add(len_test_0), + *buf.offset(len_test_0.wrapping_sub(1 as u32) as isize) as u32, + true_0 != 0, + *buf_back_0.offset(len_test_0 as isize) as u32, + *buf.offset(len_test_0 as isize) as u32, + ) as u32); + state_2_0 = (if state_2_0 as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { + STATE_LIT_LIT as c_uint + } else if state_2_0 as c_uint <= STATE_LIT_SHORTREP as c_uint { + (state_2_0 as c_uint).wrapping_sub(3 as c_uint) } else { - (state_2_0 as ::core::ffi::c_uint) - .wrapping_sub(6 as ::core::ffi::c_uint) + (state_2_0 as c_uint).wrapping_sub(6 as c_uint) }) as lzma_lzma_state; - pos_state_next_0 = position + pos_state_next_0 = + position.wrapping_add(len_test_0).wrapping_add(1 as u32) & (*coder).pos_mask; + let next_rep_match_price_0: u32 = cur_and_len_literal_price + .wrapping_add(rc_bit_1_price( + (*coder).is_match[state_2_0 as usize][pos_state_next_0 as usize], + ) as u32) + .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2_0 as usize]) as u32); + let offset_0: u32 = cur .wrapping_add(len_test_0) - .wrapping_add(1 as uint32_t) & (*coder).pos_mask; - let next_rep_match_price_0: uint32_t = cur_and_len_literal_price - .wrapping_add( - rc_bit_1_price( - (*coder) - .is_match[state_2_0 as usize][pos_state_next_0 as usize], - ) as uint32_t, - ) - .wrapping_add( - rc_bit_1_price((*coder).is_rep[state_2_0 as usize]) as uint32_t, - ); - let offset_0: uint32_t = cur - .wrapping_add(len_test_0) - .wrapping_add(1 as uint32_t) + .wrapping_add(1 as u32) .wrapping_add(len_test_2); while len_end < offset_0 { len_end = len_end.wrapping_add(1); - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE - as uint32_t; + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } - let cur_and_len_price_1: uint32_t = next_rep_match_price_0 - .wrapping_add( - get_rep_price( - coder, - 0 as uint32_t, - len_test_2, - state_2_0, - pos_state_next_0, - ) as uint32_t, - ); + let cur_and_len_price_1: u32 = next_rep_match_price_0.wrapping_add(get_rep_price( + coder, + 0 as u32, + len_test_2, + state_2_0, + pos_state_next_0, + ) + as u32); if cur_and_len_price_1 < (*coder).opts[offset_0 as usize].price { (*coder).opts[offset_0 as usize].price = cur_and_len_price_1; - (*coder).opts[offset_0 as usize].pos_prev = cur - .wrapping_add(len_test_0) - .wrapping_add(1 as uint32_t); - (*coder).opts[offset_0 as usize].back_prev = 0 as uint32_t; + (*coder).opts[offset_0 as usize].pos_prev = + cur.wrapping_add(len_test_0).wrapping_add(1 as u32); + (*coder).opts[offset_0 as usize].back_prev = 0 as u32; (*coder).opts[offset_0 as usize].prev_1_is_literal = true_0 != 0; (*coder).opts[offset_0 as usize].prev_2 = true_0 != 0; (*coder).opts[offset_0 as usize].pos_prev_2 = cur; @@ -1308,7 +1095,7 @@ unsafe extern "C" fn helper2( } if new_len > buf_avail { new_len = buf_avail; - matches_count = 0 as uint32_t; + matches_count = 0 as u32; while new_len > (*coder).matches[matches_count as usize].len { matches_count = matches_count.wrapping_add(1); } @@ -1317,142 +1104,100 @@ unsafe extern "C" fn helper2( (*coder).matches[fresh0 as usize].len = new_len; } if new_len >= start_len { - let normal_match_price: uint32_t = match_price - .wrapping_add(rc_bit_0_price((*coder).is_rep[state as usize]) as uint32_t); + let normal_match_price: u32 = + match_price.wrapping_add(rc_bit_0_price((*coder).is_rep[state as usize]) as u32); while len_end < cur.wrapping_add(new_len) { len_end = len_end.wrapping_add(1); - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as uint32_t; + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } - let mut i_2: uint32_t = 0 as uint32_t; + let mut i_2: u32 = 0 as u32; while start_len > (*coder).matches[i_2 as usize].len { i_2 = i_2.wrapping_add(1); } - let mut len_test_1: uint32_t = start_len; + let mut len_test_1: u32 = start_len; loop { - let cur_back: uint32_t = (*coder).matches[i_2 as usize].dist; - let mut cur_and_len_price_2: uint32_t = normal_match_price - .wrapping_add( - get_dist_len_price(coder, cur_back, len_test_1, pos_state), - ); - if cur_and_len_price_2 - < (*coder).opts[cur.wrapping_add(len_test_1) as usize].price - { + let cur_back: u32 = (*coder).matches[i_2 as usize].dist; + let mut cur_and_len_price_2: u32 = normal_match_price + .wrapping_add(get_dist_len_price(coder, cur_back, len_test_1, pos_state)); + if cur_and_len_price_2 < (*coder).opts[cur.wrapping_add(len_test_1) as usize].price { (*coder).opts[cur.wrapping_add(len_test_1) as usize].price = cur_and_len_price_2; (*coder).opts[cur.wrapping_add(len_test_1) as usize].pos_prev = cur; - (*coder).opts[cur.wrapping_add(len_test_1) as usize].back_prev = cur_back - .wrapping_add(REPS as uint32_t); - (*coder).opts[cur.wrapping_add(len_test_1) as usize].prev_1_is_literal = false_0 - != 0; + (*coder).opts[cur.wrapping_add(len_test_1) as usize].back_prev = + cur_back.wrapping_add(REPS as u32); + (*coder).opts[cur.wrapping_add(len_test_1) as usize].prev_1_is_literal = + false_0 != 0; } if len_test_1 == (*coder).matches[i_2 as usize].len { - let buf_back_1: *const uint8_t = buf - .offset(-(cur_back as isize)) - .offset(-(1 as ::core::ffi::c_int as isize)); - let mut len_test_2_0: uint32_t = len_test_1.wrapping_add(1 as uint32_t); - let limit_1: uint32_t = if buf_avail_full - < len_test_2_0.wrapping_add(nice_len) - { + let buf_back_1: *const u8 = buf.offset(-(cur_back as isize)).offset(-(1 as isize)); + let mut len_test_2_0: u32 = len_test_1.wrapping_add(1 as u32); + let limit_1: u32 = if buf_avail_full < len_test_2_0.wrapping_add(nice_len) { buf_avail_full } else { len_test_2_0.wrapping_add(nice_len) }; if len_test_2_0 < limit_1 { - len_test_2_0 = lzma_memcmplen( - buf, - buf_back_1, - len_test_2_0, - limit_1, - ); + len_test_2_0 = lzma_memcmplen(buf, buf_back_1, len_test_2_0, limit_1); } - len_test_2_0 = len_test_2_0 - .wrapping_sub(len_test_1.wrapping_add(1 as uint32_t)); - if len_test_2_0 >= 2 as uint32_t { + len_test_2_0 = len_test_2_0.wrapping_sub(len_test_1.wrapping_add(1 as u32)); + if len_test_2_0 >= 2 as u32 { let mut state_2_1: lzma_lzma_state = state; - state_2_1 = (if (state_2_1 as ::core::ffi::c_uint) - < LIT_STATES as ::core::ffi::c_uint - { - STATE_LIT_MATCH as ::core::ffi::c_int + state_2_1 = (if (state_2_1 as c_uint) < LIT_STATES as c_uint { + STATE_LIT_MATCH as c_int } else { - STATE_NONLIT_MATCH as ::core::ffi::c_int + STATE_NONLIT_MATCH as c_int }) as lzma_lzma_state; - let mut pos_state_next_1: uint32_t = position - .wrapping_add(len_test_1) & (*coder).pos_mask; - let cur_and_len_literal_price_0: uint32_t = cur_and_len_price_2 - .wrapping_add( - rc_bit_0_price( - (*coder) - .is_match[state_2_1 as usize][pos_state_next_1 as usize], - ) as uint32_t, - ) - .wrapping_add( - get_literal_price( - coder, - position.wrapping_add(len_test_1), - *buf.offset(len_test_1.wrapping_sub(1 as uint32_t) as isize) - as uint32_t, - true_0 != 0, - *buf_back_1.offset(len_test_1 as isize) as uint32_t, - *buf.offset(len_test_1 as isize) as uint32_t, - ) as uint32_t, - ); - state_2_1 = (if state_2_1 as ::core::ffi::c_uint - <= STATE_SHORTREP_LIT_LIT as ::core::ffi::c_int - as ::core::ffi::c_uint - { - STATE_LIT_LIT as ::core::ffi::c_int as ::core::ffi::c_uint - } else if state_2_1 as ::core::ffi::c_uint - <= STATE_LIT_SHORTREP as ::core::ffi::c_int - as ::core::ffi::c_uint - { - (state_2_1 as ::core::ffi::c_uint) - .wrapping_sub(3 as ::core::ffi::c_uint) + let mut pos_state_next_1: u32 = + position.wrapping_add(len_test_1) & (*coder).pos_mask; + let cur_and_len_literal_price_0: u32 = cur_and_len_price_2 + .wrapping_add(rc_bit_0_price( + (*coder).is_match[state_2_1 as usize][pos_state_next_1 as usize], + ) as u32) + .wrapping_add(get_literal_price( + coder, + position.wrapping_add(len_test_1), + *buf.offset(len_test_1.wrapping_sub(1 as u32) as isize) as u32, + true_0 != 0, + *buf_back_1.offset(len_test_1 as isize) as u32, + *buf.offset(len_test_1 as isize) as u32, + ) as u32); + state_2_1 = (if state_2_1 as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { + STATE_LIT_LIT as c_uint + } else if state_2_1 as c_uint <= STATE_LIT_SHORTREP as c_uint { + (state_2_1 as c_uint).wrapping_sub(3 as c_uint) } else { - (state_2_1 as ::core::ffi::c_uint) - .wrapping_sub(6 as ::core::ffi::c_uint) + (state_2_1 as c_uint).wrapping_sub(6 as c_uint) }) as lzma_lzma_state; - pos_state_next_1 = pos_state_next_1.wrapping_add(1 as uint32_t) - & (*coder).pos_mask; - let next_rep_match_price_1: uint32_t = cur_and_len_literal_price_0 - .wrapping_add( - rc_bit_1_price( - (*coder) - .is_match[state_2_1 as usize][pos_state_next_1 as usize], - ) as uint32_t, - ) - .wrapping_add( - rc_bit_1_price((*coder).is_rep[state_2_1 as usize]) - as uint32_t, - ); - let offset_1: uint32_t = cur + pos_state_next_1 = pos_state_next_1.wrapping_add(1 as u32) & (*coder).pos_mask; + let next_rep_match_price_1: u32 = cur_and_len_literal_price_0 + .wrapping_add(rc_bit_1_price( + (*coder).is_match[state_2_1 as usize][pos_state_next_1 as usize], + ) as u32) + .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2_1 as usize]) as u32); + let offset_1: u32 = cur .wrapping_add(len_test_1) - .wrapping_add(1 as uint32_t) + .wrapping_add(1 as u32) .wrapping_add(len_test_2_0); while len_end < offset_1 { len_end = len_end.wrapping_add(1); - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE - as uint32_t; + (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } - cur_and_len_price_2 = next_rep_match_price_1 - .wrapping_add( - get_rep_price( - coder, - 0 as uint32_t, - len_test_2_0, - state_2_1, - pos_state_next_1, - ), - ); + cur_and_len_price_2 = next_rep_match_price_1.wrapping_add(get_rep_price( + coder, + 0 as u32, + len_test_2_0, + state_2_1, + pos_state_next_1, + )); if cur_and_len_price_2 < (*coder).opts[offset_1 as usize].price { (*coder).opts[offset_1 as usize].price = cur_and_len_price_2; - (*coder).opts[offset_1 as usize].pos_prev = cur - .wrapping_add(len_test_1) - .wrapping_add(1 as uint32_t); - (*coder).opts[offset_1 as usize].back_prev = 0 as uint32_t; + (*coder).opts[offset_1 as usize].pos_prev = + cur.wrapping_add(len_test_1).wrapping_add(1 as u32); + (*coder).opts[offset_1 as usize].back_prev = 0 as u32; (*coder).opts[offset_1 as usize].prev_1_is_literal = true_0 != 0; (*coder).opts[offset_1 as usize].prev_2 = true_0 != 0; (*coder).opts[offset_1 as usize].pos_prev_2 = cur; - (*coder).opts[offset_1 as usize].back_prev_2 = cur_back - .wrapping_add(REPS as uint32_t); + (*coder).opts[offset_1 as usize].back_prev_2 = + cur_back.wrapping_add(REPS as u32); } } i_2 = i_2.wrapping_add(1); @@ -1469,43 +1214,38 @@ unsafe extern "C" fn helper2( pub unsafe extern "C" fn lzma_lzma_optimum_normal( mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf, - mut back_res: *mut uint32_t, - mut len_res: *mut uint32_t, - mut position: uint32_t, + mut back_res: *mut u32, + mut len_res: *mut u32, + mut position: u32, ) { if (*coder).opts_end_index != (*coder).opts_current_index { - *len_res = (*coder) - .opts[(*coder).opts_current_index as usize] + *len_res = (*coder).opts[(*coder).opts_current_index as usize] .pos_prev .wrapping_sub((*coder).opts_current_index); *back_res = (*coder).opts[(*coder).opts_current_index as usize].back_prev; - (*coder).opts_current_index = (*coder) - .opts[(*coder).opts_current_index as usize] - .pos_prev; + (*coder).opts_current_index = (*coder).opts[(*coder).opts_current_index as usize].pos_prev; return; } - if (*mf).read_ahead == 0 as uint32_t { - if (*coder).match_price_count - >= ((1 as ::core::ffi::c_int) << 7 as ::core::ffi::c_int) as uint32_t - { + if (*mf).read_ahead == 0 as u32 { + if (*coder).match_price_count >= ((1 as c_int) << 7 as c_int) as u32 { fill_dist_prices(coder); } - if (*coder).align_price_count >= ALIGN_SIZE as uint32_t { + if (*coder).align_price_count >= ALIGN_SIZE as u32 { fill_align_prices(coder); } } - let mut len_end: uint32_t = helper1(coder, mf, back_res, len_res, position); - if len_end == UINT32_MAX as uint32_t { + let mut len_end: u32 = helper1(coder, mf, back_res, len_res, position); + if len_end == UINT32_MAX as u32 { return; } - let mut reps: [uint32_t; 4] = [0; 4]; + let mut reps: [u32; 4] = [0; 4]; memcpy( - &raw mut reps as *mut uint32_t as *mut ::core::ffi::c_void, - &raw mut (*coder).reps as *mut uint32_t as *const ::core::ffi::c_void, - ::core::mem::size_of::<[uint32_t; 4]>() as size_t, + &raw mut reps as *mut u32 as *mut c_void, + &raw mut (*coder).reps as *mut u32 as *const c_void, + ::core::mem::size_of::<[u32; 4]>() as size_t, ); - let mut cur: uint32_t = 0; - cur = 1 as uint32_t; + let mut cur: u32 = 0; + cur = 1 as u32; while cur < len_end { (*coder).longest_match_length = lzma_mf_find( mf, @@ -1517,22 +1257,18 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( } len_end = helper2( coder, - &raw mut reps as *mut uint32_t, - mf_ptr(mf).offset(-(1 as ::core::ffi::c_int as isize)), + &raw mut reps as *mut u32, + mf_ptr(mf).offset(-(1 as isize)), len_end, position.wrapping_add(cur), cur, (*mf).nice_len, - if mf_avail(mf).wrapping_add(1 as uint32_t) - < ((((1 as ::core::ffi::c_int) << 12 as ::core::ffi::c_int) - - 1 as ::core::ffi::c_int) as uint32_t) - .wrapping_sub(cur) + if mf_avail(mf).wrapping_add(1 as u32) + < ((((1 as c_int) << 12 as c_int) - 1 as c_int) as u32).wrapping_sub(cur) { - mf_avail(mf).wrapping_add(1 as uint32_t) + mf_avail(mf).wrapping_add(1 as u32) } else { - ((((1 as ::core::ffi::c_int) << 12 as ::core::ffi::c_int) - - 1 as ::core::ffi::c_int) as uint32_t) - .wrapping_sub(cur) + ((((1 as c_int) << 12 as c_int) - 1 as c_int) as u32).wrapping_sub(cur) }, ); cur = cur.wrapping_add(1); diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index 8bfafcd6..7c70f9a3 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -1,127 +1,106 @@ -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type lzma_bool = ::core::ffi::c_uchar; -pub type lzma_reserved_enum = ::core::ffi::c_uint; +use crate::types::*; +use core::ffi::{c_int, c_uchar, c_uint, c_void}; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub type lzma_match_finder = ::core::ffi::c_uint; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub type lzma_mode = ::core::ffi::c_uint; pub const LZMA_MODE_NORMAL: lzma_mode = 2; pub const LZMA_MODE_FAST: lzma_mode = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { - pub dict_size: uint32_t, - pub preset_dict: *const uint8_t, - pub preset_dict_size: uint32_t, - pub lc: uint32_t, - pub lp: uint32_t, - pub pb: uint32_t, + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, pub mode: lzma_mode, - pub nice_len: uint32_t, + pub nice_len: u32, pub mf: lzma_match_finder, - pub depth: uint32_t, - pub ext_flags: uint32_t, - pub ext_size_low: uint32_t, - pub ext_size_high: uint32_t, - pub reserved_int4: uint32_t, - pub reserved_int5: uint32_t, - pub reserved_int6: uint32_t, - pub reserved_int7: uint32_t, - pub reserved_int8: uint32_t, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, pub reserved_enum3: lzma_reserved_enum, pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut ::core::ffi::c_void, - pub reserved_ptr2: *mut ::core::ffi::c_void, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_LC_DEFAULT: ::core::ffi::c_int = 3 as ::core::ffi::c_int; -pub const LZMA_LP_DEFAULT: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_PB_DEFAULT: ::core::ffi::c_int = 2 as ::core::ffi::c_int; -pub const LZMA_PRESET_LEVEL_MASK: ::core::ffi::c_uint = 0x1f as ::core::ffi::c_uint; -pub const LZMA_PRESET_EXTREME: ::core::ffi::c_uint = (1 as ::core::ffi::c_uint) - << 31 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_LC_DEFAULT: c_int = 3 as c_int; +pub const LZMA_LP_DEFAULT: c_int = 0 as c_int; +pub const LZMA_PB_DEFAULT: c_int = 2 as c_int; +pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f as c_uint; +pub const LZMA_PRESET_EXTREME: c_uint = (1 as c_uint) << 31 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_preset( mut options: *mut lzma_options_lzma, - mut preset: uint32_t, + mut preset: u32, ) -> lzma_bool { - let level: uint32_t = preset & LZMA_PRESET_LEVEL_MASK as uint32_t; - let flags: uint32_t = preset & !(LZMA_PRESET_LEVEL_MASK as uint32_t); - let supported_flags: uint32_t = LZMA_PRESET_EXTREME as uint32_t; - if level > 9 as uint32_t || flags & !supported_flags != 0 { + let level: u32 = preset & LZMA_PRESET_LEVEL_MASK as u32; + let flags: u32 = preset & !(LZMA_PRESET_LEVEL_MASK as u32); + let supported_flags: u32 = LZMA_PRESET_EXTREME as u32; + if level > 9 as u32 || flags & !supported_flags != 0 { return true_0 as lzma_bool; } - (*options).preset_dict = ::core::ptr::null::(); - (*options).preset_dict_size = 0 as uint32_t; - (*options).lc = LZMA_LC_DEFAULT as uint32_t; - (*options).lp = LZMA_LP_DEFAULT as uint32_t; - (*options).pb = LZMA_PB_DEFAULT as uint32_t; - static mut dict_pow2: [uint8_t; 10] = [ - 18 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 26 as ::core::ffi::c_int as uint8_t, + (*options).preset_dict = ::core::ptr::null::(); + (*options).preset_dict_size = 0 as u32; + (*options).lc = LZMA_LC_DEFAULT as u32; + (*options).lp = LZMA_LP_DEFAULT as u32; + (*options).pb = LZMA_PB_DEFAULT as u32; + static mut dict_pow2: [u8; 10] = [ + 18 as u8, 20 as u8, 21 as u8, 22 as u8, 22 as u8, 23 as u8, 23 as u8, 24 as u8, 25 as u8, + 26 as u8, ]; - (*options).dict_size = ((1 as ::core::ffi::c_uint) - << dict_pow2[level as usize] as ::core::ffi::c_int) as uint32_t; - if level <= 3 as uint32_t { + (*options).dict_size = ((1 as c_uint) << dict_pow2[level as usize] as c_int) as u32; + if level <= 3 as u32 { (*options).mode = LZMA_MODE_FAST; - (*options).mf = (if level == 0 as uint32_t { - LZMA_MF_HC3 as ::core::ffi::c_int + (*options).mf = (if level == 0 as u32 { + LZMA_MF_HC3 as c_int } else { - LZMA_MF_HC4 as ::core::ffi::c_int + LZMA_MF_HC4 as c_int }) as lzma_match_finder; - (*options).nice_len = (if level <= 1 as uint32_t { - 128 as ::core::ffi::c_int + (*options).nice_len = (if level <= 1 as u32 { + 128 as c_int } else { - 273 as ::core::ffi::c_int - }) as uint32_t; - static mut depths: [uint8_t; 4] = [ - 4 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 48 as ::core::ffi::c_int as uint8_t, - ]; - (*options).depth = depths[level as usize] as uint32_t; + 273 as c_int + }) as u32; + static mut depths: [u8; 4] = [4 as u8, 8 as u8, 24 as u8, 48 as u8]; + (*options).depth = depths[level as usize] as u32; } else { (*options).mode = LZMA_MODE_NORMAL; (*options).mf = LZMA_MF_BT4; - (*options).nice_len = (if level == 4 as uint32_t { - 16 as ::core::ffi::c_int - } else if level == 5 as uint32_t { - 32 as ::core::ffi::c_int + (*options).nice_len = (if level == 4 as u32 { + 16 as c_int + } else if level == 5 as u32 { + 32 as c_int } else { - 64 as ::core::ffi::c_int - }) as uint32_t; - (*options).depth = 0 as uint32_t; + 64 as c_int + }) as u32; + (*options).depth = 0 as u32; } - if flags & LZMA_PRESET_EXTREME as uint32_t != 0 { + if flags & LZMA_PRESET_EXTREME as u32 != 0 { (*options).mode = LZMA_MODE_NORMAL; (*options).mf = LZMA_MF_BT4; - if level == 3 as uint32_t || level == 5 as uint32_t { - (*options).nice_len = 192 as uint32_t; - (*options).depth = 0 as uint32_t; + if level == 3 as u32 || level == 5 as u32 { + (*options).nice_len = 192 as u32; + (*options).depth = 0 as u32; } else { - (*options).nice_len = 273 as uint32_t; - (*options).depth = 512 as uint32_t; + (*options).nice_len = 273 as u32; + (*options).depth = 512 as u32; } } return false_0 as lzma_bool; diff --git a/liblzma-rs/src/rangecoder/price_table.rs b/liblzma-rs/src/rangecoder/price_table.rs index 7e1e149b..43e798b8 100644 --- a/liblzma-rs/src/rangecoder/price_table.rs +++ b/liblzma-rs/src/rangecoder/price_table.rs @@ -1,132 +1,10 @@ -pub type uint8_t = u8; +use crate::types::*; +use core::ffi::c_int; #[no_mangle] -pub static mut lzma_rc_prices: [uint8_t; 128] = [ - 128 as ::core::ffi::c_int as uint8_t, - 103 as ::core::ffi::c_int as uint8_t, - 91 as ::core::ffi::c_int as uint8_t, - 84 as ::core::ffi::c_int as uint8_t, - 78 as ::core::ffi::c_int as uint8_t, - 73 as ::core::ffi::c_int as uint8_t, - 69 as ::core::ffi::c_int as uint8_t, - 66 as ::core::ffi::c_int as uint8_t, - 63 as ::core::ffi::c_int as uint8_t, - 61 as ::core::ffi::c_int as uint8_t, - 58 as ::core::ffi::c_int as uint8_t, - 56 as ::core::ffi::c_int as uint8_t, - 54 as ::core::ffi::c_int as uint8_t, - 52 as ::core::ffi::c_int as uint8_t, - 51 as ::core::ffi::c_int as uint8_t, - 49 as ::core::ffi::c_int as uint8_t, - 48 as ::core::ffi::c_int as uint8_t, - 46 as ::core::ffi::c_int as uint8_t, - 45 as ::core::ffi::c_int as uint8_t, - 44 as ::core::ffi::c_int as uint8_t, - 43 as ::core::ffi::c_int as uint8_t, - 42 as ::core::ffi::c_int as uint8_t, - 41 as ::core::ffi::c_int as uint8_t, - 40 as ::core::ffi::c_int as uint8_t, - 39 as ::core::ffi::c_int as uint8_t, - 38 as ::core::ffi::c_int as uint8_t, - 37 as ::core::ffi::c_int as uint8_t, - 36 as ::core::ffi::c_int as uint8_t, - 35 as ::core::ffi::c_int as uint8_t, - 34 as ::core::ffi::c_int as uint8_t, - 34 as ::core::ffi::c_int as uint8_t, - 33 as ::core::ffi::c_int as uint8_t, - 32 as ::core::ffi::c_int as uint8_t, - 31 as ::core::ffi::c_int as uint8_t, - 31 as ::core::ffi::c_int as uint8_t, - 30 as ::core::ffi::c_int as uint8_t, - 29 as ::core::ffi::c_int as uint8_t, - 29 as ::core::ffi::c_int as uint8_t, - 28 as ::core::ffi::c_int as uint8_t, - 28 as ::core::ffi::c_int as uint8_t, - 27 as ::core::ffi::c_int as uint8_t, - 26 as ::core::ffi::c_int as uint8_t, - 26 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 25 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 24 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 23 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 22 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 21 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 20 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 19 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 18 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 17 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 16 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 15 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 14 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 13 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 12 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 11 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 10 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 9 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 8 as ::core::ffi::c_int as uint8_t, - 7 as ::core::ffi::c_int as uint8_t, - 7 as ::core::ffi::c_int as uint8_t, - 7 as ::core::ffi::c_int as uint8_t, - 7 as ::core::ffi::c_int as uint8_t, - 6 as ::core::ffi::c_int as uint8_t, - 6 as ::core::ffi::c_int as uint8_t, - 6 as ::core::ffi::c_int as uint8_t, - 6 as ::core::ffi::c_int as uint8_t, - 5 as ::core::ffi::c_int as uint8_t, - 5 as ::core::ffi::c_int as uint8_t, - 5 as ::core::ffi::c_int as uint8_t, - 5 as ::core::ffi::c_int as uint8_t, - 5 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 4 as ::core::ffi::c_int as uint8_t, - 3 as ::core::ffi::c_int as uint8_t, - 3 as ::core::ffi::c_int as uint8_t, - 3 as ::core::ffi::c_int as uint8_t, - 3 as ::core::ffi::c_int as uint8_t, - 3 as ::core::ffi::c_int as uint8_t, - 2 as ::core::ffi::c_int as uint8_t, - 2 as ::core::ffi::c_int as uint8_t, - 2 as ::core::ffi::c_int as uint8_t, - 2 as ::core::ffi::c_int as uint8_t, - 2 as ::core::ffi::c_int as uint8_t, - 2 as ::core::ffi::c_int as uint8_t, - 1 as ::core::ffi::c_int as uint8_t, - 1 as ::core::ffi::c_int as uint8_t, - 1 as ::core::ffi::c_int as uint8_t, - 1 as ::core::ffi::c_int as uint8_t, - 1 as ::core::ffi::c_int as uint8_t, +pub static mut lzma_rc_prices: [u8; 128] = [ + 128, 103, 91, 84, 78, 73, 69, 66, 63, 61, 58, 56, 54, 52, 51, 49, 48, 46, 45, 44, 43, 42, 41, + 40, 39, 38, 37, 36, 35, 34, 34, 33, 32, 31, 31, 30, 29, 29, 28, 28, 27, 26, 26, 25, 25, 24, 24, + 23, 23, 22, 22, 22, 21, 21, 20, 20, 19, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 14, + 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, + 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, ]; diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index 2bf04aa2..8e2eda56 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -1,30 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, - filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + filter: Option size_t>, simple_size: size_t, unfiltered_max: size_t, - alignment: uint32_t, + alignment: u32, is_encoder: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,84 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -143,7 +96,7 @@ pub type lzma_code_function = Option< pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -153,46 +106,38 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn arm_code( - mut simple: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { - size &= !(3 as ::core::ffi::c_int as size_t); + size &= !(3 as size_t); let mut i: size_t = 0; i = 0 as size_t; while i < size { - if *buffer.offset(i.wrapping_add(3 as size_t) as isize) as ::core::ffi::c_int - == 0xeb as ::core::ffi::c_int - { - let mut src: uint32_t = (*buffer.offset(i.wrapping_add(2 as size_t) as isize) - as uint32_t) << 16 as ::core::ffi::c_int - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) - << 8 as ::core::ffi::c_int - | *buffer.offset(i.wrapping_add(0 as size_t) as isize) as uint32_t; - src <<= 2 as ::core::ffi::c_int; - let mut dest: uint32_t = 0; + if *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int == 0xeb as c_int { + let mut src: u32 = (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) + << 16 as c_int + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8 as c_int + | *buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32; + src <<= 2 as c_int; + let mut dest: u32 = 0; if is_encoder { dest = now_pos - .wrapping_add(i as uint32_t) - .wrapping_add(8 as uint32_t) + .wrapping_add(i as u32) + .wrapping_add(8 as u32) .wrapping_add(src); } else { - dest = src - .wrapping_sub( - now_pos.wrapping_add(i as uint32_t).wrapping_add(8 as uint32_t), - ); + dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(8 as u32)); } - dest >>= 2 as ::core::ffi::c_int; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest - >> 16 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest - >> 8 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = dest as uint8_t; + dest >>= 2 as c_int; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 16 as c_int) as u8; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 8 as c_int) as u8; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = dest as u8; } i = i.wrapping_add(4 as size_t); } @@ -208,19 +153,10 @@ unsafe extern "C" fn arm_coder_init( next, allocator, filters, - Some( - arm_code - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - ), + Some(arm_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), 0 as size_t, 4 as size_t, - 4 as uint32_t, + 4 as u32, is_encoder, ); } diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index 35585152..de25b14a 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -1,30 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, - filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + filter: Option size_t>, simple_size: size_t, unfiltered_max: size_t, - alignment: uint32_t, + alignment: u32, is_encoder: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,66 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, size_t, size_t) -> *mut ::core::ffi::c_void, - >, - pub free: - Option ()>, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: - Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: - Option lzma_ret>, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = - Option ()>; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -125,7 +96,7 @@ pub type lzma_code_function = Option< pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -135,64 +106,62 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::<::core::ffi::c_void>(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { - let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; - num |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) << 8 as ::core::ffi::c_int; - num |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) << 16 as ::core::ffi::c_int; - num |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) << 24 as ::core::ffi::c_int; +unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { + let mut num: u32 = *buf.offset(0 as isize) as u32; + num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; + num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; + num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; return num; } #[inline] -unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { - *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; - *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) as uint8_t; - *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) as uint8_t; - *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) as uint8_t; +unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { + *buf.offset(0 as isize) = num as u8; + *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; + *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; + *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; } unsafe extern "C" fn arm64_code( - mut simple: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { - size &= !(3 as ::core::ffi::c_int as size_t); + size &= !(3 as size_t); let mut i: size_t = 0; i = 0 as size_t; while i < size { - let mut pc: uint32_t = (now_pos as size_t).wrapping_add(i) as uint32_t; - let mut instr: uint32_t = read32le(buffer.offset(i as isize)); - if instr >> 26 as ::core::ffi::c_int == 0x25 as uint32_t { - let src: uint32_t = instr; - instr = 0x94000000 as ::core::ffi::c_uint as uint32_t; - pc >>= 2 as ::core::ffi::c_int; + let mut pc: u32 = (now_pos as size_t).wrapping_add(i) as u32; + let mut instr: u32 = read32le(buffer.offset(i as isize)); + if instr >> 26 as c_int == 0x25 as u32 { + let src: u32 = instr; + instr = 0x94000000 as c_uint as u32; + pc >>= 2 as c_int; if !is_encoder { - pc = (0 as uint32_t).wrapping_sub(pc); + pc = (0 as u32).wrapping_sub(pc); } - instr |= src.wrapping_add(pc) & 0x3ffffff as uint32_t; + instr |= src.wrapping_add(pc) & 0x3ffffff as u32; write32le(buffer.offset(i as isize), instr); - } else if instr & 0x9f000000 as uint32_t == 0x90000000 as uint32_t { - let src_0: uint32_t = instr >> 29 as ::core::ffi::c_int & 3 as uint32_t - | instr >> 3 as ::core::ffi::c_int & 0x1ffffc as uint32_t; - if !(src_0.wrapping_add(0x20000 as uint32_t) & 0x1c0000 as uint32_t != 0) { - instr = - (instr as ::core::ffi::c_uint & 0x9000001f as ::core::ffi::c_uint) as uint32_t; - pc >>= 12 as ::core::ffi::c_int; + } else if instr & 0x9f000000 as u32 == 0x90000000 as u32 { + let src_0: u32 = + instr >> 29 as c_int & 3 as u32 | instr >> 3 as c_int & 0x1ffffc as u32; + if !(src_0.wrapping_add(0x20000 as u32) & 0x1c0000 as u32 != 0) { + instr = (instr as c_uint & 0x9000001f as c_uint) as u32; + pc >>= 12 as c_int; if !is_encoder { - pc = (0 as uint32_t).wrapping_sub(pc); + pc = (0 as u32).wrapping_sub(pc); } - let dest: uint32_t = src_0.wrapping_add(pc); - instr |= (dest & 3 as uint32_t) << 29 as ::core::ffi::c_int; - instr |= (dest & 0x3fffc as uint32_t) << 3 as ::core::ffi::c_int; - instr = (instr as ::core::ffi::c_uint - | ((0 as uint32_t).wrapping_sub(dest & 0x20000 as uint32_t) - & 0xe00000 as uint32_t) as ::core::ffi::c_uint) - as uint32_t; + let dest: u32 = src_0.wrapping_add(pc); + instr |= (dest & 3 as u32) << 29 as c_int; + instr |= (dest & 0x3fffc as u32) << 3 as c_int; + instr = (instr as c_uint + | ((0 as u32).wrapping_sub(dest & 0x20000 as u32) & 0xe00000 as u32) as c_uint) + as u32; write32le(buffer.offset(i as isize), instr); } } @@ -210,19 +179,10 @@ unsafe extern "C" fn arm64_coder_init( next, allocator, filters, - Some( - arm64_code - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - ), + Some(arm64_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), 0 as size_t, 4 as size_t, - 4 as uint32_t, + 4 as u32, is_encoder, ); } @@ -236,11 +196,11 @@ pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_arm64_encode( - mut start_offset: uint32_t, - mut buf: *mut uint8_t, + mut start_offset: u32, + mut buf: *mut u8, mut size: size_t, ) -> size_t { - start_offset = (start_offset as ::core::ffi::c_uint & !(3 as ::core::ffi::c_uint)) as uint32_t; + start_offset = (start_offset as c_uint & !(3 as c_uint)) as u32; return arm64_code(NULL, start_offset, true_0 != 0, buf, size); } #[no_mangle] @@ -253,10 +213,10 @@ pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_arm64_decode( - mut start_offset: uint32_t, - mut buf: *mut uint8_t, + mut start_offset: u32, + mut buf: *mut u8, mut size: size_t, ) -> size_t { - start_offset = (start_offset as ::core::ffi::c_uint & !(3 as ::core::ffi::c_uint)) as uint32_t; + start_offset = (start_offset as c_uint & !(3 as c_uint)) as u32; return arm64_code(NULL, start_offset, false_0 != 0, buf, size); } diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index d9083001..ab58ac8f 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -1,30 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, - filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + filter: Option size_t>, simple_size: size_t, unfiltered_max: size_t, - alignment: uint32_t, + alignment: u32, is_encoder: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,84 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -143,7 +96,7 @@ pub type lzma_code_function = Option< pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -153,13 +106,13 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn armthumb_code( - mut simple: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { if size < 4 as size_t { @@ -169,39 +122,35 @@ unsafe extern "C" fn armthumb_code( let mut i: size_t = 0; i = 0 as size_t; while i <= size { - if *buffer.offset(i.wrapping_add(1 as size_t) as isize) as ::core::ffi::c_int - & 0xf8 as ::core::ffi::c_int == 0xf0 as ::core::ffi::c_int - && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as ::core::ffi::c_int - & 0xf8 as ::core::ffi::c_int == 0xf8 as ::core::ffi::c_int + if *buffer.offset(i.wrapping_add(1 as size_t) as isize) as c_int & 0xf8 as c_int + == 0xf0 as c_int + && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int & 0xf8 as c_int + == 0xf8 as c_int { - let mut src: uint32_t = (*buffer.offset(i.wrapping_add(1 as size_t) as isize) - as uint32_t & 7 as uint32_t) << 19 as ::core::ffi::c_int - | (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as uint32_t) - << 11 as ::core::ffi::c_int - | (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t - & 7 as uint32_t) << 8 as ::core::ffi::c_int - | *buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t; - src <<= 1 as ::core::ffi::c_int; - let mut dest: uint32_t = 0; + let mut src: u32 = (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32 + & 7 as u32) + << 19 as c_int + | (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32) << 11 as c_int + | (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32 & 7 as u32) + << 8 as c_int + | *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; + src <<= 1 as c_int; + let mut dest: u32 = 0; if is_encoder { dest = now_pos - .wrapping_add(i as uint32_t) - .wrapping_add(4 as uint32_t) + .wrapping_add(i as u32) + .wrapping_add(4 as u32) .wrapping_add(src); } else { - dest = src - .wrapping_sub( - now_pos.wrapping_add(i as uint32_t).wrapping_add(4 as uint32_t), - ); + dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(4 as u32)); } - dest >>= 1 as ::core::ffi::c_int; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (0xf0 as uint32_t - | dest >> 19 as ::core::ffi::c_int & 0x7 as uint32_t) as uint8_t; - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest - >> 11 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(i.wrapping_add(3 as size_t) as isize) = (0xf8 as uint32_t - | dest >> 8 as ::core::ffi::c_int & 0x7 as uint32_t) as uint8_t; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = dest as uint8_t; + dest >>= 1 as c_int; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = + (0xf0 as u32 | dest >> 19 as c_int & 0x7 as u32) as u8; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest >> 11 as c_int) as u8; + *buffer.offset(i.wrapping_add(3 as size_t) as isize) = + (0xf8 as u32 | dest >> 8 as c_int & 0x7 as u32) as u8; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = dest as u8; i = i.wrapping_add(2 as size_t); } i = i.wrapping_add(2 as size_t); @@ -220,17 +169,11 @@ unsafe extern "C" fn armthumb_coder_init( filters, Some( armthumb_code - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, + as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), 0 as size_t, 4 as size_t, - 2 as uint32_t, + 2 as u32, is_encoder, ); } diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 910f4922..fd132065 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -1,30 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, - filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + filter: Option size_t>, simple_size: size_t, unfiltered_max: size_t, - alignment: uint32_t, + alignment: u32, is_encoder: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,84 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -143,7 +96,7 @@ pub type lzma_code_function = Option< pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -153,118 +106,72 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn ia64_code( - mut simple: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { - static mut BRANCH_TABLE: [uint32_t; 32] = [ - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 4 as ::core::ffi::c_int as uint32_t, - 4 as ::core::ffi::c_int as uint32_t, - 6 as ::core::ffi::c_int as uint32_t, - 6 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 7 as ::core::ffi::c_int as uint32_t, - 7 as ::core::ffi::c_int as uint32_t, - 4 as ::core::ffi::c_int as uint32_t, - 4 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 4 as ::core::ffi::c_int as uint32_t, - 4 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, - 0 as ::core::ffi::c_int as uint32_t, + static mut BRANCH_TABLE: [u32; 32] = [ + 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, + 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 4 as u32, 4 as u32, + 6 as u32, 6 as u32, 0 as u32, 0 as u32, 7 as u32, 7 as u32, 4 as u32, 4 as u32, 0 as u32, + 0 as u32, 4 as u32, 4 as u32, 0 as u32, 0 as u32, ]; - size &= !(15 as ::core::ffi::c_int as size_t); + size &= !(15 as size_t); let mut i: size_t = 0; i = 0 as size_t; while i < size { - let instr_template: uint32_t = (*buffer.offset(i as isize) as ::core::ffi::c_int - & 0x1f as ::core::ffi::c_int) as uint32_t; - let mask: uint32_t = BRANCH_TABLE[instr_template as usize]; - let mut bit_pos: uint32_t = 5 as uint32_t; + let instr_template: u32 = (*buffer.offset(i as isize) as c_int & 0x1f as c_int) as u32; + let mask: u32 = BRANCH_TABLE[instr_template as usize]; + let mut bit_pos: u32 = 5 as u32; let mut slot: size_t = 0 as size_t; while slot < 3 as size_t { - if !(mask >> slot & 1 as uint32_t == 0 as uint32_t) { - let byte_pos: size_t = (bit_pos >> 3 as ::core::ffi::c_int) as size_t; - let bit_res: uint32_t = bit_pos & 0x7 as uint32_t; - let mut instruction: uint64_t = 0 as uint64_t; + if !(mask >> slot & 1 as u32 == 0 as u32) { + let byte_pos: size_t = (bit_pos >> 3 as c_int) as size_t; + let bit_res: u32 = bit_pos & 0x7 as u32; + let mut instruction: u64 = 0 as u64; let mut j: size_t = 0 as size_t; while j < 6 as size_t { - instruction = instruction - .wrapping_add( - (*buffer - .offset(i.wrapping_add(j).wrapping_add(byte_pos) as isize) - as uint64_t) << (8 as size_t).wrapping_mul(j), - ); + instruction = instruction.wrapping_add( + (*buffer.offset(i.wrapping_add(j).wrapping_add(byte_pos) as isize) as u64) + << (8 as size_t).wrapping_mul(j), + ); j = j.wrapping_add(1); } - let mut inst_norm: uint64_t = instruction >> bit_res; - if inst_norm >> 37 as ::core::ffi::c_int & 0xf as uint64_t - == 0x5 as uint64_t - && inst_norm >> 9 as ::core::ffi::c_int & 0x7 as uint64_t - == 0 as uint64_t + let mut inst_norm: u64 = instruction >> bit_res; + if inst_norm >> 37 as c_int & 0xf as u64 == 0x5 as u64 + && inst_norm >> 9 as c_int & 0x7 as u64 == 0 as u64 { - let mut src: uint32_t = (inst_norm >> 13 as ::core::ffi::c_int - & 0xfffff as uint64_t) as uint32_t; - src = (src as uint64_t - | (inst_norm >> 36 as ::core::ffi::c_int & 1 as uint64_t) - << 20 as ::core::ffi::c_int) as uint32_t; - src <<= 4 as ::core::ffi::c_int; - let mut dest: uint32_t = 0; + let mut src: u32 = (inst_norm >> 13 as c_int & 0xfffff as u64) as u32; + src = + (src as u64 | (inst_norm >> 36 as c_int & 1 as u64) << 20 as c_int) as u32; + src <<= 4 as c_int; + let mut dest: u32 = 0; if is_encoder { - dest = now_pos.wrapping_add(i as uint32_t).wrapping_add(src); + dest = now_pos.wrapping_add(i as u32).wrapping_add(src); } else { - dest = src.wrapping_sub(now_pos.wrapping_add(i as uint32_t)); + dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } - dest >>= 4 as ::core::ffi::c_int; - inst_norm - &= !((0x8fffff as ::core::ffi::c_int as uint64_t) - << 13 as ::core::ffi::c_int); - inst_norm - |= ((dest & 0xfffff as uint32_t) as uint64_t) - << 13 as ::core::ffi::c_int; - inst_norm - |= ((dest & 0x100000 as uint32_t) as uint64_t) - << 36 as ::core::ffi::c_int - 20 as ::core::ffi::c_int; - instruction - &= ((1 as ::core::ffi::c_uint) << bit_res) - .wrapping_sub(1 as ::core::ffi::c_uint) as uint64_t; + dest >>= 4 as c_int; + inst_norm &= !((0x8fffff as u64) << 13 as c_int); + inst_norm |= ((dest & 0xfffff as u32) as u64) << 13 as c_int; + inst_norm |= ((dest & 0x100000 as u32) as u64) << 36 as c_int - 20 as c_int; + instruction &= ((1 as c_uint) << bit_res).wrapping_sub(1 as c_uint) as u64; instruction |= inst_norm << bit_res; let mut j_0: size_t = 0 as size_t; while j_0 < 6 as size_t { - *buffer - .offset( - i.wrapping_add(j_0).wrapping_add(byte_pos) as isize, - ) = (instruction >> (8 as size_t).wrapping_mul(j_0)) - as uint8_t; + *buffer.offset(i.wrapping_add(j_0).wrapping_add(byte_pos) as isize) = + (instruction >> (8 as size_t).wrapping_mul(j_0)) as u8; j_0 = j_0.wrapping_add(1); } } } slot = slot.wrapping_add(1); - bit_pos = bit_pos.wrapping_add(41 as uint32_t); + bit_pos = bit_pos.wrapping_add(41 as u32); } i = i.wrapping_add(16 as size_t); } @@ -280,19 +187,10 @@ unsafe extern "C" fn ia64_coder_init( next, allocator, filters, - Some( - ia64_code - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - ), + Some(ia64_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), 0 as size_t, 16 as size_t, - 16 as uint32_t, + 16 as u32, is_encoder, ); } diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index aaa7042c..612aa661 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -1,30 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, - filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + filter: Option size_t>, simple_size: size_t, unfiltered_max: size_t, - alignment: uint32_t, + alignment: u32, is_encoder: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,84 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -143,7 +96,7 @@ pub type lzma_code_function = Option< pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -153,49 +106,42 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn powerpc_code( - mut simple: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { - size &= !(3 as ::core::ffi::c_int as size_t); + size &= !(3 as size_t); let mut i: size_t = 0; i = 0 as size_t; while i < size { - if *buffer.offset(i as isize) as ::core::ffi::c_int >> 2 as ::core::ffi::c_int - == 0x12 as ::core::ffi::c_int - && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as ::core::ffi::c_int - & 3 as ::core::ffi::c_int == 1 as ::core::ffi::c_int + if *buffer.offset(i as isize) as c_int >> 2 as c_int == 0x12 as c_int + && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int & 3 as c_int + == 1 as c_int { - let src: uint32_t = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) - as uint32_t & 3 as uint32_t) << 24 as ::core::ffi::c_int - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) - << 16 as ::core::ffi::c_int - | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t) - << 8 as ::core::ffi::c_int - | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t - & !(3 as uint32_t); - let mut dest: uint32_t = 0; + let src: u32 = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32 & 3 as u32) + << 24 as c_int + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 16 as c_int + | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 8 as c_int + | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32 & !(3 as u32); + let mut dest: u32 = 0; if is_encoder { - dest = now_pos.wrapping_add(i as uint32_t).wrapping_add(src); + dest = now_pos.wrapping_add(i as u32).wrapping_add(src); } else { - dest = src.wrapping_sub(now_pos.wrapping_add(i as uint32_t)); + dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (0x48 as uint32_t - | dest >> 24 as ::core::ffi::c_int & 0x3 as uint32_t) as uint8_t; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest - >> 16 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest - >> 8 as ::core::ffi::c_int) as uint8_t; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = + (0x48 as u32 | dest >> 24 as c_int & 0x3 as u32) as u8; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 16 as c_int) as u8; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 8 as c_int) as u8; let ref mut fresh0 = *buffer.offset(i.wrapping_add(3 as size_t) as isize); - *fresh0 = (*fresh0 as ::core::ffi::c_int & 0x3 as ::core::ffi::c_int) - as uint8_t; + *fresh0 = (*fresh0 as c_int & 0x3 as c_int) as u8; let ref mut fresh1 = *buffer.offset(i.wrapping_add(3 as size_t) as isize); - *fresh1 = (*fresh1 as uint32_t | dest) as uint8_t; + *fresh1 = (*fresh1 as u32 | dest) as u8; } i = i.wrapping_add(4 as size_t); } @@ -212,18 +158,11 @@ unsafe extern "C" fn powerpc_coder_init( allocator, filters, Some( - powerpc_code - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, + powerpc_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), 0 as size_t, 4 as size_t, - 4 as uint32_t, + 4 as u32, is_encoder, ); } diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 5814a12d..22c07bc0 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -1,30 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, - filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + filter: Option size_t>, simple_size: size_t, unfiltered_max: size_t, - alignment: uint32_t, + alignment: u32, is_encoder: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,66 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, size_t, size_t) -> *mut ::core::ffi::c_void, - >, - pub free: - Option ()>, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: - Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: - Option lzma_ret>, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = - Option ()>; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -125,7 +96,7 @@ pub type lzma_code_function = Option< pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -135,46 +106,45 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::<::core::ffi::c_void>(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32be(mut buf: *const uint8_t) -> uint32_t { - let mut num: uint32_t = - (*buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t) << 24 as ::core::ffi::c_int; - num |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) << 16 as ::core::ffi::c_int; - num |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) << 8 as ::core::ffi::c_int; - num |= *buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t; +unsafe extern "C" fn read32be(mut buf: *const u8) -> u32 { + let mut num: u32 = (*buf.offset(0 as isize) as u32) << 24 as c_int; + num |= (*buf.offset(1 as isize) as u32) << 16 as c_int; + num |= (*buf.offset(2 as isize) as u32) << 8 as c_int; + num |= *buf.offset(3 as isize) as u32; return num; } #[inline] -unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { - let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; - num |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) << 8 as ::core::ffi::c_int; - num |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) << 16 as ::core::ffi::c_int; - num |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) << 24 as ::core::ffi::c_int; +unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { + let mut num: u32 = *buf.offset(0 as isize) as u32; + num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; + num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; + num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; return num; } #[inline] -unsafe extern "C" fn write32be(mut buf: *mut uint8_t, mut num: uint32_t) { - *buf.offset(0 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) as uint8_t; - *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) as uint8_t; - *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) as uint8_t; - *buf.offset(3 as ::core::ffi::c_int as isize) = num as uint8_t; +unsafe extern "C" fn write32be(mut buf: *mut u8, mut num: u32) { + *buf.offset(0 as isize) = (num >> 24 as c_int) as u8; + *buf.offset(1 as isize) = (num >> 16 as c_int) as u8; + *buf.offset(2 as isize) = (num >> 8 as c_int) as u8; + *buf.offset(3 as isize) = num as u8; } #[inline] -unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { - *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; - *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) as uint8_t; - *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) as uint8_t; - *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) as uint8_t; +unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { + *buf.offset(0 as isize) = num as u8; + *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; + *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; + *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; } unsafe extern "C" fn riscv_encode( - mut simple: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { if size < 8 as size_t { @@ -185,106 +155,66 @@ unsafe extern "C" fn riscv_encode( let mut current_block_22: u64; i = 0 as size_t; while i <= size { - let mut inst: uint32_t = *buffer.offset(i as isize) as uint32_t; - if inst == 0xef as uint32_t { - let b1: uint32_t = *buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t; - if !(b1 & 0xd as uint32_t != 0 as uint32_t) { - let b2: uint32_t = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t; - let b3: uint32_t = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t; - let pc: uint32_t = now_pos.wrapping_add(i as uint32_t); - let mut addr: uint32_t = (b1 & 0xf0 as uint32_t) << 8 as ::core::ffi::c_int - | (b2 & 0xf as uint32_t) << 16 as ::core::ffi::c_int - | (b2 & 0x10 as uint32_t) << 7 as ::core::ffi::c_int - | (b2 & 0xe0 as uint32_t) >> 4 as ::core::ffi::c_int - | (b3 & 0x7f as uint32_t) << 4 as ::core::ffi::c_int - | (b3 & 0x80 as uint32_t) << 13 as ::core::ffi::c_int; + let mut inst: u32 = *buffer.offset(i as isize) as u32; + if inst == 0xef as u32 { + let b1: u32 = *buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32; + if !(b1 & 0xd as u32 != 0 as u32) { + let b2: u32 = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; + let b3: u32 = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; + let pc: u32 = now_pos.wrapping_add(i as u32); + let mut addr: u32 = (b1 & 0xf0 as u32) << 8 as c_int + | (b2 & 0xf as u32) << 16 as c_int + | (b2 & 0x10 as u32) << 7 as c_int + | (b2 & 0xe0 as u32) >> 4 as c_int + | (b3 & 0x7f as u32) << 4 as c_int + | (b3 & 0x80 as u32) << 13 as c_int; addr = addr.wrapping_add(pc); - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (b1 & 0xf as uint32_t - | addr >> 13 as ::core::ffi::c_int & 0xf0 as uint32_t) - as uint8_t; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = - (addr >> 9 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(i.wrapping_add(3 as size_t) as isize) = - (addr >> 1 as ::core::ffi::c_int) as uint8_t; - i = i.wrapping_add((4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t); + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = + (b1 & 0xf as u32 | addr >> 13 as c_int & 0xf0 as u32) as u8; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (addr >> 9 as c_int) as u8; + *buffer.offset(i.wrapping_add(3 as size_t) as isize) = (addr >> 1 as c_int) as u8; + i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); } - } else if inst & 0x7f as uint32_t == 0x17 as uint32_t { - inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t) - << 16 as ::core::ffi::c_int; - inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t) - << 24 as ::core::ffi::c_int; - if inst & 0xe80 as uint32_t != 0 { - let mut inst2: uint32_t = read32le( - buffer - .offset(i as isize) - .offset(4 as ::core::ffi::c_int as isize), - ); - if (inst << 8 as ::core::ffi::c_int ^ inst2.wrapping_sub(3 as uint32_t)) - & 0xf8003 as uint32_t - != 0 - { - i = i.wrapping_add( - (6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, - ); + } else if inst & 0x7f as u32 == 0x17 as u32 { + inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8 as c_int; + inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16 as c_int; + inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32) << 24 as c_int; + if inst & 0xe80 as u32 != 0 { + let mut inst2: u32 = read32le(buffer.offset(i as isize).offset(4 as isize)); + if (inst << 8 as c_int ^ inst2.wrapping_sub(3 as u32)) & 0xf8003 as u32 != 0 { + i = i.wrapping_add((6 as c_int - 2 as c_int) as size_t); current_block_22 = 12517898123489920830; } else { - let mut addr_0: uint32_t = inst & 0xfffff000 as uint32_t; + let mut addr_0: u32 = inst & 0xfffff000 as u32; addr_0 = addr_0.wrapping_add( - (inst2 >> 20 as ::core::ffi::c_int) - .wrapping_sub(inst2 >> 19 as ::core::ffi::c_int & 0x1000 as uint32_t), + (inst2 >> 20 as c_int).wrapping_sub(inst2 >> 19 as c_int & 0x1000 as u32), ); - addr_0 = addr_0.wrapping_add(now_pos.wrapping_add(i as uint32_t)); - inst = (0x17 as ::core::ffi::c_int - | (2 as ::core::ffi::c_int) << 7 as ::core::ffi::c_int) - as uint32_t - | inst2 << 12 as ::core::ffi::c_int; + addr_0 = addr_0.wrapping_add(now_pos.wrapping_add(i as u32)); + inst = + (0x17 as c_int | (2 as c_int) << 7 as c_int) as u32 | inst2 << 12 as c_int; write32le(buffer.offset(i as isize), inst); - write32be( - buffer - .offset(i as isize) - .offset(4 as ::core::ffi::c_int as isize), - addr_0, - ); + write32be(buffer.offset(i as isize).offset(4 as isize), addr_0); current_block_22 = 15125582407903384992; } } else { - let fake_rs1: uint32_t = inst >> 27 as ::core::ffi::c_int; - if inst.wrapping_sub(0x3117 as uint32_t) << 18 as ::core::ffi::c_int - >= fake_rs1 & 0x1d as uint32_t - { - i = i.wrapping_add( - (4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, - ); + let fake_rs1: u32 = inst >> 27 as c_int; + if inst.wrapping_sub(0x3117 as u32) << 18 as c_int >= fake_rs1 & 0x1d as u32 { + i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); current_block_22 = 12517898123489920830; } else { - let fake_addr: uint32_t = read32le( - buffer - .offset(i as isize) - .offset(4 as ::core::ffi::c_int as isize), - ) as uint32_t; - let fake_inst2: uint32_t = - inst >> 12 as ::core::ffi::c_int | fake_addr << 20 as ::core::ffi::c_int; - inst = 0x17 as uint32_t - | fake_rs1 << 7 as ::core::ffi::c_int - | fake_addr & 0xfffff000 as uint32_t; + let fake_addr: u32 = + read32le(buffer.offset(i as isize).offset(4 as isize)) as u32; + let fake_inst2: u32 = inst >> 12 as c_int | fake_addr << 20 as c_int; + inst = 0x17 as u32 | fake_rs1 << 7 as c_int | fake_addr & 0xfffff000 as u32; write32le(buffer.offset(i as isize), inst); - write32le( - buffer - .offset(i as isize) - .offset(4 as ::core::ffi::c_int as isize), - fake_inst2, - ); + write32le(buffer.offset(i as isize).offset(4 as isize), fake_inst2); current_block_22 = 15125582407903384992; } } match current_block_22 { 12517898123489920830 => {} _ => { - i = i.wrapping_add( - (8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, - ); + i = i.wrapping_add((8 as c_int - 2 as c_int) as size_t); } } } @@ -303,35 +233,28 @@ pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( allocator, filters, Some( - riscv_encode - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, + riscv_encode as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), 0 as size_t, 8 as size_t, - 2 as uint32_t, + 2 as u32, true_0 != 0, ); } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_riscv_encode( - mut start_offset: uint32_t, - mut buf: *mut uint8_t, + mut start_offset: u32, + mut buf: *mut u8, mut size: size_t, ) -> size_t { - start_offset = (start_offset as ::core::ffi::c_uint & !(1 as ::core::ffi::c_uint)) as uint32_t; + start_offset = (start_offset as c_uint & !(1 as c_uint)) as u32; return riscv_encode(NULL, start_offset, true_0 != 0, buf, size); } unsafe extern "C" fn riscv_decode( - mut simple: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { if size < 8 as size_t { @@ -342,83 +265,56 @@ unsafe extern "C" fn riscv_decode( let mut current_block_23: u64; i = 0 as size_t; while i <= size { - let mut inst: uint32_t = *buffer.offset(i as isize) as uint32_t; - if inst == 0xef as uint32_t { - let b1: uint32_t = *buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t; - if !(b1 & 0xd as uint32_t != 0 as uint32_t) { - let b2: uint32_t = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t; - let b3: uint32_t = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t; - let pc: uint32_t = now_pos.wrapping_add(i as uint32_t); - let mut addr: uint32_t = (b1 & 0xf0 as uint32_t) << 13 as ::core::ffi::c_int - | b2 << 9 as ::core::ffi::c_int - | b3 << 1 as ::core::ffi::c_int; + let mut inst: u32 = *buffer.offset(i as isize) as u32; + if inst == 0xef as u32 { + let b1: u32 = *buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32; + if !(b1 & 0xd as u32 != 0 as u32) { + let b2: u32 = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; + let b3: u32 = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; + let pc: u32 = now_pos.wrapping_add(i as u32); + let mut addr: u32 = + (b1 & 0xf0 as u32) << 13 as c_int | b2 << 9 as c_int | b3 << 1 as c_int; addr = addr.wrapping_sub(pc); - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (b1 & 0xf as uint32_t - | addr >> 8 as ::core::ffi::c_int & 0xf0 as uint32_t) - as uint8_t; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = + (b1 & 0xf as u32 | addr >> 8 as c_int & 0xf0 as u32) as u8; *buffer.offset(i.wrapping_add(2 as size_t) as isize) = - (addr >> 16 as ::core::ffi::c_int & 0xf as uint32_t - | addr >> 7 as ::core::ffi::c_int & 0x10 as uint32_t - | addr << 4 as ::core::ffi::c_int & 0xe0 as uint32_t) - as uint8_t; + (addr >> 16 as c_int & 0xf as u32 + | addr >> 7 as c_int & 0x10 as u32 + | addr << 4 as c_int & 0xe0 as u32) as u8; *buffer.offset(i.wrapping_add(3 as size_t) as isize) = - (addr >> 4 as ::core::ffi::c_int & 0x7f as uint32_t - | addr >> 13 as ::core::ffi::c_int & 0x80 as uint32_t) - as uint8_t; - i = i.wrapping_add((4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t); + (addr >> 4 as c_int & 0x7f as u32 | addr >> 13 as c_int & 0x80 as u32) as u8; + i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); } - } else if inst & 0x7f as uint32_t == 0x17 as uint32_t { - let mut inst2: uint32_t = 0; - inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t) - << 16 as ::core::ffi::c_int; - inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t) - << 24 as ::core::ffi::c_int; - if inst & 0xe80 as uint32_t != 0 { - inst2 = read32le( - buffer - .offset(i as isize) - .offset(4 as ::core::ffi::c_int as isize), - ); - if (inst << 8 as ::core::ffi::c_int ^ inst2.wrapping_sub(3 as uint32_t)) - & 0xf8003 as uint32_t - != 0 - { - i = i.wrapping_add( - (6 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, - ); + } else if inst & 0x7f as u32 == 0x17 as u32 { + let mut inst2: u32 = 0; + inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8 as c_int; + inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16 as c_int; + inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32) << 24 as c_int; + if inst & 0xe80 as u32 != 0 { + inst2 = read32le(buffer.offset(i as isize).offset(4 as isize)); + if (inst << 8 as c_int ^ inst2.wrapping_sub(3 as u32)) & 0xf8003 as u32 != 0 { + i = i.wrapping_add((6 as c_int - 2 as c_int) as size_t); current_block_23 = 12517898123489920830; } else { - let mut addr_0: uint32_t = inst & 0xfffff000 as uint32_t; - addr_0 = addr_0.wrapping_add(inst2 >> 20 as ::core::ffi::c_int); - inst = (0x17 as ::core::ffi::c_int - | (2 as ::core::ffi::c_int) << 7 as ::core::ffi::c_int) - as uint32_t - | inst2 << 12 as ::core::ffi::c_int; + let mut addr_0: u32 = inst & 0xfffff000 as u32; + addr_0 = addr_0.wrapping_add(inst2 >> 20 as c_int); + inst = + (0x17 as c_int | (2 as c_int) << 7 as c_int) as u32 | inst2 << 12 as c_int; inst2 = addr_0; current_block_23 = 6669252993407410313; } } else { - let inst2_rs1: uint32_t = inst >> 27 as ::core::ffi::c_int; - if inst.wrapping_sub(0x3117 as uint32_t) << 18 as ::core::ffi::c_int - >= inst2_rs1 & 0x1d as uint32_t - { - i = i.wrapping_add( - (4 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, - ); + let inst2_rs1: u32 = inst >> 27 as c_int; + if inst.wrapping_sub(0x3117 as u32) << 18 as c_int >= inst2_rs1 & 0x1d as u32 { + i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); current_block_23 = 12517898123489920830; } else { - let mut addr_1: uint32_t = read32be( - buffer - .offset(i as isize) - .offset(4 as ::core::ffi::c_int as isize), - ); - addr_1 = addr_1.wrapping_sub(now_pos.wrapping_add(i as uint32_t)); - inst2 = inst >> 12 as ::core::ffi::c_int | addr_1 << 20 as ::core::ffi::c_int; - inst = 0x17 as uint32_t - | inst2_rs1 << 7 as ::core::ffi::c_int - | addr_1.wrapping_add(0x800 as uint32_t) & 0xfffff000 as uint32_t; + let mut addr_1: u32 = read32be(buffer.offset(i as isize).offset(4 as isize)); + addr_1 = addr_1.wrapping_sub(now_pos.wrapping_add(i as u32)); + inst2 = inst >> 12 as c_int | addr_1 << 20 as c_int; + inst = 0x17 as u32 + | inst2_rs1 << 7 as c_int + | addr_1.wrapping_add(0x800 as u32) & 0xfffff000 as u32; current_block_23 = 6669252993407410313; } } @@ -426,15 +322,8 @@ unsafe extern "C" fn riscv_decode( 12517898123489920830 => {} _ => { write32le(buffer.offset(i as isize), inst); - write32le( - buffer - .offset(i as isize) - .offset(4 as ::core::ffi::c_int as isize), - inst2, - ); - i = i.wrapping_add( - (8 as ::core::ffi::c_int - 2 as ::core::ffi::c_int) as size_t, - ); + write32le(buffer.offset(i as isize).offset(4 as isize), inst2); + i = i.wrapping_add((8 as c_int - 2 as c_int) as size_t); } } } @@ -453,27 +342,20 @@ pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( allocator, filters, Some( - riscv_decode - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, + riscv_decode as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), 0 as size_t, 8 as size_t, - 2 as uint32_t, + 2 as u32, false_0 != 0, ); } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_riscv_decode( - mut start_offset: uint32_t, - mut buf: *mut uint8_t, + mut start_offset: u32, + mut buf: *mut u8, mut size: size_t, ) -> size_t { - start_offset = (start_offset as ::core::ffi::c_uint & !(1 as ::core::ffi::c_uint)) as uint32_t; + start_offset = (start_offset as c_uint & !(1 as c_uint)) as u32; return riscv_decode(NULL, start_offset, false_0 != 0, buf, size); } diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 6cdbc4b4..e2ab785c 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -1,19 +1,10 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __n: size_t, - ) -> *mut ::core::ffi::c_void; - fn memmove( - __dst: *mut ::core::ffi::c_void, - __src: *const ::core::ffi::c_void, - __len: size_t, - ) -> *mut ::core::ffi::c_void; - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; + fn memmove(__dst: *mut c_void, __src: *const c_void, __len: size_t) -> *mut c_void; + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -26,21 +17,14 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( - in_0: *const uint8_t, + in_0: *const u8, in_pos: *mut size_t, in_size: size_t, - out: *mut uint8_t, + out: *mut u8, out_pos: *mut size_t, out_size: size_t, ) -> size_t; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -62,7 +46,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -71,84 +54,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -157,14 +107,14 @@ pub type lzma_code_function = Option< #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_bcj { - pub start_offset: uint32_t, + pub start_offset: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -180,59 +130,42 @@ pub struct lzma_simple_coder { pub next: lzma_next_coder, pub end_was_reached: bool, pub is_encoder: bool, - pub filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, - pub simple: *mut ::core::ffi::c_void, - pub now_pos: uint32_t, + pub filter: Option size_t>, + pub simple: *mut c_void, + pub now_pos: u32, pub allocated: size_t, pub pos: size_t, pub filtered: size_t, pub size: size_t, - pub buffer: [uint8_t; 0], + pub buffer: [u8; 0], } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; -pub const UINT64_MAX: ::core::ffi::c_ulonglong = 18446744073709551615 - as ::core::ffi::c_ulonglong; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; -pub const LZMA_VLI_UNKNOWN: ::core::ffi::c_ulonglong = UINT64_MAX; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; +pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; unsafe extern "C" fn copy_or_code( mut coder: *mut lzma_simple_coder, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, ) -> lzma_ret { if (*coder).next.code.is_none() { lzma_bufcpy(in_0, in_pos, in_size, out, out_pos, out_size); - if (*coder).is_encoder as ::core::ffi::c_int != 0 - && action as ::core::ffi::c_uint - == LZMA_FINISH as ::core::ffi::c_int as ::core::ffi::c_uint + if (*coder).is_encoder as c_int != 0 + && action as c_uint == LZMA_FINISH as c_uint && *in_pos == in_size { (*coder).end_was_reached = true_0 != 0; } } else { - let ret: lzma_ret = (*coder) - .next - .code - .expect( - "non-null function pointer", - )( + let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, in_0, @@ -243,53 +176,47 @@ unsafe extern "C" fn copy_or_code( out_size, action, ) as lzma_ret; - if ret as ::core::ffi::c_uint - == LZMA_STREAM_END as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_STREAM_END as c_uint { (*coder).end_was_reached = true_0 != 0; - } else if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { - return ret + } else if ret as c_uint != LZMA_OK as c_uint { + return ret; } } return LZMA_OK; } unsafe extern "C" fn call_filter( mut coder: *mut lzma_simple_coder, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { - let filtered: size_t = (*coder) - .filter - .expect( - "non-null function pointer", - )((*coder).simple, (*coder).now_pos, (*coder).is_encoder, buffer, size) - as size_t; - (*coder).now_pos = ((*coder).now_pos as size_t).wrapping_add(filtered) as uint32_t - as uint32_t; + let filtered: size_t = (*coder).filter.expect("non-null function pointer")( + (*coder).simple, + (*coder).now_pos, + (*coder).is_encoder, + buffer, + size, + ) as size_t; + (*coder).now_pos = ((*coder).now_pos as size_t).wrapping_add(filtered) as u32 as u32; return filtered; } unsafe extern "C" fn simple_code( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, - mut in_0: *const uint8_t, + mut in_0: *const u8, mut in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut uint8_t, + mut out: *mut u8, mut out_pos: *mut size_t, mut out_size: size_t, mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; - if action as ::core::ffi::c_uint - == LZMA_SYNC_FLUSH as ::core::ffi::c_int as ::core::ffi::c_uint - { + if action as c_uint == LZMA_SYNC_FLUSH as c_uint { return LZMA_OPTIONS_ERROR; } if (*coder).pos < (*coder).filtered { lzma_bufcpy( - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, &raw mut (*coder).pos, (*coder).filtered, out, @@ -310,27 +237,17 @@ unsafe extern "C" fn simple_code( let out_start: size_t = *out_pos; if buf_avail > 0 as size_t { memcpy( - out.offset(*out_pos as isize) as *mut ::core::ffi::c_void, - (&raw mut (*coder).buffer as *mut uint8_t).offset((*coder).pos as isize) - as *const ::core::ffi::c_void, + out.offset(*out_pos as isize) as *mut c_void, + (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) + as *const c_void, buf_avail, ); } *out_pos = (*out_pos).wrapping_add(buf_avail); let ret: lzma_ret = copy_or_code( - coder, - allocator, - in_0, - in_pos, - in_size, - out, - out_pos, - out_size, - action, + coder, allocator, in_0, in_pos, in_size, out, out_pos, out_size, action, ) as lzma_ret; - if ret as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint != LZMA_OK as c_uint { return ret; } let size: size_t = (*out_pos).wrapping_sub(out_start); @@ -347,16 +264,15 @@ unsafe extern "C" fn simple_code( } else if unfiltered > 0 as size_t { *out_pos = (*out_pos).wrapping_sub(unfiltered); memcpy( - &raw mut (*coder).buffer as *mut uint8_t as *mut ::core::ffi::c_void, - out.offset(*out_pos as isize) as *const ::core::ffi::c_void, + &raw mut (*coder).buffer as *mut u8 as *mut c_void, + out.offset(*out_pos as isize) as *const c_void, unfiltered, ); } } else if (*coder).pos > 0 as size_t { memmove( - &raw mut (*coder).buffer as *mut uint8_t as *mut ::core::ffi::c_void, - (&raw mut (*coder).buffer as *mut uint8_t).offset((*coder).pos as isize) - as *const ::core::ffi::c_void, + &raw mut (*coder).buffer as *mut u8 as *mut c_void, + (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const c_void, buf_avail, ); (*coder).size = (*coder).size.wrapping_sub((*coder).pos); @@ -369,26 +285,20 @@ unsafe extern "C" fn simple_code( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, &raw mut (*coder).size, (*coder).allocated, action, ) as lzma_ret; - if ret_0 as ::core::ffi::c_uint - != LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret_0 as c_uint != LZMA_OK as c_uint { return ret_0; } - (*coder).filtered = call_filter( - coder, - &raw mut (*coder).buffer as *mut uint8_t, - (*coder).size, - ); + (*coder).filtered = call_filter(coder, &raw mut (*coder).buffer as *mut u8, (*coder).size); if (*coder).end_was_reached { (*coder).filtered = (*coder).size; } lzma_bufcpy( - &raw mut (*coder).buffer as *mut uint8_t, + &raw mut (*coder).buffer as *mut u8, &raw mut (*coder).pos, (*coder).filtered, out, @@ -396,24 +306,22 @@ unsafe extern "C" fn simple_code( out_size, ); } - if (*coder).end_was_reached as ::core::ffi::c_int != 0 - && (*coder).pos == (*coder).size - { + if (*coder).end_was_reached as c_int != 0 && (*coder).pos == (*coder).size { return LZMA_STREAM_END; } return LZMA_OK; } unsafe extern "C" fn simple_coder_end( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, ) { let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free((*coder).simple, allocator); - lzma_free(coder as *mut ::core::ffi::c_void, allocator); + lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn simple_coder_update( - mut coder_ptr: *mut ::core::ffi::c_void, + mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, mut filters_null: *const lzma_filter, mut reversed_filters: *const lzma_filter, @@ -422,7 +330,7 @@ unsafe extern "C" fn simple_coder_update( return lzma_next_filter_update( &raw mut (*coder).next, allocator, - reversed_filters.offset(1 as ::core::ffi::c_int as isize), + reversed_filters.offset(1 as isize), ); } #[no_mangle] @@ -430,18 +338,10 @@ pub unsafe extern "C" fn lzma_simple_coder_init( mut next: *mut lzma_next_coder, mut allocator: *const lzma_allocator, mut filters: *const lzma_filter_info, - mut filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + mut filter: Option size_t>, mut simple_size: size_t, mut unfiltered_max: size_t, - mut alignment: uint32_t, + mut alignment: u32, mut is_encoder: bool, ) -> lzma_ret { let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; @@ -454,32 +354,28 @@ pub unsafe extern "C" fn lzma_simple_coder_init( if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut ::core::ffi::c_void; + (*next).coder = coder as *mut c_void; (*next).code = Some( simple_code as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, ) -> lzma_ret, ) as lzma_code_function; (*next).end = Some( - simple_coder_end - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *const lzma_allocator, - ) -> (), + simple_coder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*next).update = Some( simple_coder_update as unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -487,7 +383,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( ) as Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, @@ -496,7 +392,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*coder).next = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::<::core::ffi::c_void>() as uintptr_t, + init: ::core::ptr::null_mut::() as uintptr_t, code: None, end: None, get_progress: None, @@ -516,16 +412,15 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*coder).simple = NULL; } } - if !(*filters.offset(0 as ::core::ffi::c_int as isize)).options.is_null() { - let mut simple: *const lzma_options_bcj = (*filters - .offset(0 as ::core::ffi::c_int as isize)) - .options as *const lzma_options_bcj; + if !(*filters.offset(0 as isize)).options.is_null() { + let mut simple: *const lzma_options_bcj = + (*filters.offset(0 as isize)).options as *const lzma_options_bcj; (*coder).now_pos = (*simple).start_offset; - if (*coder).now_pos & alignment.wrapping_sub(1 as uint32_t) != 0 { + if (*coder).now_pos & alignment.wrapping_sub(1 as u32) != 0 { return LZMA_OPTIONS_ERROR; } } else { - (*coder).now_pos = 0 as uint32_t; + (*coder).now_pos = 0 as u32; } (*coder).is_encoder = is_encoder; (*coder).end_was_reached = false_0 != 0; @@ -535,6 +430,6 @@ pub unsafe extern "C" fn lzma_simple_coder_init( return lzma_next_filter_init( &raw mut (*coder).next, allocator, - filters.offset(1 as ::core::ffi::c_int as isize), + filters.offset(1 as isize), ); } diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs index 2d3f6e54..d47ac6b1 100644 --- a/liblzma-rs/src/simple/simple_decoder.rs +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -1,15 +1,9 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn lzma_alloc( - size: size_t, - allocator: *const lzma_allocator, - ) -> *mut ::core::ffi::c_void; - fn lzma_free(ptr: *mut ::core::ffi::c_void, allocator: *const lzma_allocator); + fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); } -pub type __darwin_size_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -34,46 +28,30 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_bcj { - pub start_offset: uint32_t, + pub start_offset: u32, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; #[inline] -unsafe extern "C" fn read32le(mut buf: *const uint8_t) -> uint32_t { - let mut num: uint32_t = *buf.offset(0 as ::core::ffi::c_int as isize) as uint32_t; - num - |= (*buf.offset(1 as ::core::ffi::c_int as isize) as uint32_t) - << 8 as ::core::ffi::c_int; - num - |= (*buf.offset(2 as ::core::ffi::c_int as isize) as uint32_t) - << 16 as ::core::ffi::c_int; - num - |= (*buf.offset(3 as ::core::ffi::c_int as isize) as uint32_t) - << 24 as ::core::ffi::c_int; +unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { + let mut num: u32 = *buf.offset(0 as isize) as u32; + num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; + num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; + num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; return num; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_decode( - mut options: *mut *mut ::core::ffi::c_void, + mut options: *mut *mut c_void, mut allocator: *const lzma_allocator, - mut props: *const uint8_t, + mut props: *const u8, mut props_size: size_t, ) -> lzma_ret { if props_size == 0 as size_t { @@ -90,10 +68,10 @@ pub unsafe extern "C" fn lzma_simple_props_decode( return LZMA_MEM_ERROR; } (*opt).start_offset = read32le(props); - if (*opt).start_offset == 0 as uint32_t { - lzma_free(opt as *mut ::core::ffi::c_void, allocator); + if (*opt).start_offset == 0 as u32 { + lzma_free(opt as *mut c_void, allocator); } else { - *options = opt as *mut ::core::ffi::c_void; + *options = opt as *mut c_void; } return LZMA_OK; } diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index 80a8b7d5..6d548ad6 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -1,6 +1,5 @@ -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type lzma_ret = ::core::ffi::c_uint; +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -25,42 +24,37 @@ pub const LZMA_OK: lzma_ret = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_bcj { - pub start_offset: uint32_t, + pub start_offset: u32, } -pub const __DARWIN_NULL: *mut ::core::ffi::c_void = ::core::ptr::null_mut::< - ::core::ffi::c_void, ->(); -pub const NULL: *mut ::core::ffi::c_void = __DARWIN_NULL; +pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); +pub const NULL: *mut c_void = __DARWIN_NULL; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut uint8_t, mut num: uint32_t) { - *buf.offset(0 as ::core::ffi::c_int as isize) = num as uint8_t; - *buf.offset(1 as ::core::ffi::c_int as isize) = (num >> 8 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(2 as ::core::ffi::c_int as isize) = (num >> 16 as ::core::ffi::c_int) - as uint8_t; - *buf.offset(3 as ::core::ffi::c_int as isize) = (num >> 24 as ::core::ffi::c_int) - as uint8_t; +unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { + *buf.offset(0 as isize) = num as u8; + *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; + *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; + *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_size( - mut size: *mut uint32_t, - mut options: *const ::core::ffi::c_void, + mut size: *mut u32, + mut options: *const c_void, ) -> lzma_ret { let opt: *const lzma_options_bcj = options as *const lzma_options_bcj; - *size = (if opt.is_null() || (*opt).start_offset == 0 as uint32_t { - 0 as ::core::ffi::c_int + *size = (if opt.is_null() || (*opt).start_offset == 0 as u32 { + 0 as c_int } else { - 4 as ::core::ffi::c_int - }) as uint32_t; + 4 as c_int + }) as u32; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_encode( - mut options: *const ::core::ffi::c_void, - mut out: *mut uint8_t, + mut options: *const c_void, + mut out: *mut u8, ) -> lzma_ret { let opt: *const lzma_options_bcj = options as *const lzma_options_bcj; - if opt.is_null() || (*opt).start_offset == 0 as uint32_t { + if opt.is_null() || (*opt).start_offset == 0 as u32 { return LZMA_OK; } write32le(out, (*opt).start_offset); diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index 7f6b91ec..bbc1fdae 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -1,30 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, - filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + filter: Option size_t>, simple_size: size_t, unfiltered_max: size_t, - alignment: uint32_t, + alignment: u32, is_encoder: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,84 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -143,7 +96,7 @@ pub type lzma_code_function = Option< pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -153,54 +106,47 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn sparc_code( - mut simple: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { - size &= !(3 as ::core::ffi::c_int as size_t); + size &= !(3 as size_t); let mut i: size_t = 0; i = 0 as size_t; while i < size { - if *buffer.offset(i as isize) as ::core::ffi::c_int == 0x40 as ::core::ffi::c_int - && *buffer.offset(i.wrapping_add(1 as size_t) as isize) as ::core::ffi::c_int - & 0xc0 as ::core::ffi::c_int == 0 as ::core::ffi::c_int - || *buffer.offset(i as isize) as ::core::ffi::c_int - == 0x7f as ::core::ffi::c_int - && *buffer.offset(i.wrapping_add(1 as size_t) as isize) - as ::core::ffi::c_int & 0xc0 as ::core::ffi::c_int - == 0xc0 as ::core::ffi::c_int + if *buffer.offset(i as isize) as c_int == 0x40 as c_int + && *buffer.offset(i.wrapping_add(1 as size_t) as isize) as c_int & 0xc0 as c_int + == 0 as c_int + || *buffer.offset(i as isize) as c_int == 0x7f as c_int + && *buffer.offset(i.wrapping_add(1 as size_t) as isize) as c_int & 0xc0 as c_int + == 0xc0 as c_int { - let mut src: uint32_t = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) - as uint32_t) << 24 as ::core::ffi::c_int - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as uint32_t) - << 16 as ::core::ffi::c_int - | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as uint32_t) - << 8 as ::core::ffi::c_int - | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as uint32_t; - src <<= 2 as ::core::ffi::c_int; - let mut dest: uint32_t = 0; + let mut src: u32 = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32) + << 24 as c_int + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 16 as c_int + | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 8 as c_int + | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; + src <<= 2 as c_int; + let mut dest: u32 = 0; if is_encoder { - dest = now_pos.wrapping_add(i as uint32_t).wrapping_add(src); + dest = now_pos.wrapping_add(i as u32).wrapping_add(src); } else { - dest = src.wrapping_sub(now_pos.wrapping_add(i as uint32_t)); + dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } - dest >>= 2 as ::core::ffi::c_int; - dest = (0 as uint32_t) - .wrapping_sub(dest >> 22 as ::core::ffi::c_int & 1 as uint32_t) - << 22 as ::core::ffi::c_int & 0x3fffffff as uint32_t - | dest & 0x3fffff as uint32_t | 0x40000000 as uint32_t; - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest - >> 24 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest - >> 16 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest - >> 8 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(i.wrapping_add(3 as size_t) as isize) = dest as uint8_t; + dest >>= 2 as c_int; + dest = (0 as u32).wrapping_sub(dest >> 22 as c_int & 1 as u32) << 22 as c_int + & 0x3fffffff as u32 + | dest & 0x3fffff as u32 + | 0x40000000 as u32; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest >> 24 as c_int) as u8; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 16 as c_int) as u8; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 8 as c_int) as u8; + *buffer.offset(i.wrapping_add(3 as size_t) as isize) = dest as u8; } i = i.wrapping_add(4 as size_t); } @@ -216,19 +162,10 @@ unsafe extern "C" fn sparc_coder_init( next, allocator, filters, - Some( - sparc_code - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - ), + Some(sparc_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), 0 as size_t, 4 as size_t, - 4 as uint32_t, + 4 as u32, is_encoder, ); } diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index a66005f9..ae7b48ec 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -1,30 +1,17 @@ +use crate::types::*; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, - filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, + filter: Option size_t>, simple_size: size_t, unfiltered_max: size_t, - alignment: uint32_t, + alignment: u32, is_encoder: bool, ) -> lzma_ret; } -pub type __darwin_size_t = usize; -pub type uintptr_t = usize; -pub type size_t = __darwin_size_t; -pub type uint8_t = u8; -pub type uint32_t = u32; -pub type uint64_t = u64; -pub type lzma_ret = ::core::ffi::c_uint; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -46,7 +33,6 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub type lzma_action = ::core::ffi::c_uint; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; pub const LZMA_FULL_FLUSH: lzma_action = 2; @@ -55,84 +41,51 @@ pub const LZMA_RUN: lzma_action = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { - pub alloc: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - size_t, - size_t, - ) -> *mut ::core::ffi::c_void, - >, - pub free: Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *mut ::core::ffi::c_void) -> (), - >, - pub opaque: *mut ::core::ffi::c_void, + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, } pub type lzma_next_coder = lzma_next_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_next_coder_s { - pub coder: *mut ::core::ffi::c_void, + pub coder: *mut c_void, pub id: lzma_vli, pub init: uintptr_t, pub code: lzma_code_function, pub end: lzma_end_function, - pub get_progress: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - ) -> (), - >, - pub get_check: Option< - unsafe extern "C" fn(*const ::core::ffi::c_void) -> lzma_check, - >, - pub memconfig: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, pub update: Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, *const lzma_filter, *const lzma_filter, ) -> lzma_ret, >, - pub set_out_limit: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - *mut uint64_t, - uint64_t, - ) -> lzma_ret, - >, + pub set_out_limit: Option lzma_ret>, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } -pub type lzma_vli = uint64_t; -pub type lzma_check = ::core::ffi::c_uint; pub const LZMA_CHECK_SHA256: lzma_check = 10; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option< - unsafe extern "C" fn(*mut ::core::ffi::c_void, *const lzma_allocator) -> (), ->; +pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( - *mut ::core::ffi::c_void, + *mut c_void, *const lzma_allocator, - *const uint8_t, + *const u8, *mut size_t, size_t, - *mut uint8_t, + *mut u8, *mut size_t, size_t, lzma_action, @@ -141,15 +94,15 @@ pub type lzma_code_function = Option< #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_simple_x86 { - pub prev_mask: uint32_t, - pub prev_pos: uint32_t, + pub prev_mask: u32, + pub prev_pos: u32, } #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_info_s { pub id: lzma_vli, pub init: lzma_init_function, - pub options: *mut ::core::ffi::c_void, + pub options: *mut c_void, } pub type lzma_init_function = Option< unsafe extern "C" fn( @@ -165,138 +118,107 @@ pub struct lzma_simple_coder { pub next: lzma_next_coder, pub end_was_reached: bool, pub is_encoder: bool, - pub filter: Option< - unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - >, - pub simple: *mut ::core::ffi::c_void, - pub now_pos: uint32_t, + pub filter: Option size_t>, + pub simple: *mut c_void, + pub now_pos: u32, pub allocated: size_t, pub pos: size_t, pub filtered: size_t, pub size: size_t, - pub buffer: [uint8_t; 0], + pub buffer: [u8; 0], } -pub const true_0: ::core::ffi::c_int = 1 as ::core::ffi::c_int; -pub const false_0: ::core::ffi::c_int = 0 as ::core::ffi::c_int; +pub const true_0: c_int = 1 as c_int; +pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn x86_code( - mut simple_ptr: *mut ::core::ffi::c_void, - mut now_pos: uint32_t, + mut simple_ptr: *mut c_void, + mut now_pos: u32, mut is_encoder: bool, - mut buffer: *mut uint8_t, + mut buffer: *mut u8, mut size: size_t, ) -> size_t { - static mut MASK_TO_BIT_NUMBER: [uint32_t; 5] = [ - 0 as ::core::ffi::c_int as uint32_t, - 1 as ::core::ffi::c_int as uint32_t, - 2 as ::core::ffi::c_int as uint32_t, - 2 as ::core::ffi::c_int as uint32_t, - 3 as ::core::ffi::c_int as uint32_t, - ]; + static mut MASK_TO_BIT_NUMBER: [u32; 5] = [0 as u32, 1 as u32, 2 as u32, 2 as u32, 3 as u32]; let mut simple: *mut lzma_simple_x86 = simple_ptr as *mut lzma_simple_x86; - let mut prev_mask: uint32_t = (*simple).prev_mask; - let mut prev_pos: uint32_t = (*simple).prev_pos; + let mut prev_mask: u32 = (*simple).prev_mask; + let mut prev_pos: u32 = (*simple).prev_pos; if size < 5 as size_t { return 0 as size_t; } - if now_pos.wrapping_sub(prev_pos) > 5 as uint32_t { - prev_pos = now_pos.wrapping_sub(5 as uint32_t); + if now_pos.wrapping_sub(prev_pos) > 5 as u32 { + prev_pos = now_pos.wrapping_sub(5 as u32); } let limit: size_t = size.wrapping_sub(5 as size_t); let mut buffer_pos: size_t = 0 as size_t; while buffer_pos <= limit { - let mut b: uint8_t = *buffer.offset(buffer_pos as isize); - if b as ::core::ffi::c_int != 0xe8 as ::core::ffi::c_int - && b as ::core::ffi::c_int != 0xe9 as ::core::ffi::c_int - { + let mut b: u8 = *buffer.offset(buffer_pos as isize); + if b as c_int != 0xe8 as c_int && b as c_int != 0xe9 as c_int { buffer_pos = buffer_pos.wrapping_add(1); } else { - let offset: uint32_t = now_pos - .wrapping_add(buffer_pos as uint32_t) + let offset: u32 = now_pos + .wrapping_add(buffer_pos as u32) .wrapping_sub(prev_pos); - prev_pos = now_pos.wrapping_add(buffer_pos as uint32_t); - if offset > 5 as uint32_t { - prev_mask = 0 as uint32_t; + prev_pos = now_pos.wrapping_add(buffer_pos as u32); + if offset > 5 as u32 { + prev_mask = 0 as u32; } else { - let mut i: uint32_t = 0 as uint32_t; + let mut i: u32 = 0 as u32; while i < offset { - prev_mask &= 0x77 as uint32_t; - prev_mask <<= 1 as ::core::ffi::c_int; + prev_mask &= 0x77 as u32; + prev_mask <<= 1 as c_int; i = i.wrapping_add(1); } } b = *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize); - if (b as ::core::ffi::c_int == 0 as ::core::ffi::c_int - || b as ::core::ffi::c_int == 0xff as ::core::ffi::c_int) - && prev_mask >> 1 as ::core::ffi::c_int <= 4 as uint32_t - && prev_mask >> 1 as ::core::ffi::c_int != 3 as uint32_t + if (b as c_int == 0 as c_int || b as c_int == 0xff as c_int) + && prev_mask >> 1 as c_int <= 4 as u32 + && prev_mask >> 1 as c_int != 3 as u32 { - let mut src: uint32_t = (b as uint32_t) << 24 as ::core::ffi::c_int - | (*buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) - as uint32_t) << 16 as ::core::ffi::c_int - | (*buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) - as uint32_t) << 8 as ::core::ffi::c_int - | *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) - as uint32_t; - let mut dest: uint32_t = 0; + let mut src: u32 = (b as u32) << 24 as c_int + | (*buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) as u32) + << 16 as c_int + | (*buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) as u32) + << 8 as c_int + | *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) as u32; + let mut dest: u32 = 0; loop { if is_encoder { - dest = src - .wrapping_add( - now_pos - .wrapping_add(buffer_pos as uint32_t) - .wrapping_add(5 as uint32_t), - ); + dest = src.wrapping_add( + now_pos + .wrapping_add(buffer_pos as u32) + .wrapping_add(5 as u32), + ); } else { - dest = src - .wrapping_sub( - now_pos - .wrapping_add(buffer_pos as uint32_t) - .wrapping_add(5 as uint32_t), - ); + dest = src.wrapping_sub( + now_pos + .wrapping_add(buffer_pos as u32) + .wrapping_add(5 as u32), + ); } - if prev_mask == 0 as uint32_t { + if prev_mask == 0 as u32 { break; } - let i_0: uint32_t = MASK_TO_BIT_NUMBER[(prev_mask - >> 1 as ::core::ffi::c_int) as usize]; - b = (dest - >> (24 as uint32_t) - .wrapping_sub(i_0.wrapping_mul(8 as uint32_t))) as uint8_t; - if !(b as ::core::ffi::c_int == 0 as ::core::ffi::c_int - || b as ::core::ffi::c_int == 0xff as ::core::ffi::c_int) - { + let i_0: u32 = MASK_TO_BIT_NUMBER[(prev_mask >> 1 as c_int) as usize]; + b = (dest >> (24 as u32).wrapping_sub(i_0.wrapping_mul(8 as u32))) as u8; + if !(b as c_int == 0 as c_int || b as c_int == 0xff as c_int) { break; } src = dest - ^ ((1 as uint32_t) - << (32 as uint32_t) - .wrapping_sub(i_0.wrapping_mul(8 as uint32_t))) - .wrapping_sub(1 as uint32_t); + ^ ((1 as u32) << (32 as u32).wrapping_sub(i_0.wrapping_mul(8 as u32))) + .wrapping_sub(1 as u32); } - *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize) = !(dest - >> 24 as ::core::ffi::c_int & 1 as uint32_t) - .wrapping_sub(1 as uint32_t) as uint8_t; - *buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) = (dest - >> 16 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) = (dest - >> 8 as ::core::ffi::c_int) as uint8_t; - *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) = dest - as uint8_t; + *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize) = + !(dest >> 24 as c_int & 1 as u32).wrapping_sub(1 as u32) as u8; + *buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) = + (dest >> 16 as c_int) as u8; + *buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) = + (dest >> 8 as c_int) as u8; + *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) = dest as u8; buffer_pos = buffer_pos.wrapping_add(5 as size_t); - prev_mask = 0 as uint32_t; + prev_mask = 0 as u32; } else { buffer_pos = buffer_pos.wrapping_add(1); - prev_mask |= 1 as uint32_t; - if b as ::core::ffi::c_int == 0 as ::core::ffi::c_int - || b as ::core::ffi::c_int == 0xff as ::core::ffi::c_int - { - prev_mask |= 0x10 as uint32_t; + prev_mask |= 1 as u32; + if b as c_int == 0 as c_int || b as c_int == 0xff as c_int { + prev_mask |= 0x10 as u32; } } } @@ -315,27 +237,17 @@ unsafe extern "C" fn x86_coder_init( next, allocator, filters, - Some( - x86_code - as unsafe extern "C" fn( - *mut ::core::ffi::c_void, - uint32_t, - bool, - *mut uint8_t, - size_t, - ) -> size_t, - ), + Some(x86_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), ::core::mem::size_of::() as size_t, 5 as size_t, - 1 as uint32_t, + 1 as u32, is_encoder, ) as lzma_ret; - if ret as ::core::ffi::c_uint == LZMA_OK as ::core::ffi::c_int as ::core::ffi::c_uint - { + if ret as c_uint == LZMA_OK as c_uint { let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; let mut simple: *mut lzma_simple_x86 = (*coder).simple as *mut lzma_simple_x86; - (*simple).prev_mask = 0 as uint32_t; - (*simple).prev_pos = -(5 as ::core::ffi::c_int) as uint32_t; + (*simple).prev_mask = 0 as u32; + (*simple).prev_pos = -(5 as c_int) as u32; } return ret; } @@ -349,16 +261,16 @@ pub unsafe extern "C" fn lzma_simple_x86_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_x86_encode( - mut start_offset: uint32_t, - mut buf: *mut uint8_t, + mut start_offset: u32, + mut buf: *mut u8, mut size: size_t, ) -> size_t { let mut simple: lzma_simple_x86 = lzma_simple_x86 { - prev_mask: 0 as uint32_t, - prev_pos: -(5 as ::core::ffi::c_int) as uint32_t, + prev_mask: 0 as u32, + prev_pos: -(5 as c_int) as u32, }; return x86_code( - &raw mut simple as *mut ::core::ffi::c_void, + &raw mut simple as *mut c_void, start_offset, true_0 != 0, buf, @@ -375,16 +287,16 @@ pub unsafe extern "C" fn lzma_simple_x86_decoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_x86_decode( - mut start_offset: uint32_t, - mut buf: *mut uint8_t, + mut start_offset: u32, + mut buf: *mut u8, mut size: size_t, ) -> size_t { let mut simple: lzma_simple_x86 = lzma_simple_x86 { - prev_mask: 0 as uint32_t, - prev_pos: -(5 as ::core::ffi::c_int) as uint32_t, + prev_mask: 0 as u32, + prev_pos: -(5 as c_int) as u32, }; return x86_code( - &raw mut simple as *mut ::core::ffi::c_void, + &raw mut simple as *mut c_void, start_offset, false_0 != 0, buf, diff --git a/liblzma-rs/src/tuklib/tuklib_cpucores.rs b/liblzma-rs/src/tuklib/tuklib_cpucores.rs index c6019781..7092289d 100644 --- a/liblzma-rs/src/tuklib/tuklib_cpucores.rs +++ b/liblzma-rs/src/tuklib/tuklib_cpucores.rs @@ -1,9 +1,9 @@ -pub type uint32_t = u32; +use crate::types::*; #[no_mangle] -pub unsafe extern "C" fn tuklib_cpucores() -> uint32_t { +pub unsafe extern "C" fn tuklib_cpucores() -> u32 { match std::thread::available_parallelism() { - Ok(n) => n.get() as uint32_t, + Ok(n) => n.get() as u32, Err(_) => 0, } } diff --git a/liblzma-rs/src/tuklib/tuklib_physmem.rs b/liblzma-rs/src/tuklib/tuklib_physmem.rs index f1181bd8..0b2392d6 100644 --- a/liblzma-rs/src/tuklib/tuklib_physmem.rs +++ b/liblzma-rs/src/tuklib/tuklib_physmem.rs @@ -1,7 +1,8 @@ -pub type uint64_t = u64; +use crate::types::*; +use core::ffi::{c_int, c_void}; #[no_mangle] -pub unsafe extern "C" fn tuklib_physmem() -> uint64_t { +pub unsafe extern "C" fn tuklib_physmem() -> u64 { #[cfg(target_os = "macos")] { let mut memsize: u64 = 0; diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs new file mode 100644 index 00000000..96e5cdfc --- /dev/null +++ b/liblzma-rs/src/types.rs @@ -0,0 +1,18 @@ +use core::ffi::{c_uchar, c_uint}; + +// Platform-dependent type aliases +pub type size_t = libc::size_t; +pub type uintptr_t = libc::uintptr_t; + +// lzma type aliases +pub type lzma_bool = c_uchar; +pub type lzma_ret = c_uint; +pub type lzma_action = c_uint; +pub type lzma_check = c_uint; +pub type lzma_vli = u64; +pub type lzma_reserved_enum = c_uint; +pub type lzma_mode = c_uint; +pub type lzma_match_finder = c_uint; +pub type lzma_lzma_state = c_uint; +pub type lzma_delta_type = c_uint; +pub type probability = u16; diff --git a/tests/sys_equivalence.rs b/tests/sys_equivalence.rs index f36549ed..ecf6a2c7 100644 --- a/tests/sys_equivalence.rs +++ b/tests/sys_equivalence.rs @@ -520,8 +520,7 @@ fn differential_roundtrip_across_backends() { let (c_enc_ret, c_encoded) = c_encode_easy(&input); let (rs_enc_ret, rs_encoded) = rs_encode_easy(&input); assert_eq!( - c_enc_ret, - rs_enc_ret, + c_enc_ret, rs_enc_ret, "encoder ret mismatch at case {case}: c={c_enc_ret} rs={rs_enc_ret}" ); assert_eq!( @@ -544,10 +543,22 @@ fn differential_roundtrip_across_backends() { "decode(rs_encoded) ret mismatch at case {case}: c={c_from_rs_ret} rs={rs_from_rs_ret}" ); - assert_eq!(c_from_c, input, "C decode(C encode) payload mismatch at case {case}"); - assert_eq!(rs_from_c, input, "RS decode(C encode) payload mismatch at case {case}"); - assert_eq!(c_from_rs, input, "C decode(RS encode) payload mismatch at case {case}"); - assert_eq!(rs_from_rs, input, "RS decode(RS encode) payload mismatch at case {case}"); + assert_eq!( + c_from_c, input, + "C decode(C encode) payload mismatch at case {case}" + ); + assert_eq!( + rs_from_c, input, + "RS decode(C encode) payload mismatch at case {case}" + ); + assert_eq!( + c_from_rs, input, + "C decode(RS encode) payload mismatch at case {case}" + ); + assert_eq!( + rs_from_rs, input, + "RS decode(RS encode) payload mismatch at case {case}" + ); } } } @@ -575,9 +586,12 @@ fn differential_error_codes_on_invalid_corpus() { let (c_ret, _) = c_decode_stream_buffer(&data, 4096); let (rs_ret, _) = rs_decode_stream_buffer(&data, 4096); assert_eq!( - c_ret, rs_ret, + c_ret, + rs_ret, "error ret mismatch for {}: c={} rs={}", - path.display(), c_ret, rs_ret + path.display(), + c_ret, + rs_ret ); } } From 70ee0b2a93a0b77b7826de04ceae2430e5623438 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Feb 2026 15:59:16 +0900 Subject: [PATCH 03/51] remove c_uint casts, replace with u32 --- liblzma-rs/src/check/check.rs | 22 +- liblzma-rs/src/check/crc32_fast.rs | 26 +- liblzma-rs/src/check/crc64_fast.rs | 18 +- liblzma-rs/src/check/sha256.rs | 2579 ++++------------- liblzma-rs/src/common/alone_decoder.rs | 37 +- liblzma-rs/src/common/alone_encoder.rs | 38 +- liblzma-rs/src/common/auto_decoder.rs | 38 +- liblzma-rs/src/common/block_buffer_decoder.rs | 8 +- liblzma-rs/src/common/block_buffer_encoder.rs | 62 +- liblzma-rs/src/common/block_decoder.rs | 16 +- liblzma-rs/src/common/block_encoder.rs | 28 +- liblzma-rs/src/common/block_header_decoder.rs | 31 +- liblzma-rs/src/common/block_header_encoder.rs | 34 +- liblzma-rs/src/common/block_util.rs | 10 +- liblzma-rs/src/common/common.rs | 74 +- .../src/common/easy_decoder_memusage.rs | 2 +- .../src/common/easy_encoder_memusage.rs | 2 +- liblzma-rs/src/common/easy_preset.rs | 10 +- liblzma-rs/src/common/file_info.rs | 51 +- .../src/common/filter_buffer_decoder.rs | 8 +- .../src/common/filter_buffer_encoder.rs | 8 +- liblzma-rs/src/common/filter_common.rs | 36 +- liblzma-rs/src/common/filter_decoder.rs | 28 +- liblzma-rs/src/common/filter_encoder.rs | 32 +- liblzma-rs/src/common/filter_flags_decoder.rs | 6 +- liblzma-rs/src/common/filter_flags_encoder.rs | 12 +- liblzma-rs/src/common/index.rs | 30 +- liblzma-rs/src/common/index_decoder.rs | 41 +- liblzma-rs/src/common/index_encoder.rs | 14 +- liblzma-rs/src/common/index_hash.rs | 31 +- liblzma-rs/src/common/lzip_decoder.rs | 64 +- liblzma-rs/src/common/microlzma_decoder.rs | 23 +- liblzma-rs/src/common/microlzma_encoder.rs | 15 +- liblzma-rs/src/common/outqueue.rs | 2 +- .../src/common/stream_buffer_decoder.rs | 12 +- .../src/common/stream_buffer_encoder.rs | 30 +- liblzma-rs/src/common/stream_decoder.rs | 58 +- liblzma-rs/src/common/stream_decoder_mt.rs | 265 +- liblzma-rs/src/common/stream_encoder.rs | 48 +- liblzma-rs/src/common/stream_encoder_mt.rs | 257 +- liblzma-rs/src/common/stream_flags_common.rs | 12 +- liblzma-rs/src/common/stream_flags_decoder.rs | 16 +- liblzma-rs/src/common/stream_flags_encoder.rs | 26 +- liblzma-rs/src/common/string_conversion.rs | 95 +- liblzma-rs/src/common/vli_encoder.rs | 4 +- liblzma-rs/src/common/vli_size.rs | 4 +- liblzma-rs/src/delta/delta_common.rs | 14 +- liblzma-rs/src/delta/delta_decoder.rs | 2 +- liblzma-rs/src/delta/delta_encoder.rs | 8 +- liblzma-rs/src/lz/lz_decoder.rs | 29 +- liblzma-rs/src/lz/lz_encoder.rs | 69 +- liblzma-rs/src/lz/lz_encoder_mf.rs | 170 +- liblzma-rs/src/lzma/lzma2_decoder.rs | 31 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 73 +- liblzma-rs/src/lzma/lzma_decoder.rs | 985 +++---- liblzma-rs/src/lzma/lzma_encoder.rs | 198 +- .../src/lzma/lzma_encoder_optimum_fast.rs | 34 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 202 +- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 6 +- liblzma-rs/src/simple/arm.rs | 9 +- liblzma-rs/src/simple/arm64.rs | 36 +- liblzma-rs/src/simple/armthumb.rs | 18 +- liblzma-rs/src/simple/ia64.rs | 19 +- liblzma-rs/src/simple/powerpc.rs | 14 +- liblzma-rs/src/simple/riscv.rs | 126 +- liblzma-rs/src/simple/simple_coder.rs | 31 +- liblzma-rs/src/simple/simple_decoder.rs | 8 +- liblzma-rs/src/simple/simple_encoder.rs | 8 +- liblzma-rs/src/simple/sparc.rs | 16 +- liblzma-rs/src/simple/x86.rs | 24 +- 70 files changed, 2320 insertions(+), 4073 deletions(-) diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index 105c9dfb..f49f904f 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -37,13 +37,13 @@ pub union C2RustUnnamed_0 { pub u32_0: [u32; 16], pub u64_0: [u64; 8], } -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT32_MAX: c_uint = 4294967295; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; #[no_mangle] pub unsafe extern "C" fn lzma_check_is_supported(mut type_0: lzma_check) -> lzma_bool { - if type_0 as c_uint > LZMA_CHECK_ID_MAX as c_uint { + if type_0 > LZMA_CHECK_ID_MAX { return false_0 as lzma_bool; } static mut available_checks: [lzma_bool; 16] = [ @@ -64,22 +64,22 @@ pub unsafe extern "C" fn lzma_check_is_supported(mut type_0: lzma_check) -> lzma false_0 as lzma_bool, false_0 as lzma_bool, ]; - return available_checks[type_0 as c_uint as usize]; + return available_checks[type_0 as usize]; } #[no_mangle] pub unsafe extern "C" fn lzma_check_size(mut type_0: lzma_check) -> u32 { - if type_0 as c_uint > LZMA_CHECK_ID_MAX as c_uint { + if type_0 > LZMA_CHECK_ID_MAX { return UINT32_MAX as u32; } static mut check_sizes: [u8; 16] = [ 0 as u8, 4 as u8, 4 as u8, 4 as u8, 8 as u8, 8 as u8, 8 as u8, 16 as u8, 16 as u8, 16 as u8, 32 as u8, 32 as u8, 32 as u8, 64 as u8, 64 as u8, 64 as u8, ]; - return check_sizes[type_0 as c_uint as usize] as u32; + return check_sizes[type_0 as usize] as u32; } #[no_mangle] pub unsafe extern "C" fn lzma_check_init(mut check: *mut lzma_check_state, mut type_0: lzma_check) { - match type_0 as c_uint { + match type_0 { 1 => { (*check).state.crc32 = 0 as u32; } @@ -99,7 +99,7 @@ pub unsafe extern "C" fn lzma_check_update( mut buf: *const u8, mut size: size_t, ) { - match type_0 as c_uint { + match type_0 { 1 => { (*check).state.crc32 = lzma_crc32(buf, size, (*check).state.crc32); } @@ -117,12 +117,12 @@ pub unsafe extern "C" fn lzma_check_finish( mut check: *mut lzma_check_state, mut type_0: lzma_check, ) { - match type_0 as c_uint { + match type_0 { 1 => { - (*check).buffer.u32_0[0 as usize] = (*check).state.crc32; + (*check).buffer.u32_0[0] = (*check).state.crc32; } 4 => { - (*check).buffer.u64_0[0 as usize] = (*check).state.crc64; + (*check).buffer.u64_0[0] = (*check).state.crc64; } 10 => { lzma_sha256_finish(check); diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index 34584723..441de40c 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -325,26 +325,25 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu while buf as uintptr_t & 7 as uintptr_t != 0 { let fresh0 = buf; buf = buf.offset(1); - crc = lzma_crc32_table[0 as usize][(*fresh0 as u32 ^ crc & 0xff) as usize] - ^ crc >> 8 as c_int; + crc = lzma_crc32_table[0][(*fresh0 as u32 ^ crc & 0xff) as usize] ^ crc >> 8; size = size.wrapping_sub(1); } let limit: *const u8 = buf.offset((size & !(7 as size_t)) as isize); size &= 7 as size_t; while buf < limit { crc ^= aligned_read32ne(buf); - buf = buf.offset(4 as isize); - crc = lzma_crc32_table[7 as usize][(crc & 0xff) as usize] - ^ lzma_crc32_table[6 as usize][(crc >> 8 as c_int & 0xff) as usize] - ^ lzma_crc32_table[5 as usize][(crc >> 16 as c_int & 0xff) as usize] - ^ lzma_crc32_table[4 as usize][(crc >> 24 as c_int) as usize]; + buf = buf.offset(4); + crc = lzma_crc32_table[7][(crc & 0xff) as usize] + ^ lzma_crc32_table[6][(crc >> 8 & 0xff) as usize] + ^ lzma_crc32_table[5][(crc >> 16 & 0xff) as usize] + ^ lzma_crc32_table[4][(crc >> 24) as usize]; let tmp: u32 = aligned_read32ne(buf) as u32; - buf = buf.offset(4 as isize); - crc = lzma_crc32_table[3 as usize][(tmp & 0xff) as usize] - ^ lzma_crc32_table[2 as usize][(tmp >> 8 as c_int & 0xff) as usize] + buf = buf.offset(4); + crc = lzma_crc32_table[3][(tmp & 0xff) as usize] + ^ lzma_crc32_table[2][(tmp >> 8 & 0xff) as usize] ^ crc - ^ lzma_crc32_table[1 as usize][(tmp >> 16 as c_int & 0xff) as usize] - ^ lzma_crc32_table[0 as usize][(tmp >> 24 as c_int) as usize]; + ^ lzma_crc32_table[1][(tmp >> 16 & 0xff) as usize] + ^ lzma_crc32_table[0][(tmp >> 24) as usize]; } } loop { @@ -355,8 +354,7 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu } let fresh2 = buf; buf = buf.offset(1); - crc = lzma_crc32_table[0 as usize][(*fresh2 as u32 ^ crc & 0xff) as usize] - ^ crc >> 8 as c_int; + crc = lzma_crc32_table[0][(*fresh2 as u32 ^ crc & 0xff) as usize] ^ crc >> 8; } return !crc; } diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index 978baf1a..ec6f5a1f 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1045,20 +1045,19 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu while buf as uintptr_t & 3 as uintptr_t != 0 { let fresh0 = buf; buf = buf.offset(1); - crc = lzma_crc64_table[0 as usize][(*fresh0 as u64 ^ crc & 0xff as u64) as usize] - ^ crc >> 8 as c_int; + crc = lzma_crc64_table[0][(*fresh0 as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; size = size.wrapping_sub(1); } let limit: *const u8 = buf.offset((size & !(3 as size_t)) as isize); size &= 3 as size_t; while buf < limit { let tmp: u32 = crc as u32 ^ aligned_read32ne(buf) as u32; - buf = buf.offset(4 as isize); - crc = lzma_crc64_table[3 as usize][(tmp & 0xff as u32) as usize] - ^ lzma_crc64_table[2 as usize][(tmp >> 8 as c_int & 0xff as u32) as usize] - ^ crc >> 32 as c_int - ^ lzma_crc64_table[1 as usize][(tmp >> 16 as c_int & 0xff as u32) as usize] - ^ lzma_crc64_table[0 as usize][(tmp >> 24 as c_int) as usize]; + buf = buf.offset(4); + crc = lzma_crc64_table[3][(tmp & 0xff as u32) as usize] + ^ lzma_crc64_table[2][(tmp >> 8 & 0xff as u32) as usize] + ^ crc >> 32 + ^ lzma_crc64_table[1][(tmp >> 16 & 0xff as u32) as usize] + ^ lzma_crc64_table[0][(tmp >> 24) as usize]; } } loop { @@ -1069,8 +1068,7 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu } let fresh2 = buf; buf = buf.offset(1); - crc = lzma_crc64_table[0 as usize][(*fresh2 as u64 ^ crc & 0xff as u64) as usize] - ^ crc >> 8 as c_int; + crc = lzma_crc64_table[0][(*fresh2 as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; } return !crc; } diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index e22b8d69..48c816b4 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -31,7 +31,7 @@ pub union C2RustUnnamed_0 { } #[inline] unsafe extern "C" fn rotr_32(mut num: u32, mut amount: c_uint) -> u32 { - return num >> amount | num << (32 as c_uint).wrapping_sub(amount); + return num >> amount | num << 32u32.wrapping_sub(amount); } static mut SHA256_K: [u32; 64] = [ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, @@ -51,2042 +51,522 @@ unsafe extern "C" fn transform(mut state: *mut u32, mut data: *const u32) { state as *const c_void, ::core::mem::size_of::<[u32; 8]>() as size_t, ); - W[0 as usize] = (*data.offset(0 as isize) & 0xff) << 24 as c_int - | (*data.offset(0 as isize) & 0xff00) << 8 as c_int - | (*data.offset(0 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(0 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 0 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 0 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 0 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 0 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(0 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[0 as usize]), - ); - T[(3 as c_int - 0 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 0 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 0 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 0 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 0 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 0 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 0 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 0 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 0 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[1 as usize] = (*data.offset(1 as isize) & 0xff) << 24 as c_int - | (*data.offset(1 as isize) & 0xff00) << 8 as c_int - | (*data.offset(1 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(1 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 1 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 1 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 1 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 1 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(1 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[1 as usize]), - ); - T[(3 as c_int - 1 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 1 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 1 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 1 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 1 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 1 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 1 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 1 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 1 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[2 as usize] = (*data.offset(2 as isize) & 0xff) << 24 as c_int - | (*data.offset(2 as isize) & 0xff00) << 8 as c_int - | (*data.offset(2 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(2 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 2 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 2 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 2 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 2 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(2 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[2 as usize]), - ); - T[(3 as c_int - 2 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 2 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 2 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 2 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 2 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 2 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 2 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 2 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 2 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[3 as usize] = (*data.offset(3 as isize) & 0xff) << 24 as c_int - | (*data.offset(3 as isize) & 0xff00) << 8 as c_int - | (*data.offset(3 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(3 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 3 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 3 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 3 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 3 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(3 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[3 as usize]), - ); - T[(3 as c_int - 3 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 3 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 3 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 3 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 3 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 3 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 3 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 3 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 3 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[4 as usize] = (*data.offset(4 as isize) & 0xff) << 24 as c_int - | (*data.offset(4 as isize) & 0xff00) << 8 as c_int - | (*data.offset(4 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(4 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 4 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 4 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 4 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 4 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(4 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[4 as usize]), - ); - T[(3 as c_int - 4 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 4 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 4 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 4 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 4 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 4 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 4 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 4 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 4 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[5 as usize] = (*data.offset(5 as isize) & 0xff) << 24 as c_int - | (*data.offset(5 as isize) & 0xff00) << 8 as c_int - | (*data.offset(5 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(5 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 5 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 5 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 5 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 5 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(5 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[5 as usize]), - ); - T[(3 as c_int - 5 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 5 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 5 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 5 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 5 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 5 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 5 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 5 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 5 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[6 as usize] = (*data.offset(6 as isize) & 0xff) << 24 as c_int - | (*data.offset(6 as isize) & 0xff00) << 8 as c_int - | (*data.offset(6 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(6 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 6 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 6 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 6 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 6 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(6 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[6 as usize]), - ); - T[(3 as c_int - 6 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 6 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 6 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 6 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 6 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 6 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 6 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 6 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 6 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[7 as usize] = (*data.offset(7 as isize) & 0xff) << 24 as c_int - | (*data.offset(7 as isize) & 0xff00) << 8 as c_int - | (*data.offset(7 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(7 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 7 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 7 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 7 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 7 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(7 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[7 as usize]), - ); - T[(3 as c_int - 7 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 7 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 7 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 7 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 7 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 7 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 7 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 7 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 7 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[8 as usize] = (*data.offset(8 as isize) & 0xff) << 24 as c_int - | (*data.offset(8 as isize) & 0xff00) << 8 as c_int - | (*data.offset(8 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(8 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 8 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 8 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 8 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 8 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(8 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[8 as usize]), - ); - T[(3 as c_int - 8 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 8 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 8 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 8 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 8 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 8 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 8 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 8 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 8 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[9 as usize] = (*data.offset(9 as isize) & 0xff) << 24 as c_int - | (*data.offset(9 as isize) & 0xff00) << 8 as c_int - | (*data.offset(9 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(9 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 9 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 9 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 9 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 9 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(9 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[9 as usize]), - ); - T[(3 as c_int - 9 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 9 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 9 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 9 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 9 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 9 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 9 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 9 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 9 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[10 as usize] = (*data.offset(10 as isize) & 0xff) << 24 as c_int - | (*data.offset(10 as isize) & 0xff00) << 8 as c_int - | (*data.offset(10 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(10 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 10 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 10 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 10 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 10 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(10 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[10 as usize]), - ); - T[(3 as c_int - 10 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 10 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 10 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 10 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 10 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 10 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 10 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 10 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 10 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[11 as usize] = (*data.offset(11 as isize) & 0xff) << 24 as c_int - | (*data.offset(11 as isize) & 0xff00) << 8 as c_int - | (*data.offset(11 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(11 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 11 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 11 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 11 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 11 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(11 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[11 as usize]), - ); - T[(3 as c_int - 11 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 11 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 11 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 11 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 11 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 11 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 11 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 11 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 11 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[12 as usize] = (*data.offset(12 as isize) & 0xff) << 24 as c_int - | (*data.offset(12 as isize) & 0xff00) << 8 as c_int - | (*data.offset(12 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(12 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 12 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 12 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 12 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 12 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(12 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[12 as usize]), - ); - T[(3 as c_int - 12 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 12 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 12 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 12 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 12 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 12 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 12 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 12 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 12 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[13 as usize] = (*data.offset(13 as isize) & 0xff) << 24 as c_int - | (*data.offset(13 as isize) & 0xff00) << 8 as c_int - | (*data.offset(13 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(13 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 13 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 13 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 13 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 13 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(13 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[13 as usize]), - ); - T[(3 as c_int - 13 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 13 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 13 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 13 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 13 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 13 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 13 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 13 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 13 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[14 as usize] = (*data.offset(14 as isize) & 0xff) << 24 as c_int - | (*data.offset(14 as isize) & 0xff00) << 8 as c_int - | (*data.offset(14 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(14 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 14 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 14 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 14 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 14 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(14 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[14 as usize]), - ); - T[(3 as c_int - 14 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 14 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 14 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 14 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 14 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 14 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 14 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 14 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 14 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[15 as usize] = (*data.offset(15 as isize) & 0xff) << 24 as c_int - | (*data.offset(15 as isize) & 0xff00) << 8 as c_int - | (*data.offset(15 as isize) & 0xff0000) >> 8 as c_int - | (*data.offset(15 as isize) & 0xff000000) >> 24 as c_int; - T[(7 as c_int - 15 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 15 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 15 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 15 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(15 as c_int + 0 as c_int) as usize]) - .wrapping_add(W[15 as usize]), - ); - T[(3 as c_int - 15 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 15 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 15 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 15 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 15 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 15 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 15 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 15 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 15 as c_int & 7 as c_int) as usize], - ), - ), - ); - let mut j: c_uint = 16 as c_uint; - while j < 64 as c_uint { - W[(0 as c_int & 15 as c_int) as usize] = W[(0 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(0 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(0 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(0 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(0 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(0 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(0 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(0 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 0 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 0 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 0 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 0 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 0 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(0 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(0 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 0 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 0 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 0 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 0 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 0 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 0 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 0 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 0 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 0 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 0 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 0 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(1 as c_int & 15 as c_int) as usize] = W[(1 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(1 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(1 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(1 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(1 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(1 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(1 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(1 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 1 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 1 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 1 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 1 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 1 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(1 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(1 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 1 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 1 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 1 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 1 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 1 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 1 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 1 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 1 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 1 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 1 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 1 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(2 as c_int & 15 as c_int) as usize] = W[(2 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(2 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(2 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(2 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(2 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(2 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(2 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(2 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 2 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 2 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 2 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 2 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 2 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(2 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(2 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 2 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 2 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 2 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 2 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 2 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 2 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 2 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 2 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 2 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 2 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 2 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(3 as c_int & 15 as c_int) as usize] = W[(3 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(3 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(3 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(3 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(3 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(3 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(3 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(3 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 3 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 3 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 3 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 3 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 3 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(3 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(3 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 3 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 3 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 3 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 3 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 3 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 3 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 3 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 3 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 3 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 3 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 3 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(4 as c_int & 15 as c_int) as usize] = W[(4 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(4 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(4 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(4 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(4 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(4 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(4 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(4 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 4 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 4 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 4 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 4 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 4 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(4 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(4 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 4 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 4 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 4 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 4 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 4 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 4 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 4 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 4 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 4 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 4 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 4 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(5 as c_int & 15 as c_int) as usize] = W[(5 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(5 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(5 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(5 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(5 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(5 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(5 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(5 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 5 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 5 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 5 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 5 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 5 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(5 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(5 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 5 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 5 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 5 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 5 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 5 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 5 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 5 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 5 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 5 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 5 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 5 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(6 as c_int & 15 as c_int) as usize] = W[(6 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(6 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(6 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(6 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(6 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(6 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(6 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(6 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 6 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 6 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 6 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 6 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 6 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(6 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(6 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 6 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 6 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 6 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 6 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 6 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 6 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 6 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 6 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 6 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 6 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 6 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(7 as c_int & 15 as c_int) as usize] = W[(7 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(7 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(7 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(7 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(7 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(7 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(7 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(7 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 7 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 7 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 7 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 7 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 7 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(7 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(7 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 7 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 7 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 7 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 7 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 7 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 7 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 7 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 7 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 7 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 7 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 7 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(8 as c_int & 15 as c_int) as usize] = W[(8 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(8 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(8 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(8 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(8 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(8 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(8 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(8 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 8 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 8 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 8 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 8 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 8 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(8 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(8 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 8 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 8 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 8 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 8 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 8 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 8 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 8 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 8 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 8 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 8 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 8 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(9 as c_int & 15 as c_int) as usize] = W[(9 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(9 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(9 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(9 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(9 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(9 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(9 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(9 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 9 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 9 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 9 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 9 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 9 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(9 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(9 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 9 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 9 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 9 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 9 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 9 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 9 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 9 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 9 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 9 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 9 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 9 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(10 as c_int & 15 as c_int) as usize] = W[(10 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(10 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(10 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(10 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(10 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(10 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(10 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(10 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 10 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 10 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 10 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 10 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 10 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(10 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(10 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 10 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 10 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 10 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 10 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 10 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 10 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 10 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 10 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 10 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 10 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 10 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(11 as c_int & 15 as c_int) as usize] = W[(11 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(11 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(11 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(11 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(11 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(11 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(11 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(11 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 11 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 11 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 11 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 11 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 11 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(11 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(11 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 11 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 11 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 11 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 11 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 11 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 11 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 11 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 11 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 11 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 11 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 11 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(12 as c_int & 15 as c_int) as usize] = W[(12 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(12 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(12 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(12 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(12 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(12 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(12 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(12 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 12 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 12 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 12 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 12 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 12 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(12 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(12 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 12 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 12 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 12 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 12 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 12 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 12 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 12 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 12 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 12 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 12 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 12 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(13 as c_int & 15 as c_int) as usize] = W[(13 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(13 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(13 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(13 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(13 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(13 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(13 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(13 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 13 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 13 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 13 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 13 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 13 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(13 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(13 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 13 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 13 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 13 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 13 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 13 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 13 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 13 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 13 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 13 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 13 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 13 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(14 as c_int & 15 as c_int) as usize] = W[(14 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(14 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(14 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(14 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(14 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(14 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(14 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(14 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 14 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 14 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 14 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 14 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 14 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(14 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(14 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 14 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 14 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 14 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 14 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 14 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 14 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 14 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 14 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 14 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 14 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 14 as c_int & 7 as c_int) as usize], - ), - ), - ); - W[(15 as c_int & 15 as c_int) as usize] = W[(15 as c_int & 15 as c_int) as usize] - .wrapping_add( - (rotr_32( - W[(15 as c_int - 2 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(15 as c_int - 2 as c_int & 15 as c_int) as usize], - 2 as c_uint, - ), - 17 as c_uint, - ) ^ W[(15 as c_int - 2 as c_int & 15 as c_int) as usize] >> 10 as c_int) - .wrapping_add(W[(15 as c_int - 7 as c_int & 15 as c_int) as usize]) - .wrapping_add( - rotr_32( - W[(15 as c_int - 15 as c_int & 15 as c_int) as usize] - ^ rotr_32( - W[(15 as c_int - 15 as c_int & 15 as c_int) as usize], - 11 as c_uint, - ), - 7 as c_uint, - ) ^ W[(15 as c_int - 15 as c_int & 15 as c_int) as usize] >> 3 as c_int, - ), - ); - T[(7 as c_int - 15 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 15 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(4 as c_int - 15 as c_int & 7 as c_int) as usize], - 14 as c_uint, - ), - 5 as c_uint, - ), - 6 as c_uint, - ) - .wrapping_add( - T[(6 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ T[(4 as c_int - 15 as c_int & 7 as c_int) as usize] - & (T[(5 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ T[(6 as c_int - 15 as c_int & 7 as c_int) as usize]), - ) - .wrapping_add(SHA256_K[(15 as c_uint).wrapping_add(j) as usize]) - .wrapping_add(W[(15 as c_int & 15 as c_int) as usize]), - ); - T[(3 as c_int - 15 as c_int & 7 as c_int) as usize] = T - [(3 as c_int - 15 as c_int & 7 as c_int) as usize] - .wrapping_add(T[(7 as c_int - 15 as c_int & 7 as c_int) as usize]); - T[(7 as c_int - 15 as c_int & 7 as c_int) as usize] = - T[(7 as c_int - 15 as c_int & 7 as c_int) as usize].wrapping_add( - rotr_32( - T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ rotr_32( - T[(0 as c_int - 15 as c_int & 7 as c_int) as usize], - 9 as c_uint, - ), - 11 as c_uint, - ), - 2 as c_uint, - ) - .wrapping_add( - (T[(0 as c_int - 15 as c_int & 7 as c_int) as usize] - & (T[(1 as c_int - 15 as c_int & 7 as c_int) as usize] - ^ T[(2 as c_int - 15 as c_int & 7 as c_int) as usize])) - .wrapping_add( - T[(1 as c_int - 15 as c_int & 7 as c_int) as usize] - & T[(2 as c_int - 15 as c_int & 7 as c_int) as usize], - ), - ), - ); - j = j.wrapping_add(16 as c_uint); + W[0] = (*data.offset(0) & 0xff) << 24 + | (*data.offset(0) & 0xff00) << 8 + | (*data.offset(0) & 0xff0000) >> 8 + | (*data.offset(0) & 0xff000000) >> 24; + T[7] = T[7].wrapping_add( + rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 14), 5), 6) + .wrapping_add(T[6] ^ T[4] & (T[5] ^ T[6])) + .wrapping_add(SHA256_K[0]) + .wrapping_add(W[0]), + ); + T[3] = T[3].wrapping_add(T[7]); + T[7] = T[7].wrapping_add( + rotr_32(T[0] ^ rotr_32(T[0] ^ rotr_32(T[0], 9), 11), 2) + .wrapping_add((T[0] & (T[1] ^ T[2])).wrapping_add(T[1] & T[2])), + ); + W[1] = (*data.offset(1) & 0xff) << 24 + | (*data.offset(1) & 0xff00) << 8 + | (*data.offset(1) & 0xff0000) >> 8 + | (*data.offset(1) & 0xff000000) >> 24; + T[6] = T[6].wrapping_add( + rotr_32(T[3] ^ rotr_32(T[3] ^ rotr_32(T[3], 14), 5), 6) + .wrapping_add(T[5] ^ T[3] & (T[4] ^ T[5])) + .wrapping_add(SHA256_K[1]) + .wrapping_add(W[1]), + ); + T[2] = T[2].wrapping_add(T[6]); + T[6] = T[6].wrapping_add( + rotr_32(T[7] ^ rotr_32(T[7] ^ rotr_32(T[7], 9), 11), 2) + .wrapping_add((T[7] & (T[0] ^ T[1])).wrapping_add(T[0] & T[1])), + ); + W[2] = (*data.offset(2) & 0xff) << 24 + | (*data.offset(2) & 0xff00) << 8 + | (*data.offset(2) & 0xff0000) >> 8 + | (*data.offset(2) & 0xff000000) >> 24; + T[5] = T[5].wrapping_add( + rotr_32(T[2] ^ rotr_32(T[2] ^ rotr_32(T[2], 14), 5), 6) + .wrapping_add(T[4] ^ T[2] & (T[3] ^ T[4])) + .wrapping_add(SHA256_K[2]) + .wrapping_add(W[2]), + ); + T[1] = T[1].wrapping_add(T[5]); + T[5] = T[5].wrapping_add( + rotr_32(T[6] ^ rotr_32(T[6] ^ rotr_32(T[6], 9), 11), 2) + .wrapping_add((T[6] & (T[7] ^ T[0])).wrapping_add(T[7] & T[0])), + ); + W[3] = (*data.offset(3) & 0xff) << 24 + | (*data.offset(3) & 0xff00) << 8 + | (*data.offset(3) & 0xff0000) >> 8 + | (*data.offset(3) & 0xff000000) >> 24; + T[4] = T[4].wrapping_add( + rotr_32(T[1] ^ rotr_32(T[1] ^ rotr_32(T[1], 14), 5), 6) + .wrapping_add(T[3] ^ T[1] & (T[2] ^ T[3])) + .wrapping_add(SHA256_K[3]) + .wrapping_add(W[3]), + ); + T[0] = T[0].wrapping_add(T[4]); + T[4] = T[4].wrapping_add( + rotr_32(T[5] ^ rotr_32(T[5] ^ rotr_32(T[5], 9), 11), 2) + .wrapping_add((T[5] & (T[6] ^ T[7])).wrapping_add(T[6] & T[7])), + ); + W[4] = (*data.offset(4) & 0xff) << 24 + | (*data.offset(4) & 0xff00) << 8 + | (*data.offset(4) & 0xff0000) >> 8 + | (*data.offset(4) & 0xff000000) >> 24; + T[3] = T[3].wrapping_add( + rotr_32(T[0] ^ rotr_32(T[0] ^ rotr_32(T[0], 14), 5), 6) + .wrapping_add(T[2] ^ T[0] & (T[1] ^ T[2])) + .wrapping_add(SHA256_K[4]) + .wrapping_add(W[4]), + ); + T[7] = T[7].wrapping_add(T[3]); + T[3] = T[3].wrapping_add( + rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 9), 11), 2) + .wrapping_add((T[4] & (T[5] ^ T[6])).wrapping_add(T[5] & T[6])), + ); + W[5] = (*data.offset(5) & 0xff) << 24 + | (*data.offset(5) & 0xff00) << 8 + | (*data.offset(5) & 0xff0000) >> 8 + | (*data.offset(5) & 0xff000000) >> 24; + T[2] = T[2].wrapping_add( + rotr_32(T[7] ^ rotr_32(T[7] ^ rotr_32(T[7], 14), 5), 6) + .wrapping_add(T[1] ^ T[7] & (T[0] ^ T[1])) + .wrapping_add(SHA256_K[5]) + .wrapping_add(W[5]), + ); + T[6] = T[6].wrapping_add(T[2]); + T[2] = T[2].wrapping_add( + rotr_32(T[3] ^ rotr_32(T[3] ^ rotr_32(T[3], 9), 11), 2) + .wrapping_add((T[3] & (T[4] ^ T[5])).wrapping_add(T[4] & T[5])), + ); + W[6] = (*data.offset(6) & 0xff) << 24 + | (*data.offset(6) & 0xff00) << 8 + | (*data.offset(6) & 0xff0000) >> 8 + | (*data.offset(6) & 0xff000000) >> 24; + T[1] = T[1].wrapping_add( + rotr_32(T[6] ^ rotr_32(T[6] ^ rotr_32(T[6], 14), 5), 6) + .wrapping_add(T[0] ^ T[6] & (T[7] ^ T[0])) + .wrapping_add(SHA256_K[6]) + .wrapping_add(W[6]), + ); + T[5] = T[5].wrapping_add(T[1]); + T[1] = T[1].wrapping_add( + rotr_32(T[2] ^ rotr_32(T[2] ^ rotr_32(T[2], 9), 11), 2) + .wrapping_add((T[2] & (T[3] ^ T[4])).wrapping_add(T[3] & T[4])), + ); + W[7] = (*data.offset(7) & 0xff) << 24 + | (*data.offset(7) & 0xff00) << 8 + | (*data.offset(7) & 0xff0000) >> 8 + | (*data.offset(7) & 0xff000000) >> 24; + T[0] = T[0].wrapping_add( + rotr_32(T[5] ^ rotr_32(T[5] ^ rotr_32(T[5], 14), 5), 6) + .wrapping_add(T[7] ^ T[5] & (T[6] ^ T[7])) + .wrapping_add(SHA256_K[7]) + .wrapping_add(W[7]), + ); + T[4] = T[4].wrapping_add(T[0]); + T[0] = T[0].wrapping_add( + rotr_32(T[1] ^ rotr_32(T[1] ^ rotr_32(T[1], 9), 11), 2) + .wrapping_add((T[1] & (T[2] ^ T[3])).wrapping_add(T[2] & T[3])), + ); + W[8] = (*data.offset(8) & 0xff) << 24 + | (*data.offset(8) & 0xff00) << 8 + | (*data.offset(8) & 0xff0000) >> 8 + | (*data.offset(8) & 0xff000000) >> 24; + T[7] = T[7].wrapping_add( + rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 14), 5), 6) + .wrapping_add(T[6] ^ T[4] & (T[5] ^ T[6])) + .wrapping_add(SHA256_K[8]) + .wrapping_add(W[8]), + ); + T[3] = T[3].wrapping_add(T[7]); + T[7] = T[7].wrapping_add( + rotr_32(T[0] ^ rotr_32(T[0] ^ rotr_32(T[0], 9), 11), 2) + .wrapping_add((T[0] & (T[1] ^ T[2])).wrapping_add(T[1] & T[2])), + ); + W[9] = (*data.offset(9) & 0xff) << 24 + | (*data.offset(9) & 0xff00) << 8 + | (*data.offset(9) & 0xff0000) >> 8 + | (*data.offset(9) & 0xff000000) >> 24; + T[6] = T[6].wrapping_add( + rotr_32(T[3] ^ rotr_32(T[3] ^ rotr_32(T[3], 14), 5), 6) + .wrapping_add(T[5] ^ T[3] & (T[4] ^ T[5])) + .wrapping_add(SHA256_K[9]) + .wrapping_add(W[9]), + ); + T[2] = T[2].wrapping_add(T[6]); + T[6] = T[6].wrapping_add( + rotr_32(T[7] ^ rotr_32(T[7] ^ rotr_32(T[7], 9), 11), 2) + .wrapping_add((T[7] & (T[0] ^ T[1])).wrapping_add(T[0] & T[1])), + ); + W[10] = (*data.offset(10) & 0xff) << 24 + | (*data.offset(10) & 0xff00) << 8 + | (*data.offset(10) & 0xff0000) >> 8 + | (*data.offset(10) & 0xff000000) >> 24; + T[5] = T[5].wrapping_add( + rotr_32(T[2] ^ rotr_32(T[2] ^ rotr_32(T[2], 14), 5), 6) + .wrapping_add(T[4] ^ T[2] & (T[3] ^ T[4])) + .wrapping_add(SHA256_K[10]) + .wrapping_add(W[10]), + ); + T[1] = T[1].wrapping_add(T[5]); + T[5] = T[5].wrapping_add( + rotr_32(T[6] ^ rotr_32(T[6] ^ rotr_32(T[6], 9), 11), 2) + .wrapping_add((T[6] & (T[7] ^ T[0])).wrapping_add(T[7] & T[0])), + ); + W[11] = (*data.offset(11) & 0xff) << 24 + | (*data.offset(11) & 0xff00) << 8 + | (*data.offset(11) & 0xff0000) >> 8 + | (*data.offset(11) & 0xff000000) >> 24; + T[4] = T[4].wrapping_add( + rotr_32(T[1] ^ rotr_32(T[1] ^ rotr_32(T[1], 14), 5), 6) + .wrapping_add(T[3] ^ T[1] & (T[2] ^ T[3])) + .wrapping_add(SHA256_K[11]) + .wrapping_add(W[11]), + ); + T[0] = T[0].wrapping_add(T[4]); + T[4] = T[4].wrapping_add( + rotr_32(T[5] ^ rotr_32(T[5] ^ rotr_32(T[5], 9), 11), 2) + .wrapping_add((T[5] & (T[6] ^ T[7])).wrapping_add(T[6] & T[7])), + ); + W[12] = (*data.offset(12) & 0xff) << 24 + | (*data.offset(12) & 0xff00) << 8 + | (*data.offset(12) & 0xff0000) >> 8 + | (*data.offset(12) & 0xff000000) >> 24; + T[3] = T[3].wrapping_add( + rotr_32(T[0] ^ rotr_32(T[0] ^ rotr_32(T[0], 14), 5), 6) + .wrapping_add(T[2] ^ T[0] & (T[1] ^ T[2])) + .wrapping_add(SHA256_K[12]) + .wrapping_add(W[12]), + ); + T[7] = T[7].wrapping_add(T[3]); + T[3] = T[3].wrapping_add( + rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 9), 11), 2) + .wrapping_add((T[4] & (T[5] ^ T[6])).wrapping_add(T[5] & T[6])), + ); + W[13] = (*data.offset(13) & 0xff) << 24 + | (*data.offset(13) & 0xff00) << 8 + | (*data.offset(13) & 0xff0000) >> 8 + | (*data.offset(13) & 0xff000000) >> 24; + T[2] = T[2].wrapping_add( + rotr_32(T[7] ^ rotr_32(T[7] ^ rotr_32(T[7], 14), 5), 6) + .wrapping_add(T[1] ^ T[7] & (T[0] ^ T[1])) + .wrapping_add(SHA256_K[13]) + .wrapping_add(W[13]), + ); + T[6] = T[6].wrapping_add(T[2]); + T[2] = T[2].wrapping_add( + rotr_32(T[3] ^ rotr_32(T[3] ^ rotr_32(T[3], 9), 11), 2) + .wrapping_add((T[3] & (T[4] ^ T[5])).wrapping_add(T[4] & T[5])), + ); + W[14] = (*data.offset(14) & 0xff) << 24 + | (*data.offset(14) & 0xff00) << 8 + | (*data.offset(14) & 0xff0000) >> 8 + | (*data.offset(14) & 0xff000000) >> 24; + T[1] = T[1].wrapping_add( + rotr_32(T[6] ^ rotr_32(T[6] ^ rotr_32(T[6], 14), 5), 6) + .wrapping_add(T[0] ^ T[6] & (T[7] ^ T[0])) + .wrapping_add(SHA256_K[14]) + .wrapping_add(W[14]), + ); + T[5] = T[5].wrapping_add(T[1]); + T[1] = T[1].wrapping_add( + rotr_32(T[2] ^ rotr_32(T[2] ^ rotr_32(T[2], 9), 11), 2) + .wrapping_add((T[2] & (T[3] ^ T[4])).wrapping_add(T[3] & T[4])), + ); + W[15] = (*data.offset(15) & 0xff) << 24 + | (*data.offset(15) & 0xff00) << 8 + | (*data.offset(15) & 0xff0000) >> 8 + | (*data.offset(15) & 0xff000000) >> 24; + T[0] = T[0].wrapping_add( + rotr_32(T[5] ^ rotr_32(T[5] ^ rotr_32(T[5], 14), 5), 6) + .wrapping_add(T[7] ^ T[5] & (T[6] ^ T[7])) + .wrapping_add(SHA256_K[15]) + .wrapping_add(W[15]), + ); + T[4] = T[4].wrapping_add(T[0]); + T[0] = T[0].wrapping_add( + rotr_32(T[1] ^ rotr_32(T[1] ^ rotr_32(T[1], 9), 11), 2) + .wrapping_add((T[1] & (T[2] ^ T[3])).wrapping_add(T[2] & T[3])), + ); + let mut j: c_uint = 16; + while j < 64 { + W[0] = W[0].wrapping_add( + (rotr_32(W[14] ^ rotr_32(W[14], 2), 17) ^ W[14] >> 10) + .wrapping_add(W[9]) + .wrapping_add(rotr_32(W[1] ^ rotr_32(W[1], 11), 7) ^ W[1] >> 3), + ); + T[7] = T[7].wrapping_add( + rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 14), 5), 6) + .wrapping_add(T[6] ^ T[4] & (T[5] ^ T[6])) + .wrapping_add(SHA256_K[0u32.wrapping_add(j) as usize]) + .wrapping_add(W[0]), + ); + T[3] = T[3].wrapping_add(T[7]); + T[7] = T[7].wrapping_add( + rotr_32(T[0] ^ rotr_32(T[0] ^ rotr_32(T[0], 9), 11), 2) + .wrapping_add((T[0] & (T[1] ^ T[2])).wrapping_add(T[1] & T[2])), + ); + W[1] = W[1].wrapping_add( + (rotr_32(W[15] ^ rotr_32(W[15], 2), 17) ^ W[15] >> 10) + .wrapping_add(W[10]) + .wrapping_add(rotr_32(W[2] ^ rotr_32(W[2], 11), 7) ^ W[2] >> 3), + ); + T[6] = T[6].wrapping_add( + rotr_32(T[3] ^ rotr_32(T[3] ^ rotr_32(T[3], 14), 5), 6) + .wrapping_add(T[5] ^ T[3] & (T[4] ^ T[5])) + .wrapping_add(SHA256_K[1u32.wrapping_add(j) as usize]) + .wrapping_add(W[1]), + ); + T[2] = T[2].wrapping_add(T[6]); + T[6] = T[6].wrapping_add( + rotr_32(T[7] ^ rotr_32(T[7] ^ rotr_32(T[7], 9), 11), 2) + .wrapping_add((T[7] & (T[0] ^ T[1])).wrapping_add(T[0] & T[1])), + ); + W[2] = W[2].wrapping_add( + (rotr_32(W[0] ^ rotr_32(W[0], 2), 17) ^ W[0] >> 10) + .wrapping_add(W[11]) + .wrapping_add(rotr_32(W[3] ^ rotr_32(W[3], 11), 7) ^ W[3] >> 3), + ); + T[5] = T[5].wrapping_add( + rotr_32(T[2] ^ rotr_32(T[2] ^ rotr_32(T[2], 14), 5), 6) + .wrapping_add(T[4] ^ T[2] & (T[3] ^ T[4])) + .wrapping_add(SHA256_K[2u32.wrapping_add(j) as usize]) + .wrapping_add(W[2]), + ); + T[1] = T[1].wrapping_add(T[5]); + T[5] = T[5].wrapping_add( + rotr_32(T[6] ^ rotr_32(T[6] ^ rotr_32(T[6], 9), 11), 2) + .wrapping_add((T[6] & (T[7] ^ T[0])).wrapping_add(T[7] & T[0])), + ); + W[3] = W[3].wrapping_add( + (rotr_32(W[1] ^ rotr_32(W[1], 2), 17) ^ W[1] >> 10) + .wrapping_add(W[12]) + .wrapping_add(rotr_32(W[4] ^ rotr_32(W[4], 11), 7) ^ W[4] >> 3), + ); + T[4] = T[4].wrapping_add( + rotr_32(T[1] ^ rotr_32(T[1] ^ rotr_32(T[1], 14), 5), 6) + .wrapping_add(T[3] ^ T[1] & (T[2] ^ T[3])) + .wrapping_add(SHA256_K[3u32.wrapping_add(j) as usize]) + .wrapping_add(W[3]), + ); + T[0] = T[0].wrapping_add(T[4]); + T[4] = T[4].wrapping_add( + rotr_32(T[5] ^ rotr_32(T[5] ^ rotr_32(T[5], 9), 11), 2) + .wrapping_add((T[5] & (T[6] ^ T[7])).wrapping_add(T[6] & T[7])), + ); + W[4] = W[4].wrapping_add( + (rotr_32(W[2] ^ rotr_32(W[2], 2), 17) ^ W[2] >> 10) + .wrapping_add(W[13]) + .wrapping_add(rotr_32(W[5] ^ rotr_32(W[5], 11), 7) ^ W[5] >> 3), + ); + T[3] = T[3].wrapping_add( + rotr_32(T[0] ^ rotr_32(T[0] ^ rotr_32(T[0], 14), 5), 6) + .wrapping_add(T[2] ^ T[0] & (T[1] ^ T[2])) + .wrapping_add(SHA256_K[4u32.wrapping_add(j) as usize]) + .wrapping_add(W[4]), + ); + T[7] = T[7].wrapping_add(T[3]); + T[3] = T[3].wrapping_add( + rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 9), 11), 2) + .wrapping_add((T[4] & (T[5] ^ T[6])).wrapping_add(T[5] & T[6])), + ); + W[5] = W[5].wrapping_add( + (rotr_32(W[3] ^ rotr_32(W[3], 2), 17) ^ W[3] >> 10) + .wrapping_add(W[14]) + .wrapping_add(rotr_32(W[6] ^ rotr_32(W[6], 11), 7) ^ W[6] >> 3), + ); + T[2] = T[2].wrapping_add( + rotr_32(T[7] ^ rotr_32(T[7] ^ rotr_32(T[7], 14), 5), 6) + .wrapping_add(T[1] ^ T[7] & (T[0] ^ T[1])) + .wrapping_add(SHA256_K[5u32.wrapping_add(j) as usize]) + .wrapping_add(W[5]), + ); + T[6] = T[6].wrapping_add(T[2]); + T[2] = T[2].wrapping_add( + rotr_32(T[3] ^ rotr_32(T[3] ^ rotr_32(T[3], 9), 11), 2) + .wrapping_add((T[3] & (T[4] ^ T[5])).wrapping_add(T[4] & T[5])), + ); + W[6] = W[6].wrapping_add( + (rotr_32(W[4] ^ rotr_32(W[4], 2), 17) ^ W[4] >> 10) + .wrapping_add(W[15]) + .wrapping_add(rotr_32(W[7] ^ rotr_32(W[7], 11), 7) ^ W[7] >> 3), + ); + T[1] = T[1].wrapping_add( + rotr_32(T[6] ^ rotr_32(T[6] ^ rotr_32(T[6], 14), 5), 6) + .wrapping_add(T[0] ^ T[6] & (T[7] ^ T[0])) + .wrapping_add(SHA256_K[6u32.wrapping_add(j) as usize]) + .wrapping_add(W[6]), + ); + T[5] = T[5].wrapping_add(T[1]); + T[1] = T[1].wrapping_add( + rotr_32(T[2] ^ rotr_32(T[2] ^ rotr_32(T[2], 9), 11), 2) + .wrapping_add((T[2] & (T[3] ^ T[4])).wrapping_add(T[3] & T[4])), + ); + W[7] = W[7].wrapping_add( + (rotr_32(W[5] ^ rotr_32(W[5], 2), 17) ^ W[5] >> 10) + .wrapping_add(W[0]) + .wrapping_add(rotr_32(W[8] ^ rotr_32(W[8], 11), 7) ^ W[8] >> 3), + ); + T[0] = T[0].wrapping_add( + rotr_32(T[5] ^ rotr_32(T[5] ^ rotr_32(T[5], 14), 5), 6) + .wrapping_add(T[7] ^ T[5] & (T[6] ^ T[7])) + .wrapping_add(SHA256_K[7u32.wrapping_add(j) as usize]) + .wrapping_add(W[7]), + ); + T[4] = T[4].wrapping_add(T[0]); + T[0] = T[0].wrapping_add( + rotr_32(T[1] ^ rotr_32(T[1] ^ rotr_32(T[1], 9), 11), 2) + .wrapping_add((T[1] & (T[2] ^ T[3])).wrapping_add(T[2] & T[3])), + ); + W[8] = W[8].wrapping_add( + (rotr_32(W[6] ^ rotr_32(W[6], 2), 17) ^ W[6] >> 10) + .wrapping_add(W[1]) + .wrapping_add(rotr_32(W[9] ^ rotr_32(W[9], 11), 7) ^ W[9] >> 3), + ); + T[7] = T[7].wrapping_add( + rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 14), 5), 6) + .wrapping_add(T[6] ^ T[4] & (T[5] ^ T[6])) + .wrapping_add(SHA256_K[8u32.wrapping_add(j) as usize]) + .wrapping_add(W[8]), + ); + T[3] = T[3].wrapping_add(T[7]); + T[7] = T[7].wrapping_add( + rotr_32(T[0] ^ rotr_32(T[0] ^ rotr_32(T[0], 9), 11), 2) + .wrapping_add((T[0] & (T[1] ^ T[2])).wrapping_add(T[1] & T[2])), + ); + W[9] = W[9].wrapping_add( + (rotr_32(W[7] ^ rotr_32(W[7], 2), 17) ^ W[7] >> 10) + .wrapping_add(W[2]) + .wrapping_add(rotr_32(W[10] ^ rotr_32(W[10], 11), 7) ^ W[10] >> 3), + ); + T[6] = T[6].wrapping_add( + rotr_32(T[3] ^ rotr_32(T[3] ^ rotr_32(T[3], 14), 5), 6) + .wrapping_add(T[5] ^ T[3] & (T[4] ^ T[5])) + .wrapping_add(SHA256_K[9u32.wrapping_add(j) as usize]) + .wrapping_add(W[9]), + ); + T[2] = T[2].wrapping_add(T[6]); + T[6] = T[6].wrapping_add( + rotr_32(T[7] ^ rotr_32(T[7] ^ rotr_32(T[7], 9), 11), 2) + .wrapping_add((T[7] & (T[0] ^ T[1])).wrapping_add(T[0] & T[1])), + ); + W[10] = W[10].wrapping_add( + (rotr_32(W[8] ^ rotr_32(W[8], 2), 17) ^ W[8] >> 10) + .wrapping_add(W[3]) + .wrapping_add(rotr_32(W[11] ^ rotr_32(W[11], 11), 7) ^ W[11] >> 3), + ); + T[5] = T[5].wrapping_add( + rotr_32(T[2] ^ rotr_32(T[2] ^ rotr_32(T[2], 14), 5), 6) + .wrapping_add(T[4] ^ T[2] & (T[3] ^ T[4])) + .wrapping_add(SHA256_K[10u32.wrapping_add(j) as usize]) + .wrapping_add(W[10]), + ); + T[1] = T[1].wrapping_add(T[5]); + T[5] = T[5].wrapping_add( + rotr_32(T[6] ^ rotr_32(T[6] ^ rotr_32(T[6], 9), 11), 2) + .wrapping_add((T[6] & (T[7] ^ T[0])).wrapping_add(T[7] & T[0])), + ); + W[11] = W[11].wrapping_add( + (rotr_32(W[9] ^ rotr_32(W[9], 2), 17) ^ W[9] >> 10) + .wrapping_add(W[4]) + .wrapping_add(rotr_32(W[12] ^ rotr_32(W[12], 11), 7) ^ W[12] >> 3), + ); + T[4] = T[4].wrapping_add( + rotr_32(T[1] ^ rotr_32(T[1] ^ rotr_32(T[1], 14), 5), 6) + .wrapping_add(T[3] ^ T[1] & (T[2] ^ T[3])) + .wrapping_add(SHA256_K[11u32.wrapping_add(j) as usize]) + .wrapping_add(W[11]), + ); + T[0] = T[0].wrapping_add(T[4]); + T[4] = T[4].wrapping_add( + rotr_32(T[5] ^ rotr_32(T[5] ^ rotr_32(T[5], 9), 11), 2) + .wrapping_add((T[5] & (T[6] ^ T[7])).wrapping_add(T[6] & T[7])), + ); + W[12] = W[12].wrapping_add( + (rotr_32(W[10] ^ rotr_32(W[10], 2), 17) ^ W[10] >> 10) + .wrapping_add(W[5]) + .wrapping_add(rotr_32(W[13] ^ rotr_32(W[13], 11), 7) ^ W[13] >> 3), + ); + T[3] = T[3].wrapping_add( + rotr_32(T[0] ^ rotr_32(T[0] ^ rotr_32(T[0], 14), 5), 6) + .wrapping_add(T[2] ^ T[0] & (T[1] ^ T[2])) + .wrapping_add(SHA256_K[12u32.wrapping_add(j) as usize]) + .wrapping_add(W[12]), + ); + T[7] = T[7].wrapping_add(T[3]); + T[3] = T[3].wrapping_add( + rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 9), 11), 2) + .wrapping_add((T[4] & (T[5] ^ T[6])).wrapping_add(T[5] & T[6])), + ); + W[13] = W[13].wrapping_add( + (rotr_32(W[11] ^ rotr_32(W[11], 2), 17) ^ W[11] >> 10) + .wrapping_add(W[6]) + .wrapping_add(rotr_32(W[14] ^ rotr_32(W[14], 11), 7) ^ W[14] >> 3), + ); + T[2] = T[2].wrapping_add( + rotr_32(T[7] ^ rotr_32(T[7] ^ rotr_32(T[7], 14), 5), 6) + .wrapping_add(T[1] ^ T[7] & (T[0] ^ T[1])) + .wrapping_add(SHA256_K[13u32.wrapping_add(j) as usize]) + .wrapping_add(W[13]), + ); + T[6] = T[6].wrapping_add(T[2]); + T[2] = T[2].wrapping_add( + rotr_32(T[3] ^ rotr_32(T[3] ^ rotr_32(T[3], 9), 11), 2) + .wrapping_add((T[3] & (T[4] ^ T[5])).wrapping_add(T[4] & T[5])), + ); + W[14] = W[14].wrapping_add( + (rotr_32(W[12] ^ rotr_32(W[12], 2), 17) ^ W[12] >> 10) + .wrapping_add(W[7]) + .wrapping_add(rotr_32(W[15] ^ rotr_32(W[15], 11), 7) ^ W[15] >> 3), + ); + T[1] = T[1].wrapping_add( + rotr_32(T[6] ^ rotr_32(T[6] ^ rotr_32(T[6], 14), 5), 6) + .wrapping_add(T[0] ^ T[6] & (T[7] ^ T[0])) + .wrapping_add(SHA256_K[14u32.wrapping_add(j) as usize]) + .wrapping_add(W[14]), + ); + T[5] = T[5].wrapping_add(T[1]); + T[1] = T[1].wrapping_add( + rotr_32(T[2] ^ rotr_32(T[2] ^ rotr_32(T[2], 9), 11), 2) + .wrapping_add((T[2] & (T[3] ^ T[4])).wrapping_add(T[3] & T[4])), + ); + W[15] = W[15].wrapping_add( + (rotr_32(W[13] ^ rotr_32(W[13], 2), 17) ^ W[13] >> 10) + .wrapping_add(W[8]) + .wrapping_add(rotr_32(W[0] ^ rotr_32(W[0], 11), 7) ^ W[0] >> 3), + ); + T[0] = T[0].wrapping_add( + rotr_32(T[5] ^ rotr_32(T[5] ^ rotr_32(T[5], 14), 5), 6) + .wrapping_add(T[7] ^ T[5] & (T[6] ^ T[7])) + .wrapping_add(SHA256_K[15u32.wrapping_add(j) as usize]) + .wrapping_add(W[15]), + ); + T[4] = T[4].wrapping_add(T[0]); + T[0] = T[0].wrapping_add( + rotr_32(T[1] ^ rotr_32(T[1] ^ rotr_32(T[1], 9), 11), 2) + .wrapping_add((T[1] & (T[2] ^ T[3])).wrapping_add(T[2] & T[3])), + ); + j = j.wrapping_add(16); } - let ref mut fresh0 = *state.offset(0 as isize); - *fresh0 = (*fresh0).wrapping_add(T[(0 as c_int - 0 as c_int & 7 as c_int) as usize]); - let ref mut fresh1 = *state.offset(1 as isize); - *fresh1 = (*fresh1).wrapping_add(T[(1 as c_int - 0 as c_int & 7 as c_int) as usize]); - let ref mut fresh2 = *state.offset(2 as isize); - *fresh2 = (*fresh2).wrapping_add(T[(2 as c_int - 0 as c_int & 7 as c_int) as usize]); - let ref mut fresh3 = *state.offset(3 as isize); - *fresh3 = (*fresh3).wrapping_add(T[(3 as c_int - 0 as c_int & 7 as c_int) as usize]); - let ref mut fresh4 = *state.offset(4 as isize); - *fresh4 = (*fresh4).wrapping_add(T[(4 as c_int - 0 as c_int & 7 as c_int) as usize]); - let ref mut fresh5 = *state.offset(5 as isize); - *fresh5 = (*fresh5).wrapping_add(T[(5 as c_int - 0 as c_int & 7 as c_int) as usize]); - let ref mut fresh6 = *state.offset(6 as isize); - *fresh6 = (*fresh6).wrapping_add(T[(6 as c_int - 0 as c_int & 7 as c_int) as usize]); - let ref mut fresh7 = *state.offset(7 as isize); - *fresh7 = (*fresh7).wrapping_add(T[(7 as c_int - 0 as c_int & 7 as c_int) as usize]); + let ref mut fresh0 = *state.offset(0); + *fresh0 = (*fresh0).wrapping_add(T[0]); + let ref mut fresh1 = *state.offset(1); + *fresh1 = (*fresh1).wrapping_add(T[1]); + let ref mut fresh2 = *state.offset(2); + *fresh2 = (*fresh2).wrapping_add(T[2]); + let ref mut fresh3 = *state.offset(3); + *fresh3 = (*fresh3).wrapping_add(T[3]); + let ref mut fresh4 = *state.offset(4); + *fresh4 = (*fresh4).wrapping_add(T[4]); + let ref mut fresh5 = *state.offset(5); + *fresh5 = (*fresh5).wrapping_add(T[5]); + let ref mut fresh6 = *state.offset(6); + *fresh6 = (*fresh6).wrapping_add(T[6]); + let ref mut fresh7 = *state.offset(7); + *fresh7 = (*fresh7).wrapping_add(T[7]); } unsafe extern "C" fn process(mut check: *mut lzma_check_state) { transform( @@ -2148,23 +628,22 @@ pub unsafe extern "C" fn lzma_sha256_finish(mut check: *mut lzma_check_state) { (*check).buffer.u8_0[fresh9 as usize] = 0 as u8; } (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8 as u64); - (*check).buffer.u64_0[((64 as c_int - 8 as c_int) / 8 as c_int) as usize] = - ((*check).state.sha256.size & 0xff as u64) << 56 as c_int - | ((*check).state.sha256.size & 0xff00 as u64) << 40 as c_int - | ((*check).state.sha256.size & 0xff0000 as u64) << 24 as c_int - | ((*check).state.sha256.size & 0xff000000 as u64) << 8 as c_int - | ((*check).state.sha256.size & 0xff00000000 as u64) >> 8 as c_int - | ((*check).state.sha256.size & 0xff0000000000 as u64) >> 24 as c_int - | ((*check).state.sha256.size & 0xff000000000000 as u64) >> 40 as c_int - | ((*check).state.sha256.size & 0xff00000000000000 as u64) >> 56 as c_int; + (*check).buffer.u64_0[7] = + ((*check).state.sha256.size & 0xff as u64) << 56 + | ((*check).state.sha256.size & 0xff00 as u64) << 40 + | ((*check).state.sha256.size & 0xff0000 as u64) << 24 + | ((*check).state.sha256.size & 0xff000000 as u64) << 8 + | ((*check).state.sha256.size & 0xff00000000 as u64) >> 8 + | ((*check).state.sha256.size & 0xff0000000000 as u64) >> 24 + | ((*check).state.sha256.size & 0xff000000000000 as u64) >> 40 + | ((*check).state.sha256.size & 0xff00000000000000 as u64) >> 56; process(check); let mut i: size_t = 0 as size_t; while i < 8 as size_t { - (*check).buffer.u32_0[i as usize] = ((*check).state.sha256.state[i as usize] & 0xff) - << 24 as c_int - | ((*check).state.sha256.state[i as usize] & 0xff00) << 8 as c_int - | ((*check).state.sha256.state[i as usize] & 0xff0000) >> 8 as c_int - | ((*check).state.sha256.state[i as usize] & 0xff000000) >> 24 as c_int; + (*check).buffer.u32_0[i as usize] = ((*check).state.sha256.state[i as usize] & 0xff) << 24 + | ((*check).state.sha256.state[i as usize] & 0xff00) << 8 + | ((*check).state.sha256.state[i as usize] & 0xff0000) >> 8 + | ((*check).state.sha256.state[i as usize] & 0xff000000) >> 24; i = i.wrapping_add(1); } } diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index e0825154..c0c9b783 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -209,13 +209,13 @@ pub type lzma_init_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT32_MAX: c_uint = 4294967295; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; -pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1 as c_uint; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; unsafe extern "C" fn alone_decode( mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, @@ -228,11 +228,9 @@ unsafe extern "C" fn alone_decode( mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; - while *out_pos < out_size - && ((*coder).sequence as c_uint == SEQ_CODE as c_uint || *in_pos < in_size) - { + while *out_pos < out_size && ((*coder).sequence == SEQ_CODE || *in_pos < in_size) { let mut current_block_42: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { if lzma_lzma_lclppb_decode( &raw mut (*coder).options, @@ -255,11 +253,11 @@ unsafe extern "C" fn alone_decode( && (*coder).options.dict_size != UINT32_MAX as u32 { let mut d: u32 = (*coder).options.dict_size.wrapping_sub(1 as u32); - d |= d >> 2 as c_int; - d |= d >> 3 as c_int; - d |= d >> 4 as c_int; - d |= d >> 8 as c_int; - d |= d >> 16 as c_int; + d |= d >> 2; + d |= d >> 3; + d |= d >> 4; + d |= d >> 8; + d |= d >> 16; d = d.wrapping_add(1); if d != (*coder).options.dict_size { return LZMA_FORMAT_ERROR; @@ -281,14 +279,13 @@ unsafe extern "C" fn alone_decode( } else { if (*coder).picky as c_int != 0 && (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli - && (*coder).uncompressed_size >= (1 as lzma_vli) << 38 as c_int + && (*coder).uncompressed_size >= (1 as lzma_vli) << 38 { return LZMA_FORMAT_ERROR; } (*coder).options.ext_flags = LZMA_LZMA1EXT_ALLOW_EOPM as u32; (*coder).options.ext_size_low = (*coder).uncompressed_size as u32; - (*coder).options.ext_size_high = - ((*coder).uncompressed_size >> 32 as c_int) as u32; + (*coder).options.ext_size_high = ((*coder).uncompressed_size >> 32) as u32; (*coder).memusage = lzma_lzma_decoder_memusage_nocheck( &raw mut (*coder).options as *const c_void, ) @@ -346,7 +343,7 @@ unsafe extern "C" fn alone_decode( allocator, &raw mut filters as *mut lzma_filter_info, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } (*coder).sequence = SEQ_CODE; @@ -495,7 +492,7 @@ pub unsafe extern "C" fn lzma_alone_decoder( mut memlimit: u64, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_alone_decoder_init( @@ -504,7 +501,7 @@ pub unsafe extern "C" fn lzma_alone_decoder( memlimit, 0 as c_int != 0, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index c09b5b55..76b73636 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -210,19 +210,19 @@ pub const SEQ_CODE: C2RustUnnamed_0 = 1; pub const SEQ_HEADER: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT32_MAX: c_uint = 4294967295; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0 as isize) = num as u8; - *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; - *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; - *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; pub const ALONE_HEADER_SIZE: c_int = 1 as c_int + 4 as c_int + 8 as c_int; unsafe extern "C" fn alone_encode( mut coder_ptr: *mut c_void, @@ -237,7 +237,7 @@ unsafe extern "C" fn alone_encode( ) -> lzma_ret { let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; while *out_pos < out_size { - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { lzma_bufcpy( &raw mut (*coder).header as *mut u8, @@ -369,19 +369,17 @@ unsafe extern "C" fn alone_encoder_init( return LZMA_OPTIONS_ERROR; } let mut d: u32 = (*options).dict_size.wrapping_sub(1 as u32); - d |= d >> 2 as c_int; - d |= d >> 3 as c_int; - d |= d >> 4 as c_int; - d |= d >> 8 as c_int; - d |= d >> 16 as c_int; + d |= d >> 2; + d |= d >> 3; + d |= d >> 4; + d |= d >> 8; + d |= d >> 16; if d != UINT32_MAX as u32 { d = d.wrapping_add(1); } - write32le((&raw mut (*coder).header as *mut u8).offset(1 as isize), d); + write32le((&raw mut (*coder).header as *mut u8).offset(1), d); memset( - (&raw mut (*coder).header as *mut u8) - .offset(1 as isize) - .offset(4 as isize) as *mut c_void, + (&raw mut (*coder).header as *mut u8).offset(1).offset(4) as *mut c_void, 0xff as c_int, 8 as size_t, ); @@ -416,7 +414,7 @@ pub unsafe extern "C" fn lzma_alone_encoder( mut options: *const lzma_options_lzma, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = alone_encoder_init( @@ -424,7 +422,7 @@ pub unsafe extern "C" fn lzma_alone_encoder( (*strm).allocator, options, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index d869ccd1..102e11a1 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -153,16 +153,16 @@ pub struct lzma_auto_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_NO_CHECK: c_uint = 0x1 as c_uint; -pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2 as c_uint; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; -pub const LZMA_IGNORE_CHECK: c_uint = 0x10 as c_uint; -pub const LZMA_CONCATENATED: c_uint = 0x8 as c_uint; -pub const LZMA_FAIL_FAST: c_uint = 0x20 as c_uint; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10; +pub const LZMA_CONCATENATED: c_uint = 0x8; +pub const LZMA_FAIL_FAST: c_uint = 0x20; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK @@ -182,7 +182,7 @@ unsafe extern "C" fn auto_decode( ) -> lzma_ret { let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; let mut current_block_28: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { if *in_pos >= in_size { return LZMA_OK; @@ -195,7 +195,7 @@ unsafe extern "C" fn auto_decode( (*coder).memlimit, (*coder).flags, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } } else { @@ -205,7 +205,7 @@ unsafe extern "C" fn auto_decode( (*coder).memlimit, 1 as c_int != 0, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } if (*coder).flags & LZMA_TELL_NO_CHECK as u32 != 0 { @@ -238,9 +238,7 @@ unsafe extern "C" fn auto_decode( out_size, action, ) as lzma_ret; - if ret as c_uint != LZMA_STREAM_END as c_uint - || (*coder).flags & LZMA_CONCATENATED as u32 == 0 as u32 - { + if ret != LZMA_STREAM_END || (*coder).flags & LZMA_CONCATENATED as u32 == 0 as u32 { return ret; } (*coder).sequence = SEQ_FINISH; @@ -250,7 +248,7 @@ unsafe extern "C" fn auto_decode( if *in_pos < in_size { return LZMA_DATA_ERROR; } - return (if action as c_uint == LZMA_FINISH as c_uint { + return (if action == LZMA_FINISH { LZMA_STREAM_END as c_int } else { LZMA_OK as c_int @@ -267,9 +265,9 @@ unsafe extern "C" fn auto_decoder_end( unsafe extern "C" fn auto_decoder_get_check(mut coder_ptr: *const c_void) -> lzma_check { let mut coder: *const lzma_auto_coder = coder_ptr as *const lzma_auto_coder; return (if (*coder).next.get_check.is_none() { - LZMA_CHECK_NONE as c_uint + LZMA_CHECK_NONE } else { - (*coder).next.get_check.expect("non-null function pointer")((*coder).next.coder) as c_uint + (*coder).next.get_check.expect("non-null function pointer")((*coder).next.coder) }) as lzma_check; } unsafe extern "C" fn auto_decoder_memconfig( @@ -295,7 +293,7 @@ unsafe extern "C" fn auto_decoder_memconfig( ret = LZMA_MEMLIMIT_ERROR; } } - if ret as c_uint == LZMA_OK as c_uint && new_memlimit != 0 as u64 { + if ret == LZMA_OK && new_memlimit != 0 as u64 { (*coder).memlimit = new_memlimit; } return ret; @@ -404,7 +402,7 @@ pub unsafe extern "C" fn lzma_auto_decoder( mut flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = auto_decoder_init( @@ -413,7 +411,7 @@ pub unsafe extern "C" fn lzma_auto_decoder( memlimit, flags, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index 0df0eb1b..06999e02 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -124,7 +124,7 @@ pub struct lzma_block { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_decode( @@ -159,7 +159,7 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( set_out_limit: None, }; let mut ret: lzma_ret = lzma_block_decoder_init(&raw mut block_decoder, allocator, block); - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; ret = block_decoder.code.expect("non-null function pointer")( @@ -173,10 +173,10 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( out_size, LZMA_FINISH, ); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = LZMA_OK; } else { - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { if *in_pos == in_size { ret = LZMA_DATA_ERROR; } else { diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index a034646a..cd6397c9 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -198,22 +198,22 @@ pub struct lzma_sha256_state { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_CHECK_SIZE_MAX: c_int = 64 as c_int; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX - .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as c_ulonglong) - .wrapping_sub(LZMA_CHECK_SIZE_MAX as c_ulonglong) - & !(3 as c_ulonglong); -pub const LZMA2_CHUNK_MAX: c_uint = (1 as c_uint) << 16 as c_int; + .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) + .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) + & !3; +pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3 as c_int; pub const HEADERS_BOUND: c_int = 1 as c_int + 1 as c_int @@ -290,12 +290,12 @@ unsafe extern "C" fn block_encode_uncompressed( id: 0, options: ::core::ptr::null_mut::(), }; 2]; - filters[0 as usize].id = LZMA_FILTER_LZMA2 as lzma_vli; - filters[0 as usize].options = &raw mut lzma2 as *mut c_void; - filters[1 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + filters[0].id = LZMA_FILTER_LZMA2 as lzma_vli; + filters[0].options = &raw mut lzma2 as *mut c_void; + filters[1].id = LZMA_VLI_UNKNOWN as lzma_vli; let mut filters_orig: *mut lzma_filter = (*block).filters; (*block).filters = &raw mut filters as *mut lzma_filter; - if lzma_block_header_size(block) as c_uint != LZMA_OK as c_uint { + if lzma_block_header_size(block) != LZMA_OK { (*block).filters = filters_orig; return LZMA_PROG_ERROR; } @@ -305,8 +305,7 @@ unsafe extern "C" fn block_encode_uncompressed( (*block).filters = filters_orig; return LZMA_BUF_ERROR; } - if lzma_block_header_encode(block, out.offset(*out_pos as isize)) as c_uint != LZMA_OK as c_uint - { + if lzma_block_header_encode(block, out.offset(*out_pos as isize)) != LZMA_OK { (*block).filters = filters_orig; return LZMA_PROG_ERROR; } @@ -319,15 +318,14 @@ unsafe extern "C" fn block_encode_uncompressed( *out_pos = (*out_pos).wrapping_add(1); *out.offset(fresh1 as isize) = control; control = 0x2 as u8; - let copy_size: size_t = - if in_size.wrapping_sub(in_pos) < ((1 as c_uint) << 16 as c_int) as size_t { - in_size.wrapping_sub(in_pos) - } else { - ((1 as c_uint) << 16 as c_int) as size_t - }; + let copy_size: size_t = if in_size.wrapping_sub(in_pos) < (1u32 << 16) as size_t { + in_size.wrapping_sub(in_pos) + } else { + (1u32 << 16) as size_t + }; let fresh2 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1 as size_t) >> 8 as c_int) as u8; + *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1 as size_t) >> 8) as u8; let fresh3 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1 as size_t) & 0xff as size_t) as u8; @@ -354,7 +352,7 @@ unsafe extern "C" fn block_encode_normal( mut out_size: size_t, ) -> lzma_ret { let ret_: lzma_ret = lzma_block_header_size(block) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } if out_size.wrapping_sub(*out_pos) <= (*block).header_size as size_t { @@ -379,7 +377,7 @@ unsafe extern "C" fn block_encode_normal( }; let mut ret: lzma_ret = lzma_raw_encoder_init(&raw mut raw_encoder, allocator, (*block).filters); - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { let mut in_pos: size_t = 0 as size_t; ret = raw_encoder.code.expect("non-null function pointer")( raw_encoder.coder, @@ -394,18 +392,18 @@ unsafe extern "C" fn block_encode_normal( ); } lzma_next_end(&raw mut raw_encoder, allocator); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { (*block).compressed_size = (*out_pos) .wrapping_sub(out_start.wrapping_add((*block).header_size as size_t)) as lzma_vli; ret = lzma_block_header_encode(block, out.offset(out_start as isize)); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { ret = LZMA_PROG_ERROR; } - } else if ret as c_uint == LZMA_OK as c_uint { + } else if ret == LZMA_OK { ret = LZMA_BUF_ERROR; } - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { *out_pos = out_start; } return ret; @@ -431,7 +429,7 @@ unsafe extern "C" fn block_buffer_encode( if (*block).version > 1 as u32 { return LZMA_OPTIONS_ERROR; } - if (*block).check as c_uint > LZMA_CHECK_ID_MAX as c_uint + if (*block).check > LZMA_CHECK_ID_MAX || try_to_compress as c_int != 0 && (*block).filters.is_null() { return LZMA_PROG_ERROR; @@ -454,13 +452,13 @@ unsafe extern "C" fn block_buffer_encode( if try_to_compress { ret = block_encode_normal(block, allocator, in_0, in_size, out, out_pos, out_size); } - if ret as c_uint != LZMA_OK as c_uint { - if ret as c_uint != LZMA_BUF_ERROR as c_uint { + if ret != LZMA_OK { + if ret != LZMA_BUF_ERROR { return ret; } let ret_: lzma_ret = block_encode_uncompressed(block, in_0, in_size, out, out_pos, out_size) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } } diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 62f73da7..b67b2fd5 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -232,10 +232,10 @@ pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[inline] unsafe extern "C" fn is_size_valid(mut size: lzma_vli, mut reference: lzma_vli) -> bool { @@ -255,7 +255,7 @@ unsafe extern "C" fn block_decode( let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; 's_177: { let mut current_block_40: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; @@ -303,7 +303,7 @@ unsafe extern "C" fn block_decode( (*coder).uncompressed_size = (*coder) .uncompressed_size .wrapping_add(out_used as lzma_vli); - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { let comp_done: bool = (*coder).compressed_size == (*(*coder).block).compressed_size; let uncomp_done: bool = @@ -326,7 +326,7 @@ unsafe extern "C" fn block_decode( out_used, ); } - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { return ret; } if !is_size_valid((*coder).compressed_size, (*(*coder).block).compressed_size) @@ -365,7 +365,7 @@ unsafe extern "C" fn block_decode( return LZMA_DATA_ERROR; } } - if (*(*coder).block).check as c_uint == LZMA_CHECK_NONE as c_uint { + if (*(*coder).block).check == LZMA_CHECK_NONE { return LZMA_STREAM_END; } if !(*coder).ignore_check { @@ -529,13 +529,13 @@ pub unsafe extern "C" fn lzma_block_decoder( mut block: *mut lzma_block, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_block_decoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 992ce3db..9eeb44ab 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -233,17 +233,17 @@ pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_CHECK_SIZE_MAX: c_int = 64 as c_int; pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX - .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as c_ulonglong) - .wrapping_sub(LZMA_CHECK_SIZE_MAX as c_ulonglong) - & !(3 as c_ulonglong); + .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) + .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) + & !3; unsafe extern "C" fn block_encode( mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, @@ -263,7 +263,7 @@ unsafe extern "C" fn block_encode( } 's_142: { let mut current_block_34: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; @@ -297,9 +297,7 @@ unsafe extern "C" fn block_encode( in_used, ); } - if ret as c_uint != LZMA_STREAM_END as c_uint - || action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + if ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH { return ret; } (*(*coder).block).compressed_size = (*coder).compressed_size; @@ -327,7 +325,7 @@ unsafe extern "C" fn block_encode( *out_pos = (*out_pos).wrapping_add(1); (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); } - if (*(*coder).block).check as c_uint == LZMA_CHECK_NONE as c_uint { + if (*(*coder).block).check == LZMA_CHECK_NONE { return LZMA_STREAM_END; } lzma_check_finish(&raw mut (*coder).check, (*(*coder).block).check); @@ -371,7 +369,7 @@ unsafe extern "C" fn block_encoder_update( mut reversed_filters: *const lzma_filter, ) -> lzma_ret { let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; - if (*coder).sequence as c_uint != SEQ_CODE as c_uint { + if (*coder).sequence != SEQ_CODE { return LZMA_PROG_ERROR; } return lzma_next_filter_update(&raw mut (*coder).next, allocator, reversed_filters); @@ -425,7 +423,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( if (*block).version > 1 as u32 { return LZMA_OPTIONS_ERROR; } - if (*block).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { + if (*block).check > LZMA_CHECK_ID_MAX { return LZMA_PROG_ERROR; } if lzma_check_is_supported((*block).check) == 0 { @@ -502,13 +500,13 @@ pub unsafe extern "C" fn lzma_block_encoder( mut block: *mut lzma_block, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_block_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 90279d07..3454526c 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -94,18 +94,18 @@ pub struct lzma_block { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0 as isize) as u32; - num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; - num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; - num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; return num; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_block_header_decode( @@ -127,11 +127,11 @@ pub unsafe extern "C" fn lzma_block_header_decode( (*block).version = 1 as u32; } (*block).ignore_check = false_0 as lzma_bool; - if (*in_0.offset(0 as isize) as u32) + if (*in_0.offset(0) as u32) .wrapping_add(1 as u32) .wrapping_mul(4 as u32) != (*block).header_size - || (*block).check as c_uint > LZMA_CHECK_ID_MAX as c_uint + || (*block).check > LZMA_CHECK_ID_MAX { return LZMA_PROG_ERROR; } @@ -139,11 +139,11 @@ pub unsafe extern "C" fn lzma_block_header_decode( if lzma_crc32(in_0, in_size, 0 as u32) != read32le(in_0.offset(in_size as isize)) { return LZMA_DATA_ERROR; } - if *in_0.offset(1 as isize) as c_int & 0x3c as c_int != 0 { + if *in_0.offset(1) as c_int & 0x3c as c_int != 0 { return LZMA_OPTIONS_ERROR; } let mut in_pos: size_t = 2 as size_t; - if *in_0.offset(1 as isize) as c_int & 0x40 as c_int != 0 { + if *in_0.offset(1) as c_int & 0x40 as c_int != 0 { let ret_: lzma_ret = lzma_vli_decode( &raw mut (*block).compressed_size, ::core::ptr::null_mut::(), @@ -151,7 +151,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( &raw mut in_pos, in_size, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } if lzma_block_unpadded_size(block) == 0 as lzma_vli { @@ -160,7 +160,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( } else { (*block).compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; } - if *in_0.offset(1 as isize) as c_int & 0x80 as c_int != 0 { + if *in_0.offset(1) as c_int & 0x80 as c_int != 0 { let ret__0: lzma_ret = lzma_vli_decode( &raw mut (*block).uncompressed_size, ::core::ptr::null_mut::(), @@ -168,14 +168,13 @@ pub unsafe extern "C" fn lzma_block_header_decode( &raw mut in_pos, in_size, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } } else { (*block).uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; } - let filter_count: size_t = - (*in_0.offset(1 as isize) as c_uint & 3 as c_uint).wrapping_add(1 as c_uint) as size_t; + let filter_count: size_t = (u32::from(*in_0.offset(1)) & 3).wrapping_add(1) as size_t; let mut i_0: size_t = 0 as size_t; while i_0 < filter_count { let ret: lzma_ret = lzma_filter_flags_decode( @@ -185,7 +184,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( &raw mut in_pos, in_size, ) as lzma_ret; - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { lzma_filters_free((*block).filters, allocator); return ret; } diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index e9d20312..63bfb24a 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -88,15 +88,15 @@ pub struct lzma_block { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0 as isize) = num as u8; - *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; - *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; - *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; } -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; #[no_mangle] @@ -120,7 +120,7 @@ pub unsafe extern "C" fn lzma_block_header_size(mut block: *mut lzma_block) -> l size = size.wrapping_add(add_0); } if (*block).filters.is_null() - || (*(*block).filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli + || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_PROG_ERROR; } @@ -132,7 +132,7 @@ pub unsafe extern "C" fn lzma_block_header_size(mut block: *mut lzma_block) -> l let mut add_1: u32 = 0; let ret_: lzma_ret = lzma_filter_flags_size(&raw mut add_1, (*block).filters.offset(i as isize)) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } size = size.wrapping_add(add_1); @@ -153,8 +153,8 @@ pub unsafe extern "C" fn lzma_block_header_encode( return LZMA_PROG_ERROR; } let out_size: size_t = (*block).header_size.wrapping_sub(4 as u32) as size_t; - *out.offset(0 as isize) = out_size.wrapping_div(4 as size_t) as u8; - *out.offset(1 as isize) = 0 as u8; + *out.offset(0) = out_size.wrapping_div(4 as size_t) as u8; + *out.offset(1) = 0 as u8; let mut out_pos: size_t = 2 as size_t; if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { let ret_: lzma_ret = lzma_vli_encode( @@ -164,10 +164,10 @@ pub unsafe extern "C" fn lzma_block_header_encode( &raw mut out_pos, out_size, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } - let ref mut fresh0 = *out.offset(1 as isize); + let ref mut fresh0 = *out.offset(1); *fresh0 = (*fresh0 as c_int | 0x40 as c_int) as u8; } if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { @@ -178,14 +178,14 @@ pub unsafe extern "C" fn lzma_block_header_encode( &raw mut out_pos, out_size, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } - let ref mut fresh1 = *out.offset(1 as isize); + let ref mut fresh1 = *out.offset(1); *fresh1 = (*fresh1 as c_int | 0x80 as c_int) as u8; } if (*block).filters.is_null() - || (*(*block).filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli + || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_PROG_ERROR; } @@ -200,7 +200,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( &raw mut out_pos, out_size, ) as lzma_ret; - if ret__1 as c_uint != LZMA_OK as c_uint { + if ret__1 != LZMA_OK { return ret__1; } filter_count = filter_count.wrapping_add(1); @@ -208,7 +208,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( break; } } - let ref mut fresh2 = *out.offset(1 as isize); + let ref mut fresh2 = *out.offset(1); *fresh2 = (*fresh2 as size_t | filter_count.wrapping_sub(1 as size_t)) as u8; memset( out.offset(out_pos as isize) as *mut c_void, diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 5cf6ebc1..37710664 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -71,13 +71,13 @@ pub struct lzma_block { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_BLOCK_HEADER_SIZE_MIN: c_int = 8 as c_int; pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; -pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !(3 as c_ulonglong); +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); @@ -115,7 +115,7 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(mut block: *const lzma_block) || !((*block).compressed_size <= LZMA_VLI_MAX as lzma_vli || (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli) || (*block).compressed_size == 0 as lzma_vli - || (*block).check as c_uint > LZMA_CHECK_ID_MAX as c_uint + || (*block).check > LZMA_CHECK_ID_MAX { return 0 as lzma_vli; } diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index 910ecee4..cbc7d5c4 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -144,7 +144,7 @@ pub type lzma_init_function = Option< pub type lzma_filter_info = lzma_filter_info_s; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VERSION_MAJOR: c_int = 5 as c_int; @@ -152,13 +152,13 @@ pub const LZMA_VERSION_MINOR: c_int = 8 as c_int; pub const LZMA_VERSION_PATCH: c_int = 2 as c_int; pub const LZMA_VERSION_STABILITY: c_int = LZMA_VERSION_STABILITY_STABLE; pub const LZMA_VERSION_STABILITY_STABLE: c_int = 2 as c_int; -pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR as c_uint) - .wrapping_mul(10000000 as c_uint) - .wrapping_add((LZMA_VERSION_MINOR as c_uint).wrapping_mul(10000 as c_uint)) - .wrapping_add((LZMA_VERSION_PATCH as c_uint).wrapping_mul(10 as c_uint)) - .wrapping_add(LZMA_VERSION_STABILITY as c_uint); +pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR as u32) + .wrapping_mul(10000000) + .wrapping_add((LZMA_VERSION_MINOR as u32).wrapping_mul(10000)) + .wrapping_add((LZMA_VERSION_PATCH as u32).wrapping_mul(10)) + .wrapping_add(LZMA_VERSION_STABILITY as u32); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_TIMED_OUT: c_uint = 101 as c_uint; +pub const LZMA_TIMED_OUT: c_uint = 101; #[no_mangle] pub unsafe extern "C" fn lzma_version_number() -> u32 { return LZMA_VERSION as u32; @@ -251,20 +251,20 @@ pub unsafe extern "C" fn lzma_next_filter_init( mut allocator: *const lzma_allocator, mut filters: *const lzma_filter_info, ) -> lzma_ret { - if ::core::mem::transmute::((*filters.offset(0 as isize)).init) + if ::core::mem::transmute::((*filters.offset(0)).init) != (*next).init { lzma_next_end(next, allocator); } (*next).init = - ::core::mem::transmute::((*filters.offset(0 as isize)).init); - (*next).id = (*filters.offset(0 as isize)).id; - return (if (*filters.offset(0 as isize)).init.is_none() { - LZMA_OK as c_uint + ::core::mem::transmute::((*filters.offset(0)).init); + (*next).id = (*filters.offset(0)).id; + return (if (*filters.offset(0)).init.is_none() { + LZMA_OK } else { - (*filters.offset(0 as isize)) + (*filters.offset(0)) .init - .expect("non-null function pointer")(next, allocator, filters) as c_uint + .expect("non-null function pointer")(next, allocator, filters) }) as lzma_ret; } #[no_mangle] @@ -273,10 +273,10 @@ pub unsafe extern "C" fn lzma_next_filter_update( mut allocator: *const lzma_allocator, mut reversed_filters: *const lzma_filter, ) -> lzma_ret { - if (*reversed_filters.offset(0 as isize)).id != (*next).id { + if (*reversed_filters.offset(0)).id != (*next).id { return LZMA_PROG_ERROR; } - if (*reversed_filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli { + if (*reversed_filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_OK; } return (*next).update.expect("non-null function pointer")( @@ -357,7 +357,7 @@ pub unsafe extern "C" fn lzma_code( || (*strm).next_out.is_null() && (*strm).avail_out != 0 as size_t || (*strm).internal.is_null() || (*(*strm).internal).next.code.is_none() - || action as c_uint > LZMA_FULL_BARRIER as c_uint + || action > LZMA_FULL_BARRIER || !(*(*strm).internal).supported_actions[action as usize] { return LZMA_PROG_ERROR; @@ -369,13 +369,13 @@ pub unsafe extern "C" fn lzma_code( || (*strm).reserved_int2 != 0 as u64 || (*strm).reserved_int3 != 0 as size_t || (*strm).reserved_int4 != 0 as size_t - || (*strm).reserved_enum1 as c_uint != LZMA_RESERVED_ENUM as c_uint - || (*strm).reserved_enum2 as c_uint != LZMA_RESERVED_ENUM as c_uint + || (*strm).reserved_enum1 != LZMA_RESERVED_ENUM + || (*strm).reserved_enum2 != LZMA_RESERVED_ENUM { return LZMA_OPTIONS_ERROR; } - match (*(*strm).internal).sequence as c_uint { - 0 => match action as c_uint { + match (*(*strm).internal).sequence { + 0 => match action { 1 => { (*(*strm).internal).sequence = ISEQ_SYNC_FLUSH; } @@ -391,30 +391,22 @@ pub unsafe extern "C" fn lzma_code( 0 | _ => {} }, 1 => { - if action as c_uint != LZMA_SYNC_FLUSH as c_uint - || (*(*strm).internal).avail_in != (*strm).avail_in - { + if action != LZMA_SYNC_FLUSH || (*(*strm).internal).avail_in != (*strm).avail_in { return LZMA_PROG_ERROR; } } 2 => { - if action as c_uint != LZMA_FULL_FLUSH as c_uint - || (*(*strm).internal).avail_in != (*strm).avail_in - { + if action != LZMA_FULL_FLUSH || (*(*strm).internal).avail_in != (*strm).avail_in { return LZMA_PROG_ERROR; } } 3 => { - if action as c_uint != LZMA_FINISH as c_uint - || (*(*strm).internal).avail_in != (*strm).avail_in - { + if action != LZMA_FINISH || (*(*strm).internal).avail_in != (*strm).avail_in { return LZMA_PROG_ERROR; } } 4 => { - if action as c_uint != LZMA_FULL_BARRIER as c_uint - || (*(*strm).internal).avail_in != (*strm).avail_in - { + if action != LZMA_FULL_BARRIER || (*(*strm).internal).avail_in != (*strm).avail_in { return LZMA_PROG_ERROR; } } @@ -449,7 +441,7 @@ pub unsafe extern "C" fn lzma_code( } (*(*strm).internal).avail_in = (*strm).avail_in; let mut current_block_49: u64; - match ret as c_uint { + match ret { 0 => { if out_pos == 0 as size_t && in_pos == 0 as size_t { if (*(*strm).internal).allow_buf_error { @@ -469,15 +461,15 @@ pub unsafe extern "C" fn lzma_code( } 12 => { (*(*strm).internal).allow_buf_error = false_0 != 0; - if (*(*strm).internal).sequence as c_uint == ISEQ_FINISH as c_uint { + if (*(*strm).internal).sequence == ISEQ_FINISH { (*(*strm).internal).sequence = ISEQ_RUN; } current_block_49 = 12556861819962772176; } 1 => { - if (*(*strm).internal).sequence as c_uint == ISEQ_SYNC_FLUSH as c_uint - || (*(*strm).internal).sequence as c_uint == ISEQ_FULL_FLUSH as c_uint - || (*(*strm).internal).sequence as c_uint == ISEQ_FULL_BARRIER as c_uint + if (*(*strm).internal).sequence == ISEQ_SYNC_FLUSH + || (*(*strm).internal).sequence == ISEQ_FULL_FLUSH + || (*(*strm).internal).sequence == ISEQ_FULL_BARRIER { (*(*strm).internal).sequence = ISEQ_RUN; } else { @@ -554,8 +546,7 @@ pub unsafe extern "C" fn lzma_memusage(mut strm: *const lzma_stream) -> u64 { &raw mut memusage, &raw mut old_memlimit, 0 as u64, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return 0 as u64; } @@ -576,8 +567,7 @@ pub unsafe extern "C" fn lzma_memlimit_get(mut strm: *const lzma_stream) -> u64 &raw mut memusage, &raw mut old_memlimit, 0 as u64, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return 0 as u64; } diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index 8aeffbc4..d31c76eb 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -52,7 +52,7 @@ pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT32_MAX: c_uint = 4294967295; #[no_mangle] pub unsafe extern "C" fn lzma_easy_decoder_memusage(mut preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index c56b60f2..4319134a 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -52,7 +52,7 @@ pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT32_MAX: c_uint = 4294967295; #[no_mangle] pub unsafe extern "C" fn lzma_easy_encoder_memusage(mut preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index bf3c0675..fa2a1c08 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -51,11 +51,11 @@ pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; #[no_mangle] pub unsafe extern "C" fn lzma_easy_preset( mut opt_easy: *mut lzma_options_easy, @@ -64,8 +64,8 @@ pub unsafe extern "C" fn lzma_easy_preset( if lzma_lzma_preset(&raw mut (*opt_easy).opt_lzma, preset) != 0 { return true_0 != 0; } - (*opt_easy).filters[0 as usize].id = LZMA_FILTER_LZMA2 as lzma_vli; - (*opt_easy).filters[0 as usize].options = &raw mut (*opt_easy).opt_lzma as *mut c_void; - (*opt_easy).filters[1 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*opt_easy).filters[0].id = LZMA_FILTER_LZMA2 as lzma_vli; + (*opt_easy).filters[0].options = &raw mut (*opt_easy).opt_lzma as *mut c_void; + (*opt_easy).filters[1].id = LZMA_VLI_UNKNOWN as lzma_vli; return false_0 != 0; } diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 1d735d04..2bab0b08 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -220,10 +220,10 @@ pub const SEQ_PADDING_SEEK: C2RustUnnamed_0 = 1; pub const SEQ_MAGIC_BYTES: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; unsafe extern "C" fn fill_temp( @@ -312,7 +312,7 @@ unsafe extern "C" fn get_padding_size(mut buf: *const u8, mut buf_size: size_t) return padding; } unsafe extern "C" fn hide_format_error(mut ret: lzma_ret) -> lzma_ret { - if ret as c_uint == LZMA_FORMAT_ERROR as c_uint { + if ret == LZMA_FORMAT_ERROR { ret = LZMA_DATA_ERROR; } return ret; @@ -371,7 +371,7 @@ unsafe extern "C" fn file_info_decode( } loop { let mut current_block_142: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { if (*coder).file_size < LZMA_STREAM_HEADER_SIZE as u64 { return LZMA_FORMAT_ERROR; @@ -383,7 +383,7 @@ unsafe extern "C" fn file_info_decode( &raw mut (*coder).first_header_flags, &raw mut (*coder).temp as *mut u8, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } if (*coder).file_size > LZMA_VLI_MAX as u64 || (*coder).file_size & 3 as u64 != 0 { @@ -419,7 +419,7 @@ unsafe extern "C" fn file_info_decode( 10445208204442080639 => { (*coder).sequence = SEQ_PADDING_DECODE; let ret__0: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } current_block_142 = 13242334135786603907; @@ -452,7 +452,7 @@ unsafe extern "C" fn file_info_decode( if (*coder).temp_size < LZMA_STREAM_HEADER_SIZE as size_t { let ret__1: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; - if ret__1 as c_uint != LZMA_OK as c_uint { + if ret__1 != LZMA_OK { return ret__1; } } @@ -476,7 +476,7 @@ unsafe extern "C" fn file_info_decode( &raw mut (*coder).footer_flags, (&raw mut (*coder).temp as *mut u8).offset((*coder).temp_size as isize), )) as lzma_ret; - if ret__2 as c_uint != LZMA_OK as c_uint { + if ret__2 != LZMA_OK { return ret__2; } if (*coder).file_target_pos @@ -521,7 +521,7 @@ unsafe extern "C" fn file_info_decode( &raw mut (*coder).this_index, (*coder).memlimit.wrapping_sub(memused), ) as lzma_ret; - if ret__3 as c_uint != LZMA_OK as c_uint { + if ret__3 != LZMA_OK { return ret__3; } (*coder).index_remaining = (*coder).footer_flags.backward_size; @@ -549,7 +549,7 @@ unsafe extern "C" fn file_info_decode( } ret = decode_index(coder, allocator, in_0, in_pos, in_stop, true_0 != 0); } - match ret as c_uint { + match ret { 0 => { if (*coder).index_remaining == 0 as lzma_vli { return LZMA_DATA_ERROR; @@ -592,7 +592,7 @@ unsafe extern "C" fn file_info_decode( } else { let ret__4: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; - if ret__4 as c_uint != LZMA_OK as c_uint { + if ret__4 != LZMA_OK { return ret__4; } } @@ -617,7 +617,7 @@ unsafe extern "C" fn file_info_decode( &raw mut (*coder).header_flags, (&raw mut (*coder).temp as *mut u8).offset((*coder).temp_size as isize), )) as lzma_ret; - if ret__5 as c_uint != LZMA_OK as c_uint { + if ret__5 != LZMA_OK { return ret__5; } (*coder).sequence = SEQ_HEADER_COMPARE; @@ -631,17 +631,16 @@ unsafe extern "C" fn file_info_decode( &raw mut (*coder).header_flags, &raw mut (*coder).footer_flags, ) as lzma_ret; - if ret__6 as c_uint != LZMA_OK as c_uint { + if ret__6 != LZMA_OK { return ret__6; } if lzma_index_stream_flags((*coder).this_index, &raw mut (*coder).footer_flags) - as c_uint - != LZMA_OK as c_uint + != LZMA_OK { return LZMA_PROG_ERROR; } - if lzma_index_stream_padding((*coder).this_index, (*coder).stream_padding) as c_uint - != LZMA_OK as c_uint + if lzma_index_stream_padding((*coder).this_index, (*coder).stream_padding) + != LZMA_OK { return LZMA_PROG_ERROR; } @@ -650,7 +649,7 @@ unsafe extern "C" fn file_info_decode( let ret__7: lzma_ret = lzma_index_cat((*coder).this_index, (*coder).combined_index, allocator) as lzma_ret; - if ret__7 as c_uint != LZMA_OK as c_uint { + if ret__7 != LZMA_OK { return ret__7; } } @@ -686,7 +685,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( } if !(*coder).this_index.is_null() { this_index_memusage = lzma_index_memused((*coder).this_index); - } else if (*coder).sequence as c_uint == SEQ_INDEX_DECODE as c_uint { + } else if (*coder).sequence == SEQ_INDEX_DECODE { let mut dummy: u64 = 0; if (*coder) .index_decoder @@ -696,8 +695,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( &raw mut this_index_memusage, &raw mut dummy, 0 as u64, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return LZMA_PROG_ERROR; } @@ -711,9 +709,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( if new_memlimit < *memusage { return LZMA_MEMLIMIT_ERROR; } - if (*coder).this_index.is_null() - && (*coder).sequence as c_uint == SEQ_INDEX_DECODE as c_uint - { + if (*coder).this_index.is_null() && (*coder).sequence == SEQ_INDEX_DECODE { let idec_new_memlimit: u64 = new_memlimit.wrapping_sub(combined_index_memusage); let mut dummy1: u64 = 0; let mut dummy2: u64 = 0; @@ -725,8 +721,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( &raw mut dummy1, &raw mut dummy2, idec_new_memlimit, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return LZMA_PROG_ERROR; } @@ -880,7 +875,7 @@ pub unsafe extern "C" fn lzma_file_info_decoder( mut file_size: u64, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_file_info_decoder_init( @@ -891,7 +886,7 @@ pub unsafe extern "C" fn lzma_file_info_decoder( memlimit, file_size, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index 693607d6..a3ee5096 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -89,7 +89,7 @@ pub type lzma_code_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_decode( @@ -124,7 +124,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( set_out_limit: None, }; let ret_: lzma_ret = lzma_raw_decoder_init(&raw mut next, allocator, filters) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let in_start: size_t = *in_pos; @@ -140,10 +140,10 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( out_size, LZMA_FINISH, ); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = LZMA_OK; } else { - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { if *in_pos != in_size { ret = LZMA_BUF_ERROR; } else if *out_pos != out_size { diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index 2314297d..96031d55 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -89,7 +89,7 @@ pub type lzma_code_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_encode( @@ -121,7 +121,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( set_out_limit: None, }; let ret_: lzma_ret = lzma_raw_encoder_init(&raw mut next, allocator, filters) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let out_start: size_t = *out_pos; @@ -138,10 +138,10 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( LZMA_FINISH, ); lzma_next_end(&raw mut next, allocator); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = LZMA_OK; } else { - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { ret = LZMA_BUF_ERROR; } *out_pos = out_start; diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index b1083d94..6d80af9e 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -178,24 +178,24 @@ pub struct lzma_filter_coder { pub type lzma_filter_find = Option *const lzma_filter_coder>; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; -pub const LZMA_FILTER_X86: c_ulonglong = 0x4 as c_ulonglong; -pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5 as c_ulonglong; -pub const LZMA_FILTER_IA64: c_ulonglong = 0x6 as c_ulonglong; -pub const LZMA_FILTER_ARM: c_ulonglong = 0x7 as c_ulonglong; -pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8 as c_ulonglong; -pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9 as c_ulonglong; -pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa as c_ulonglong; -pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb as c_ulonglong; -pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3 as c_ulonglong; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_FILTER_X86: c_ulonglong = 0x4; +pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; +pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; +pub const LZMA_FILTER_ARM: c_ulonglong = 0x7; +pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8; +pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; +pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; +pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; +pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; static mut features: [C2RustUnnamed; 13] = [ C2RustUnnamed { id: LZMA_FILTER_LZMA1 as lzma_vli, @@ -393,7 +393,7 @@ pub unsafe extern "C" fn lzma_validate_chain( mut filters: *const lzma_filter, mut count: *mut size_t, ) -> lzma_ret { - if filters.is_null() || (*filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli { + if filters.is_null() || (*filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_PROG_ERROR; } let mut changes_size_count: size_t = 0 as size_t; @@ -437,7 +437,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( ) -> lzma_ret { let mut count: size_t = 0; let ret_: lzma_ret = lzma_validate_chain(options, &raw mut count) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let mut filters: [lzma_filter_info; 5] = [lzma_filter_info_s { @@ -480,7 +480,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( let ret: lzma_ret = lzma_next_filter_init(next, allocator, &raw mut filters as *mut lzma_filter_info) as lzma_ret; - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { lzma_next_end(next, allocator); } return ret; @@ -491,7 +491,7 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( mut filters: *const lzma_filter, ) -> u64 { let mut tmp: size_t = 0; - if lzma_validate_chain(filters, &raw mut tmp) as c_uint != LZMA_OK as c_uint { + if lzma_validate_chain(filters, &raw mut tmp) != LZMA_OK { return UINT64_MAX as u64; } let mut total: u64 = 0 as u64; diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 0f9879bc..e433e5b1 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -256,18 +256,18 @@ pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; -pub const LZMA_FILTER_X86: c_ulonglong = 0x4 as c_ulonglong; -pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5 as c_ulonglong; -pub const LZMA_FILTER_IA64: c_ulonglong = 0x6 as c_ulonglong; -pub const LZMA_FILTER_ARM: c_ulonglong = 0x7 as c_ulonglong; -pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8 as c_ulonglong; -pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9 as c_ulonglong; -pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa as c_ulonglong; -pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb as c_ulonglong; -pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3 as c_ulonglong; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; +pub const LZMA_FILTER_X86: c_ulonglong = 0x4; +pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; +pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; +pub const LZMA_FILTER_ARM: c_ulonglong = 0x7; +pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8; +pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; +pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; +pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; +pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; static mut decoders: [lzma_filter_decoder; 12] = [ lzma_filter_decoder { id: LZMA_FILTER_LZMA1 as lzma_vli, @@ -562,7 +562,7 @@ pub unsafe extern "C" fn lzma_raw_decoder( mut options: *const lzma_filter, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_raw_decoder_init( @@ -570,7 +570,7 @@ pub unsafe extern "C" fn lzma_raw_decoder( (*strm).allocator, options, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index ce378c3e..72572e0d 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -232,22 +232,22 @@ pub struct lzma_filter_coder { pub type lzma_filter_find = Option *const lzma_filter_coder>; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_X86: c_ulonglong = 0x4 as c_ulonglong; -pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5 as c_ulonglong; -pub const LZMA_FILTER_IA64: c_ulonglong = 0x6 as c_ulonglong; -pub const LZMA_FILTER_ARM: c_ulonglong = 0x7 as c_ulonglong; -pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8 as c_ulonglong; -pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9 as c_ulonglong; -pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa as c_ulonglong; -pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb as c_ulonglong; -pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3 as c_ulonglong; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; +pub const LZMA_FILTER_X86: c_ulonglong = 0x4; +pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; +pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; +pub const LZMA_FILTER_ARM: c_ulonglong = 0x7; +pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8; +pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; +pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; +pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; +pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; static mut encoders: [lzma_filter_encoder; 12] = [ lzma_filter_encoder { id: LZMA_FILTER_LZMA1 as lzma_vli, @@ -558,7 +558,7 @@ pub unsafe extern "C" fn lzma_raw_encoder( mut filters: *const lzma_filter, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_raw_coder_init( @@ -568,7 +568,7 @@ pub unsafe extern "C" fn lzma_raw_encoder( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), 1 as c_int != 0, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 5d98c4c7..2db89bff 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -51,7 +51,7 @@ pub struct lzma_filter { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const LZMA_FILTER_RESERVED_START: c_ulonglong = (1 as c_ulonglong) << 62 as c_int; +pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_decode( mut filter: *mut lzma_filter, @@ -68,7 +68,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( in_pos, in_size, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { @@ -82,7 +82,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( in_pos, in_size, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } if (in_size.wrapping_sub(*in_pos) as lzma_vli) < props_size { diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index 6b68bb39..40934be2 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -39,7 +39,7 @@ pub struct lzma_filter { pub id: lzma_vli, pub options: *mut c_void, } -pub const LZMA_FILTER_RESERVED_START: c_ulonglong = (1 as c_ulonglong) << 62 as c_int; +pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_size( mut size: *mut u32, @@ -49,7 +49,7 @@ pub unsafe extern "C" fn lzma_filter_flags_size( return LZMA_PROG_ERROR; } let ret_: lzma_ret = lzma_properties_size(size, filter) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } *size = (*size) @@ -73,12 +73,12 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( out_pos, out_size, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let mut props_size: u32 = 0; let ret__0: lzma_ret = lzma_properties_size(&raw mut props_size, filter) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } let ret__1: lzma_ret = lzma_vli_encode( @@ -88,7 +88,7 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( out_pos, out_size, ) as lzma_ret; - if ret__1 as c_uint != LZMA_OK as c_uint { + if ret__1 != LZMA_OK { return ret__1; } if out_size.wrapping_sub(*out_pos) < props_size as size_t { @@ -96,7 +96,7 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( } let ret__2: lzma_ret = lzma_properties_encode(filter, out.offset(*out_pos as isize)) as lzma_ret; - if ret__2 as c_uint != LZMA_OK as c_uint { + if ret__2 != LZMA_OK { return ret__2; } *out_pos = (*out_pos).wrapping_add(props_size as size_t); diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index f15d3604..6f9b215d 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -201,8 +201,8 @@ pub type C2RustUnnamed_2 = c_uint; pub type C2RustUnnamed_3 = c_uint; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT32_MAX: c_uint = 4294967295; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const true_0: c_int = 1 as c_int; @@ -215,12 +215,12 @@ unsafe extern "C" fn bsr32(mut n: u32) -> u32 { unsafe extern "C" fn ctz32(mut n: u32) -> u32 { return n.trailing_zeros() as i32 as u32; } -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; -pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = (1 as c_ulonglong) << 34 as c_int; -pub const UNPADDED_SIZE_MIN: c_ulonglong = 5 as c_ulonglong; -pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !(3 as c_ulonglong); +pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; +pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); @@ -538,7 +538,7 @@ pub unsafe extern "C" fn lzma_index_checks(mut i: *const lzma_index) -> u32 { let mut checks: u32 = (*i).checks; let mut s: *const index_stream = (*i).streams.rightmost as *const index_stream; if (*s).stream_flags.version != UINT32_MAX as u32 { - checks = (checks as c_uint | (1 as c_uint) << (*s).stream_flags.check as c_uint) as u32; + checks = (checks | 1u32 << (*s).stream_flags.check) as u32; } return checks; } @@ -557,7 +557,7 @@ pub unsafe extern "C" fn lzma_index_stream_flags( return LZMA_PROG_ERROR; } let ret_: lzma_ret = lzma_stream_flags_compare(stream_flags, stream_flags) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let mut s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; @@ -982,7 +982,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( mut iter: *mut lzma_index_iter, mut mode: lzma_index_iter_mode, ) -> lzma_bool { - if mode as c_uint > LZMA_INDEX_ITER_NONEMPTY_BLOCK as c_uint { + if mode > LZMA_INDEX_ITER_NONEMPTY_BLOCK { return true_0 as lzma_bool; } let mut i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; @@ -990,7 +990,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( (*iter).internal[ITER_STREAM as usize].p as *const index_stream; let mut group: *const index_group = ::core::ptr::null::(); let mut record: size_t = (*iter).internal[ITER_RECORD as usize].s; - if mode as c_uint != LZMA_INDEX_ITER_STREAM as c_uint { + if mode != LZMA_INDEX_ITER_STREAM { match (*iter).internal[ITER_METHOD as usize].s { 0 => { group = (*iter).internal[ITER_GROUP as usize].p as *const index_group; @@ -1009,7 +1009,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( loop { if stream.is_null() { stream = (*i).streams.leftmost as *const index_stream; - if mode as c_uint >= LZMA_INDEX_ITER_BLOCK as c_uint { + if mode >= LZMA_INDEX_ITER_BLOCK { while (*stream).groups.leftmost.is_null() { stream = index_tree_next(&raw const (*stream).node) as *const index_stream; if stream.is_null() { @@ -1032,21 +1032,19 @@ pub unsafe extern "C" fn lzma_index_iter_next( if stream.is_null() { return true_0 as lzma_bool; } - if !(mode as c_uint >= LZMA_INDEX_ITER_BLOCK as c_uint - && (*stream).groups.leftmost.is_null()) - { + if !(mode >= LZMA_INDEX_ITER_BLOCK && (*stream).groups.leftmost.is_null()) { break; } } group = (*stream).groups.leftmost as *const index_group; } } - if !(mode as c_uint == LZMA_INDEX_ITER_NONEMPTY_BLOCK as c_uint) { + if !(mode == LZMA_INDEX_ITER_NONEMPTY_BLOCK) { break; } if record == 0 as size_t { if !((*group).node.uncompressed_base - == (*(&raw const (*group).records as *const index_record).offset(0 as isize)) + == (*(&raw const (*group).records as *const index_record).offset(0)) .uncompressed_sum) { break; diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 9f0d3d20..fdf8f9dc 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -175,11 +175,11 @@ pub const SEQ_COUNT: C2RustUnnamed_0 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); -pub const UNPADDED_SIZE_MIN: c_ulonglong = 5 as c_ulonglong; -pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !(3 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); +pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; pub const INDEX_INDICATOR: c_int = 0 as c_int; unsafe extern "C" fn index_decode( mut coder_ptr: *mut c_void, @@ -197,7 +197,7 @@ unsafe extern "C" fn index_decode( let in_start: size_t = *in_pos; let mut ret: lzma_ret = LZMA_OK; while *in_pos < in_size { - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); @@ -215,7 +215,7 @@ unsafe extern "C" fn index_decode( in_pos, in_size, ); - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { break; } (*coder).pos = 0 as size_t; @@ -226,19 +226,18 @@ unsafe extern "C" fn index_decode( current_block = 7642845755631126846; } 3 | 4 => { - let mut size: *mut lzma_vli = - if (*coder).sequence as c_uint == SEQ_UNPADDED as c_uint { - &raw mut (*coder).unpadded_size - } else { - &raw mut (*coder).uncompressed_size - }; + let mut size: *mut lzma_vli = if (*coder).sequence == SEQ_UNPADDED { + &raw mut (*coder).unpadded_size + } else { + &raw mut (*coder).uncompressed_size + }; ret = lzma_vli_decode(size, &raw mut (*coder).pos, in_0, in_pos, in_size); - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { break; } ret = LZMA_OK; (*coder).pos = 0 as size_t; - if (*coder).sequence as c_uint == SEQ_UNPADDED as c_uint { + if (*coder).sequence == SEQ_UNPADDED { if (*coder).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || (*coder).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli { @@ -252,7 +251,7 @@ unsafe extern "C" fn index_decode( (*coder).unpadded_size, (*coder).uncompressed_size, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } (*coder).count = (*coder).count.wrapping_sub(1); @@ -486,7 +485,7 @@ pub unsafe extern "C" fn lzma_index_decoder( *i = ::core::ptr::null_mut::(); } let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_index_decoder_init( @@ -495,7 +494,7 @@ pub unsafe extern "C" fn lzma_index_decoder( i, memlimit, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } @@ -531,7 +530,7 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( crc32: 0, }; let ret_: lzma_ret = index_decoder_reset(&raw mut coder, allocator, i, *memlimit) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let in_start: size_t = *in_pos; @@ -546,14 +545,14 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( 0 as size_t, LZMA_RUN, ); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = LZMA_OK; } else { lzma_index_end(coder.index, allocator); *in_pos = in_start; - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { ret = LZMA_DATA_ERROR; - } else if ret as c_uint == LZMA_MEMLIMIT_ERROR as c_uint { + } else if ret == LZMA_MEMLIMIT_ERROR { *memlimit = lzma_index_memusage(1 as lzma_vli, coder.count); } } diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index 125863e1..b84da787 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -262,7 +262,7 @@ unsafe extern "C" fn index_encode( let out_start: size_t = *out_pos; let mut ret: lzma_ret = LZMA_OK; while *out_pos < out_size { - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { *out.offset(*out_pos as isize) = INDEX_INDICATOR as u8; *out_pos = (*out_pos).wrapping_add(1); @@ -272,7 +272,7 @@ unsafe extern "C" fn index_encode( 1 => { let count: lzma_vli = lzma_index_block_count((*coder).index) as lzma_vli; ret = lzma_vli_encode(count, &raw mut (*coder).pos, out, out_pos, out_size); - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { break; } ret = LZMA_OK; @@ -317,13 +317,13 @@ unsafe extern "C" fn index_encode( } match current_block { 10048703153582371463 => { - let size: lzma_vli = if (*coder).sequence as c_uint == SEQ_UNPADDED as c_uint { + let size: lzma_vli = if (*coder).sequence == SEQ_UNPADDED { (*coder).iter.block.unpadded_size } else { (*coder).iter.block.uncompressed_size }; ret = lzma_vli_encode(size, &raw mut (*coder).pos, out, out_pos, out_size); - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { break; } ret = LZMA_OK; @@ -451,13 +451,13 @@ pub unsafe extern "C" fn lzma_index_encoder( mut i: *const lzma_index, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_index_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, i) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } @@ -538,7 +538,7 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( out_size, LZMA_RUN, ); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = LZMA_OK; } else { *out_pos = out_start; diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index a5a230f2..882e01ab 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -113,12 +113,12 @@ pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; pub type lzma_index_hash = lzma_index_hash_s; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; -pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = (1 as c_ulonglong) << 34 as c_int; -pub const UNPADDED_SIZE_MIN: c_ulonglong = 5 as c_ulonglong; -pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !(3 as c_ulonglong); +pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; +pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; pub const INDEX_INDICATOR: c_int = 0 as c_int; #[inline] unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { @@ -219,7 +219,7 @@ pub unsafe extern "C" fn lzma_index_hash_append( mut uncompressed_size: lzma_vli, ) -> lzma_ret { if index_hash.is_null() - || (*index_hash).sequence as c_uint != SEQ_BLOCK as c_uint + || (*index_hash).sequence != SEQ_BLOCK || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli || uncompressed_size > LZMA_VLI_MAX as lzma_vli @@ -261,7 +261,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( let in_start: size_t = *in_pos; let mut ret: lzma_ret = LZMA_OK; while *in_pos < in_size { - match (*index_hash).sequence as c_uint { + match (*index_hash).sequence { 0 => { let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); @@ -279,7 +279,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( in_pos, in_size, ); - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { break; } if (*index_hash).remaining != (*index_hash).blocks.count { @@ -295,19 +295,18 @@ pub unsafe extern "C" fn lzma_index_hash_decode( continue; } 2 | 3 => { - let mut size: *mut lzma_vli = - if (*index_hash).sequence as c_uint == SEQ_UNPADDED as c_uint { - &raw mut (*index_hash).unpadded_size - } else { - &raw mut (*index_hash).uncompressed_size - }; + let mut size: *mut lzma_vli = if (*index_hash).sequence == SEQ_UNPADDED { + &raw mut (*index_hash).unpadded_size + } else { + &raw mut (*index_hash).uncompressed_size + }; ret = lzma_vli_decode(size, &raw mut (*index_hash).pos, in_0, in_pos, in_size); - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { break; } ret = LZMA_OK; (*index_hash).pos = 0 as size_t; - if (*index_hash).sequence as c_uint == SEQ_UNPADDED as c_uint { + if (*index_hash).sequence == SEQ_UNPADDED { if (*index_hash).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || (*index_hash).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli { diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index c6d59407..2df6985a 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -225,38 +225,38 @@ pub type lzma_init_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0 as isize) as u32; - num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; - num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; - num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; return num; } #[inline] unsafe extern "C" fn read64le(mut buf: *const u8) -> u64 { - let mut num: u64 = *buf.offset(0 as isize) as u64; - num |= (*buf.offset(1 as isize) as u64) << 8 as c_int; - num |= (*buf.offset(2 as isize) as u64) << 16 as c_int; - num |= (*buf.offset(3 as isize) as u64) << 24 as c_int; - num |= (*buf.offset(4 as isize) as u64) << 32 as c_int; - num |= (*buf.offset(5 as isize) as u64) << 40 as c_int; - num |= (*buf.offset(6 as isize) as u64) << 48 as c_int; - num |= (*buf.offset(7 as isize) as u64) << 56 as c_int; + let mut num: u64 = *buf.offset(0) as u64; + num |= (*buf.offset(1) as u64) << 8; + num |= (*buf.offset(2) as u64) << 16; + num |= (*buf.offset(3) as u64) << 24; + num |= (*buf.offset(4) as u64) << 32; + num |= (*buf.offset(5) as u64) << 40; + num |= (*buf.offset(6) as u64) << 48; + num |= (*buf.offset(7) as u64) << 56; return num; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; -pub const LZMA_TELL_NO_CHECK: c_uint = 0x1 as c_uint; -pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2 as c_uint; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; -pub const LZMA_IGNORE_CHECK: c_uint = 0x10 as c_uint; -pub const LZMA_CONCATENATED: c_uint = 0x8 as c_uint; -pub const LZMA_FAIL_FAST: c_uint = 0x20 as c_uint; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10; +pub const LZMA_CONCATENATED: c_uint = 0x8; +pub const LZMA_FAIL_FAST: c_uint = 0x20; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK @@ -282,14 +282,12 @@ unsafe extern "C" fn lzip_decode( let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; loop { let mut current_block_80: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { let lzip_id_string: [u8; 4] = [0x4c as u8, 0x5a as u8, 0x49 as u8, 0x50 as u8]; while (*coder).pos < ::core::mem::size_of::<[u8; 4]>() as usize { if *in_pos >= in_size { - return (if !(*coder).first_member - && action as c_uint == LZMA_FINISH as c_uint - { + return (if !(*coder).first_member && action == LZMA_FINISH { LZMA_STREAM_END as c_int } else { LZMA_OK as c_int @@ -361,7 +359,7 @@ unsafe extern "C" fn lzip_decode( let ds: u32 = *in_0.offset(fresh1 as isize) as u32; (*coder).member_size = (*coder).member_size.wrapping_add(1); let b2log: u32 = ds & 0x1f as u32; - let fracnum: u32 = ds >> 5 as c_int; + let fracnum: u32 = ds >> 5; if b2log < 12 as u32 || b2log > 29 as u32 || b2log == 12 as u32 && fracnum > 0 as u32 @@ -412,7 +410,7 @@ unsafe extern "C" fn lzip_decode( allocator, &raw const filters as *const lzma_filter_info, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } (*coder).crc32 = 0 as u32; @@ -449,7 +447,7 @@ unsafe extern "C" fn lzip_decode( (*coder).crc32 = lzma_crc32(out.offset(out_start as isize), out_used, (*coder).crc32); } - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { return ret; } (*coder).sequence = SEQ_MEMBER_FOOTER; @@ -476,18 +474,18 @@ unsafe extern "C" fn lzip_decode( (*coder).member_size = (*coder).member_size.wrapping_add(footer_size as u64); if !(*coder).ignore_check && (*coder).crc32 - != read32le((&raw mut (*coder).buffer as *mut u8).offset(0 as isize) as *mut u8) + != read32le((&raw mut (*coder).buffer as *mut u8).offset(0) as *mut u8) { return LZMA_DATA_ERROR; } if (*coder).uncompressed_size - != read64le((&raw mut (*coder).buffer as *mut u8).offset(4 as isize) as *mut u8) + != read64le((&raw mut (*coder).buffer as *mut u8).offset(4) as *mut u8) { return LZMA_DATA_ERROR; } if (*coder).version > 0 as u32 { if (*coder).member_size - != read64le((&raw mut (*coder).buffer as *mut u8).offset(12 as isize) as *mut u8) + != read64le((&raw mut (*coder).buffer as *mut u8).offset(12) as *mut u8) { return LZMA_DATA_ERROR; } @@ -637,7 +635,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder( mut flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_lzip_decoder_init( @@ -646,7 +644,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder( memlimit, flags, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index 6cf1b7df..d5954096 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -200,13 +200,13 @@ pub type lzma_init_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT32_MAX: c_uint = 4294967295; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; unsafe extern "C" fn microlzma_decode( mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, @@ -261,7 +261,7 @@ unsafe extern "C" fn microlzma_decode( }; if (*coder).uncomp_size_is_exact { options.ext_size_low = (*coder).uncomp_size as u32; - options.ext_size_high = ((*coder).uncomp_size >> 32 as c_int) as u32; + options.ext_size_high = ((*coder).uncomp_size >> 32) as u32; } if lzma_lzma_lclppb_decode( &raw mut options, @@ -294,7 +294,7 @@ unsafe extern "C" fn microlzma_decode( allocator, &raw mut filters as *mut lzma_filter_info, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let dummy_in: u8 = 0 as u8; @@ -309,8 +309,7 @@ unsafe extern "C" fn microlzma_decode( out_pos, out_size, LZMA_RUN, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return LZMA_PROG_ERROR; } @@ -331,14 +330,14 @@ unsafe extern "C" fn microlzma_decode( .comp_size .wrapping_sub((*in_pos).wrapping_sub(in_start) as u64); if (*coder).uncomp_size_is_exact { - if ret as c_uint == LZMA_STREAM_END as c_uint && (*coder).comp_size != 0 as u64 { + if ret == LZMA_STREAM_END && (*coder).comp_size != 0 as u64 { ret = LZMA_DATA_ERROR; } } else { (*coder).uncomp_size = (*coder) .uncomp_size .wrapping_sub((*out_pos).wrapping_sub(out_start) as lzma_vli); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = LZMA_DATA_ERROR; } else if (*coder).uncomp_size == 0 as lzma_vli { ret = LZMA_STREAM_END; @@ -470,7 +469,7 @@ pub unsafe extern "C" fn lzma_microlzma_decoder( mut dict_size: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = microlzma_decoder_init( @@ -481,7 +480,7 @@ pub unsafe extern "C" fn lzma_microlzma_decoder( uncomp_size_is_exact != 0, dict_size, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index f5a6656c..5abd860d 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -196,10 +196,10 @@ pub struct lzma_microlzma_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; unsafe extern "C" fn microlzma_encode( mut coder_ptr: *mut c_void, mut allocator: *const lzma_allocator, @@ -222,8 +222,7 @@ unsafe extern "C" fn microlzma_encode( (*coder).lzma.coder, &raw mut uncomp_size, out_size.wrapping_sub(*out_pos) as u64, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return LZMA_PROG_ERROR; } @@ -238,8 +237,8 @@ unsafe extern "C" fn microlzma_encode( out_size, action, ) as lzma_ret; - if ret as c_uint != LZMA_STREAM_END as c_uint { - if ret as c_uint == LZMA_OK as c_uint { + if ret != LZMA_STREAM_END { + if ret == LZMA_OK { return LZMA_PROG_ERROR; } return ret; @@ -372,7 +371,7 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( mut options: *const lzma_options_lzma, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = microlzma_encoder_init( @@ -380,7 +379,7 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( (*strm).allocator, options, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index 3a1903ea..3935799a 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -70,7 +70,7 @@ pub struct lzma_outq { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const false_0: c_int = 0 as c_int; diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index 69a0f04b..1cc02404 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -90,9 +90,9 @@ pub type lzma_code_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; #[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_decode( mut memlimit: *mut u64, @@ -131,7 +131,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( }; let mut ret: lzma_ret = lzma_stream_decoder_init(&raw mut stream_decoder, allocator, *memlimit, flags); - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; ret = stream_decoder.code.expect("non-null function pointer")( @@ -145,18 +145,18 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( out_size, LZMA_FINISH, ); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = LZMA_OK; } else { *in_pos = in_start; *out_pos = out_start; - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { if *in_pos == in_size { ret = LZMA_DATA_ERROR; } else { ret = LZMA_BUF_ERROR; } - } else if ret as c_uint == LZMA_MEMLIMIT_ERROR as c_uint { + } else if ret == LZMA_MEMLIMIT_ERROR { let mut memusage: u64 = 0; stream_decoder.memconfig.expect("non-null function pointer")( stream_decoder.coder, diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 2f114203..644251fc 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -133,7 +133,7 @@ pub struct lzma_block { pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; pub const INDEX_BOUND: c_int = 1 as c_int + 1 as c_int + 2 as c_int * LZMA_VLI_BYTES_MAX + 4 as c_int + 3 as c_int @@ -145,15 +145,13 @@ pub unsafe extern "C" fn lzma_stream_buffer_bound(mut uncompressed_size: size_t) if block_bound == 0 as size_t { return 0 as size_t; } - if (if (18446744073709551615 as c_ulonglong) - < (18446744073709551615 as c_ulonglong).wrapping_div(2 as c_ulonglong) - { - 18446744073709551615 as c_ulonglong + if (if 18446744073709551615_u64 < 18446744073709551615_u64.wrapping_div(2) { + 18446744073709551615_u64 } else { - (18446744073709551615 as c_ulonglong).wrapping_div(2 as c_ulonglong) + 18446744073709551615_u64.wrapping_div(2) }) - .wrapping_sub(block_bound as c_ulonglong) - < HEADERS_BOUND as c_ulonglong + .wrapping_sub(block_bound as u64) + < HEADERS_BOUND as u64 { return 0 as size_t; } @@ -171,7 +169,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( mut out_size: size_t, ) -> lzma_ret { if filters.is_null() - || check as c_uint > LZMA_CHECK_ID_MAX as c_uint + || check > LZMA_CHECK_ID_MAX || in_0.is_null() && in_size != 0 as size_t || out.is_null() || out_pos_ptr.is_null() @@ -206,9 +204,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( reserved_int1: 0, reserved_int2: 0, }; - if lzma_stream_header_encode(&raw mut stream_flags, out.offset(out_pos as isize)) as c_uint - != LZMA_OK as c_uint - { + if lzma_stream_header_encode(&raw mut stream_flags, out.offset(out_pos as isize)) != LZMA_OK { return LZMA_PROG_ERROR; } out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); @@ -254,7 +250,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( &raw mut out_pos, out_size, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } } @@ -271,17 +267,15 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( block.uncompressed_size, ); } - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { ret = lzma_index_buffer_encode(i, out, &raw mut out_pos, out_size); stream_flags.backward_size = lzma_index_size(i); } lzma_index_end(i, allocator); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { return ret; } - if lzma_stream_footer_encode(&raw mut stream_flags, out.offset(out_pos as isize)) as c_uint - != LZMA_OK as c_uint - { + if lzma_stream_footer_encode(&raw mut stream_flags, out.offset(out_pos as isize)) != LZMA_OK { return LZMA_PROG_ERROR; } out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index f6aff12c..0eabf1f2 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -261,18 +261,18 @@ pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_NO_CHECK: c_uint = 0x1 as c_uint; -pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2 as c_uint; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; -pub const LZMA_IGNORE_CHECK: c_uint = 0x10 as c_uint; -pub const LZMA_CONCATENATED: c_uint = 0x8 as c_uint; -pub const LZMA_FAIL_FAST: c_uint = 0x20 as c_uint; +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10; +pub const LZMA_CONCATENATED: c_uint = 0x8; +pub const LZMA_FAIL_FAST: c_uint = 0x20; pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK @@ -306,7 +306,7 @@ unsafe extern "C" fn stream_decode( let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; loop { let mut current_block_100: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { lzma_bufcpy( in_0, @@ -324,20 +324,18 @@ unsafe extern "C" fn stream_decode( &raw mut (*coder).stream_flags, &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret as c_uint != LZMA_OK as c_uint { - return (if ret as c_uint == LZMA_FORMAT_ERROR as c_uint - && !(*coder).first_stream - { - LZMA_DATA_ERROR as c_uint + if ret != LZMA_OK { + return (if ret == LZMA_FORMAT_ERROR && !(*coder).first_stream { + LZMA_DATA_ERROR } else { - ret as c_uint + ret }) as lzma_ret; } (*coder).first_stream = false_0 != 0; (*coder).block_options.check = (*coder).stream_flags.check; (*coder).sequence = SEQ_BLOCK_HEADER; if (*coder).tell_no_check as c_int != 0 - && (*coder).stream_flags.check as c_uint == LZMA_CHECK_NONE as c_uint + && (*coder).stream_flags.check == LZMA_CHECK_NONE { return LZMA_NO_CHECK; } @@ -366,7 +364,7 @@ unsafe extern "C" fn stream_decode( } let ret_2: lzma_ret = lzma_index_hash_decode((*coder).index_hash, in_0, in_pos, in_size) as lzma_ret; - if ret_2 as c_uint != LZMA_STREAM_END as c_uint { + if ret_2 != LZMA_STREAM_END { return ret_2; } (*coder).sequence = SEQ_STREAM_FOOTER; @@ -455,11 +453,11 @@ unsafe extern "C" fn stream_decode( &raw mut footer_flags, &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret_3 as c_uint != LZMA_OK as c_uint { - return (if ret_3 as c_uint == LZMA_FORMAT_ERROR as c_uint { - LZMA_DATA_ERROR as c_uint + if ret_3 != LZMA_OK { + return (if ret_3 == LZMA_FORMAT_ERROR { + LZMA_DATA_ERROR } else { - ret_3 as c_uint + ret_3 }) as lzma_ret; } if lzma_index_hash_size((*coder).index_hash) != footer_flags.backward_size { @@ -469,7 +467,7 @@ unsafe extern "C" fn stream_decode( &raw mut (*coder).stream_flags, &raw mut footer_flags, ) as lzma_ret; - if ret__1 as c_uint != LZMA_OK as c_uint { + if ret__1 != LZMA_OK { return ret__1; } if !(*coder).concatenated { @@ -484,7 +482,7 @@ unsafe extern "C" fn stream_decode( 15462640364611497761 => { loop { if *in_pos >= in_size { - if action as c_uint != LZMA_FINISH as c_uint { + if action != LZMA_FINISH { return LZMA_OK; } return (if (*coder).pos == 0 as size_t { @@ -504,7 +502,7 @@ unsafe extern "C" fn stream_decode( return LZMA_DATA_ERROR; } let ret__2: lzma_ret = stream_decoder_reset(coder, allocator) as lzma_ret; - if ret__2 as c_uint != LZMA_OK as c_uint { + if ret__2 != LZMA_OK { return ret__2; } current_block_100 = 16789764818708874114; @@ -521,7 +519,7 @@ unsafe extern "C" fn stream_decode( allocator, &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } (*coder).block_options.ignore_check = (*coder).ignore_check as lzma_bool; @@ -544,7 +542,7 @@ unsafe extern "C" fn stream_decode( } lzma_filters_free(&raw mut filters as *mut lzma_filter, allocator); (*coder).block_options.filters = ::core::ptr::null_mut::(); - if ret_0 as c_uint != LZMA_OK as c_uint { + if ret_0 != LZMA_OK { return ret_0; } (*coder).sequence = SEQ_BLOCK_RUN; @@ -568,7 +566,7 @@ unsafe extern "C" fn stream_decode( out_size, action, ) as lzma_ret; - if ret_1 as c_uint != LZMA_STREAM_END as c_uint { + if ret_1 != LZMA_STREAM_END { return ret_1; } let ret__0: lzma_ret = lzma_index_hash_append( @@ -576,7 +574,7 @@ unsafe extern "C" fn stream_decode( lzma_block_unpadded_size(&raw mut (*coder).block_options), (*coder).block_options.uncompressed_size, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } (*coder).sequence = SEQ_BLOCK_HEADER; @@ -726,7 +724,7 @@ pub unsafe extern "C" fn lzma_stream_decoder( mut flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = lzma_stream_decoder_init( @@ -735,7 +733,7 @@ pub unsafe extern "C" fn lzma_stream_decoder( memlimit, flags, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 58c70caf..d43441a6 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -508,7 +508,7 @@ pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const SIG_SETMASK: c_int = 3 as c_int; @@ -628,15 +628,15 @@ unsafe extern "C" fn mythread_condtime_set( } } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_NO_CHECK: c_uint = 0x1 as c_uint; -pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2 as c_uint; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4 as c_uint; -pub const LZMA_IGNORE_CHECK: c_uint = 0x10 as c_uint; -pub const LZMA_CONCATENATED: c_uint = 0x8 as c_uint; -pub const LZMA_FAIL_FAST: c_uint = 0x20 as c_uint; +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10; +pub const LZMA_CONCATENATED: c_uint = 0x8; +pub const LZMA_FAIL_FAST: c_uint = 0x20; pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK @@ -662,7 +662,7 @@ unsafe extern "C" fn lzma_outq_outbuf_memusage(mut buf_size: size_t) -> u64 { } unsafe extern "C" fn worker_enable_partial_update(mut thr_ptr: *mut c_void) { let mut thr: *mut worker_thread = thr_ptr as *mut worker_thread; - let mut mythread_i_325: c_uint = 0 as c_uint; + let mut mythread_i_325: c_uint = 0; while if mythread_i_325 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); 0 as c_int @@ -671,13 +671,13 @@ unsafe extern "C" fn worker_enable_partial_update(mut thr_ptr: *mut c_void) { 1 as c_int } != 0 { - let mut mythread_j_325: c_uint = 0 as c_uint; + let mut mythread_j_325: c_uint = 0; while mythread_j_325 == 0 { (*thr).partial_update_enabled = true_0 != 0; mythread_cond_signal(&raw mut (*thr).cond); - mythread_j_325 = 1 as c_uint; + mythread_j_325 = 1; } - mythread_i_325 = 1 as c_uint; + mythread_i_325 = 1; } } unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { @@ -688,10 +688,10 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { loop { mythread_mutex_lock(&raw mut (*thr).mutex); loop { - if (*thr).state as c_uint == THR_IDLE as c_uint { + if (*thr).state == THR_IDLE { mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); } else { - if (*thr).state as c_uint == THR_EXIT as c_uint { + if (*thr).state == THR_EXIT { mythread_mutex_unlock(&raw mut (*thr).mutex); lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); lzma_next_end(&raw mut (*thr).block_decoder, (*thr).allocator); @@ -730,10 +730,10 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { (*(*thr).outbuf).allocated, LZMA_RUN, ); - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { if partial_update_enabled { (*thr).partial_update_started = true_0 != 0; - let mut mythread_i_415: c_uint = 0 as c_uint; + let mut mythread_i_415: c_uint = 0; while if mythread_i_415 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); 0 as c_int @@ -742,18 +742,18 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { 1 as c_int } != 0 { - let mut mythread_j_415: c_uint = 0 as c_uint; + let mut mythread_j_415: c_uint = 0; while mythread_j_415 == 0 { (*(*thr).outbuf).pos = (*thr).out_pos; (*(*thr).outbuf).decoder_in_pos = (*thr).in_pos; mythread_cond_signal(&raw mut (*(*thr).coder).cond); - mythread_j_415 = 1 as c_uint; + mythread_j_415 = 1; } - mythread_i_415 = 1 as c_uint; + mythread_i_415 = 1; } } } else { - let mut mythread_i_434: c_uint = 0 as c_uint; + let mut mythread_i_434: c_uint = 0; while if mythread_i_434 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); 0 as c_int @@ -762,25 +762,23 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { 1 as c_int } != 0 { - let mut mythread_j_434: c_uint = 0 as c_uint; + let mut mythread_j_434: c_uint = 0; while mythread_j_434 == 0 { - if ret as c_uint == LZMA_STREAM_END as c_uint - && (*thr).in_filled != (*thr).in_size - { + if ret == LZMA_STREAM_END && (*thr).in_filled != (*thr).in_size { ret = LZMA_PROG_ERROR; } - if (*thr).state as c_uint != THR_EXIT as c_uint { + if (*thr).state != THR_EXIT { (*thr).state = THR_IDLE; } - mythread_j_434 = 1 as c_uint; + mythread_j_434 = 1; } - mythread_i_434 = 1 as c_uint; + mythread_i_434 = 1; } - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); (*thr).in_0 = ::core::ptr::null_mut::(); } - let mut mythread_i_458: c_uint = 0 as c_uint; + let mut mythread_i_458: c_uint = 0; while if mythread_i_458 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); 0 as c_int @@ -789,7 +787,7 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { 1 as c_int } != 0 { - let mut mythread_j_458: c_uint = 0 as c_uint; + let mut mythread_j_458: c_uint = 0; while mythread_j_458 == 0 { (*(*thr).coder).progress_in = (*(*thr).coder) .progress_in @@ -804,12 +802,10 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { (*(*thr).outbuf).finished = true_0 != 0; (*(*thr).outbuf).finish_ret = ret; (*thr).outbuf = ::core::ptr::null_mut::(); - if ret as c_uint != LZMA_STREAM_END as c_uint - && (*(*thr).coder).thread_error as c_uint == LZMA_OK as c_uint - { + if ret != LZMA_STREAM_END && (*(*thr).coder).thread_error == LZMA_OK { (*(*thr).coder).thread_error = ret; } - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { (*(*thr).coder).mem_in_use = (*(*thr).coder) .mem_in_use .wrapping_sub((*thr).in_size as u64); @@ -821,9 +817,9 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { (*(*thr).coder).threads_free = thr; } mythread_cond_signal(&raw mut (*(*thr).coder).cond); - mythread_j_458 = 1 as c_uint; + mythread_j_458 = 1; } - mythread_i_458 = 1 as c_uint; + mythread_i_458 = 1; } } } @@ -834,7 +830,7 @@ unsafe extern "C" fn threads_end( ) { let mut i: u32 = 0 as u32; while i < (*coder).threads_initialized { - let mut mythread_i_502: c_uint = 0 as c_uint; + let mut mythread_i_502: c_uint = 0; while if mythread_i_502 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); 0 as c_int @@ -843,13 +839,13 @@ unsafe extern "C" fn threads_end( 1 as c_int } != 0 { - let mut mythread_j_502: c_uint = 0 as c_uint; + let mut mythread_j_502: c_uint = 0; while mythread_j_502 == 0 { (*(*coder).threads.offset(i as isize)).state = THR_EXIT; mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); - mythread_j_502 = 1 as c_uint; + mythread_j_502 = 1; } - mythread_i_502 = 1 as c_uint; + mythread_i_502 = 1; } i = i.wrapping_add(1); } @@ -868,7 +864,7 @@ unsafe extern "C" fn threads_end( unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder) { let mut i: u32 = 0 as u32; while i < (*coder).threads_initialized { - let mut mythread_i_538: c_uint = 0 as c_uint; + let mut mythread_i_538: c_uint = 0; while if mythread_i_538 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); 0 as c_int @@ -877,12 +873,12 @@ unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder) { 1 as c_int } != 0 { - let mut mythread_j_538: c_uint = 0 as c_uint; + let mut mythread_j_538: c_uint = 0; while mythread_j_538 == 0 { (*(*coder).threads.offset(i as isize)).state = THR_IDLE; - mythread_j_538 = 1 as c_uint; + mythread_j_538 = 1; } - mythread_i_538 = 1 as c_uint; + mythread_i_538 = 1; } i = i.wrapping_add(1); } @@ -947,7 +943,7 @@ unsafe extern "C" fn get_thread( mut coder: *mut lzma_stream_coder, mut allocator: *const lzma_allocator, ) -> lzma_ret { - let mut mythread_i_608: c_uint = 0 as c_uint; + let mut mythread_i_608: c_uint = 0; while if mythread_i_608 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -956,7 +952,7 @@ unsafe extern "C" fn get_thread( 1 as c_int } != 0 { - let mut mythread_j_608: c_uint = 0 as c_uint; + let mut mythread_j_608: c_uint = 0; while mythread_j_608 == 0 { if !(*coder).threads_free.is_null() { (*coder).thr = (*coder).threads_free; @@ -965,13 +961,13 @@ unsafe extern "C" fn get_thread( .mem_cached .wrapping_sub((*(*coder).thr).mem_filters); } - mythread_j_608 = 1 as c_uint; + mythread_j_608 = 1; } - mythread_i_608 = 1 as c_uint; + mythread_i_608 = 1; } if (*coder).thr.is_null() { let ret_: lzma_ret = initialize_new_thread(coder, allocator) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } } @@ -996,7 +992,7 @@ unsafe extern "C" fn read_output_and_wait( mut has_blocked: *mut bool, ) -> lzma_ret { let mut ret: lzma_ret = LZMA_OK; - let mut mythread_i_654: c_uint = 0 as c_uint; + let mut mythread_i_654: c_uint = 0; while if mythread_i_654 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1005,7 +1001,7 @@ unsafe extern "C" fn read_output_and_wait( 1 as c_int } != 0 { - let mut mythread_j_654: c_uint = 0 as c_uint; + let mut mythread_j_654: c_uint = 0; while mythread_j_654 == 0 { loop { let out_start: size_t = *out_pos; @@ -1019,7 +1015,7 @@ unsafe extern "C" fn read_output_and_wait( ::core::ptr::null_mut::(), ::core::ptr::null_mut::(), ); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { lzma_outq_enable_partial_output( &raw mut (*coder).outq, Some( @@ -1028,17 +1024,17 @@ unsafe extern "C" fn read_output_and_wait( ), ); } - if !(ret as c_uint == LZMA_STREAM_END as c_uint) { + if !(ret == LZMA_STREAM_END) { break; } } - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { break; } if *out_pos == out_size && *out_pos != out_start { (*coder).out_was_filled = true_0 != 0; } - if (*coder).thread_error as c_uint != LZMA_OK as c_uint { + if (*coder).thread_error != LZMA_OK { if (*coder).fail_fast { ret = (*coder).thread_error; break; @@ -1096,16 +1092,16 @@ unsafe extern "C" fn read_output_and_wait( } else { mythread_cond_wait(&raw mut (*coder).cond, &raw mut (*coder).mutex); } - if !(ret as c_uint == LZMA_OK as c_uint) { + if !(ret == LZMA_OK) { break; } } } - mythread_j_654 = 1 as c_uint; + mythread_j_654 = 1; } - mythread_i_654 = 1 as c_uint; + mythread_i_654 = 1; } - if ret as c_uint != LZMA_OK as c_uint && ret as c_uint != LZMA_RET_INTERNAL1 as c_uint { + if ret != LZMA_OK && ret != LZMA_RET_INTERNAL1 { threads_stop(coder); } return ret; @@ -1147,7 +1143,7 @@ unsafe extern "C" fn decode_block_header( allocator, &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } (*coder).block_options.ignore_check = (*coder).ignore_check as lzma_bool; @@ -1192,11 +1188,11 @@ unsafe extern "C" fn stream_decode_mt( }; let mut has_blocked: bool = false_0 != 0; let waiting_allowed: bool = - action as c_uint == LZMA_FINISH as c_uint || *in_pos == in_size && !(*coder).out_was_filled; + action == LZMA_FINISH || *in_pos == in_size && !(*coder).out_was_filled; (*coder).out_was_filled = false_0 != 0; loop { let mut current_block_239: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { let in_old: size_t = *in_pos; lzma_bufcpy( @@ -1218,20 +1214,18 @@ unsafe extern "C" fn stream_decode_mt( &raw mut (*coder).stream_flags, &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret as c_uint != LZMA_OK as c_uint { - return (if ret as c_uint == LZMA_FORMAT_ERROR as c_uint - && !(*coder).first_stream - { - LZMA_DATA_ERROR as c_uint + if ret != LZMA_OK { + return (if ret == LZMA_FORMAT_ERROR && !(*coder).first_stream { + LZMA_DATA_ERROR } else { - ret as c_uint + ret }) as lzma_ret; } (*coder).first_stream = false_0 != 0; (*coder).block_options.check = (*coder).stream_flags.check; (*coder).sequence = SEQ_BLOCK_HEADER; if (*coder).tell_no_check as c_int != 0 - && (*coder).stream_flags.check as c_uint == LZMA_CHECK_NONE as c_uint + && (*coder).stream_flags.check == LZMA_CHECK_NONE { return LZMA_NO_CHECK; } @@ -1269,7 +1263,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut wait_abs, &raw mut has_blocked, ) as lzma_ret; - if ret__3 as c_uint != LZMA_OK as c_uint { + if ret__3 != LZMA_OK { return ret__3; } if !lzma_outq_is_empty(&raw mut (*coder).outq) { @@ -1284,7 +1278,7 @@ unsafe extern "C" fn stream_decode_mt( ) as lzma_ret; lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); (*coder).block_options.filters = ::core::ptr::null_mut::(); - if ret_3 as c_uint != LZMA_OK as c_uint { + if ret_3 != LZMA_OK { return ret_3; } (*coder).mem_direct_mode = (*coder).mem_next_filters; @@ -1306,7 +1300,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut wait_abs, &raw mut has_blocked, ) as lzma_ret; - if ret__5 as c_uint != LZMA_OK as c_uint { + if ret__5 != LZMA_OK { return ret__5; } if !lzma_outq_is_empty(&raw mut (*coder).outq) { @@ -1337,7 +1331,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut wait_abs, &raw mut has_blocked, ) as lzma_ret; - if ret__8 as c_uint != LZMA_OK as c_uint { + if ret__8 != LZMA_OK { return ret__8; } if !lzma_outq_is_empty(&raw mut (*coder).outq) { @@ -1372,7 +1366,7 @@ unsafe extern "C" fn stream_decode_mt( (*coder).progress_out = (*coder) .progress_out .wrapping_add((*out_pos).wrapping_sub(out_old) as u64); - if ret_4 as c_uint != LZMA_STREAM_END as c_uint { + if ret_4 != LZMA_STREAM_END { return ret_4; } let ret__4: lzma_ret = lzma_index_hash_append( @@ -1380,7 +1374,7 @@ unsafe extern "C" fn stream_decode_mt( lzma_block_unpadded_size(&raw mut (*coder).block_options), (*coder).block_options.uncompressed_size, ) as lzma_ret; - if ret__4 as c_uint != LZMA_OK as c_uint { + if ret__4 != LZMA_OK { return ret__4; } (*coder).sequence = SEQ_BLOCK_HEADER; @@ -1393,9 +1387,8 @@ unsafe extern "C" fn stream_decode_mt( (*coder).progress_in = (*coder) .progress_in .wrapping_add((*in_pos).wrapping_sub(in_old_0) as u64); - if ret_0 as c_uint == LZMA_OK as c_uint { - if action as c_uint == LZMA_FINISH as c_uint && (*coder).fail_fast as c_int != 0 - { + if ret_0 == LZMA_OK { + if action == LZMA_FINISH && (*coder).fail_fast as c_int != 0 { threads_stop(coder); return LZMA_DATA_ERROR; } @@ -1410,19 +1403,19 @@ unsafe extern "C" fn stream_decode_mt( &raw mut wait_abs, &raw mut has_blocked, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } - if (*coder).pending_error as c_uint != LZMA_OK as c_uint { + if (*coder).pending_error != LZMA_OK { (*coder).sequence = SEQ_ERROR; } else { return LZMA_OK; } current_block_239 = 11639917216603986996; - } else if ret_0 as c_uint == LZMA_RET_INTERNAL2 as c_uint { + } else if ret_0 == LZMA_RET_INTERNAL2 { (*coder).sequence = SEQ_INDEX_WAIT_OUTPUT; current_block_239 = 11639917216603986996; - } else if ret_0 as c_uint != LZMA_STREAM_END as c_uint { + } else if ret_0 != LZMA_STREAM_END { (*coder).pending_error = ret_0; (*coder).sequence = SEQ_ERROR; current_block_239 = 11639917216603986996; @@ -1449,7 +1442,7 @@ unsafe extern "C" fn stream_decode_mt( (*coder).progress_in = (*coder) .progress_in .wrapping_add((*in_pos).wrapping_sub(in_old_2) as u64); - if ret_5 as c_uint != LZMA_STREAM_END as c_uint { + if ret_5 != LZMA_STREAM_END { return ret_5; } (*coder).sequence = SEQ_STREAM_FOOTER; @@ -1471,7 +1464,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut wait_abs, &raw mut has_blocked, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } if !lzma_outq_is_empty(&raw mut (*coder).outq) { @@ -1507,7 +1500,7 @@ unsafe extern "C" fn stream_decode_mt( lzma_block_unpadded_size(&raw mut (*coder).block_options), (*coder).block_options.uncompressed_size, ) as lzma_ret; - if ret_1 as c_uint != LZMA_OK as c_uint { + if ret_1 != LZMA_OK { (*coder).pending_error = ret_1; (*coder).sequence = SEQ_ERROR; current_block_239 = 11639917216603986996; @@ -1559,11 +1552,11 @@ unsafe extern "C" fn stream_decode_mt( &raw mut footer_flags, &raw mut (*coder).buffer as *mut u8, ) as lzma_ret; - if ret_6 as c_uint != LZMA_OK as c_uint { - return (if ret_6 as c_uint == LZMA_FORMAT_ERROR as c_uint { - LZMA_DATA_ERROR as c_uint + if ret_6 != LZMA_OK { + return (if ret_6 == LZMA_FORMAT_ERROR { + LZMA_DATA_ERROR } else { - ret_6 as c_uint + ret_6 }) as lzma_ret; } if lzma_index_hash_size((*coder).index_hash) != footer_flags.backward_size { @@ -1573,7 +1566,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut (*coder).stream_flags, &raw mut footer_flags, ) as lzma_ret; - if ret__6 as c_uint != LZMA_OK as c_uint { + if ret__6 != LZMA_OK { return ret__6; } if !(*coder).concatenated { @@ -1588,7 +1581,7 @@ unsafe extern "C" fn stream_decode_mt( 17073193239823527980 => { loop { if *in_pos >= in_size { - if action as c_uint != LZMA_FINISH as c_uint { + if action != LZMA_FINISH { return LZMA_OK; } return (if (*coder).pos == 0 as size_t { @@ -1610,7 +1603,7 @@ unsafe extern "C" fn stream_decode_mt( return LZMA_DATA_ERROR; } let ret__7: lzma_ret = stream_decoder_reset(coder, allocator) as lzma_ret; - if ret__7 as c_uint != LZMA_OK as c_uint { + if ret__7 != LZMA_OK { return ret__7; } current_block_239 = 11639917216603986996; @@ -1628,10 +1621,10 @@ unsafe extern "C" fn stream_decode_mt( &raw mut wait_abs, &raw mut has_blocked, ) as lzma_ret; - if ret__1 as c_uint != LZMA_OK as c_uint { + if ret__1 != LZMA_OK { return ret__1; } - if (*coder).pending_error as c_uint != LZMA_OK as c_uint { + if (*coder).pending_error != LZMA_OK { (*coder).sequence = SEQ_ERROR; current_block_239 = 11639917216603986996; } else { @@ -1641,7 +1634,7 @@ unsafe extern "C" fn stream_decode_mt( let mut mem_in_use: u64 = 0 as u64; let mut mem_cached: u64 = 0 as u64; let mut thr: *mut worker_thread = ::core::ptr::null_mut::(); - let mut mythread_i_1347: c_uint = 0 as c_uint; + let mut mythread_i_1347: c_uint = 0; while if mythread_i_1347 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1650,14 +1643,14 @@ unsafe extern "C" fn stream_decode_mt( 1 as c_int } != 0 { - let mut mythread_j_1347: c_uint = 0 as c_uint; + let mut mythread_j_1347: c_uint = 0; while mythread_j_1347 == 0 { mem_in_use = (*coder).mem_in_use; mem_cached = (*coder).mem_cached; thr = (*coder).threads_free; - mythread_j_1347 = 1 as c_uint; + mythread_j_1347 = 1; } - mythread_i_1347 = 1 as c_uint; + mythread_i_1347 = 1; } let mem_max: u64 = (*coder) .memlimit_threading @@ -1690,7 +1683,7 @@ unsafe extern "C" fn stream_decode_mt( thr = (*thr).next; } } - let mut mythread_i_1410: c_uint = 0 as c_uint; + let mut mythread_i_1410: c_uint = 0; while if mythread_i_1410 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1699,27 +1692,27 @@ unsafe extern "C" fn stream_decode_mt( 1 as c_int } != 0 { - let mut mythread_j_1410: c_uint = 0 as c_uint; + let mut mythread_j_1410: c_uint = 0; while mythread_j_1410 == 0 { (*coder).mem_cached = (*coder).mem_cached.wrapping_sub(mem_freed); (*coder).mem_in_use = (*coder).mem_in_use.wrapping_add( (*coder).mem_next_in.wrapping_add((*coder).mem_next_filters), ); - mythread_j_1410 = 1 as c_uint; + mythread_j_1410 = 1; } - mythread_i_1410 = 1 as c_uint; + mythread_i_1410 = 1; } let mut ret_2: lzma_ret = lzma_outq_prealloc_buf( &raw mut (*coder).outq, allocator, (*coder).block_options.uncompressed_size as size_t, ); - if ret_2 as c_uint != LZMA_OK as c_uint { + if ret_2 != LZMA_OK { threads_stop(coder); return ret_2; } ret_2 = get_thread(coder, allocator); - if ret_2 as c_uint != LZMA_OK as c_uint { + if ret_2 != LZMA_OK { threads_stop(coder); return ret_2; } @@ -1732,7 +1725,7 @@ unsafe extern "C" fn stream_decode_mt( ); lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); (*(*coder).thr).block_options.filters = ::core::ptr::null_mut::(); - if ret_2 as c_uint != LZMA_OK as c_uint { + if ret_2 != LZMA_OK { (*coder).pending_error = ret_2; (*coder).sequence = SEQ_ERROR; current_block_239 = 11639917216603986996; @@ -1746,7 +1739,7 @@ unsafe extern "C" fn stream_decode_mt( } (*(*coder).thr).outbuf = lzma_outq_get_buf(&raw mut (*coder).outq, (*coder).thr as *mut c_void); - let mut mythread_i_1478: c_uint = 0 as c_uint; + let mut mythread_i_1478: c_uint = 0; while if mythread_i_1478 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); 0 as c_int @@ -1755,15 +1748,15 @@ unsafe extern "C" fn stream_decode_mt( 1 as c_int } != 0 { - let mut mythread_j_1478: c_uint = 0 as c_uint; + let mut mythread_j_1478: c_uint = 0; while mythread_j_1478 == 0 { (*(*coder).thr).state = THR_RUN; mythread_cond_signal(&raw mut (*(*coder).thr).cond); - mythread_j_1478 = 1 as c_uint; + mythread_j_1478 = 1; } - mythread_i_1478 = 1 as c_uint; + mythread_i_1478 = 1; } - let mut mythread_i_1486: c_uint = 0 as c_uint; + let mut mythread_i_1486: c_uint = 0; while if mythread_i_1486 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1772,7 +1765,7 @@ unsafe extern "C" fn stream_decode_mt( 1 as c_int } != 0 { - let mut mythread_j_1486: c_uint = 0 as c_uint; + let mut mythread_j_1486: c_uint = 0; while mythread_j_1486 == 0 { lzma_outq_enable_partial_output( &raw mut (*coder).outq, @@ -1781,9 +1774,9 @@ unsafe extern "C" fn stream_decode_mt( as unsafe extern "C" fn(*mut c_void) -> (), ), ); - mythread_j_1486 = 1 as c_uint; + mythread_j_1486 = 1; } - mythread_i_1486 = 1 as c_uint; + mythread_i_1486 = 1; } (*coder).sequence = SEQ_BLOCK_THR_RUN; current_block_239 = 7728257318064351663; @@ -1794,7 +1787,7 @@ unsafe extern "C" fn stream_decode_mt( } match current_block_239 { 7728257318064351663 => { - if action as c_uint == LZMA_FINISH as c_uint && (*coder).fail_fast as c_int != 0 { + if action == LZMA_FINISH && (*coder).fail_fast as c_int != 0 { let in_avail: size_t = in_size.wrapping_sub(*in_pos); let in_needed: size_t = (*(*coder).thr) .in_size @@ -1813,7 +1806,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut cur_in_filled, (*(*coder).thr).in_size, ); - let mut mythread_i_1517: c_uint = 0 as c_uint; + let mut mythread_i_1517: c_uint = 0; while if mythread_i_1517 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); 0 as c_int @@ -1822,13 +1815,13 @@ unsafe extern "C" fn stream_decode_mt( 1 as c_int } != 0 { - let mut mythread_j_1517: c_uint = 0 as c_uint; + let mut mythread_j_1517: c_uint = 0; while mythread_j_1517 == 0 { (*(*coder).thr).in_filled = cur_in_filled; mythread_cond_signal(&raw mut (*(*coder).thr).cond); - mythread_j_1517 = 1 as c_uint; + mythread_j_1517 = 1; } - mythread_i_1517 = 1 as c_uint; + mythread_i_1517 = 1; } let ret__2: lzma_ret = read_output_and_wait( coder, @@ -1841,10 +1834,10 @@ unsafe extern "C" fn stream_decode_mt( &raw mut wait_abs, &raw mut has_blocked, ) as lzma_ret; - if ret__2 as c_uint != LZMA_OK as c_uint { + if ret__2 != LZMA_OK { return ret__2; } - if (*coder).pending_error as c_uint != LZMA_OK as c_uint { + if (*coder).pending_error != LZMA_OK { (*coder).sequence = SEQ_ERROR; } else { if (*(*coder).thr).in_filled < (*(*coder).thr).in_size { @@ -1881,7 +1874,7 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( mut new_memlimit: u64, ) -> lzma_ret { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - let mut mythread_i_1829: c_uint = 0 as c_uint; + let mut mythread_i_1829: c_uint = 0; while if mythread_i_1829 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1890,16 +1883,16 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( 1 as c_int } != 0 { - let mut mythread_j_1829: c_uint = 0 as c_uint; + let mut mythread_j_1829: c_uint = 0; while mythread_j_1829 == 0 { *memusage = (*coder) .mem_direct_mode .wrapping_add((*coder).mem_in_use) .wrapping_add((*coder).mem_cached) .wrapping_add((*coder).outq.mem_allocated); - mythread_j_1829 = 1 as c_uint; + mythread_j_1829 = 1; } - mythread_i_1829 = 1 as c_uint; + mythread_i_1829 = 1; } if *memusage < LZMA_MEMUSAGE_BASE as u64 { *memusage = LZMA_MEMUSAGE_BASE as u64; @@ -1919,7 +1912,7 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( mut progress_out: *mut u64, ) { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - let mut mythread_i_1862: c_uint = 0 as c_uint; + let mut mythread_i_1862: c_uint = 0; while if mythread_i_1862 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1928,13 +1921,13 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( 1 as c_int } != 0 { - let mut mythread_j_1862: c_uint = 0 as c_uint; + let mut mythread_j_1862: c_uint = 0; while mythread_j_1862 == 0 { *progress_in = (*coder).progress_in; *progress_out = (*coder).progress_out; let mut i: size_t = 0 as size_t; while i < (*coder).threads_initialized as size_t { - let mut mythread_i_1867: c_uint = 0 as c_uint; + let mut mythread_i_1867: c_uint = 0; while if mythread_i_1867 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); 0 as c_int @@ -1943,7 +1936,7 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( 1 as c_int } != 0 { - let mut mythread_j_1867: c_uint = 0 as c_uint; + let mut mythread_j_1867: c_uint = 0; while mythread_j_1867 == 0 { *progress_in = (*progress_in).wrapping_add( (*(*coder).threads.offset(i as isize)).progress_in as u64, @@ -1951,15 +1944,15 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( *progress_out = (*progress_out).wrapping_add( (*(*coder).threads.offset(i as isize)).progress_out as u64, ); - mythread_j_1867 = 1 as c_uint; + mythread_j_1867 = 1; } - mythread_i_1867 = 1 as c_uint; + mythread_i_1867 = 1; } i = i.wrapping_add(1); } - mythread_j_1862 = 1 as c_uint; + mythread_j_1862 = 1; } - mythread_i_1862 = 1 as c_uint; + mythread_i_1862 = 1; } } unsafe extern "C" fn stream_decoder_mt_init( @@ -2060,7 +2053,7 @@ unsafe extern "C" fn stream_decoder_mt_init( as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> (), ) as Option ()>; - (*coder).filters[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; memset( &raw mut (*coder).outq as *mut c_void, 0 as c_int, @@ -2122,7 +2115,7 @@ unsafe extern "C" fn stream_decoder_mt_init( (*coder).threads_max = (*options).threads; let ret_: lzma_ret = lzma_outq_init(&raw mut (*coder).outq, allocator, (*coder).threads_max) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } return stream_decoder_reset(coder, allocator); @@ -2133,7 +2126,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_mt( mut options: *const lzma_mt, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = stream_decoder_mt_init( @@ -2141,7 +2134,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_mt( (*strm).allocator, options, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index fbeb492c..a65ec88c 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -249,7 +249,7 @@ pub struct lzma_stream_flags { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; @@ -261,7 +261,7 @@ unsafe extern "C" fn block_encoder_init( (*coder).block_options.compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).block_options.uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; let ret_: lzma_ret = lzma_block_header_size(&raw mut (*coder).block_options) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } return lzma_block_encoder_init( @@ -283,7 +283,7 @@ unsafe extern "C" fn stream_encode( ) -> lzma_ret { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; while *out_pos < out_size { - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 | 2 | 5 => { lzma_bufcpy( &raw mut (*coder).buffer as *mut u8, @@ -296,7 +296,7 @@ unsafe extern "C" fn stream_encode( if (*coder).buffer_pos < (*coder).buffer_size { return LZMA_OK; } - if (*coder).sequence as c_uint == SEQ_STREAM_FOOTER as c_uint { + if (*coder).sequence == SEQ_STREAM_FOOTER { return LZMA_STREAM_END; } (*coder).buffer_pos = 0 as size_t; @@ -304,8 +304,8 @@ unsafe extern "C" fn stream_encode( } 1 => { if *in_pos == in_size { - if action as c_uint != LZMA_FINISH as c_uint { - return (if action as c_uint == LZMA_RUN as c_uint { + if action != LZMA_FINISH { + return (if action == LZMA_RUN { LZMA_OK as c_int } else { LZMA_STREAM_END as c_int @@ -316,14 +316,14 @@ unsafe extern "C" fn stream_encode( allocator, (*coder).index, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } (*coder).sequence = SEQ_INDEX_ENCODE; } else { if !(*coder).block_encoder_is_initialized { let ret__0: lzma_ret = block_encoder_init(coder, allocator) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } } @@ -331,8 +331,7 @@ unsafe extern "C" fn stream_encode( if lzma_block_header_encode( &raw mut (*coder).block_options, &raw mut (*coder).buffer as *mut u8, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return LZMA_PROG_ERROR; } @@ -362,9 +361,7 @@ unsafe extern "C" fn stream_encode( out_size, convert[action as usize], ) as lzma_ret; - if ret as c_uint != LZMA_STREAM_END as c_uint - || action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + if ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH { return ret; } let unpadded_size: lzma_vli = @@ -375,7 +372,7 @@ unsafe extern "C" fn stream_encode( unpadded_size, (*coder).block_options.uncompressed_size, ) as lzma_ret; - if ret__1 as c_uint != LZMA_OK as c_uint { + if ret__1 != LZMA_OK { return ret__1; } (*coder).sequence = SEQ_BLOCK_INIT; @@ -395,7 +392,7 @@ unsafe extern "C" fn stream_encode( out_size, LZMA_RUN, ) as lzma_ret; - if ret_0 as c_uint != LZMA_STREAM_END as c_uint { + if ret_0 != LZMA_STREAM_END { return ret_0; } let stream_flags: lzma_stream_flags = lzma_stream_flags { @@ -420,8 +417,7 @@ unsafe extern "C" fn stream_encode( if lzma_stream_footer_encode( &raw const stream_flags, &raw mut (*coder).buffer as *mut u8, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return LZMA_PROG_ERROR; } @@ -459,21 +455,21 @@ unsafe extern "C" fn stream_encoder_update( }; 5]; let ret_: lzma_ret = lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } - if (*coder).sequence as c_uint <= SEQ_BLOCK_INIT as c_uint { + if (*coder).sequence <= SEQ_BLOCK_INIT { (*coder).block_encoder_is_initialized = false_0 != 0; (*coder).block_options.filters = &raw mut temp as *mut lzma_filter; ret = block_encoder_init(coder, allocator); (*coder).block_options.filters = &raw mut (*coder).filters as *mut lzma_filter; - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { current_block = 9913398440939854562; } else { (*coder).block_encoder_is_initialized = true_0 != 0; current_block = 8236137900636309791; } - } else if (*coder).sequence as c_uint <= SEQ_BLOCK_ENCODE as c_uint { + } else if (*coder).sequence <= SEQ_BLOCK_ENCODE { ret = (*coder) .block_encoder .update @@ -483,7 +479,7 @@ unsafe extern "C" fn stream_encoder_update( filters, reversed_filters, ); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { current_block = 9913398440939854562; } else { current_block = 8236137900636309791; @@ -602,7 +598,7 @@ unsafe extern "C" fn stream_encoder_init( *const lzma_filter, ) -> lzma_ret, >; - (*coder).filters[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).block_encoder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, @@ -659,7 +655,7 @@ unsafe extern "C" fn stream_encoder_init( let ret_: lzma_ret = lzma_stream_header_encode(&raw mut stream_flags, &raw mut (*coder).buffer as *mut u8) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } (*coder).buffer_pos = 0 as size_t; @@ -678,7 +674,7 @@ pub unsafe extern "C" fn lzma_stream_encoder( mut check: lzma_check, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = stream_encoder_init( @@ -687,7 +683,7 @@ pub unsafe extern "C" fn lzma_stream_encoder( filters, check, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 7af08dee..6946de5a 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -522,7 +522,7 @@ pub struct lzma_options_easy { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const SIG_SETMASK: c_int = 3 as c_int; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; @@ -640,10 +640,10 @@ unsafe extern "C" fn mythread_condtime_set( } } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = (1 as c_ulonglong) << 15 as c_int; +pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; #[inline] unsafe extern "C" fn lzma_outq_has_buf(mut outq: *const lzma_outq) -> bool { return (*outq).bufs_in_use < (*outq).bufs_limit; @@ -652,9 +652,9 @@ unsafe extern "C" fn lzma_outq_has_buf(mut outq: *const lzma_outq) -> bool { unsafe extern "C" fn lzma_outq_is_empty(mut outq: *const lzma_outq) -> bool { return (*outq).bufs_in_use == 0 as u32; } -pub const BLOCK_SIZE_MAX: c_ulonglong = UINT64_MAX.wrapping_div(LZMA_THREADS_MAX as c_ulonglong); +pub const BLOCK_SIZE_MAX: c_ulonglong = UINT64_MAX.wrapping_div(LZMA_THREADS_MAX as u64); unsafe extern "C" fn worker_error(mut thr: *mut worker_thread, mut ret: lzma_ret) { - let mut mythread_i_207: c_uint = 0 as c_uint; + let mut mythread_i_207: c_uint = 0; while if mythread_i_207 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); 0 as c_int @@ -663,15 +663,15 @@ unsafe extern "C" fn worker_error(mut thr: *mut worker_thread, mut ret: lzma_ret 1 as c_int } != 0 { - let mut mythread_j_207: c_uint = 0 as c_uint; + let mut mythread_j_207: c_uint = 0; while mythread_j_207 == 0 { - if (*(*thr).coder).thread_error as c_uint == LZMA_OK as c_uint { + if (*(*thr).coder).thread_error == LZMA_OK { (*(*thr).coder).thread_error = ret; } mythread_cond_signal(&raw mut (*(*thr).coder).cond); - mythread_j_207 = 1 as c_uint; + mythread_j_207 = 1; } - mythread_i_207 = 1 as c_uint; + mythread_i_207 = 1; } } unsafe extern "C" fn worker_encode( @@ -712,7 +712,7 @@ unsafe extern "C" fn worker_encode( reserved_bool8: 0, }; let mut ret: lzma_ret = lzma_block_header_size(&raw mut (*thr).block_options); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { worker_error(thr, ret); return THR_STOP; } @@ -721,7 +721,7 @@ unsafe extern "C" fn worker_encode( (*thr).allocator, &raw mut (*thr).block_options, ); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { worker_error(thr, ret); return THR_STOP; } @@ -730,7 +730,7 @@ unsafe extern "C" fn worker_encode( *out_pos = (*thr).block_options.header_size as size_t; let out_size: size_t = (*(*thr).outbuf).allocated; loop { - let mut mythread_i_258: c_uint = 0 as c_uint; + let mut mythread_i_258: c_uint = 0; while if mythread_i_258 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); 0 as c_int @@ -739,23 +739,23 @@ unsafe extern "C" fn worker_encode( 1 as c_int } != 0 { - let mut mythread_j_258: c_uint = 0 as c_uint; + let mut mythread_j_258: c_uint = 0; while mythread_j_258 == 0 { (*thr).progress_in = in_pos as u64; (*thr).progress_out = *out_pos as u64; - while in_size == (*thr).in_size && (*thr).state as c_uint == THR_RUN as c_uint { + while in_size == (*thr).in_size && (*thr).state == THR_RUN { mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); } state = (*thr).state; in_size = (*thr).in_size; - mythread_j_258 = 1 as c_uint; + mythread_j_258 = 1; } - mythread_i_258 = 1 as c_uint; + mythread_i_258 = 1; } - if state as c_uint >= THR_STOP as c_uint { + if state >= THR_STOP { return state; } - let mut action: lzma_action = (if state as c_uint == THR_FINISH as c_uint { + let mut action: lzma_action = (if state == THR_FINISH { LZMA_FINISH as c_int } else { LZMA_RUN as c_int @@ -780,23 +780,23 @@ unsafe extern "C" fn worker_encode( out_size, action, ); - if !(ret as c_uint == LZMA_OK as c_uint && *out_pos < out_size) { + if !(ret == LZMA_OK && *out_pos < out_size) { break; } } - match ret as c_uint { + match ret { 1 => { ret = lzma_block_header_encode( &raw mut (*thr).block_options, &raw mut (*(*thr).outbuf).buf as *mut u8, ); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { worker_error(thr, ret); return THR_STOP; } } 0 => { - let mut mythread_i_321: c_uint = 0 as c_uint; + let mut mythread_i_321: c_uint = 0; while if mythread_i_321 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); 0 as c_int @@ -805,18 +805,18 @@ unsafe extern "C" fn worker_encode( 1 as c_int } != 0 { - let mut mythread_j_321: c_uint = 0 as c_uint; + let mut mythread_j_321: c_uint = 0; while mythread_j_321 == 0 { - while (*thr).state as c_uint == THR_RUN as c_uint { + while (*thr).state == THR_RUN { mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); } state = (*thr).state; in_size = (*thr).in_size; - mythread_j_321 = 1 as c_uint; + mythread_j_321 = 1; } - mythread_i_321 = 1 as c_uint; + mythread_i_321 = 1; } - if state as c_uint >= THR_STOP as c_uint { + if state >= THR_STOP { return state; } *out_pos = 0 as size_t; @@ -828,7 +828,7 @@ unsafe extern "C" fn worker_encode( out_pos, out_size, ); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { worker_error(thr, LZMA_PROG_ERROR); return THR_STOP; } @@ -846,7 +846,7 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { let mut thr: *mut worker_thread = thr_ptr as *mut worker_thread; let mut state: worker_state = THR_IDLE; loop { - let mut mythread_i_370: c_uint = 0 as c_uint; + let mut mythread_i_370: c_uint = 0; while if mythread_i_370 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); 0 as c_int @@ -855,31 +855,31 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { 1 as c_int } != 0 { - let mut mythread_j_370: c_uint = 0 as c_uint; + let mut mythread_j_370: c_uint = 0; while mythread_j_370 == 0 { loop { - if (*thr).state as c_uint == THR_STOP as c_uint { + if (*thr).state == THR_STOP { (*thr).state = THR_IDLE; mythread_cond_signal(&raw mut (*thr).cond); } state = (*thr).state; - if state as c_uint != THR_IDLE as c_uint { + if state != THR_IDLE { break; } mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); } - mythread_j_370 = 1 as c_uint; + mythread_j_370 = 1; } - mythread_i_370 = 1 as c_uint; + mythread_i_370 = 1; } let mut out_pos: size_t = 0 as size_t; - if state as c_uint <= THR_FINISH as c_uint { + if state <= THR_FINISH { state = worker_encode(thr, &raw mut out_pos, state); } - if state as c_uint == THR_EXIT as c_uint { + if state == THR_EXIT { break; } - let mut mythread_i_401: c_uint = 0 as c_uint; + let mut mythread_i_401: c_uint = 0; while if mythread_i_401 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); 0 as c_int @@ -888,17 +888,17 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { 1 as c_int } != 0 { - let mut mythread_j_401: c_uint = 0 as c_uint; + let mut mythread_j_401: c_uint = 0; while mythread_j_401 == 0 { - if (*thr).state as c_uint != THR_EXIT as c_uint { + if (*thr).state != THR_EXIT { (*thr).state = THR_IDLE; mythread_cond_signal(&raw mut (*thr).cond); } - mythread_j_401 = 1 as c_uint; + mythread_j_401 = 1; } - mythread_i_401 = 1 as c_uint; + mythread_i_401 = 1; } - let mut mythread_i_408: c_uint = 0 as c_uint; + let mut mythread_i_408: c_uint = 0; while if mythread_i_408 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); 0 as c_int @@ -907,9 +907,9 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { 1 as c_int } != 0 { - let mut mythread_j_408: c_uint = 0 as c_uint; + let mut mythread_j_408: c_uint = 0; while mythread_j_408 == 0 { - if state as c_uint == THR_FINISH as c_uint { + if state == THR_FINISH { (*(*thr).outbuf).pos = out_pos; (*(*thr).outbuf).finished = true_0 != 0; } @@ -923,9 +923,9 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { (*thr).next = (*(*thr).coder).threads_free; (*(*thr).coder).threads_free = thr; mythread_cond_signal(&raw mut (*(*thr).coder).cond); - mythread_j_408 = 1 as c_uint; + mythread_j_408 = 1; } - mythread_i_408 = 1 as c_uint; + mythread_i_408 = 1; } } lzma_filters_free( @@ -941,7 +941,7 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder, mut wait_for_threads: bool) { let mut i: u32 = 0 as u32; while i < (*coder).threads_initialized { - let mut mythread_i_449: c_uint = 0 as c_uint; + let mut mythread_i_449: c_uint = 0; while if mythread_i_449 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); 0 as c_int @@ -950,13 +950,13 @@ unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder, mut wait_fo 1 as c_int } != 0 { - let mut mythread_j_449: c_uint = 0 as c_uint; + let mut mythread_j_449: c_uint = 0; while mythread_j_449 == 0 { (*(*coder).threads.offset(i as isize)).state = THR_STOP; mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); - mythread_j_449 = 1 as c_uint; + mythread_j_449 = 1; } - mythread_i_449 = 1 as c_uint; + mythread_i_449 = 1; } i = i.wrapping_add(1); } @@ -965,7 +965,7 @@ unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder, mut wait_fo } let mut i_0: u32 = 0 as u32; while i_0 < (*coder).threads_initialized { - let mut mythread_i_460: c_uint = 0 as c_uint; + let mut mythread_i_460: c_uint = 0; while if mythread_i_460 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i_0 as isize)).mutex); 0 as c_int @@ -974,18 +974,17 @@ unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder, mut wait_fo 1 as c_int } != 0 { - let mut mythread_j_460: c_uint = 0 as c_uint; + let mut mythread_j_460: c_uint = 0; while mythread_j_460 == 0 { - while (*(*coder).threads.offset(i_0 as isize)).state as c_uint != THR_IDLE as c_uint - { + while (*(*coder).threads.offset(i_0 as isize)).state != THR_IDLE { mythread_cond_wait( &raw mut (*(*coder).threads.offset(i_0 as isize)).cond, &raw mut (*(*coder).threads.offset(i_0 as isize)).mutex, ); } - mythread_j_460 = 1 as c_uint; + mythread_j_460 = 1; } - mythread_i_460 = 1 as c_uint; + mythread_i_460 = 1; } i_0 = i_0.wrapping_add(1); } @@ -996,7 +995,7 @@ unsafe extern "C" fn threads_end( ) { let mut i: u32 = 0 as u32; while i < (*coder).threads_initialized { - let mut mythread_i_477: c_uint = 0 as c_uint; + let mut mythread_i_477: c_uint = 0; while if mythread_i_477 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); 0 as c_int @@ -1005,13 +1004,13 @@ unsafe extern "C" fn threads_end( 1 as c_int } != 0 { - let mut mythread_j_477: c_uint = 0 as c_uint; + let mut mythread_j_477: c_uint = 0; while mythread_j_477 == 0 { (*(*coder).threads.offset(i as isize)).state = THR_EXIT; mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); - mythread_j_477 = 1 as c_uint; + mythread_j_477 = 1; } - mythread_i_477 = 1 as c_uint; + mythread_i_477 = 1; } i = i.wrapping_add(1); } @@ -1053,7 +1052,7 @@ unsafe extern "C" fn initialize_new_thread( update: None, set_out_limit: None, }; - (*thr).filters[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*thr).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; if mythread_create( &raw mut (*thr).thread_id, Some(worker_start as unsafe extern "C" fn(*mut c_void) -> *mut c_void), @@ -1084,20 +1083,20 @@ unsafe extern "C" fn get_thread( allocator, (*coder).outbuf_alloc_size, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } - if (*coder).filters_cache[0 as usize].id == LZMA_VLI_UNKNOWN as lzma_vli { + if (*coder).filters_cache[0].id == LZMA_VLI_UNKNOWN as lzma_vli { let ret__0: lzma_ret = lzma_filters_copy( &raw mut (*coder).filters as *mut lzma_filter, &raw mut (*coder).filters_cache as *mut lzma_filter, allocator, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } } - let mut mythread_i_560: c_uint = 0 as c_uint; + let mut mythread_i_560: c_uint = 0; while if mythread_i_560 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1106,26 +1105,26 @@ unsafe extern "C" fn get_thread( 1 as c_int } != 0 { - let mut mythread_j_560: c_uint = 0 as c_uint; + let mut mythread_j_560: c_uint = 0; while mythread_j_560 == 0 { if !(*coder).threads_free.is_null() { (*coder).thr = (*coder).threads_free; (*coder).threads_free = (*(*coder).threads_free).next; } - mythread_j_560 = 1 as c_uint; + mythread_j_560 = 1; } - mythread_i_560 = 1 as c_uint; + mythread_i_560 = 1; } if (*coder).thr.is_null() { if (*coder).threads_initialized == (*coder).threads_max { return LZMA_OK; } let ret__1: lzma_ret = initialize_new_thread(coder, allocator) as lzma_ret; - if ret__1 as c_uint != LZMA_OK as c_uint { + if ret__1 != LZMA_OK { return ret__1; } } - let mut mythread_i_578: c_uint = 0 as c_uint; + let mut mythread_i_578: c_uint = 0; while if mythread_i_578 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); 0 as c_int @@ -1134,7 +1133,7 @@ unsafe extern "C" fn get_thread( 1 as c_int } != 0 { - let mut mythread_j_578: c_uint = 0 as c_uint; + let mut mythread_j_578: c_uint = 0; while mythread_j_578 == 0 { (*(*coder).thr).state = THR_RUN; (*(*coder).thr).in_size = 0 as size_t; @@ -1148,11 +1147,11 @@ unsafe extern "C" fn get_thread( &raw mut (*coder).filters_cache as *mut lzma_filter as *const c_void, ::core::mem::size_of::<[lzma_filter; 5]>() as size_t, ); - (*coder).filters_cache[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN as lzma_vli; mythread_cond_signal(&raw mut (*(*coder).thr).cond); - mythread_j_578 = 1 as c_uint; + mythread_j_578 = 1; } - mythread_i_578 = 1 as c_uint; + mythread_i_578 = 1; } return LZMA_OK; } @@ -1164,7 +1163,7 @@ unsafe extern "C" fn stream_encode_in( mut in_size: size_t, mut action: lzma_action, ) -> lzma_ret { - while *in_pos < in_size || !(*coder).thr.is_null() && action as c_uint != LZMA_RUN as c_uint { + while *in_pos < in_size || !(*coder).thr.is_null() && action != LZMA_RUN { if (*coder).thr.is_null() { let ret: lzma_ret = get_thread(coder, allocator) as lzma_ret; if (*coder).thr.is_null() { @@ -1180,10 +1179,10 @@ unsafe extern "C" fn stream_encode_in( &raw mut thr_in_size, (*coder).block_size, ); - let finish: bool = thr_in_size == (*coder).block_size - || *in_pos == in_size && action as c_uint != LZMA_RUN as c_uint; + let finish: bool = + thr_in_size == (*coder).block_size || *in_pos == in_size && action != LZMA_RUN; let mut block_error: bool = false_0 != 0; - let mut mythread_i_628: c_uint = 0 as c_uint; + let mut mythread_i_628: c_uint = 0; while if mythread_i_628 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); 0 as c_int @@ -1192,9 +1191,9 @@ unsafe extern "C" fn stream_encode_in( 1 as c_int } != 0 { - let mut mythread_j_628: c_uint = 0 as c_uint; + let mut mythread_j_628: c_uint = 0; while mythread_j_628 == 0 { - if (*(*coder).thr).state as c_uint == THR_IDLE as c_uint { + if (*(*coder).thr).state == THR_IDLE { block_error = true_0 != 0; } else { (*(*coder).thr).in_size = thr_in_size; @@ -1203,13 +1202,13 @@ unsafe extern "C" fn stream_encode_in( } mythread_cond_signal(&raw mut (*(*coder).thr).cond); } - mythread_j_628 = 1 as c_uint; + mythread_j_628 = 1; } - mythread_i_628 = 1 as c_uint; + mythread_i_628 = 1; } if block_error { let mut ret_0: lzma_ret = LZMA_OK; - let mut mythread_i_649: c_uint = 0 as c_uint; + let mut mythread_i_649: c_uint = 0; while if mythread_i_649 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1218,12 +1217,12 @@ unsafe extern "C" fn stream_encode_in( 1 as c_int } != 0 { - let mut mythread_j_649: c_uint = 0 as c_uint; + let mut mythread_j_649: c_uint = 0; while mythread_j_649 == 0 { ret_0 = (*coder).thread_error; - mythread_j_649 = 1 as c_uint; + mythread_j_649 = 1; } - mythread_i_649 = 1 as c_uint; + mythread_i_649 = 1; } return ret_0; } @@ -1244,7 +1243,7 @@ unsafe extern "C" fn wait_for_work( mythread_condtime_set(wait_abs, &raw mut (*coder).cond, (*coder).timeout); } let mut timed_out: bool = false_0 != 0; - let mut mythread_i_689: c_uint = 0 as c_uint; + let mut mythread_i_689: c_uint = 0; while if mythread_i_689 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1253,13 +1252,13 @@ unsafe extern "C" fn wait_for_work( 1 as c_int } != 0 { - let mut mythread_j_689: c_uint = 0 as c_uint; + let mut mythread_j_689: c_uint = 0; while mythread_j_689 == 0 { while (!has_input || (*coder).threads_free.is_null() || !lzma_outq_has_buf(&raw mut (*coder).outq)) && !lzma_outq_is_readable(&raw mut (*coder).outq) - && (*coder).thread_error as c_uint == LZMA_OK as c_uint + && (*coder).thread_error == LZMA_OK && !timed_out { if (*coder).timeout != 0 as u32 { @@ -1272,9 +1271,9 @@ unsafe extern "C" fn wait_for_work( mythread_cond_wait(&raw mut (*coder).cond, &raw mut (*coder).mutex); } } - mythread_j_689 = 1 as c_uint; + mythread_j_689 = 1; } - mythread_i_689 = 1 as c_uint; + mythread_i_689 = 1; } return timed_out; } @@ -1292,7 +1291,7 @@ unsafe extern "C" fn stream_encode_mt( let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; 's_270: { let mut current_block_53: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { lzma_bufcpy( &raw mut (*coder).header as *mut u8, @@ -1333,7 +1332,7 @@ unsafe extern "C" fn stream_encode_mt( tv_nsec: 0, }; loop { - let mut mythread_i_747: c_uint = 0 as c_uint; + let mut mythread_i_747: c_uint = 0; while if mythread_i_747 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1342,10 +1341,10 @@ unsafe extern "C" fn stream_encode_mt( 1 as c_int } != 0 { - let mut mythread_j_747: c_uint = 0 as c_uint; + let mut mythread_j_747: c_uint = 0; while mythread_j_747 == 0 { ret = (*coder).thread_error; - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { break; } ret = lzma_outq_read( @@ -1357,18 +1356,18 @@ unsafe extern "C" fn stream_encode_mt( &raw mut unpadded_size, &raw mut uncompressed_size, ); - mythread_j_747 = 1 as c_uint; + mythread_j_747 = 1; } - mythread_i_747 = 1 as c_uint; + mythread_i_747 = 1; } - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = lzma_index_append( (*coder).index, allocator, unpadded_size, uncompressed_size, ); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { threads_stop(coder, false_0 != 0); return ret; } @@ -1376,27 +1375,27 @@ unsafe extern "C" fn stream_encode_mt( continue; } } - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { threads_stop(coder, false_0 != 0); return ret; } ret = stream_encode_in(coder, allocator, in_0, in_pos, in_size, action); - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { threads_stop(coder, false_0 != 0); return ret; } if *in_pos == in_size { - if action as c_uint == LZMA_RUN as c_uint { + if action == LZMA_RUN { return LZMA_OK; } - if action as c_uint == LZMA_FULL_BARRIER as c_uint { + if action == LZMA_FULL_BARRIER { return LZMA_STREAM_END; } if lzma_outq_is_empty(&raw mut (*coder).outq) { - if action as c_uint == LZMA_FINISH as c_uint { + if action == LZMA_FINISH { break; } - if action as c_uint == LZMA_FULL_FLUSH as c_uint { + if action == LZMA_FULL_FLUSH { return LZMA_STREAM_END; } } @@ -1418,7 +1417,7 @@ unsafe extern "C" fn stream_encode_mt( allocator, (*coder).index, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } (*coder).sequence = SEQ_INDEX; @@ -1447,15 +1446,14 @@ unsafe extern "C" fn stream_encode_mt( out_size, LZMA_RUN, ) as lzma_ret; - if ret_0 as c_uint != LZMA_STREAM_END as c_uint { + if ret_0 != LZMA_STREAM_END { return ret_0; } (*coder).stream_flags.backward_size = lzma_index_size((*coder).index); if lzma_stream_footer_encode( &raw mut (*coder).stream_flags, &raw mut (*coder).header as *mut u8, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return LZMA_PROG_ERROR; } @@ -1504,7 +1502,7 @@ unsafe extern "C" fn stream_encoder_mt_update( mut reversed_filters: *const lzma_filter, ) -> lzma_ret { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - if (*coder).sequence as c_uint > SEQ_BLOCK as c_uint { + if (*coder).sequence > SEQ_BLOCK { return LZMA_PROG_ERROR; } if !(*coder).thr.is_null() { @@ -1519,7 +1517,7 @@ unsafe extern "C" fn stream_encoder_mt_update( }; 5]; let ret_: lzma_ret = lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); @@ -1578,7 +1576,7 @@ unsafe extern "C" fn get_progress( mut progress_out: *mut u64, ) { let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - let mut mythread_i_1010: c_uint = 0 as c_uint; + let mut mythread_i_1010: c_uint = 0; while if mythread_i_1010 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); 0 as c_int @@ -1587,13 +1585,13 @@ unsafe extern "C" fn get_progress( 1 as c_int } != 0 { - let mut mythread_j_1010: c_uint = 0 as c_uint; + let mut mythread_j_1010: c_uint = 0; while mythread_j_1010 == 0 { *progress_in = (*coder).progress_in; *progress_out = (*coder).progress_out; let mut i: size_t = 0 as size_t; while i < (*coder).threads_initialized as size_t { - let mut mythread_i_1015: c_uint = 0 as c_uint; + let mut mythread_i_1015: c_uint = 0; while if mythread_i_1015 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); 0 as c_int @@ -1602,21 +1600,21 @@ unsafe extern "C" fn get_progress( 1 as c_int } != 0 { - let mut mythread_j_1015: c_uint = 0 as c_uint; + let mut mythread_j_1015: c_uint = 0; while mythread_j_1015 == 0 { *progress_in = (*progress_in) .wrapping_add((*(*coder).threads.offset(i as isize)).progress_in); *progress_out = (*progress_out) .wrapping_add((*(*coder).threads.offset(i as isize)).progress_out); - mythread_j_1015 = 1 as c_uint; + mythread_j_1015 = 1; } - mythread_i_1015 = 1 as c_uint; + mythread_i_1015 = 1; } i = i.wrapping_add(1); } - mythread_j_1010 = 1 as c_uint; + mythread_j_1010 = 1; } - mythread_i_1010 = 1 as c_uint; + mythread_i_1010 = 1; } } unsafe extern "C" fn stream_encoder_mt_init( @@ -1703,13 +1701,13 @@ unsafe extern "C" fn stream_encoder_mt_init( &raw mut block_size, &raw mut outbuf_size_max, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } if lzma_raw_encoder_memusage(filters) == UINT64_MAX as u64 { return LZMA_OPTIONS_ERROR; } - if (*options).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { + if (*options).check > LZMA_CHECK_ID_MAX { return LZMA_PROG_ERROR; } if lzma_check_is_supported((*options).check) == 0 { @@ -1773,8 +1771,8 @@ unsafe extern "C" fn stream_encoder_mt_init( *const lzma_filter, ) -> lzma_ret, >; - (*coder).filters[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; - (*coder).filters_cache[0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).index_encoder = lzma_next_coder_s { coder: NULL, id: LZMA_VLI_UNKNOWN as lzma_vli, @@ -1822,7 +1820,7 @@ unsafe extern "C" fn stream_encoder_mt_init( } let ret__0: lzma_ret = lzma_outq_init(&raw mut (*coder).outq, allocator, (*options).threads) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { return ret__0; } (*coder).timeout = (*options).timeout; @@ -1836,7 +1834,7 @@ unsafe extern "C" fn stream_encoder_mt_init( &raw mut (*coder).filters as *mut lzma_filter, allocator, ) as lzma_ret; - if ret__1 as c_uint != LZMA_OK as c_uint { + if ret__1 != LZMA_OK { return ret__1; } lzma_index_end((*coder).index, allocator); @@ -1850,7 +1848,7 @@ unsafe extern "C" fn stream_encoder_mt_init( &raw mut (*coder).stream_flags, &raw mut (*coder).header as *mut u8, ) as lzma_ret; - if ret__2 as c_uint != LZMA_OK as c_uint { + if ret__2 != LZMA_OK { return ret__2; } (*coder).header_pos = 0 as size_t; @@ -1864,7 +1862,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( mut options: *const lzma_mt, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = stream_encoder_mt_init( @@ -1872,7 +1870,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( (*strm).allocator, options, ) as lzma_ret; - if ret__0 as c_uint != LZMA_OK as c_uint { + if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; } @@ -1925,8 +1923,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(mut options: *const lzm &raw mut filters, &raw mut block_size, &raw mut outbuf_size_max, - ) as c_uint - != LZMA_OK as c_uint + ) != LZMA_OK { return UINT64_MAX as u64; } diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index f1157fea..432493b4 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -47,11 +47,11 @@ pub struct lzma_stream_flags { pub reserved_int1: u32, pub reserved_int2: u32, } -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4 as c_int; -pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = (1 as c_ulonglong) << 34 as c_int; +pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; #[inline] unsafe extern "C" fn is_backward_size_valid(mut options: *const lzma_stream_flags) -> bool { return (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli @@ -72,12 +72,10 @@ pub unsafe extern "C" fn lzma_stream_flags_compare( if (*a).version != 0 as u32 || (*b).version != 0 as u32 { return LZMA_OPTIONS_ERROR; } - if (*a).check as c_uint > LZMA_CHECK_ID_MAX as c_uint - || (*b).check as c_uint > LZMA_CHECK_ID_MAX as c_uint - { + if (*a).check > LZMA_CHECK_ID_MAX || (*b).check > LZMA_CHECK_ID_MAX { return LZMA_PROG_ERROR; } - if (*a).check as c_uint != (*b).check as c_uint { + if (*a).check != (*b).check { return LZMA_DATA_ERROR; } if (*a).backward_size != LZMA_VLI_UNKNOWN as lzma_vli diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 6d360bed..4974d74a 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -53,15 +53,15 @@ pub struct lzma_stream_flags { pub reserved_int1: u32, pub reserved_int2: u32, } -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0 as isize) as u32; - num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; - num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; - num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; return num; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; @@ -70,13 +70,11 @@ unsafe extern "C" fn stream_flags_decode( mut options: *mut lzma_stream_flags, mut in_0: *const u8, ) -> bool { - if *in_0.offset(0 as isize) as c_int != 0 as c_int - || *in_0.offset(1 as isize) as c_int & 0xf0 as c_int != 0 - { + if *in_0.offset(0) as c_int != 0 as c_int || *in_0.offset(1) as c_int & 0xf0 as c_int != 0 { return true_0 != 0; } (*options).version = 0 as u32; - (*options).check = (*in_0.offset(1 as isize) as c_int & 0xf as c_int) as lzma_check; + (*options).check = (*in_0.offset(1) as c_int & 0xf as c_int) as lzma_check; return false_0 != 0; } #[no_mangle] diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 1cb08f01..935581bb 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -57,14 +57,14 @@ pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0 as isize) = num as u8; - *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; - *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; - *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; } -pub const LZMA_CHECK_ID_MAX: c_int = 15 as c_int; +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4 as c_int; -pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = (1 as c_ulonglong) << 34 as c_int; +pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2 as c_int; #[inline] unsafe extern "C" fn is_backward_size_valid(mut options: *const lzma_stream_flags) -> bool { @@ -76,11 +76,11 @@ unsafe extern "C" fn stream_flags_encode( mut options: *const lzma_stream_flags, mut out: *mut u8, ) -> bool { - if (*options).check as c_uint > LZMA_CHECK_ID_MAX as c_uint { + if (*options).check > LZMA_CHECK_ID_MAX { return true_0 != 0; } - *out.offset(0 as isize) = 0 as u8; - *out.offset(1 as isize) = (*options).check as u8; + *out.offset(0) = 0 as u8; + *out.offset(1) = (*options).check as u8; return false_0 != 0; } #[no_mangle] @@ -126,23 +126,23 @@ pub unsafe extern "C" fn lzma_stream_footer_encode( return LZMA_PROG_ERROR; } write32le( - out.offset(4 as isize), + out.offset(4), (*options) .backward_size .wrapping_div(4 as lzma_vli) .wrapping_sub(1 as lzma_vli) as u32, ); - if stream_flags_encode(options, out.offset((2 as c_int * 4 as c_int) as isize)) { + if stream_flags_encode(options, out.offset((2 as c_int * 4) as isize)) { return LZMA_PROG_ERROR; } let crc: u32 = lzma_crc32( - out.offset(4 as isize), + out.offset(4), (4 as c_int + LZMA_STREAM_FLAGS_SIZE) as size_t, 0 as u32, ) as u32; write32le(out, crc); memcpy( - out.offset((2 as c_int * 4 as c_int) as isize) + out.offset((2 as c_int * 4) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut c_void, &raw const lzma_footer_magic as *const u8 as *const c_void, ::core::mem::size_of::<[u8; 2]>() as size_t, diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index aa0d5aac..d6886fba 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -153,41 +153,41 @@ pub type C2RustUnnamed_2 = c_uint; pub const OPTMAP_TYPE_UINT32: C2RustUnnamed_2 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT32_MAX: c_uint = 4294967295; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const INT_MAX: c_int = 2147483647 as c_int; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; -pub const LZMA_STR_ALL_FILTERS: c_uint = 0x1 as c_uint; -pub const LZMA_STR_NO_VALIDATION: c_uint = 0x2 as c_uint; -pub const LZMA_STR_ENCODER: c_uint = 0x10 as c_uint; -pub const LZMA_STR_DECODER: c_uint = 0x20 as c_uint; -pub const LZMA_STR_GETOPT_LONG: c_uint = 0x40 as c_uint; -pub const LZMA_STR_NO_SPACES: c_uint = 0x80 as c_uint; -pub const LZMA_FILTER_X86: c_ulonglong = 0x4 as c_ulonglong; -pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5 as c_ulonglong; -pub const LZMA_FILTER_IA64: c_ulonglong = 0x6 as c_ulonglong; -pub const LZMA_FILTER_ARM: c_ulonglong = 0x7 as c_ulonglong; -pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8 as c_ulonglong; -pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9 as c_ulonglong; -pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa as c_ulonglong; -pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb as c_ulonglong; -pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3 as c_ulonglong; +pub const LZMA_STR_ALL_FILTERS: c_uint = 0x1; +pub const LZMA_STR_NO_VALIDATION: c_uint = 0x2; +pub const LZMA_STR_ENCODER: c_uint = 0x10; +pub const LZMA_STR_DECODER: c_uint = 0x20; +pub const LZMA_STR_GETOPT_LONG: c_uint = 0x40; +pub const LZMA_STR_NO_SPACES: c_uint = 0x80; +pub const LZMA_FILTER_X86: c_ulonglong = 0x4; +pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; +pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; +pub const LZMA_FILTER_ARM: c_ulonglong = 0x7; +pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8; +pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; +pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; +pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; +pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21 as c_ulonglong; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; -pub const LZMA_DICT_SIZE_DEFAULT: c_uint = (1 as c_uint) << 23 as c_int; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; +pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; +pub const LZMA_DICT_SIZE_DEFAULT: c_uint = 1u32 << 23; pub const LZMA_LCLP_MIN: c_int = 0 as c_int; pub const LZMA_LCLP_MAX: c_int = 4 as c_int; pub const LZMA_PB_MIN: c_int = 0 as c_int; pub const LZMA_PB_MAX: c_int = 4 as c_int; -pub const LZMA_PRESET_DEFAULT: c_uint = 6 as c_uint; -pub const LZMA_PRESET_EXTREME: c_uint = (1 as c_uint) << 31 as c_int; -pub const LZMA_FILTER_RESERVED_START: c_ulonglong = (1 as c_ulonglong) << 62 as c_int; +pub const LZMA_PRESET_DEFAULT: c_uint = 6; +pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; +pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; pub const STR_ALLOC_SIZE: c_int = 800 as c_int; unsafe extern "C" fn str_init( mut str: *mut lzma_str, @@ -357,7 +357,7 @@ unsafe extern "C" fn parse_lzma12_preset( } match **str as c_int { 101 => { - *preset = (*preset as c_uint | LZMA_PRESET_EXTREME) as u32; + *preset = (*preset | LZMA_PRESET_EXTREME) as u32; } _ => { return b"Unsupported flag in the preset\0" as *const u8 as *const c_char; @@ -695,7 +695,7 @@ unsafe extern "C" fn parse_options( } i = i.wrapping_add(1); } - *str = equals_sign.offset(1 as isize); + *str = equals_sign.offset(1); let value_len: size_t = name_eq_value_end.offset_from(*str) as c_long as size_t; if value_len == 0 as size_t { return b"Option value cannot be empty\0" as *const u8 as *const c_char; @@ -715,7 +715,7 @@ unsafe extern "C" fn parse_options( let mut map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0 as size_t; loop { - if (*map.offset(j as isize)).name[0 as usize] as c_int == '\0' as i32 { + if (*map.offset(j as isize)).name[0] as c_int == '\0' as i32 { return b"Invalid option value\0" as *const u8 as *const c_char; } if memcmp( @@ -840,7 +840,7 @@ unsafe extern "C" fn parse_filter( while p < str_end { if *p as c_int == ':' as i32 || *p as c_int == '=' as i32 { name_end = p; - opts_start = p.offset(1 as isize); + opts_start = p.offset(1); break; } else { p = p.offset(1); @@ -908,8 +908,8 @@ unsafe extern "C" fn str_to_filters( } if **str as c_int >= '0' as i32 && **str as c_int <= '9' as i32 || **str as c_int == '-' as i32 - && (*(*str).offset(1 as isize) as c_int >= '0' as i32 - && *(*str).offset(1 as isize) as c_int <= '9' as i32) + && (*(*str).offset(1) as c_int >= '0' as i32 + && *(*str).offset(1) as c_int <= '9' as i32) { if **str as c_int == '-' as i32 { *str = (*str).offset(1); @@ -944,11 +944,11 @@ unsafe extern "C" fn str_to_filters( lzma_free(opts as *mut c_void, allocator); return b"Unsupported preset\0" as *const u8 as *const c_char; } - (*filters.offset(0 as isize)).id = LZMA_FILTER_LZMA2 as lzma_vli; - let ref mut fresh0 = (*filters.offset(0 as isize)).options; + (*filters.offset(0)).id = LZMA_FILTER_LZMA2 as lzma_vli; + let ref mut fresh0 = (*filters.offset(0)).options; *fresh0 = opts as *mut c_void; - (*filters.offset(1 as isize)).id = LZMA_VLI_UNKNOWN as lzma_vli; - let ref mut fresh1 = (*filters.offset(1 as isize)).options; + (*filters.offset(1)).id = LZMA_VLI_UNKNOWN as lzma_vli; + let ref mut fresh1 = (*filters.offset(1)).options; *fresh1 = NULL; return ::core::ptr::null::(); } @@ -964,16 +964,15 @@ unsafe extern "C" fn str_to_filters( current_block = 6100283484465977373; break; } else { - if *(*str).offset(0 as isize) as c_int == '-' as i32 - && *(*str).offset(1 as isize) as c_int == '-' as i32 + if *(*str).offset(0) as c_int == '-' as i32 && *(*str).offset(1) as c_int == '-' as i32 { - *str = (*str).offset(2 as isize); + *str = (*str).offset(2); } let mut filter_end: *const c_char = *str; - while *filter_end.offset(0 as isize) as c_int != '\0' as i32 { - if *filter_end.offset(0 as isize) as c_int == '-' as i32 - && *filter_end.offset(1 as isize) as c_int == '-' as i32 - || *filter_end.offset(0 as isize) as c_int == ' ' as i32 + while *filter_end.offset(0) as c_int != '\0' as i32 { + if *filter_end.offset(0) as c_int == '-' as i32 + && *filter_end.offset(1) as c_int == '-' as i32 + || *filter_end.offset(0) as c_int == ' ' as i32 { break; } @@ -1016,7 +1015,7 @@ unsafe extern "C" fn str_to_filters( let ret: lzma_ret = lzma_validate_chain(&raw mut temp_filters as *mut lzma_filter, &raw mut dummy) as lzma_ret; - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { errmsg = b"Invalid filter chain ('lzma2' missing at the end?)\0" as *const u8 as *const c_char; current_block = 6100283484465977373; @@ -1121,7 +1120,7 @@ unsafe extern "C" fn strfy_filter( let mut map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0 as size_t; loop { - if (*map.offset(j as isize)).name[0 as usize] as c_int == '\0' as i32 { + if (*map.offset(j as isize)).name[0] as c_int == '\0' as i32 { str_append_str(dest, b"UNKNOWN\0" as *const u8 as *const c_char); break; } else if (*map.offset(j as isize)).value == v { @@ -1167,7 +1166,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( if flags & !supported_flags != 0 { return LZMA_OPTIONS_ERROR; } - if (*filters.offset(0 as isize)).id == LZMA_VLI_UNKNOWN as lzma_vli { + if (*filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_OPTIONS_ERROR; } let mut dest: lzma_str = lzma_str { @@ -1175,7 +1174,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( pos: 0, }; let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; @@ -1268,7 +1267,7 @@ pub unsafe extern "C" fn lzma_str_list_filters( pos: 0, }; let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; @@ -1335,7 +1334,7 @@ pub unsafe extern "C" fn lzma_str_list_filters( { let mut m: *const name_value_map = (*optmap.offset(j as isize)).u.map; let mut k: size_t = 0 as size_t; - while (*m.offset(k as isize)).name[0 as usize] as c_int != '\0' as i32 { + while (*m.offset(k as isize)).name[0] as c_int != '\0' as i32 { if k > 0 as size_t { str_append_str( &raw mut dest, @@ -1397,7 +1396,7 @@ unsafe extern "C" fn run_static_initializers() { u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: LZMA_DICT_SIZE_MIN as u32, - max: ((1 as u32) << 30 as c_int).wrapping_add((1 as u32) << 29 as c_int), + max: ((1 as u32) << 30).wrapping_add((1 as u32) << 29), }, }, }, diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index c702963f..1f309fea 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -23,8 +23,8 @@ pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; #[no_mangle] pub unsafe extern "C" fn lzma_vli_encode( diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index c5ac22a4..f4c4d224 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -1,7 +1,7 @@ use crate::types::*; use core::ffi::{c_int, c_ulonglong}; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2 as c_ulonglong); +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); #[no_mangle] pub unsafe extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { if vli > LZMA_VLI_MAX as lzma_vli { diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index 6684aa08..ee6647ee 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -128,7 +128,7 @@ pub struct lzma_delta_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; @@ -172,11 +172,11 @@ pub unsafe extern "C" fn lzma_delta_coder_init( set_out_limit: None, }; } - if lzma_delta_coder_memusage((*filters.offset(0 as isize)).options) == UINT64_MAX as u64 { + if lzma_delta_coder_memusage((*filters.offset(0)).options) == UINT64_MAX as u64 { return LZMA_OPTIONS_ERROR; } let mut opt: *const lzma_options_delta = - (*filters.offset(0 as isize)).options as *const lzma_options_delta; + (*filters.offset(0)).options as *const lzma_options_delta; (*coder).distance = (*opt).dist as size_t; (*coder).pos = 0 as u8; memset( @@ -184,17 +184,13 @@ pub unsafe extern "C" fn lzma_delta_coder_init( 0 as c_int, 256 as size_t, ); - return lzma_next_filter_init( - &raw mut (*coder).next, - allocator, - filters.offset(1 as isize), - ); + return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } #[no_mangle] pub unsafe extern "C" fn lzma_delta_coder_memusage(mut options: *const c_void) -> u64 { let mut opt: *const lzma_options_delta = options as *const lzma_options_delta; if opt.is_null() - || (*opt).type_0 as c_uint != LZMA_DELTA_TYPE_BYTE as c_uint + || (*opt).type_0 != LZMA_DELTA_TYPE_BYTE || (*opt).dist < LZMA_DELTA_DIST_MIN as u32 || (*opt).dist > LZMA_DELTA_DIST_MAX as u32 { diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index a53892de..b1831527 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -214,7 +214,7 @@ pub unsafe extern "C" fn lzma_delta_props_decode( return LZMA_MEM_ERROR; } (*opt).type_0 = LZMA_DELTA_TYPE_BYTE; - (*opt).dist = (*props.offset(0 as isize) as c_uint).wrapping_add(1 as c_uint) as u32; + (*opt).dist = u32::from(*props.offset(0)).wrapping_add(1); *options = opt as *mut c_void; return LZMA_OK; } diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index a12d5d64..99809a8a 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -130,7 +130,7 @@ pub struct lzma_delta_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; unsafe extern "C" fn copy_and_encode( mut coder: *mut lzma_delta_coder, @@ -199,7 +199,7 @@ unsafe extern "C" fn delta_encode( } *in_pos = (*in_pos).wrapping_add(size); *out_pos = (*out_pos).wrapping_add(size); - ret = (if action as c_uint != LZMA_RUN as c_uint && *in_pos == in_size { + ret = (if action != LZMA_RUN && *in_pos == in_size { LZMA_STREAM_END as c_int } else { LZMA_OK as c_int @@ -234,7 +234,7 @@ unsafe extern "C" fn delta_encoder_update( return lzma_next_filter_update( &raw mut (*coder).next, allocator, - reversed_filters.offset(1 as isize), + reversed_filters.offset(1), ); } #[no_mangle] @@ -285,6 +285,6 @@ pub unsafe extern "C" fn lzma_delta_props_encode( return LZMA_PROG_ERROR; } let mut opt: *const lzma_options_delta = options as *const lzma_options_delta; - *out.offset(0 as isize) = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN as u32) as u8; + *out.offset(0) = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN as u32) as u8; return LZMA_OK; } diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 83f2a8fe..902e4c40 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -159,7 +159,7 @@ pub struct C2RustUnnamed { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const true_0: c_int = 1 as c_int; @@ -236,13 +236,10 @@ unsafe extern "C" fn decode_buffer( *out_pos = (*out_pos).wrapping_add(copy_size); if (*coder).dict.need_reset { lz_decoder_reset(coder); - if ret as c_uint != LZMA_OK as c_uint || *out_pos == out_size { + if ret != LZMA_OK || *out_pos == out_size { return ret; } - } else if ret as c_uint != LZMA_OK as c_uint - || *out_pos == out_size - || (*coder).dict.pos < (*coder).dict.size - { + } else if ret != LZMA_OK || *out_pos == out_size || (*coder).dict.pos < (*coder).dict.size { return ret; } } @@ -277,9 +274,9 @@ unsafe extern "C" fn lz_decode( LZMA_BUFFER_SIZE as size_t, action, ) as lzma_ret; - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { (*coder).next_finished = true_0 != 0; - } else if ret as c_uint != LZMA_OK as c_uint || (*coder).temp.size == 0 as size_t { + } else if ret != LZMA_OK || (*coder).temp.size == 0 as size_t { return ret; } } @@ -301,9 +298,9 @@ unsafe extern "C" fn lz_decode( out_pos, out_size, ) as lzma_ret; - if ret_0 as c_uint == LZMA_STREAM_END as c_uint { + if ret_0 == LZMA_STREAM_END { (*coder).this_finished = true_0 != 0; - } else if ret_0 as c_uint != LZMA_OK as c_uint { + } else if ret_0 != LZMA_OK { return ret_0; } else if (*coder).next_finished as c_int != 0 && *out_pos < out_size { return LZMA_DATA_ERROR; @@ -389,11 +386,11 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( let ret_: lzma_ret = lz_init.expect("non-null function pointer")( &raw mut (*coder).lz, allocator, - (*filters.offset(0 as isize)).id, - (*filters.offset(0 as isize)).options, + (*filters.offset(0)).id, + (*filters.offset(0)).options, &raw mut lz_options, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } if lz_options.dict_size < 4096 as size_t { @@ -440,11 +437,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( (*coder).this_finished = false_0 != 0; (*coder).temp.pos = 0 as size_t; (*coder).temp.size = 0 as size_t; - return lzma_next_filter_init( - &raw mut (*coder).next, - allocator, - filters.offset(1 as isize), - ); + return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } #[no_mangle] pub unsafe extern "C" fn lzma_lz_decoder_memusage(mut dictionary_size: size_t) -> u64 { diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index d132be4d..455b9616 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -203,17 +203,17 @@ pub struct lzma_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; #[inline] unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> u32 { return match_finder as u32 & 0xf as u32; } -pub const HASH_2_SIZE: c_uint = (1 as c_uint) << 10 as c_int; -pub const HASH_3_SIZE: c_uint = (1 as c_uint) << 16 as c_int; +pub const HASH_2_SIZE: c_uint = 1u32 << 10; +pub const HASH_3_SIZE: c_uint = 1u32 << 16; pub const LZMA_MEMCMPLEN_EXTRA: c_int = 0 as c_int; unsafe extern "C" fn move_window(mut mf: *mut lzma_mf) { let move_offset: u32 = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) & !(15 as u32); @@ -250,7 +250,7 @@ unsafe extern "C" fn fill_window( &raw mut write_pos, (*coder).mf.size as size_t, ); - ret = (if action as c_uint != LZMA_RUN as c_uint && *in_pos == in_size { + ret = (if action != LZMA_RUN && *in_pos == in_size { LZMA_STREAM_END as c_int } else { LZMA_OK as c_int @@ -274,7 +274,7 @@ unsafe extern "C" fn fill_window( 0 as c_int, 0 as size_t, ); - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { ret = LZMA_OK; (*coder).mf.action = action; (*coder).mf.read_limit = (*coder).mf.write_pos; @@ -304,13 +304,11 @@ unsafe extern "C" fn lz_encode( mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; - while *out_pos < out_size && (*in_pos < in_size || action as c_uint != LZMA_RUN as c_uint) { - if (*coder).mf.action as c_uint == LZMA_RUN as c_uint - && (*coder).mf.read_pos >= (*coder).mf.read_limit - { + while *out_pos < out_size && (*in_pos < in_size || action != LZMA_RUN) { + if (*coder).mf.action == LZMA_RUN && (*coder).mf.read_pos >= (*coder).mf.read_limit { let ret_: lzma_ret = fill_window(coder, allocator, in_0, in_pos, in_size, action) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } } @@ -321,7 +319,7 @@ unsafe extern "C" fn lz_encode( out_pos, out_size, ) as lzma_ret; - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { (*coder).mf.action = LZMA_RUN; return ret; } @@ -334,8 +332,7 @@ unsafe extern "C" fn lz_encoder_prepare( mut lz_options: *const lzma_lz_options, ) -> bool { if !((*lz_options).dict_size >= LZMA_DICT_SIZE_MIN as size_t - && (*lz_options).dict_size - <= ((1 as c_uint) << 30 as c_int).wrapping_add((1 as c_uint) << 29 as c_int) as size_t) + && (*lz_options).dict_size <= (1u32 << 30).wrapping_add(1u32 << 29) as size_t) || (*lz_options).nice_len > (*lz_options).match_len_max { return true_0 != 0; @@ -347,7 +344,7 @@ unsafe extern "C" fn lz_encoder_prepare( .after_size .wrapping_add((*lz_options).match_len_max) as u32; let mut reserve: u32 = (*lz_options).dict_size.wrapping_div(2 as size_t) as u32; - if reserve > (1 as u32) << 30 as c_int { + if reserve > (1 as u32) << 30 { reserve = reserve.wrapping_div(2 as u32); } reserve = (reserve as size_t).wrapping_add( @@ -356,8 +353,8 @@ unsafe extern "C" fn lz_encoder_prepare( .wrapping_add((*lz_options).match_len_max) .wrapping_add((*lz_options).after_size) .wrapping_div(2 as size_t) - .wrapping_add(((1 as c_uint) << 19 as c_int) as size_t), - ) as u32 as u32; + .wrapping_add((1u32 << 19) as size_t), + ) as u32; let old_size: u32 = (*mf).size; (*mf).size = (*mf) .keep_size_before @@ -370,7 +367,7 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).match_len_max = (*lz_options).match_len_max as u32; (*mf).nice_len = (*lz_options).nice_len as u32; (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1 as size_t) as u32; - match (*lz_options).match_finder as c_uint { + match (*lz_options).match_finder { 3 => { (*mf).find = Some( lzma_mf_hc3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, @@ -414,21 +411,21 @@ unsafe extern "C" fn lz_encoder_prepare( _ => return true_0 != 0, } let hash_bytes: u32 = mf_get_hash_bytes((*lz_options).match_finder) as u32; - let is_bt: bool = (*lz_options).match_finder as c_uint & 0x10 as c_uint != 0 as c_uint; + let is_bt: bool = (*lz_options).match_finder & 0x10 != 0; let mut hs: u32 = 0; if hash_bytes == 2 as u32 { hs = 0xffff as u32; } else { hs = (*lz_options).dict_size.wrapping_sub(1 as size_t) as u32; - hs |= hs >> 1 as c_int; - hs |= hs >> 2 as c_int; - hs |= hs >> 4 as c_int; - hs |= hs >> 8 as c_int; + hs |= hs >> 1; + hs |= hs >> 2; + hs |= hs >> 4; + hs |= hs >> 8; hs >>= 1 as c_int; hs |= 0xffff as u32; - if hs > (1 as u32) << 24 as c_int { + if hs > (1 as u32) << 24 { if hash_bytes == 3 as u32 { - hs = ((1 as c_uint) << 24 as c_int).wrapping_sub(1 as c_uint) as u32; + hs = (1u32 << 24).wrapping_sub(1) as u32; } else { hs >>= 1 as c_int; } @@ -437,10 +434,10 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).hash_mask = hs; hs = hs.wrapping_add(1); if hash_bytes > 2 as u32 { - hs = (hs as c_uint).wrapping_add(HASH_2_SIZE) as u32 as u32; + hs = hs.wrapping_add(HASH_2_SIZE); } if hash_bytes > 3 as u32 { - hs = (hs as c_uint).wrapping_add(HASH_3_SIZE) as u32 as u32; + hs = hs.wrapping_add(HASH_3_SIZE); } let old_hash_count: u32 = (*mf).hash_count; let old_sons_count: u32 = (*mf).sons_count; @@ -606,13 +603,13 @@ unsafe extern "C" fn lz_encoder_update( .expect("non-null function pointer")( (*coder).lz.coder, reversed_filters ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } return lzma_next_filter_update( &raw mut (*coder).next, allocator, - reversed_filters.offset(1 as isize), + reversed_filters.offset(1), ); } unsafe extern "C" fn lz_encoder_set_out_limit( @@ -731,11 +728,11 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( let ret_: lzma_ret = lz_init.expect("non-null function pointer")( &raw mut (*coder).lz, allocator, - (*filters.offset(0 as isize)).id, - (*filters.offset(0 as isize)).options, + (*filters.offset(0)).id, + (*filters.offset(0)).options, &raw mut lz_options, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } if lz_encoder_prepare(&raw mut (*coder).mf, allocator, &raw mut lz_options) { @@ -744,15 +741,11 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( if lz_encoder_init(&raw mut (*coder).mf, allocator, &raw mut lz_options) { return LZMA_MEM_ERROR; } - return lzma_next_filter_init( - &raw mut (*coder).next, - allocator, - filters.offset(1 as isize), - ); + return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } #[no_mangle] pub unsafe extern "C" fn lzma_mf_is_supported(mut mf: lzma_match_finder) -> lzma_bool { - match mf as c_uint { + match mf { 3 => return true_0 as lzma_bool, 4 => return true_0 as lzma_bool, 18 => return true_0 as lzma_bool, diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 3372db6d..f7ac0fda 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -42,7 +42,7 @@ pub struct lzma_mf_s { pub sons_count: u32, } pub type lzma_mf = lzma_mf_s; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT32_MAX: c_uint = 4294967295; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] @@ -53,11 +53,11 @@ unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const u8 { unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> u32 { return (*mf).write_pos.wrapping_sub((*mf).read_pos); } -pub const HASH_2_SIZE: c_uint = (1 as c_uint) << 10 as c_int; -pub const HASH_3_SIZE: c_uint = (1 as c_uint) << 16 as c_int; -pub const HASH_2_MASK: c_uint = HASH_2_SIZE.wrapping_sub(1 as c_uint); -pub const HASH_3_MASK: c_uint = HASH_3_SIZE.wrapping_sub(1 as c_uint); -pub const FIX_3_HASH_SIZE: c_uint = (1 as c_uint) << 10 as c_int; +pub const HASH_2_SIZE: c_uint = 1u32 << 10; +pub const HASH_3_SIZE: c_uint = 1u32 << 16; +pub const HASH_2_MASK: c_uint = HASH_2_SIZE.wrapping_sub(1); +pub const HASH_3_MASK: c_uint = HASH_3_SIZE.wrapping_sub(1); +pub const FIX_3_HASH_SIZE: c_uint = 1u32 << 10; pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); #[inline(always)] unsafe extern "C" fn lzma_memcmplen( @@ -87,10 +87,10 @@ pub unsafe extern "C" fn lzma_mf_find( if limit > (*mf).match_len_max { limit = (*mf).match_len_max; } - let mut p1: *const u8 = mf_ptr(mf).offset(-(1 as isize)); + let mut p1: *const u8 = mf_ptr(mf).offset(-1); let mut p2: *const u8 = p1 .offset(-((*matches.offset(count.wrapping_sub(1 as u32) as isize)).dist as isize)) - .offset(-(1 as isize)); + .offset(-1); len_best = lzma_memcmplen(p1, p2, len_best, limit); } } @@ -167,7 +167,7 @@ unsafe extern "C" fn hc_find_func( }), ) as isize); if *pb.offset(len_best as isize) as c_int == *cur.offset(len_best as isize) as c_int - && *pb.offset(0 as isize) as c_int == *cur.offset(0 as isize) as c_int + && *pb.offset(0) as c_int == *cur.offset(0) as c_int { let mut len: u32 = lzma_memcmplen(pb, cur, 1 as u32, len_limit); if len_best < len { @@ -190,19 +190,16 @@ pub unsafe extern "C" fn lzma_mf_hc3_find( let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 3 as u32 - || 0 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + } else if len_limit < 3 as u32 || 0 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0 as u32; } let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0 as u32; - let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] - ^ *cur.offset(1 as isize) as u32; + let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_value: u32 = (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & (*mf).hash_mask; + let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); let cur_match: u32 = *(*mf) .hash @@ -214,8 +211,8 @@ pub unsafe extern "C" fn lzma_mf_hc3_find( let mut len_best: u32 = 2 as u32; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); - (*matches.offset(0 as isize)).len = len_best; - (*matches.offset(0 as isize)).dist = delta2.wrapping_sub(1 as u32); + (*matches.offset(0)).len = len_best; + (*matches.offset(0)).dist = delta2.wrapping_sub(1 as u32); matches_count = 1 as u32; if len_best == len_limit { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; @@ -247,11 +244,9 @@ pub unsafe extern "C" fn lzma_mf_hc3_skip(mut mf: *mut lzma_mf, mut amount: u32) } else { let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] - ^ *cur.offset(1 as isize) as u32; + let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_value: u32 = - (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & (*mf).hash_mask; + let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let cur_match: u32 = *(*mf) .hash .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); @@ -276,24 +271,19 @@ pub unsafe extern "C" fn lzma_mf_hc4_find( let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 4 as u32 - || 0 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + } else if len_limit < 4 as u32 || 0 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0 as u32; } let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0 as u32; - let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] - ^ *cur.offset(1 as isize) as u32; + let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_3_value: u32 = - (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & HASH_3_MASK as u32; - let hash_value: u32 = (temp - ^ (*cur.offset(2 as isize) as u32) << 8 as c_int - ^ lzma_crc32_table[0 as usize][*cur.offset(3 as isize) as usize] << 5 as c_int) - & (*mf).hash_mask; + let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; + let hash_value: u32 = + (temp ^ (*cur.offset(2) as u32) << 8 ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) + & (*mf).hash_mask; let mut delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); let delta3: u32 = pos.wrapping_sub( *(*mf) @@ -313,8 +303,8 @@ pub unsafe extern "C" fn lzma_mf_hc4_find( let mut len_best: u32 = 1 as u32; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { len_best = 2 as u32; - (*matches.offset(0 as isize)).len = 2 as u32; - (*matches.offset(0 as isize)).dist = delta2.wrapping_sub(1 as u32); + (*matches.offset(0)).len = 2 as u32; + (*matches.offset(0)).dist = delta2.wrapping_sub(1 as u32); matches_count = 1 as u32; } if delta2 != delta3 @@ -363,14 +353,12 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mut mf: *mut lzma_mf, mut amount: u32) } else { let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] - ^ *cur.offset(1 as isize) as u32; + let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_3_value: u32 = - (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & HASH_3_MASK as u32; + let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; let hash_value: u32 = (temp - ^ (*cur.offset(2 as isize) as u32) << 8 as c_int - ^ lzma_crc32_table[0 as usize][*cur.offset(3 as isize) as usize] << 5 as c_int) + ^ (*cur.offset(2) as u32) << 8 + ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) & (*mf).hash_mask; let cur_match: u32 = *(*mf) .hash @@ -403,10 +391,8 @@ unsafe extern "C" fn bt_find_func( mut matches: *mut lzma_match, mut len_best: u32, ) -> *mut lzma_match { - let mut ptr0: *mut u32 = son - .offset((cyclic_pos << 1 as c_int) as isize) - .offset(1 as isize); - let mut ptr1: *mut u32 = son.offset((cyclic_pos << 1 as c_int) as isize); + let mut ptr0: *mut u32 = son.offset((cyclic_pos << 1) as isize).offset(1); + let mut ptr1: *mut u32 = son.offset((cyclic_pos << 1) as isize); let mut len0: u32 = 0 as u32; let mut len1: u32 = 0 as u32; loop { @@ -425,7 +411,7 @@ unsafe extern "C" fn bt_find_func( } else { 0 as u32 }), - ) << 1 as c_int) as isize, + ) << 1) as isize, ); let pb: *const u8 = cur.offset(-(delta as isize)); let mut len: u32 = if len0 < len1 { len0 } else { len1 }; @@ -437,15 +423,15 @@ unsafe extern "C" fn bt_find_func( (*matches).dist = delta.wrapping_sub(1 as u32); matches = matches.offset(1); if len == len_limit { - *ptr1 = *pair.offset(0 as isize); - *ptr0 = *pair.offset(1 as isize); + *ptr1 = *pair.offset(0); + *ptr0 = *pair.offset(1); return matches; } } } if (*pb.offset(len as isize) as c_int) < *cur.offset(len as isize) as c_int { *ptr1 = cur_match; - ptr1 = pair.offset(1 as isize); + ptr1 = pair.offset(1); cur_match = *ptr1; len1 = len; } else { @@ -466,10 +452,8 @@ unsafe extern "C" fn bt_skip_func( cyclic_pos: u32, cyclic_size: u32, ) { - let mut ptr0: *mut u32 = son - .offset((cyclic_pos << 1 as c_int) as isize) - .offset(1 as isize); - let mut ptr1: *mut u32 = son.offset((cyclic_pos << 1 as c_int) as isize); + let mut ptr0: *mut u32 = son.offset((cyclic_pos << 1) as isize).offset(1); + let mut ptr1: *mut u32 = son.offset((cyclic_pos << 1) as isize); let mut len0: u32 = 0 as u32; let mut len1: u32 = 0 as u32; loop { @@ -488,21 +472,21 @@ unsafe extern "C" fn bt_skip_func( } else { 0 as u32 }), - ) << 1 as c_int) as isize, + ) << 1) as isize, ); let mut pb: *const u8 = cur.offset(-(delta as isize)); let mut len: u32 = if len0 < len1 { len0 } else { len1 }; if *pb.offset(len as isize) as c_int == *cur.offset(len as isize) as c_int { len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as u32), len_limit); if len == len_limit { - *ptr1 = *pair.offset(0 as isize); - *ptr0 = *pair.offset(1 as isize); + *ptr1 = *pair.offset(0); + *ptr0 = *pair.offset(1); return; } } if (*pb.offset(len as isize) as c_int) < *cur.offset(len as isize) as c_int { *ptr1 = cur_match; - ptr1 = pair.offset(1 as isize); + ptr1 = pair.offset(1); cur_match = *ptr1; len1 = len; } else { @@ -521,17 +505,14 @@ pub unsafe extern "C" fn lzma_mf_bt2_find( let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 2 as u32 - || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + } else if len_limit < 2 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0 as u32; } let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0 as u32; - let hash_value: u32 = - *cur.offset(0 as isize) as u32 | (*cur.offset(1 as isize) as u32) << 8 as c_int; + let hash_value: u32 = *cur.offset(0) as u32 | (*cur.offset(1) as u32) << 8; let cur_match: u32 = *(*mf).hash.offset(hash_value as isize); *(*mf).hash.offset(hash_value as isize) = pos; matches_count = bt_find_func( @@ -558,9 +539,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: u32) if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_8 = 11875828834189669668; - } else if len_limit < 2 as u32 - || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + } else if len_limit < 2 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_8 = 18088007599891946824; } else { @@ -570,8 +549,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: u32) 11875828834189669668 => { let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let hash_value: u32 = - *cur.offset(0 as isize) as u32 | (*cur.offset(1 as isize) as u32) << 8 as c_int; + let hash_value: u32 = *cur.offset(0) as u32 | (*cur.offset(1) as u32) << 8; let cur_match: u32 = *(*mf).hash.offset(hash_value as isize); *(*mf).hash.offset(hash_value as isize) = pos; bt_skip_func( @@ -602,19 +580,16 @@ pub unsafe extern "C" fn lzma_mf_bt3_find( let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 3 as u32 - || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + } else if len_limit < 3 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0 as u32; } let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0 as u32; - let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] - ^ *cur.offset(1 as isize) as u32; + let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_value: u32 = (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & (*mf).hash_mask; + let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); let cur_match: u32 = *(*mf) .hash @@ -626,8 +601,8 @@ pub unsafe extern "C" fn lzma_mf_bt3_find( let mut len_best: u32 = 2 as u32; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); - (*matches.offset(0 as isize)).len = len_best; - (*matches.offset(0 as isize)).dist = delta2.wrapping_sub(1 as u32); + (*matches.offset(0)).len = len_best; + (*matches.offset(0)).dist = delta2.wrapping_sub(1 as u32); matches_count = 1 as u32; if len_best == len_limit { bt_skip_func( @@ -668,9 +643,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: u32) if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_9 = 11875828834189669668; - } else if len_limit < 3 as u32 - || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + } else if len_limit < 3 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_9 = 18088007599891946824; } else { @@ -680,11 +653,10 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: u32) 11875828834189669668 => { let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] - ^ *cur.offset(1 as isize) as u32; + let temp: u32 = + lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_value: u32 = - (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & (*mf).hash_mask; + let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let cur_match: u32 = *(*mf) .hash .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); @@ -720,24 +692,19 @@ pub unsafe extern "C" fn lzma_mf_bt4_find( let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 4 as u32 - || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + } else if len_limit < 4 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0 as u32; } let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0 as u32; - let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] - ^ *cur.offset(1 as isize) as u32; + let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_3_value: u32 = - (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & HASH_3_MASK as u32; - let hash_value: u32 = (temp - ^ (*cur.offset(2 as isize) as u32) << 8 as c_int - ^ lzma_crc32_table[0 as usize][*cur.offset(3 as isize) as usize] << 5 as c_int) - & (*mf).hash_mask; + let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; + let hash_value: u32 = + (temp ^ (*cur.offset(2) as u32) << 8 ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) + & (*mf).hash_mask; let mut delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); let delta3: u32 = pos.wrapping_sub( *(*mf) @@ -757,8 +724,8 @@ pub unsafe extern "C" fn lzma_mf_bt4_find( let mut len_best: u32 = 1 as u32; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { len_best = 2 as u32; - (*matches.offset(0 as isize)).len = 2 as u32; - (*matches.offset(0 as isize)).dist = delta2.wrapping_sub(1 as u32); + (*matches.offset(0)).len = 2 as u32; + (*matches.offset(0)).dist = delta2.wrapping_sub(1 as u32); matches_count = 1 as u32; } if delta2 != delta3 @@ -816,9 +783,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: u32) if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_10 = 11875828834189669668; - } else if len_limit < 4 as u32 - || 1 as c_int != 0 && (*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint - { + } else if len_limit < 4 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_10 = 18088007599891946824; } else { @@ -828,14 +793,13 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: u32) 11875828834189669668 => { let mut cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = lzma_crc32_table[0 as usize][*cur.offset(0 as isize) as usize] - ^ *cur.offset(1 as isize) as u32; + let temp: u32 = + lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_3_value: u32 = - (temp ^ (*cur.offset(2 as isize) as u32) << 8 as c_int) & HASH_3_MASK as u32; + let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; let hash_value: u32 = (temp - ^ (*cur.offset(2 as isize) as u32) << 8 as c_int - ^ lzma_crc32_table[0 as usize][*cur.offset(3 as isize) as usize] << 5 as c_int) + ^ (*cur.offset(2) as u32) << 8 + ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) & (*mf).hash_mask; let cur_match: u32 = *(*mf) .hash diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index 71f58bdb..e9c37c30 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -222,7 +222,7 @@ pub const SEQ_UNCOMPRESSED_1: sequence = 1; pub const SEQ_CONTROL: sequence = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT32_MAX: c_uint = 4294967295; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZ_DICT_REPEAT_MAX: c_int = 288 as c_int; @@ -269,8 +269,8 @@ unsafe extern "C" fn lzma2_decode( mut in_size: size_t, ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; - while *in_pos < in_size || (*coder).sequence as c_uint == SEQ_LZMA as c_uint { - match (*coder).sequence as c_uint { + while *in_pos < in_size || (*coder).sequence == SEQ_LZMA { + match (*coder).sequence { 0 => { let control: u32 = *in_0.offset(*in_pos as isize) as u32; *in_pos = (*in_pos).wrapping_add(1); @@ -284,7 +284,7 @@ unsafe extern "C" fn lzma2_decode( return LZMA_DATA_ERROR; } if control >= 0x80 as u32 { - (*coder).uncompressed_size = ((control & 0x1f as u32) << 16 as c_int) as size_t; + (*coder).uncompressed_size = ((control & 0x1f as u32) << 16) as size_t; (*coder).sequence = SEQ_UNCOMPRESSED_1; if control >= 0xc0 as u32 { (*coder).need_properties = false_0 != 0; @@ -318,14 +318,14 @@ unsafe extern "C" fn lzma2_decode( *in_pos = (*in_pos).wrapping_add(1); (*coder).uncompressed_size = (*coder) .uncompressed_size - .wrapping_add(((*in_0.offset(fresh0 as isize) as u32) << 8 as c_int) as size_t); + .wrapping_add(((*in_0.offset(fresh0 as isize) as u32) << 8) as size_t); (*coder).sequence = SEQ_UNCOMPRESSED_2; } 2 => { let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); (*coder).uncompressed_size = (*coder).uncompressed_size.wrapping_add( - (*in_0.offset(fresh1 as isize) as c_uint).wrapping_add(1 as c_uint) as size_t, + u32::from(*in_0.offset(fresh1 as isize)).wrapping_add(1) as size_t, ); (*coder).sequence = SEQ_COMPRESSED_0; (*coder) @@ -340,15 +340,14 @@ unsafe extern "C" fn lzma2_decode( 3 => { let fresh2 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - (*coder).compressed_size = - ((*in_0.offset(fresh2 as isize) as u32) << 8 as c_int) as size_t; + (*coder).compressed_size = ((*in_0.offset(fresh2 as isize) as u32) << 8) as size_t; (*coder).sequence = SEQ_COMPRESSED_1; } 4 => { let fresh3 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); (*coder).compressed_size = (*coder).compressed_size.wrapping_add( - (*in_0.offset(fresh3 as isize) as c_uint).wrapping_add(1 as c_uint) as size_t, + u32::from(*in_0.offset(fresh3 as isize)).wrapping_add(1) as size_t, ); (*coder).sequence = (*coder).next_sequence as sequence; } @@ -379,7 +378,7 @@ unsafe extern "C" fn lzma2_decode( return LZMA_DATA_ERROR; } (*coder).compressed_size = (*coder).compressed_size.wrapping_sub(in_used); - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { return ret; } if (*coder).compressed_size != 0 as size_t { @@ -499,10 +498,10 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if props_size != 1 as size_t { return LZMA_OPTIONS_ERROR; } - if *props.offset(0 as isize) as c_int & 0xc0 as c_int != 0 { + if *props.offset(0) as c_int & 0xc0 as c_int != 0 { return LZMA_OPTIONS_ERROR; } - if *props.offset(0 as isize) as c_int > 40 as c_int { + if *props.offset(0) as c_int > 40 as c_int { return LZMA_OPTIONS_ERROR; } let mut opt: *mut lzma_options_lzma = lzma_alloc( @@ -512,13 +511,11 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if opt.is_null() { return LZMA_MEM_ERROR; } - if *props.offset(0 as isize) as c_int == 40 as c_int { + if *props.offset(0) as c_int == 40 as c_int { (*opt).dict_size = UINT32_MAX as u32; } else { - (*opt).dict_size = (2 as c_uint | *props.offset(0 as isize) as c_uint & 1 as c_uint) as u32; - (*opt).dict_size <<= (*props.offset(0 as isize) as c_uint) - .wrapping_div(2 as c_uint) - .wrapping_add(11 as c_uint); + (*opt).dict_size = 2u32 | (u32::from(*props.offset(0)) & 1); + (*opt).dict_size <<= u32::from(*props.offset(0)).wrapping_div(2).wrapping_add(11); } (*opt).preset_dict = ::core::ptr::null::(); (*opt).preset_dict_size = 0 as u32; diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 86f99fa5..62397644 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -264,11 +264,11 @@ pub const SEQ_LZMA_ENCODE: C2RustUnnamed = 1; pub const SEQ_INIT: C2RustUnnamed = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT32_MAX: c_uint = 4294967295; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096 as c_uint; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; pub const LZMA_LCLP_MAX: c_int = 4 as c_int; pub const LZMA_PB_MAX: c_int = 4 as c_int; #[inline] @@ -306,21 +306,19 @@ unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { return lzma_fastpos[dist as usize] as u32; } if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { - return (lzma_fastpos - [(dist >> 0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } - return (lzma_fastpos[(dist >> 0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] - as u32) + return (lzma_fastpos[(dist >> 0 + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } -pub const LZMA2_CHUNK_MAX: c_uint = (1 as c_uint) << 16 as c_int; -pub const LZMA2_UNCOMPRESSED_MAX: c_uint = (1 as c_uint) << 21 as c_int; +pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; +pub const LZMA2_UNCOMPRESSED_MAX: c_uint = 1u32 << 21; pub const LZMA2_HEADER_MAX: c_int = 6 as c_int; pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3 as c_int; unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { @@ -328,14 +326,14 @@ unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { if (*coder).need_properties { pos = 0 as size_t; if (*coder).need_dictionary_reset { - (*coder).buf[pos as usize] = (0x80 as c_int + ((3 as c_int) << 5 as c_int)) as u8; + (*coder).buf[pos as usize] = (0x80 as c_int + ((3 as c_int) << 5)) as u8; } else { - (*coder).buf[pos as usize] = (0x80 as c_int + ((2 as c_int) << 5 as c_int)) as u8; + (*coder).buf[pos as usize] = (0x80 as c_int + ((2 as c_int) << 5)) as u8; } } else { pos = 1 as size_t; if (*coder).need_state_reset { - (*coder).buf[pos as usize] = (0x80 as c_int + ((1 as c_int) << 5 as c_int)) as u8; + (*coder).buf[pos as usize] = (0x80 as c_int + ((1 as c_int) << 5)) as u8; } else { (*coder).buf[pos as usize] = 0x80 as u8; } @@ -345,17 +343,17 @@ unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { let fresh1 = pos; pos = pos.wrapping_add(1); (*coder).buf[fresh1 as usize] = - ((*coder).buf[fresh1 as usize] as size_t).wrapping_add(size >> 16 as c_int) as u8 as u8; + ((*coder).buf[fresh1 as usize] as size_t).wrapping_add(size >> 16) as u8 as u8; let fresh2 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh2 as usize] = (size >> 8 as c_int & 0xff as size_t) as u8; + (*coder).buf[fresh2 as usize] = (size >> 8 & 0xff as size_t) as u8; let fresh3 = pos; pos = pos.wrapping_add(1); (*coder).buf[fresh3 as usize] = (size & 0xff as size_t) as u8; size = (*coder).compressed_size.wrapping_sub(1 as size_t); let fresh4 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh4 as usize] = (size >> 8 as c_int) as u8; + (*coder).buf[fresh4 as usize] = (size >> 8) as u8; let fresh5 = pos; pos = pos.wrapping_add(1); (*coder).buf[fresh5 as usize] = (size & 0xff as size_t) as u8; @@ -374,15 +372,13 @@ unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { } unsafe extern "C" fn lzma2_header_uncompressed(mut coder: *mut lzma_lzma2_coder) { if (*coder).need_dictionary_reset { - (*coder).buf[0 as usize] = 1 as u8; + (*coder).buf[0] = 1 as u8; } else { - (*coder).buf[0 as usize] = 2 as u8; + (*coder).buf[0] = 2 as u8; } (*coder).need_dictionary_reset = false_0 != 0; - (*coder).buf[1 as usize] = - ((*coder).uncompressed_size.wrapping_sub(1 as size_t) >> 8 as c_int) as u8; - (*coder).buf[2 as usize] = - ((*coder).uncompressed_size.wrapping_sub(1 as size_t) & 0xff as size_t) as u8; + (*coder).buf[1] = ((*coder).uncompressed_size.wrapping_sub(1 as size_t) >> 8) as u8; + (*coder).buf[2] = ((*coder).uncompressed_size.wrapping_sub(1 as size_t) & 0xff as size_t) as u8; (*coder).buf_pos = 0 as size_t; } unsafe extern "C" fn lzma2_encode( @@ -395,15 +391,15 @@ unsafe extern "C" fn lzma2_encode( let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; while *out_pos < out_size { let mut current_block_45: u64; - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 => { if mf_unencoded(mf) == 0 as u32 { - if (*mf).action as c_uint == LZMA_FINISH as c_uint { + if (*mf).action == LZMA_FINISH { let fresh0 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); *out.offset(fresh0 as isize) = 0 as u8; } - return (if (*mf).action as c_uint == LZMA_RUN as c_uint { + return (if (*mf).action == LZMA_RUN { LZMA_OK as c_int } else { LZMA_STREAM_END as c_int @@ -414,7 +410,7 @@ unsafe extern "C" fn lzma2_encode( (*coder).lzma as *mut lzma_lzma1_encoder, &raw mut (*coder).opt_cur, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } } @@ -495,7 +491,7 @@ unsafe extern "C" fn lzma2_encode( .wrapping_sub((*mf).read_ahead) .wrapping_sub(read_start) as size_t, ); - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { return LZMA_OK; } if (*coder).compressed_size >= (*coder).uncompressed_size { @@ -548,7 +544,7 @@ unsafe extern "C" fn lzma2_encoder_options_update( mut filter: *const lzma_filter, ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; - if (*filter).options.is_null() || (*coder).sequence as c_uint != SEQ_INIT as c_uint { + if (*filter).options.is_null() || (*coder).sequence != SEQ_INIT { return LZMA_PROG_ERROR; } let mut opt: *const lzma_options_lzma = (*filter).options as *const lzma_options_lzma; @@ -634,7 +630,7 @@ unsafe extern "C" fn lzma2_encoder_init( &raw mut (*coder).opt_cur, lz_options, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } if (*lz_options) @@ -692,16 +688,15 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode( 4096 as u32 }; d = d.wrapping_sub(1); - d |= d >> 2 as c_int; - d |= d >> 3 as c_int; - d |= d >> 4 as c_int; - d |= d >> 8 as c_int; - d |= d >> 16 as c_int; + d |= d >> 2; + d |= d >> 3; + d |= d >> 4; + d |= d >> 8; + d |= d >> 16; if d == UINT32_MAX as u32 { - *out.offset(0 as isize) = 40 as u8; + *out.offset(0) = 40 as u8; } else { - *out.offset(0 as isize) = - get_dist_slot(d.wrapping_add(1 as u32)).wrapping_sub(24 as u32) as u8; + *out.offset(0) = get_dist_slot(d.wrapping_add(1 as u32)).wrapping_sub(24 as u32) as u8; } return LZMA_OK; } @@ -709,13 +704,13 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode( pub unsafe extern "C" fn lzma_lzma2_block_size(mut options: *const c_void) -> u64 { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; if !((*opt).dict_size >= LZMA_DICT_SIZE_MIN as u32 - && (*opt).dict_size <= ((1 as u32) << 30 as c_int).wrapping_add((1 as u32) << 29 as c_int)) + && (*opt).dict_size <= ((1 as u32) << 30).wrapping_add((1 as u32) << 29)) { return UINT64_MAX as u64; } - return if ((*opt).dict_size as u64).wrapping_mul(3 as u64) > (1 as u64) << 20 as c_int { + return if ((*opt).dict_size as u64).wrapping_mul(3 as u64) > (1 as u64) << 20 { ((*opt).dict_size as u64).wrapping_mul(3 as u64) } else { - (1 as u64) << 20 as c_int + (1 as u64) << 20 }; } diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 71347bab..2fad638c 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -272,23 +272,23 @@ pub struct lzma_length_decoder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT32_MAX: c_uint = 4294967295; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0 as isize) as u32; - num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; - num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; - num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; return num; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; pub const LZMA_LCLP_MAX: c_int = 4 as c_int; pub const LZMA_PB_MAX: c_int = 4 as c_int; -pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1 as c_uint; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; pub const LZ_DICT_REPEAT_MAX: c_int = 288 as c_int; pub const LZ_DICT_INIT_POS: c_int = 2 as c_int * LZ_DICT_REPEAT_MAX; #[inline] @@ -381,9 +381,9 @@ unsafe extern "C" fn dict_put_safe(mut dict: *mut lzma_dict, mut byte: u8) -> bo } pub const RC_SHIFT_BITS: c_int = 8 as c_int; pub const RC_TOP_BITS: c_int = 24 as c_int; -pub const RC_TOP_VALUE: c_uint = (1 as c_uint) << RC_TOP_BITS; +pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; -pub const RC_BIT_MODEL_TOTAL: c_uint = (1 as c_uint) << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; pub const RC_MOVE_BITS: c_int = 5 as c_int; #[inline] unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> bool { @@ -394,13 +394,13 @@ unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> b } pub const STATES: c_int = 12 as c_int; pub const LIT_STATES: c_int = 7 as c_int; -pub const LITERAL_CODER_SIZE: c_uint = 0x300 as c_uint; +pub const LITERAL_CODER_SIZE: c_uint = 0x300; #[inline] unsafe extern "C" fn literal_init(mut probs: *mut probability, mut lc: u32, mut lp: u32) { let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; let mut i: size_t = 0 as size_t; while i < coders { - *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; i = i.wrapping_add(1); } } @@ -436,7 +436,7 @@ unsafe extern "C" fn rc_read_init( { return LZMA_DATA_ERROR; } - (*rc).code = (*rc).code << 8 as c_int | *in_0.offset(*in_pos as isize) as u32; + (*rc).code = (*rc).code << 8 | *in_0.offset(*in_pos as isize) as u32; *in_pos = (*in_pos).wrapping_add(1); (*rc).init_bytes_left = (*rc).init_bytes_left.wrapping_sub(1); } @@ -452,7 +452,7 @@ unsafe extern "C" fn lzma_decode( let mut current_block: u64; let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; let ret: lzma_ret = rc_read_init(&raw mut (*coder).rc, in_0, in_pos, in_size) as lzma_ret; - if ret as c_uint != LZMA_STREAM_END as c_uint { + if ret != LZMA_STREAM_END { return ret; } let mut dict: lzma_dict = *dictptr; @@ -464,7 +464,7 @@ unsafe extern "C" fn lzma_decode( if rc_in_end.offset_from(rc_in_ptr) as c_long <= 20 as c_long { rc_in_ptr } else { - rc_in_end.offset(-(20 as isize)) + rc_in_end.offset(-20) }; let mut rc_bound: u32 = 0; let mut state: u32 = (*coder).state as u32; @@ -490,7 +490,7 @@ unsafe extern "C" fn lzma_decode( dict.limit = dict.pos.wrapping_add((*coder).uncompressed_size as size_t); might_finish_without_eopm = true_0 != 0; } - match (*coder).sequence as c_uint { + match (*coder).sequence { 0 | 1 => { current_block = 5979571030476392895; } @@ -585,9 +585,8 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.choice = - ((*coder).rep_len_decoder.choice as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).rep_len_decoder.choice as c_uint) + ((*coder).rep_len_decoder.choice as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).rep_len_decoder.choice as u32) >> RC_MOVE_BITS, ) as probability as probability; probs = &raw mut *(&raw mut (*coder).rep_len_decoder.low @@ -624,9 +623,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep2[state as usize] = - ((*coder).is_rep2[state as usize] as c_uint).wrapping_add( + ((*coder).is_rep2[state as usize] as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep2[state as usize] as c_uint) + .wrapping_sub((*coder).is_rep2[state as usize] as u32) >> RC_MOVE_BITS, ) as probability as probability; let distance_3: u32 = rep2; @@ -665,9 +664,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep1[state as usize] = - ((*coder).is_rep1[state as usize] as c_uint).wrapping_add( + ((*coder).is_rep1[state as usize] as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep1[state as usize] as c_uint) + .wrapping_sub((*coder).is_rep1[state as usize] as u32) >> RC_MOVE_BITS, ) as probability as probability; let distance_2: u32 = rep1; @@ -711,11 +710,11 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0_long[state as usize][pos_state as usize] = - ((*coder).is_rep0_long[state as usize][pos_state as usize] as c_uint) + ((*coder).is_rep0_long[state as usize][pos_state as usize] as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_rep0_long[state as usize][pos_state as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; state = (if state < LIT_STATES as u32 { @@ -753,9 +752,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0[state as usize] = - ((*coder).is_rep0[state as usize] as c_uint).wrapping_add( + ((*coder).is_rep0[state as usize] as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep0[state as usize] as c_uint) + .wrapping_sub((*coder).is_rep0[state as usize] as u32) >> RC_MOVE_BITS, ) as probability as probability; current_block = 1698084742280242340; @@ -788,9 +787,8 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep[state as usize] = - ((*coder).is_rep[state as usize] as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep[state as usize] as c_uint) + ((*coder).is_rep[state as usize] as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).is_rep[state as usize] as u32) >> RC_MOVE_BITS, ) as probability as probability; state = (if state < LIT_STATES as u32 { @@ -859,11 +857,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).pos_align[offset.wrapping_add(symbol) as usize] = - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as c_uint) + ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align[offset.wrapping_add(symbol) as usize] - as c_uint, + (*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32, ) >> RC_MOVE_BITS, ) as probability as probability; } else { @@ -902,9 +899,9 @@ unsafe extern "C" fn lzma_decode( } rc.range >>= 1 as c_int; rc.code = rc.code.wrapping_sub(rc.range); - rc_bound = (0 as u32).wrapping_sub(rc.code >> 31 as c_int); + rc_bound = (0 as u32).wrapping_sub(rc.code >> 31); rc.code = rc.code.wrapping_add(rc.range & rc_bound); - rep0 = (rep0 << 1 as c_int).wrapping_add(rc_bound.wrapping_add(1 as u32)); + rep0 = (rep0 << 1).wrapping_add(rc_bound.wrapping_add(1 as u32)); limit = limit.wrapping_sub(1); if limit > 0 as u32 { current_block = 15418612220330286504; @@ -934,8 +931,8 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh133 = *probs.offset(symbol as isize); - *fresh133 = (*fresh133 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + *fresh133 = (*fresh133 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -946,8 +943,8 @@ unsafe extern "C" fn lzma_decode( *fresh134 = (*fresh134 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); - rep0 = (rep0 as c_uint).wrapping_add((1 as c_uint) << offset) as u32 as u32; + symbol = (symbol << 1).wrapping_add(1 as u32); + rep0 = (rep0 as u32).wrapping_add(1u32 << offset) as u32; } offset = offset.wrapping_add(1); if offset < limit { @@ -974,8 +971,8 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh130 = *probs.offset(symbol as isize); - *fresh130 = (*fresh130 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + *fresh130 = (*fresh130 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -986,7 +983,7 @@ unsafe extern "C" fn lzma_decode( *fresh131 = (*fresh131 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if symbol < DIST_SLOTS as u32 { current_block = 4174862988780014241; @@ -996,14 +993,14 @@ unsafe extern "C" fn lzma_decode( if symbol < DIST_MODEL_START as u32 { rep0 = symbol; } else { - limit = (symbol >> 1 as c_int).wrapping_sub(1 as u32); + limit = (symbol >> 1).wrapping_sub(1 as u32); rep0 = (2 as u32).wrapping_add(symbol & 1 as u32); if symbol < DIST_MODEL_END as u32 { rep0 <<= limit; probs = (&raw mut (*coder).pos_special as *mut probability) .offset(rep0 as isize) .offset(-(symbol as isize)) - .offset(-(1 as isize)); + .offset(-1); symbol = 1 as u32; offset = 0 as u32; current_block = 617447976488552541; @@ -1034,8 +1031,8 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh127 = *probs.offset(symbol as isize); - *fresh127 = (*fresh127 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + *fresh127 = (*fresh127 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1046,7 +1043,7 @@ unsafe extern "C" fn lzma_decode( *fresh128 = (*fresh128 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if symbol < limit { current_block = 592696588731961849; @@ -1082,9 +1079,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.choice2 = - ((*coder).match_len_decoder.choice2 as c_uint).wrapping_add( + ((*coder).match_len_decoder.choice2 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).match_len_decoder.choice2 as c_uint) + .wrapping_sub((*coder).match_len_decoder.choice2 as u32) >> RC_MOVE_BITS, ) as probability as probability; probs = &raw mut *(&raw mut (*coder).match_len_decoder.mid @@ -1123,9 +1120,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.choice = - ((*coder).match_len_decoder.choice as c_uint).wrapping_add( + ((*coder).match_len_decoder.choice as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).match_len_decoder.choice as c_uint) + .wrapping_sub((*coder).match_len_decoder.choice as u32) >> RC_MOVE_BITS, ) as probability as probability; probs = &raw mut *(&raw mut (*coder).match_len_decoder.low @@ -1173,9 +1170,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh121 = *probs.offset(subcoder_index as isize); - *fresh121 = (*fresh121 as c_uint).wrapping_add( + *fresh121 = (*fresh121 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(subcoder_index as isize) as c_uint) + .wrapping_sub(*probs.offset(subcoder_index as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1187,11 +1184,11 @@ unsafe extern "C" fn lzma_decode( *fresh122 = (*fresh122 as c_int - (*probs.offset(subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); offset &= match_bit; } len <<= 1 as c_int; - if symbol < ((1 as c_int) << 8 as c_int) as u32 { + if symbol < ((1 as c_int) << 8) as u32 { current_block = 18125716024132132232; continue; } else { @@ -1243,17 +1240,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_match[state as usize][pos_state as usize] = - ((*coder).is_match[state as usize][pos_state as usize] as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).is_match[state as usize][pos_state as usize] as c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; + (*coder).is_match[state as usize][pos_state as usize] = ((*coder).is_match + [state as usize][pos_state as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_match[state as usize][pos_state as usize] as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; probs = (&raw mut (*coder).literal as *mut probability).offset( (3 as size_t).wrapping_mul( - ((dict.pos << 8 as c_int) - .wrapping_add(dict_get0(&raw mut dict) as size_t) + ((dict.pos << 8).wrapping_add(dict_get0(&raw mut dict) as size_t) & literal_mask as size_t) << literal_context_bits, ) as isize, @@ -1273,7 +1272,7 @@ unsafe extern "C" fn lzma_decode( } else { state.wrapping_sub(6 as u32) }; - len = (dict_get(&raw mut dict, rep0) as u32) << 1 as c_int; + len = (dict_get(&raw mut dict, rep0) as u32) << 1; offset = 0x100 as u32; current_block = 18125716024132132232; continue; @@ -1307,8 +1306,8 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh118 = *probs.offset(symbol as isize); - *fresh118 = (*fresh118 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + *fresh118 = (*fresh118 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1319,9 +1318,9 @@ unsafe extern "C" fn lzma_decode( *fresh119 = (*fresh119 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } - if symbol < ((1 as c_int) << 8 as c_int) as u32 { + if symbol < ((1 as c_int) << 8) as u32 { current_block = 13844743919235296534; continue; } else { @@ -1347,8 +1346,8 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh145 = *probs.offset(symbol as isize); - *fresh145 = (*fresh145 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as c_uint) + *fresh145 = (*fresh145 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1359,7 +1358,7 @@ unsafe extern "C" fn lzma_decode( *fresh146 = (*fresh146 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if symbol < limit { current_block = 2467942631393454738; @@ -1396,9 +1395,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.choice2 = - ((*coder).rep_len_decoder.choice2 as c_uint).wrapping_add( + ((*coder).rep_len_decoder.choice2 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).rep_len_decoder.choice2 as c_uint) + .wrapping_sub((*coder).rep_len_decoder.choice2 as u32) >> RC_MOVE_BITS, ) as probability as probability; probs = &raw mut *(&raw mut (*coder).rep_len_decoder.mid @@ -1447,17 +1446,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_match[state as usize][pos_state as usize] = - ((*coder).is_match[state as usize][pos_state as usize] as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).is_match[state as usize][pos_state as usize] as c_uint, - ) >> RC_MOVE_BITS, - ) as probability as probability; + (*coder).is_match[state as usize][pos_state as usize] = ((*coder).is_match + [state as usize][pos_state as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_match[state as usize][pos_state as usize] as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; probs = (&raw mut (*coder).literal as *mut probability).offset( (3 as size_t).wrapping_mul( - ((dict.pos << 8 as c_int) - .wrapping_add(dict_get0(&raw mut dict) as size_t) + ((dict.pos << 8).wrapping_add(dict_get0(&raw mut dict) as size_t) & literal_mask as size_t) << literal_context_bits, ) as isize, @@ -1480,9 +1481,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh5 = *probs.offset(symbol as isize); - *fresh5 = (*fresh5 as c_uint).wrapping_add( + *fresh5 = (*fresh5 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1493,7 +1494,7 @@ unsafe extern "C" fn lzma_decode( *fresh6 = (*fresh6 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1506,9 +1507,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh8 = *probs.offset(symbol as isize); - *fresh8 = (*fresh8 as c_uint).wrapping_add( + *fresh8 = (*fresh8 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1519,7 +1520,7 @@ unsafe extern "C" fn lzma_decode( *fresh9 = (*fresh9 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1532,9 +1533,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh11 = *probs.offset(symbol as isize); - *fresh11 = (*fresh11 as c_uint).wrapping_add( + *fresh11 = (*fresh11 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1545,7 +1546,7 @@ unsafe extern "C" fn lzma_decode( *fresh12 = (*fresh12 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1558,9 +1559,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh14 = *probs.offset(symbol as isize); - *fresh14 = (*fresh14 as c_uint).wrapping_add( + *fresh14 = (*fresh14 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1571,7 +1572,7 @@ unsafe extern "C" fn lzma_decode( *fresh15 = (*fresh15 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1584,9 +1585,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh17 = *probs.offset(symbol as isize); - *fresh17 = (*fresh17 as c_uint).wrapping_add( + *fresh17 = (*fresh17 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1597,7 +1598,7 @@ unsafe extern "C" fn lzma_decode( *fresh18 = (*fresh18 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1610,9 +1611,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh20 = *probs.offset(symbol as isize); - *fresh20 = (*fresh20 as c_uint).wrapping_add( + *fresh20 = (*fresh20 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1623,7 +1624,7 @@ unsafe extern "C" fn lzma_decode( *fresh21 = (*fresh21 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1636,9 +1637,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh23 = *probs.offset(symbol as isize); - *fresh23 = (*fresh23 as c_uint).wrapping_add( + *fresh23 = (*fresh23 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1649,7 +1650,7 @@ unsafe extern "C" fn lzma_decode( *fresh24 = (*fresh24 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1662,9 +1663,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh26 = *probs.offset(symbol as isize); - *fresh26 = (*fresh26 as c_uint).wrapping_add( + *fresh26 = (*fresh26 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -1675,7 +1676,7 @@ unsafe extern "C" fn lzma_decode( *fresh27 = (*fresh27 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } symbol = symbol.wrapping_add(0 as u32); } else { @@ -1703,10 +1704,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh29 = *probs.offset(t_subcoder_index as isize); - *fresh29 = (*fresh29 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(t_subcoder_index as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh29 = (*fresh29 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; t_offset &= !t_match_bit; @@ -1718,7 +1719,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1735,10 +1736,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh32 = *probs.offset(t_subcoder_index as isize); - *fresh32 = (*fresh32 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(t_subcoder_index as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh32 = (*fresh32 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; t_offset &= !t_match_bit; @@ -1750,7 +1751,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1767,10 +1768,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh35 = *probs.offset(t_subcoder_index as isize); - *fresh35 = (*fresh35 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(t_subcoder_index as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh35 = (*fresh35 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; t_offset &= !t_match_bit; @@ -1782,7 +1783,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1799,10 +1800,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh38 = *probs.offset(t_subcoder_index as isize); - *fresh38 = (*fresh38 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(t_subcoder_index as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh38 = (*fresh38 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; t_offset &= !t_match_bit; @@ -1814,7 +1815,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1831,10 +1832,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh41 = *probs.offset(t_subcoder_index as isize); - *fresh41 = (*fresh41 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(t_subcoder_index as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh41 = (*fresh41 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; t_offset &= !t_match_bit; @@ -1846,7 +1847,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1863,10 +1864,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh44 = *probs.offset(t_subcoder_index as isize); - *fresh44 = (*fresh44 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(t_subcoder_index as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh44 = (*fresh44 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; t_offset &= !t_match_bit; @@ -1878,7 +1879,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1895,10 +1896,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh47 = *probs.offset(t_subcoder_index as isize); - *fresh47 = (*fresh47 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(t_subcoder_index as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh47 = (*fresh47 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; t_offset &= !t_match_bit; @@ -1910,7 +1911,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1927,10 +1928,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh50 = *probs.offset(t_subcoder_index as isize); - *fresh50 = (*fresh50 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(t_subcoder_index as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh50 = (*fresh50 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; t_offset &= !t_match_bit; @@ -1942,7 +1943,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); t_offset &= t_match_bit; } } @@ -1965,9 +1966,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep[state as usize] = - ((*coder).is_rep[state as usize] as c_uint).wrapping_add( + ((*coder).is_rep[state as usize] as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep[state as usize] as c_uint) + .wrapping_sub((*coder).is_rep[state as usize] as u32) >> RC_MOVE_BITS, ) as probability as probability; state = (if state < LIT_STATES as u32 { @@ -1990,9 +1991,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.choice = - ((*coder).match_len_decoder.choice as c_uint).wrapping_add( + ((*coder).match_len_decoder.choice as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).match_len_decoder.choice as c_uint) + .wrapping_sub((*coder).match_len_decoder.choice as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol = 1 as u32; @@ -2011,12 +2012,12 @@ unsafe extern "C" fn lzma_decode( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -2034,7 +2035,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2051,12 +2052,12 @@ unsafe extern "C" fn lzma_decode( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -2074,7 +2075,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2091,12 +2092,12 @@ unsafe extern "C" fn lzma_decode( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -2114,10 +2115,10 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } - symbol = symbol - .wrapping_add((-((1 as c_int) << 3 as c_int) + 2 as c_int) as u32); + symbol = + symbol.wrapping_add((-((1 as c_int) << 3) + 2 as c_int) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2137,9 +2138,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.choice2 = - ((*coder).match_len_decoder.choice2 as c_uint).wrapping_add( + ((*coder).match_len_decoder.choice2 as u32).wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.choice2 as c_uint, + (*coder).match_len_decoder.choice2 as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -2161,12 +2162,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -2185,7 +2186,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2204,12 +2205,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -2228,7 +2229,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2247,12 +2248,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -2271,12 +2272,10 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } symbol = symbol.wrapping_add( - (-((1 as c_int) << 3 as c_int) - + 2 as c_int - + ((1 as c_int) << 3 as c_int)) + (-((1 as c_int) << 3) + 2 as c_int + ((1 as c_int) << 3)) as u32, ); len = symbol; @@ -2300,18 +2299,15 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2322,7 +2318,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2335,18 +2331,15 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2357,7 +2350,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2370,18 +2363,15 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2392,7 +2382,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2405,18 +2395,15 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2427,7 +2414,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2440,18 +2427,15 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2462,7 +2446,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2475,18 +2459,15 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2497,7 +2478,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2510,18 +2491,15 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2532,7 +2510,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2545,18 +2523,15 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.high[symbol as usize] = ((*coder) - .match_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).match_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).match_len_decoder.high[symbol as usize] = + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).match_len_decoder.high[symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2567,13 +2542,13 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } symbol = symbol.wrapping_add( - (-((1 as c_int) << 8 as c_int) + (-((1 as c_int) << 8) + 2 as c_int - + ((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 3 as c_int)) + + ((1 as c_int) << 3) + + ((1 as c_int) << 3)) as u32, ); len = symbol; @@ -2599,9 +2574,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh70 = *probs.offset(symbol as isize); - *fresh70 = (*fresh70 as c_uint).wrapping_add( + *fresh70 = (*fresh70 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -2612,7 +2587,7 @@ unsafe extern "C" fn lzma_decode( *fresh71 = (*fresh71 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2625,9 +2600,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh73 = *probs.offset(symbol as isize); - *fresh73 = (*fresh73 as c_uint).wrapping_add( + *fresh73 = (*fresh73 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -2638,7 +2613,7 @@ unsafe extern "C" fn lzma_decode( *fresh74 = (*fresh74 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2651,9 +2626,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh76 = *probs.offset(symbol as isize); - *fresh76 = (*fresh76 as c_uint).wrapping_add( + *fresh76 = (*fresh76 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -2664,7 +2639,7 @@ unsafe extern "C" fn lzma_decode( *fresh77 = (*fresh77 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2677,9 +2652,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh79 = *probs.offset(symbol as isize); - *fresh79 = (*fresh79 as c_uint).wrapping_add( + *fresh79 = (*fresh79 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -2690,7 +2665,7 @@ unsafe extern "C" fn lzma_decode( *fresh80 = (*fresh80 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2703,9 +2678,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh82 = *probs.offset(symbol as isize); - *fresh82 = (*fresh82 as c_uint).wrapping_add( + *fresh82 = (*fresh82 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -2716,7 +2691,7 @@ unsafe extern "C" fn lzma_decode( *fresh83 = (*fresh83 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2729,9 +2704,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh85 = *probs.offset(symbol as isize); - *fresh85 = (*fresh85 as c_uint).wrapping_add( + *fresh85 = (*fresh85 as u32).wrapping_add( RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as c_uint) + .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, ) as probability as probability; symbol <<= 1 as c_int; @@ -2742,20 +2717,20 @@ unsafe extern "C" fn lzma_decode( *fresh86 = (*fresh86 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } - symbol = symbol.wrapping_add(-((1 as c_int) << 6 as c_int) as u32); + symbol = symbol.wrapping_add(-((1 as c_int) << 6) as u32); if symbol < DIST_MODEL_START as u32 { rep0 = symbol; } else { - limit = (symbol >> 1 as c_int).wrapping_sub(1 as u32); + limit = (symbol >> 1).wrapping_sub(1 as u32); rep0 = (2 as u32).wrapping_add(symbol & 1 as u32); if symbol < DIST_MODEL_END as u32 { rep0 <<= limit; probs = (&raw mut (*coder).pos_special as *mut probability) .offset(rep0 as isize) .offset(-(symbol as isize)) - .offset(-(1 as isize)); + .offset(-1); symbol = 1 as u32; offset = 1 as u32; loop { @@ -2770,10 +2745,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; let ref mut fresh88 = *probs.offset(symbol as isize); - *fresh88 = (*fresh88 as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - *probs.offset(symbol as isize) as c_uint, - ) >> RC_MOVE_BITS, + *fresh88 = (*fresh88 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, ) as probability as probability; @@ -2786,7 +2761,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); rep0 = rep0.wrapping_add(offset); } offset <<= 1 as c_int; @@ -2798,7 +2773,7 @@ unsafe extern "C" fn lzma_decode( } else { limit = limit.wrapping_sub(ALIGN_BITS as u32); loop { - rep0 = (rep0 << 1 as c_int).wrapping_add(1 as u32); + rep0 = (rep0 << 1).wrapping_add(1 as u32); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh90 = rc_in_ptr; @@ -2807,7 +2782,7 @@ unsafe extern "C" fn lzma_decode( } rc.range >>= 1 as c_int; rc.code = rc.code.wrapping_sub(rc.range); - rc_bound = (0 as u32).wrapping_sub(rc.code >> 31 as c_int); + rc_bound = (0 as u32).wrapping_sub(rc.code >> 31); rep0 = rep0.wrapping_add(rc_bound); rc.code = rc.code.wrapping_add(rc.range & rc_bound); limit = limit.wrapping_sub(1); @@ -2831,12 +2806,12 @@ unsafe extern "C" fn lzma_decode( rc.range = rc_bound; (*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] = ((*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).pos_align [symbol.wrapping_add(1 as u32) as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -2867,12 +2842,12 @@ unsafe extern "C" fn lzma_decode( rc.range = rc_bound; (*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] = ((*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).pos_align [symbol.wrapping_add(2 as u32) as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -2903,12 +2878,12 @@ unsafe extern "C" fn lzma_decode( rc.range = rc_bound; (*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] = ((*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).pos_align [symbol.wrapping_add(4 as u32) as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -2939,12 +2914,12 @@ unsafe extern "C" fn lzma_decode( rc.range = rc_bound; (*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] = ((*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).pos_align [symbol.wrapping_add(8 as u32) as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -2996,10 +2971,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0[state as usize] = - ((*coder).is_rep0[state as usize] as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).is_rep0[state as usize] as c_uint, - ) >> RC_MOVE_BITS, + ((*coder).is_rep0[state as usize] as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).is_rep0[state as usize] as u32) + >> RC_MOVE_BITS, ) as probability as probability; if rc.range < RC_TOP_VALUE as u32 { @@ -3016,12 +2991,12 @@ unsafe extern "C" fn lzma_decode( rc.range = rc_bound; (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder).is_rep0_long[state as usize][pos_state as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_rep0_long[state as usize] [pos_state as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -3062,9 +3037,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep1[state as usize] = - ((*coder).is_rep1[state as usize] as c_uint).wrapping_add( + ((*coder).is_rep1[state as usize] as u32).wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).is_rep1[state as usize] as c_uint, + (*coder).is_rep1[state as usize] as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -3090,12 +3065,11 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep2[state as usize] = - ((*coder).is_rep2[state as usize] as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).is_rep2[state as usize] as c_uint, - ) >> RC_MOVE_BITS, - ) + ((*coder).is_rep2[state as usize] as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).is_rep2[state as usize] as u32, + ) >> RC_MOVE_BITS, + ) as probability as probability; let distance_0: u32 = rep2; @@ -3135,10 +3109,10 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.choice = - ((*coder).rep_len_decoder.choice as c_uint).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.choice as c_uint, - ) >> RC_MOVE_BITS, + ((*coder).rep_len_decoder.choice as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).rep_len_decoder.choice as u32) + >> RC_MOVE_BITS, ) as probability as probability; symbol = 1 as u32; @@ -3159,12 +3133,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -3182,7 +3156,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3201,12 +3175,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -3224,7 +3198,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3243,12 +3217,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -3266,11 +3240,10 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } - symbol = symbol.wrapping_add( - (-((1 as c_int) << 3 as c_int) + 2 as c_int) as u32, - ); + symbol = + symbol.wrapping_add((-((1 as c_int) << 3) + 2 as c_int) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3290,9 +3263,9 @@ unsafe extern "C" fn lzma_decode( if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.choice2 = - ((*coder).rep_len_decoder.choice2 as c_uint).wrapping_add( + ((*coder).rep_len_decoder.choice2 as u32).wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.choice2 as c_uint, + (*coder).rep_len_decoder.choice2 as u32, ) >> RC_MOVE_BITS, ) as probability as probability; @@ -3314,12 +3287,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -3338,7 +3311,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3357,12 +3330,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -3381,7 +3354,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3400,12 +3373,12 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_uint) + as u32) .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_uint, + as u32, ) >> RC_MOVE_BITS, ) as probability @@ -3424,12 +3397,10 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } symbol = symbol.wrapping_add( - (-((1 as c_int) << 3 as c_int) - + 2 as c_int - + ((1 as c_int) << 3 as c_int)) + (-((1 as c_int) << 3) + 2 as c_int + ((1 as c_int) << 3)) as u32, ); len = symbol; @@ -3453,18 +3424,17 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high + [symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3476,7 +3446,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3489,18 +3459,17 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high + [symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3512,7 +3481,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3525,18 +3494,17 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high + [symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3548,7 +3516,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3561,18 +3529,17 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high + [symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3584,7 +3551,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3597,18 +3564,17 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high + [symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3620,7 +3586,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3633,18 +3599,17 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high + [symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3656,7 +3621,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3669,18 +3634,17 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high + [symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3692,7 +3656,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3705,18 +3669,17 @@ unsafe extern "C" fn lzma_decode( ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.high[symbol as usize] = ((*coder) - .rep_len_decoder - .high[symbol as usize] - as c_uint) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).rep_len_decoder.high[symbol as usize] - as c_uint, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + (*coder).rep_len_decoder.high[symbol as usize] = + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).rep_len_decoder.high + [symbol as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1 as c_int; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3728,13 +3691,13 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1 as c_int).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1 as u32); } symbol = symbol.wrapping_add( - (-((1 as c_int) << 8 as c_int) + (-((1 as c_int) << 8) + 2 as c_int - + ((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 3 as c_int)) + + ((1 as c_int) << 3) + + ((1 as c_int) << 3)) as u32, ); len = symbol; @@ -3796,15 +3759,15 @@ unsafe extern "C" fn lzma_decode( .uncompressed_size .wrapping_sub(dict.pos.wrapping_sub(dict_start) as lzma_vli); if (*coder).uncompressed_size == 0 as lzma_vli - && ret_0 as c_uint == LZMA_OK as c_uint - && ((*coder).sequence as c_uint == SEQ_LITERAL_WRITE as c_uint - || (*coder).sequence as c_uint == SEQ_SHORTREP as c_uint - || (*coder).sequence as c_uint == SEQ_COPY as c_uint) + && ret_0 == LZMA_OK + && ((*coder).sequence == SEQ_LITERAL_WRITE + || (*coder).sequence == SEQ_SHORTREP + || (*coder).sequence == SEQ_COPY) { ret_0 = LZMA_DATA_ERROR; } } - if ret_0 as c_uint == LZMA_STREAM_END as c_uint { + if ret_0 == LZMA_STREAM_END { (*coder).rc.range = UINT32_MAX as u32; (*coder).rc.code = 0 as u32; (*coder).rc.init_bytes_left = 5 as u32; @@ -3824,7 +3787,7 @@ unsafe extern "C" fn lzma_decoder_uncompressed( unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *const c_void) { let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; let mut options: *const lzma_options_lzma = opt as *const lzma_options_lzma; - (*coder).pos_mask = ((1 as c_uint) << (*options).pb).wrapping_sub(1 as c_uint) as u32; + (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; literal_init( &raw mut (*coder).literal as *mut probability, (*options).lc, @@ -3832,13 +3795,13 @@ unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *co ); (*coder).literal_context_bits = (*options).lc; (*coder).literal_mask = - ((0x100 as c_uint) << (*options).lp).wrapping_sub(0x100 as c_uint >> (*options).lc) as u32; + ((0x100 as u32) << (*options).lp).wrapping_sub(0x100 >> (*options).lc) as u32; (*coder).state = STATE_LIT_LIT; (*coder).rep0 = 0 as u32; (*coder).rep1 = 0 as u32; (*coder).rep2 = 0 as u32; (*coder).rep3 = 0 as u32; - (*coder).pos_mask = ((1 as c_uint) << (*options).pb).wrapping_sub(1 as c_uint) as u32; + (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; (*coder).rc.range = UINT32_MAX as u32; (*coder).rc.code = 0 as u32; (*coder).rc.init_bytes_left = 5 as u32; @@ -3846,81 +3809,78 @@ unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *co while i < STATES as u32 { let mut j: u32 = 0 as u32; while j <= (*coder).pos_mask { - (*coder).is_match[i as usize][j as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_match[i as usize][j as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep0_long[i as usize][j as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; j = j.wrapping_add(1); } - (*coder).is_rep[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).is_rep0[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).is_rep1[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).is_rep2[i as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).is_rep0[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).is_rep1[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).is_rep2[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; i = i.wrapping_add(1); } let mut i_0: u32 = 0 as u32; while i_0 < DIST_STATES as u32 { let mut bt_i: u32 = 0 as u32; - while bt_i < ((1 as c_int) << 6 as c_int) as u32 { + while bt_i < ((1 as c_int) << 6) as u32 { (*coder).dist_slot[i_0 as usize][bt_i as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i = bt_i.wrapping_add(1); } i_0 = i_0.wrapping_add(1); } let mut i_1: u32 = 0 as u32; while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as u32 { - (*coder).pos_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).pos_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; i_1 = i_1.wrapping_add(1); } let mut bt_i_0: u32 = 0 as u32; - while bt_i_0 < ((1 as c_int) << 4 as c_int) as u32 { - (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + while bt_i_0 < ((1 as c_int) << 4) as u32 { + (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } let num_pos_states: u32 = (1 as u32) << (*options).pb; - (*coder).match_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).match_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).rep_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).rep_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).match_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).match_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).rep_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).rep_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1) as probability; let mut pos_state: u32 = 0 as u32; while pos_state < num_pos_states { let mut bt_i_1: u32 = 0 as u32; - while bt_i_1 < ((1 as c_int) << 3 as c_int) as u32 { + while bt_i_1 < ((1 as c_int) << 3) as u32 { (*coder).match_len_decoder.low[pos_state as usize][bt_i_1 as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_1 = bt_i_1.wrapping_add(1); } let mut bt_i_2: u32 = 0 as u32; - while bt_i_2 < ((1 as c_int) << 3 as c_int) as u32 { + while bt_i_2 < ((1 as c_int) << 3) as u32 { (*coder).match_len_decoder.mid[pos_state as usize][bt_i_2 as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_2 = bt_i_2.wrapping_add(1); } let mut bt_i_3: u32 = 0 as u32; - while bt_i_3 < ((1 as c_int) << 3 as c_int) as u32 { + while bt_i_3 < ((1 as c_int) << 3) as u32 { (*coder).rep_len_decoder.low[pos_state as usize][bt_i_3 as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_3 = bt_i_3.wrapping_add(1); } let mut bt_i_4: u32 = 0 as u32; - while bt_i_4 < ((1 as c_int) << 3 as c_int) as u32 { + while bt_i_4 < ((1 as c_int) << 3) as u32 { (*coder).rep_len_decoder.mid[pos_state as usize][bt_i_4 as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_4 = bt_i_4.wrapping_add(1); } pos_state = pos_state.wrapping_add(1); } let mut bt_i_5: u32 = 0 as u32; - while bt_i_5 < ((1 as c_int) << 8 as c_int) as u32 { - (*coder).match_len_decoder.high[bt_i_5 as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + while bt_i_5 < ((1 as c_int) << 8) as u32 { + (*coder).match_len_decoder.high[bt_i_5 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_5 = bt_i_5.wrapping_add(1); } let mut bt_i_6: u32 = 0 as u32; - while bt_i_6 < ((1 as c_int) << 8 as c_int) as u32 { - (*coder).rep_len_decoder.high[bt_i_6 as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + while bt_i_6 < ((1 as c_int) << 8) as u32 { + (*coder).rep_len_decoder.high[bt_i_6 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_6 = bt_i_6.wrapping_add(1); } (*coder).sequence = SEQ_IS_MATCH; @@ -3994,8 +3954,7 @@ unsafe extern "C" fn lzma_decoder_init( if (*opt).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; } - uncomp_size = ((*opt).ext_size_low as u64) - .wrapping_add(((*opt).ext_size_high as u64) << 32 as c_int) + uncomp_size = ((*opt).ext_size_low as u64).wrapping_add(((*opt).ext_size_high as u64) << 32) as lzma_vli; allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 as u32 || uncomp_size == LZMA_VLI_UNKNOWN as lzma_vli; @@ -4006,7 +3965,7 @@ unsafe extern "C" fn lzma_decoder_init( options as *const lzma_options_lzma, lz_options, ) as lzma_ret; - if ret_ as c_uint != LZMA_OK as c_uint { + if ret_ != LZMA_OK { return ret_; } lzma_decoder_reset((*lz).coder, options); @@ -4080,11 +4039,11 @@ pub unsafe extern "C" fn lzma_lzma_props_decode( if opt.is_null() { return LZMA_MEM_ERROR; } - if lzma_lzma_lclppb_decode(opt, *props.offset(0 as isize)) { + if lzma_lzma_lclppb_decode(opt, *props.offset(0)) { lzma_free(opt as *mut c_void, allocator); return LZMA_OPTIONS_ERROR; } else { - (*opt).dict_size = read32le(props.offset(1 as isize)); + (*opt).dict_size = read32le(props.offset(1)); (*opt).preset_dict = ::core::ptr::null::(); (*opt).preset_dict_size = 0 as u32; *options = opt as *mut c_void; diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 7e5a94b7..a879984f 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -321,23 +321,23 @@ pub struct lzma_length_encoder { pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT32_MAX: c_uint = 4294967295; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0 as isize) = num as u8; - *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; - *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; - *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; } -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001 as c_ulonglong; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002 as c_ulonglong; +pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; +pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; pub const LZMA_LCLP_MAX: c_int = 4 as c_int; pub const LZMA_PB_MAX: c_int = 4 as c_int; -pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1 as c_uint; -pub const LZMA2_CHUNK_MAX: c_uint = (1 as c_uint) << 16 as c_int; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; +pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; #[inline] unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> u32 { return match_finder as u32 & 0xf as u32; @@ -351,9 +351,9 @@ unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: u32) { } pub const RC_SHIFT_BITS: c_int = 8 as c_int; pub const RC_TOP_BITS: c_int = 24 as c_int; -pub const RC_TOP_VALUE: c_uint = (1 as c_uint) << RC_TOP_BITS; +pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; -pub const RC_BIT_MODEL_TOTAL: c_uint = (1 as c_uint) << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; pub const RC_MOVE_BITS: c_int = 5 as c_int; pub const RC_MOVE_REDUCING_BITS: c_int = 4 as c_int; #[inline] @@ -368,8 +368,9 @@ unsafe extern "C" fn rc_bit_0_price(prob: probability) -> u32 { } #[inline] unsafe extern "C" fn rc_bit_1_price(prob: probability) -> u32 { - return lzma_rc_prices[((prob as c_uint ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1 as c_uint)) - >> RC_MOVE_REDUCING_BITS) as usize] as u32; + return lzma_rc_prices + [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] + as u32; } #[inline] unsafe extern "C" fn rc_bittree_price( @@ -378,7 +379,7 @@ unsafe extern "C" fn rc_bittree_price( mut symbol: u32, ) -> u32 { let mut price: u32 = 0 as u32; - symbol = (symbol as c_uint).wrapping_add((1 as c_uint) << bit_levels) as u32 as u32; + symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; loop { let bit: u32 = symbol & 1 as u32; symbol >>= 1 as c_int; @@ -429,7 +430,7 @@ unsafe extern "C" fn rc_bittree( probs.offset(model_index as isize) as *mut probability, bit, ); - model_index = (model_index << 1 as c_int).wrapping_add(bit); + model_index = (model_index << 1).wrapping_add(bit); if !(bit_count != 0 as u32) { break; } @@ -451,7 +452,7 @@ unsafe extern "C" fn rc_bittree_reverse( probs.offset(model_index as isize) as *mut probability, bit, ); - model_index = (model_index << 1 as c_int).wrapping_add(bit); + model_index = (model_index << 1).wrapping_add(bit); bit_count = bit_count.wrapping_sub(1); if !(bit_count != 0 as u32) { break; @@ -492,15 +493,13 @@ unsafe extern "C" fn rc_shift_low( mut out_pos: *mut size_t, mut out_size: size_t, ) -> bool { - if ((*rc).low as u32) < 0xff000000 as c_uint as u32 - || ((*rc).low >> 32 as c_int) as u32 != 0 as u32 - { + if ((*rc).low as u32) < 0xff000000 as u32 || ((*rc).low >> 32) as u32 != 0 as u32 { loop { if *out_pos == out_size { return true_0 != 0; } *out.offset(*out_pos as isize) = - ((*rc).cache as c_int + ((*rc).low >> 32 as c_int) as u8 as c_int) as u8; + ((*rc).cache as c_int + ((*rc).low >> 32) as u8 as c_int) as u8; *out_pos = (*out_pos).wrapping_add(1); (*rc).out_total = (*rc).out_total.wrapping_add(1); (*rc).cache = 0xff as u8; @@ -509,7 +508,7 @@ unsafe extern "C" fn rc_shift_low( break; } } - (*rc).cache = ((*rc).low >> 24 as c_int & 0xff as u64) as u8; + (*rc).cache = ((*rc).low >> 24 & 0xff as u64) as u8; } (*rc).cache_size = (*rc).cache_size.wrapping_add(1); (*rc).low = ((*rc).low & 0xffffff as u64) << RC_SHIFT_BITS; @@ -523,7 +522,7 @@ unsafe extern "C" fn rc_shift_low_dummy( mut out_pos: *mut u64, mut out_size: u64, ) -> bool { - if (*low as u32) < 0xff000000 as c_uint as u32 || (*low >> 32 as c_int) as u32 != 0 as u32 { + if (*low as u32) < 0xff000000 as u32 || (*low >> 32) as u32 != 0 as u32 { loop { if *out_pos == out_size { return true_0 != 0; @@ -535,7 +534,7 @@ unsafe extern "C" fn rc_shift_low_dummy( break; } } - *cache = (*low >> 24 as c_int & 0xff as u64) as u8; + *cache = (*low >> 24 & 0xff as u64) as u8; } *cache_size = (*cache_size).wrapping_add(1); *low = (*low & 0xffffff as u64) << RC_SHIFT_BITS; @@ -555,12 +554,12 @@ unsafe extern "C" fn rc_encode( } (*rc).range <<= RC_SHIFT_BITS; } - match (*rc).symbols[(*rc).pos as usize] as c_uint { + match (*rc).symbols[(*rc).pos as usize] { 0 => { let mut prob: probability = *(*rc).probs[(*rc).pos as usize]; (*rc).range = ((*rc).range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul(prob as u32); - prob = (prob as c_uint) - .wrapping_add(RC_BIT_MODEL_TOTAL.wrapping_sub(prob as c_uint) >> RC_MOVE_BITS) + prob = (prob as u32) + .wrapping_add(RC_BIT_MODEL_TOTAL.wrapping_sub(prob as u32) >> RC_MOVE_BITS) as probability as probability; *(*rc).probs[(*rc).pos as usize] = prob; } @@ -629,7 +628,7 @@ unsafe extern "C" fn rc_encode_dummy( if pos == (*rc).count { break; } - match (*rc).symbols[pos as usize] as c_uint { + match (*rc).symbols[pos as usize] { 0 => { let mut prob: probability = *(*rc).probs[pos as usize]; range = (range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul(prob as u32); @@ -682,13 +681,13 @@ unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> b } pub const STATES: c_int = 12 as c_int; pub const LIT_STATES: c_int = 7 as c_int; -pub const LITERAL_CODER_SIZE: c_uint = 0x300 as c_uint; +pub const LITERAL_CODER_SIZE: c_uint = 0x300; #[inline] unsafe extern "C" fn literal_init(mut probs: *mut probability, mut lc: u32, mut lp: u32) { let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; let mut i: size_t = 0 as size_t; while i < coders { - *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; i = i.wrapping_add(1); } } @@ -711,7 +710,7 @@ pub const ALIGN_BITS: c_int = 4 as c_int; pub const ALIGN_SIZE: c_int = (1 as c_int) << ALIGN_BITS; pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1 as c_int; pub const REPS: c_int = 4 as c_int; -pub const OPTS: c_int = (1 as c_int) << 12 as c_int; +pub const OPTS: c_int = (1 as c_int) << 12; pub const FASTPOS_BITS: c_int = 13 as c_int; #[inline] unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { @@ -719,15 +718,13 @@ unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { return lzma_fastpos[dist as usize] as u32; } if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { - return (lzma_fastpos - [(dist >> 0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } - return (lzma_fastpos[(dist >> 0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] - as u32) + return (lzma_fastpos[(dist >> 0 + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); @@ -740,14 +737,12 @@ unsafe extern "C" fn literal_matched( mut symbol: u32, ) { let mut offset: u32 = 0x100 as u32; - symbol = (symbol as c_uint).wrapping_add((1 as c_uint) << 8 as c_int) as u32 as u32; + symbol = (symbol as u32).wrapping_add(1u32 << 8) as u32; loop { match_byte <<= 1 as c_int; let match_bit: u32 = match_byte & offset; - let subcoder_index: u32 = offset - .wrapping_add(match_bit) - .wrapping_add(symbol >> 8 as c_int); - let bit: u32 = symbol >> 7 as c_int & 1 as u32; + let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol >> 8); + let bit: u32 = symbol >> 7 & 1 as u32; rc_bit( rc, subcoder.offset(subcoder_index as isize) as *mut probability, @@ -755,7 +750,7 @@ unsafe extern "C" fn literal_matched( ); symbol <<= 1 as c_int; offset &= !(match_byte ^ symbol); - if !(symbol < (1 as u32) << 16 as c_int) { + if !(symbol < (1 as u32) << 16) { break; } } @@ -771,7 +766,7 @@ unsafe extern "C" fn literal( .offset((*mf).read_pos.wrapping_sub((*mf).read_ahead) as isize); let mut subcoder: *mut probability = (&raw mut (*coder).literal as *mut probability).offset( (3 as u32).wrapping_mul( - ((position << 8 as c_int).wrapping_add( + ((position << 8).wrapping_add( *(*mf).buffer.offset( (*mf) .read_pos @@ -782,23 +777,23 @@ unsafe extern "C" fn literal( << (*coder).literal_context_bits, ) as isize, ); - if ((*coder).state as c_uint) < LIT_STATES as c_uint { - (*coder).state = (if (*coder).state as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { - STATE_LIT_LIT as c_uint + if ((*coder).state as u32) < LIT_STATES as u32 { + (*coder).state = (if (*coder).state <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT } else { - ((*coder).state as c_uint).wrapping_sub(3 as c_uint) + ((*coder).state as u32).wrapping_sub(3) }) as lzma_lzma_state; rc_bittree(&raw mut (*coder).rc, subcoder, 8 as u32, cur_byte as u32); } else { - (*coder).state = (if (*coder).state as c_uint <= STATE_LIT_SHORTREP as c_uint { - ((*coder).state as c_uint).wrapping_sub(3 as c_uint) + (*coder).state = (if (*coder).state <= STATE_LIT_SHORTREP { + ((*coder).state as u32).wrapping_sub(3) } else { - ((*coder).state as c_uint).wrapping_sub(6 as c_uint) + ((*coder).state as u32).wrapping_sub(6) }) as lzma_lzma_state; let match_byte: u8 = *(*mf).buffer.offset( (*mf) .read_pos - .wrapping_sub((*coder).reps[0 as usize]) + .wrapping_sub((*coder).reps[0]) .wrapping_sub(1 as u32) .wrapping_sub((*mf).read_ahead) as isize, ); @@ -904,7 +899,7 @@ unsafe extern "C" fn match_0( distance: u32, len: u32, ) { - (*coder).state = (if ((*coder).state as c_uint) < LIT_STATES as c_uint { + (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { STATE_LIT_MATCH as c_int } else { STATE_NONLIT_MATCH as c_int @@ -930,7 +925,7 @@ unsafe extern "C" fn match_0( dist_slot, ); if dist_slot >= DIST_MODEL_START as u32 { - let footer_bits: u32 = (dist_slot >> 1 as c_int).wrapping_sub(1 as u32); + let footer_bits: u32 = (dist_slot >> 1).wrapping_sub(1 as u32); let base: u32 = (2 as u32 | dist_slot & 1 as u32) << footer_bits; let dist_reduced: u32 = distance.wrapping_sub(base); if dist_slot < DIST_MODEL_END as u32 { @@ -939,7 +934,7 @@ unsafe extern "C" fn match_0( (&raw mut (*coder).dist_special as *mut probability) .offset(base as isize) .offset(-(dist_slot as isize)) - .offset(-(1 as isize)), + .offset(-1), footer_bits, dist_reduced, ); @@ -958,10 +953,10 @@ unsafe extern "C" fn match_0( (*coder).align_price_count = (*coder).align_price_count.wrapping_add(1); } } - (*coder).reps[3 as usize] = (*coder).reps[2 as usize]; - (*coder).reps[2 as usize] = (*coder).reps[1 as usize]; - (*coder).reps[1 as usize] = (*coder).reps[0 as usize]; - (*coder).reps[0 as usize] = distance; + (*coder).reps[3] = (*coder).reps[2]; + (*coder).reps[2] = (*coder).reps[1]; + (*coder).reps[1] = (*coder).reps[0]; + (*coder).reps[0] = distance; (*coder).match_price_count = (*coder).match_price_count.wrapping_add(1); } #[inline] @@ -1014,15 +1009,15 @@ unsafe extern "C" fn rep_match( rep.wrapping_sub(2 as u32), ); if rep == 3 as u32 { - (*coder).reps[3 as usize] = (*coder).reps[2 as usize]; + (*coder).reps[3] = (*coder).reps[2]; } - (*coder).reps[2 as usize] = (*coder).reps[1 as usize]; + (*coder).reps[2] = (*coder).reps[1]; } - (*coder).reps[1 as usize] = (*coder).reps[0 as usize]; - (*coder).reps[0 as usize] = distance; + (*coder).reps[1] = (*coder).reps[0]; + (*coder).reps[0] = distance; } if len == 1 as u32 { - (*coder).state = (if ((*coder).state as c_uint) < LIT_STATES as c_uint { + (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { STATE_LIT_SHORTREP as c_int } else { STATE_NONLIT_REP as c_int @@ -1035,7 +1030,7 @@ unsafe extern "C" fn rep_match( len, (*coder).fast_mode, ); - (*coder).state = (if ((*coder).state as c_uint) < LIT_STATES as c_uint { + (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { STATE_LIT_LONGREP as c_int } else { STATE_NONLIT_REP as c_int @@ -1089,7 +1084,7 @@ unsafe extern "C" fn encode_symbol( } unsafe extern "C" fn encode_init(mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf) -> bool { if (*mf).read_pos == (*mf).read_limit { - if (*mf).action as c_uint == LZMA_RUN as c_uint { + if (*mf).action == LZMA_RUN { return false_0 != 0; } } else { @@ -1097,16 +1092,16 @@ unsafe extern "C" fn encode_init(mut coder: *mut lzma_lzma1_encoder, mut mf: *mu (*mf).read_ahead = 0 as u32; rc_bit( &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]).offset(0 as isize) + (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]).offset(0) as *mut probability) - .offset(0 as isize) as *mut probability, + .offset(0) as *mut probability, 0 as u32, ); rc_bittree( &raw mut (*coder).rc, - (&raw mut (*coder).literal as *mut probability).offset(0 as isize), + (&raw mut (*coder).literal as *mut probability).offset(0), 8 as u32, - *(*mf).buffer.offset(0 as isize) as u32, + *(*mf).buffer.offset(0) as u32, ); (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(1); } @@ -1152,10 +1147,10 @@ pub unsafe extern "C" fn lzma_lzma_encode( while !(limit != UINT32_MAX as u32 && ((*mf).read_pos.wrapping_sub((*mf).read_ahead) >= limit || (*out_pos as u64).wrapping_add(rc_pending(&raw mut (*coder).rc)) - >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX as c_uint) as u64)) + >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX as u32) as u64)) { if (*mf).read_pos >= (*mf).read_limit { - if (*mf).action as c_uint == LZMA_RUN as c_uint { + if (*mf).action == LZMA_RUN { return LZMA_OK; } if (*mf).read_ahead == 0 as u32 { @@ -1208,7 +1203,7 @@ unsafe extern "C" fn lzma_encode( mut out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { - if ((*mf).action as c_uint == LZMA_SYNC_FLUSH as c_uint) as c_long != 0 { + if ((*mf).action == LZMA_SYNC_FLUSH) as c_long != 0 { return LZMA_OPTIONS_ERROR; } return lzma_lzma_encode( @@ -1238,8 +1233,7 @@ unsafe extern "C" fn is_options_valid(mut options: *const lzma_options_lzma) -> return is_lclppb_valid(options) as c_int != 0 && (*options).nice_len >= MATCH_LEN_MIN as u32 && (*options).nice_len <= MATCH_LEN_MAX as u32 - && ((*options).mode as c_uint == LZMA_MODE_FAST as c_uint - || (*options).mode as c_uint == LZMA_MODE_NORMAL as c_uint); + && ((*options).mode == LZMA_MODE_FAST || (*options).mode == LZMA_MODE_NORMAL); } unsafe extern "C" fn set_lz_options( mut lz_options: *mut lzma_lz_options, @@ -1264,27 +1258,27 @@ unsafe extern "C" fn length_encoder_reset( num_pos_states: u32, fast_mode: bool, ) { - (*lencoder).choice = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*lencoder).choice2 = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*lencoder).choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*lencoder).choice2 = (RC_BIT_MODEL_TOTAL >> 1) as probability; let mut pos_state: size_t = 0 as size_t; while pos_state < num_pos_states as size_t { let mut bt_i: u32 = 0 as u32; - while bt_i < ((1 as c_int) << 3 as c_int) as u32 { + while bt_i < ((1 as c_int) << 3) as u32 { (*lencoder).low[pos_state as usize][bt_i as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i = bt_i.wrapping_add(1); } let mut bt_i_0: u32 = 0 as u32; - while bt_i_0 < ((1 as c_int) << 3 as c_int) as u32 { + while bt_i_0 < ((1 as c_int) << 3) as u32 { (*lencoder).mid[pos_state as usize][bt_i_0 as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } pos_state = pos_state.wrapping_add(1); } let mut bt_i_1: u32 = 0 as u32; - while bt_i_1 < ((1 as c_int) << 8 as c_int) as u32 { - (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + while bt_i_1 < ((1 as c_int) << 8) as u32 { + (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_1 = bt_i_1.wrapping_add(1); } if !fast_mode { @@ -1303,10 +1297,10 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( if !is_options_valid(options) { return LZMA_OPTIONS_ERROR; } - (*coder).pos_mask = ((1 as c_uint) << (*options).pb).wrapping_sub(1 as c_uint) as u32; + (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; (*coder).literal_context_bits = (*options).lc; (*coder).literal_mask = - ((0x100 as c_uint) << (*options).lp).wrapping_sub(0x100 as c_uint >> (*options).lc) as u32; + ((0x100 as u32) << (*options).lp).wrapping_sub(0x100 >> (*options).lc) as u32; rc_reset(&raw mut (*coder).rc); (*coder).state = STATE_LIT_LIT; let mut i: size_t = 0 as size_t; @@ -1323,36 +1317,35 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( while i_0 < STATES as size_t { let mut j: size_t = 0 as size_t; while j <= (*coder).pos_mask as size_t { - (*coder).is_match[i_0 as usize][j as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_match[i_0 as usize][j as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep0_long[i_0 as usize][j as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; j = j.wrapping_add(1); } - (*coder).is_rep[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).is_rep0[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).is_rep1[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; - (*coder).is_rep2[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).is_rep[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).is_rep0[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).is_rep1[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; + (*coder).is_rep2[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; i_0 = i_0.wrapping_add(1); } let mut i_1: size_t = 0 as size_t; while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as size_t { - (*coder).dist_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (*coder).dist_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; i_1 = i_1.wrapping_add(1); } let mut i_2: size_t = 0 as size_t; while i_2 < DIST_STATES as size_t { let mut bt_i: u32 = 0 as u32; - while bt_i < ((1 as c_int) << 6 as c_int) as u32 { + while bt_i < ((1 as c_int) << 6) as u32 { (*coder).dist_slot[i_2 as usize][bt_i as usize] = - (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i = bt_i.wrapping_add(1); } i_2 = i_2.wrapping_add(1); } let mut bt_i_0: u32 = 0 as u32; - while bt_i_0 < ((1 as c_int) << 4 as c_int) as u32 { - (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1 as c_int) as probability; + while bt_i_0 < ((1 as c_int) << 4) as u32 { + (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } length_encoder_reset( @@ -1365,8 +1358,8 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( (1 as u32) << (*options).pb, (*coder).fast_mode, ); - (*coder).match_price_count = UINT32_MAX.wrapping_div(2 as c_uint) as u32; - (*coder).align_price_count = UINT32_MAX.wrapping_div(2 as c_uint) as u32; + (*coder).match_price_count = UINT32_MAX.wrapping_div(2) as u32; + (*coder).align_price_count = UINT32_MAX.wrapping_div(2) as u32; (*coder).opts_end_index = 0 as u32; (*coder).opts_current_index = 0 as u32; return LZMA_OK; @@ -1389,15 +1382,13 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( } } let mut coder: *mut lzma_lzma1_encoder = *coder_ptr as *mut lzma_lzma1_encoder; - match (*options).mode as c_uint { + match (*options).mode { 1 => { (*coder).fast_mode = true_0 != 0; } 2 => { (*coder).fast_mode = false_0 != 0; - if (*options).dict_size - > ((1 as u32) << 30 as c_int).wrapping_add((1 as u32) << 29 as c_int) - { + if (*options).dict_size > ((1 as u32) << 30).wrapping_add((1 as u32) << 29) { return LZMA_OPTIONS_ERROR; } let mut log_size: u32 = 0 as u32; @@ -1549,11 +1540,10 @@ pub unsafe extern "C" fn lzma_lzma_props_encode( if lzma_lzma_lclppb_encode(opt, out) { return LZMA_PROG_ERROR; } - write32le(out.offset(1 as isize), (*opt).dict_size); + write32le(out.offset(1), (*opt).dict_size); return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_mode_is_supported(mut mode: lzma_mode) -> lzma_bool { - return (mode as c_uint == LZMA_MODE_FAST as c_uint - || mode as c_uint == LZMA_MODE_NORMAL as c_uint) as lzma_bool; + return (mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL) as lzma_bool; } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 9bc8c29a..251cb34a 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -141,7 +141,7 @@ pub struct lzma_length_encoder { pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT32_MAX: c_uint = 4294967295; #[inline] unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); @@ -191,20 +191,14 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( len_main = (*coder).longest_match_length; matches_count = (*coder).matches_count; } - let mut buf: *const u8 = mf_ptr(mf).offset(-(1 as isize)); + let mut buf: *const u8 = mf_ptr(mf).offset(-1); let buf_avail: u32 = if mf_avail(mf).wrapping_add(1 as u32) - < (2 as c_int - + (((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 8 as c_int)) + < (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - 1 as c_int) as u32 { (mf_avail(mf) as u32).wrapping_add(1 as u32) } else { - (2 as c_int - + (((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 8 as c_int)) + (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - 1 as c_int) as u32 }; if buf_avail < 2 as u32 { @@ -216,11 +210,9 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( let mut rep_index: u32 = 0 as u32; let mut i: u32 = 0 as u32; while i < REPS as u32 { - let buf_back: *const u8 = buf - .offset(-((*coder).reps[i as usize] as isize)) - .offset(-(1 as isize)); - if !(*buf.offset(0 as isize) as c_int != *buf_back.offset(0 as isize) as c_int - || *buf.offset(1 as isize) as c_int != *buf_back.offset(1 as isize) as c_int) + let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); + if !(*buf.offset(0) as c_int != *buf_back.offset(0) as c_int + || *buf.offset(1) as c_int != *buf_back.offset(1) as c_int) { let len: u32 = lzma_memcmplen(buf, buf_back, 2 as u32, buf_avail) as u32; if len >= nice_len { @@ -253,7 +245,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( .len .wrapping_add(1 as u32) { - if !(back_main >> 7 as c_int + if !(back_main >> 7 > (*coder).matches[matches_count.wrapping_sub(2 as u32) as usize].dist) { break; @@ -268,8 +260,8 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( } if rep_len >= 2 as u32 { if rep_len.wrapping_add(1 as u32) >= len_main - || rep_len.wrapping_add(2 as u32) >= len_main && back_main > (1 as u32) << 9 as c_int - || rep_len.wrapping_add(3 as u32) >= len_main && back_main > (1 as u32) << 15 as c_int + || rep_len.wrapping_add(2 as u32) >= len_main && back_main > (1 as u32) << 9 + || rep_len.wrapping_add(3 as u32) >= len_main && back_main > (1 as u32) << 15 { *back_res = rep_index; *len_res = rep_len; @@ -292,11 +284,11 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( (*coder).matches[(*coder).matches_count.wrapping_sub(1 as u32) as usize].dist; if (*coder).longest_match_length >= len_main && new_dist < back_main || (*coder).longest_match_length == len_main.wrapping_add(1 as u32) - && !(new_dist >> 7 as c_int > back_main) + && !(new_dist >> 7 > back_main) || (*coder).longest_match_length > len_main.wrapping_add(1 as u32) || (*coder).longest_match_length.wrapping_add(1 as u32) >= len_main && len_main >= 3 as u32 - && back_main >> 7 as c_int > new_dist + && back_main >> 7 > new_dist { *back_res = UINT32_MAX as u32; *len_res = 1 as u32; @@ -314,7 +306,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( if memcmp( buf as *const c_void, buf.offset(-((*coder).reps[i_0 as usize] as isize)) - .offset(-(1 as isize)) as *const c_void, + .offset(-1) as *const c_void, limit as size_t, ) == 0 as c_int { diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index b1707f70..c9842948 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -143,7 +143,7 @@ pub struct lzma_length_encoder { pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const UINT32_MAX: c_uint = 4294967295 as c_uint; +pub const UINT32_MAX: c_uint = 4294967295; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] @@ -162,10 +162,10 @@ unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: u32) { } } pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; -pub const RC_BIT_MODEL_TOTAL: c_uint = (1 as c_uint) << RC_BIT_MODEL_TOTAL_BITS; +pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; pub const RC_MOVE_REDUCING_BITS: c_int = 4 as c_int; pub const RC_BIT_PRICE_SHIFT_BITS: c_int = 4 as c_int; -pub const RC_INFINITY_PRICE: c_uint = (1 as c_uint) << 30 as c_int; +pub const RC_INFINITY_PRICE: c_uint = 1u32 << 30; #[inline] unsafe extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { return lzma_rc_prices[((prob as u32 @@ -178,8 +178,9 @@ unsafe extern "C" fn rc_bit_0_price(prob: probability) -> u32 { } #[inline] unsafe extern "C" fn rc_bit_1_price(prob: probability) -> u32 { - return lzma_rc_prices[((prob as c_uint ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1 as c_uint)) - >> RC_MOVE_REDUCING_BITS) as usize] as u32; + return lzma_rc_prices + [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] + as u32; } #[inline] unsafe extern "C" fn rc_bittree_price( @@ -188,7 +189,7 @@ unsafe extern "C" fn rc_bittree_price( mut symbol: u32, ) -> u32 { let mut price: u32 = 0 as u32; - symbol = (symbol as c_uint).wrapping_add((1 as c_uint) << bit_levels) as u32 as u32; + symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; loop { let bit: u32 = symbol & 1 as u32; symbol >>= 1 as c_int; @@ -211,7 +212,7 @@ unsafe extern "C" fn rc_bittree_reverse_price( let bit: u32 = symbol & 1 as u32; symbol >>= 1 as c_int; price = price.wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); - model_index = (model_index << 1 as c_int).wrapping_add(bit); + model_index = (model_index << 1).wrapping_add(bit); bit_levels = bit_levels.wrapping_sub(1); if !(bit_levels != 0 as u32) { break; @@ -242,15 +243,13 @@ unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { return lzma_fastpos[dist as usize] as u32; } if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { - return (lzma_fastpos - [(dist >> 0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } - return (lzma_fastpos[(dist >> 0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] - as u32) + return (lzma_fastpos[(dist >> 0 + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); @@ -263,7 +262,7 @@ unsafe extern "C" fn get_dist_slot_2(mut dist: u32) -> u32 { + (14 as c_int / 2 as c_int - 1 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { return (lzma_fastpos[(dist - >> 14 as c_int / 2 as c_int - 1 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) + >> 14 / 2 as c_int - 1 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( (2 as c_int @@ -277,7 +276,7 @@ unsafe extern "C" fn get_dist_slot_2(mut dist: u32) -> u32 { + (14 as c_int / 2 as c_int - 1 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { return (lzma_fastpos[(dist - >> 14 as c_int / 2 as c_int - 1 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) + >> 14 / 2 as c_int - 1 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( (2 as c_int @@ -285,9 +284,9 @@ unsafe extern "C" fn get_dist_slot_2(mut dist: u32) -> u32 { + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, ); } - return (lzma_fastpos[(dist - >> 14 as c_int / 2 as c_int - 1 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) - as usize] as u32) + return (lzma_fastpos + [(dist >> 14 / 2 as c_int - 1 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] + as u32) .wrapping_add( (2 as c_int * (14 as c_int / 2 as c_int - 1 as c_int @@ -317,7 +316,7 @@ unsafe extern "C" fn get_literal_price( ) -> u32 { let subcoder: *const probability = (&raw const (*coder).literal as *const probability).offset((3 as u32).wrapping_mul( - ((pos << 8 as c_int).wrapping_add(prev_byte) & (*coder).literal_mask) + ((pos << 8).wrapping_add(prev_byte) & (*coder).literal_mask) << (*coder).literal_context_bits, ) as isize); let mut price: u32 = 0 as u32; @@ -325,19 +324,17 @@ unsafe extern "C" fn get_literal_price( price = rc_bittree_price(subcoder, 8 as u32, symbol); } else { let mut offset: u32 = 0x100 as u32; - symbol = (symbol as c_uint).wrapping_add((1 as c_uint) << 8 as c_int) as u32 as u32; + symbol = (symbol as u32).wrapping_add(1u32 << 8) as u32; loop { match_byte <<= 1 as c_int; let match_bit: u32 = match_byte & offset; - let subcoder_index: u32 = offset - .wrapping_add(match_bit) - .wrapping_add(symbol >> 8 as c_int); - let bit: u32 = symbol >> 7 as c_int & 1 as u32; + let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol >> 8); + let bit: u32 = symbol >> 7 & 1 as u32; price = price.wrapping_add(rc_bit_price(*subcoder.offset(subcoder_index as isize), bit)); symbol <<= 1 as c_int; offset &= !(match_byte ^ symbol); - if !(symbol < (1 as u32) << 16 as c_int) { + if !(symbol < (1 as u32) << 16) { break; } } @@ -447,7 +444,7 @@ unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { while dist_slot_0 < (*coder).dist_table_size { let ref mut fresh1 = *dist_slot_prices.offset(dist_slot_0 as isize); *fresh1 = (*fresh1).wrapping_add(rc_direct_price( - (dist_slot_0 >> 1 as c_int) + (dist_slot_0 >> 1) .wrapping_sub(1 as u32) .wrapping_sub(ALIGN_BITS as u32), )); @@ -464,13 +461,13 @@ unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { let mut i_0: u32 = DIST_MODEL_START as u32; while i_0 < FULL_DISTANCES as u32 { let dist_slot_1: u32 = get_dist_slot(i_0) as u32; - let footer_bits: u32 = (dist_slot_1 >> 1 as c_int).wrapping_sub(1 as u32); + let footer_bits: u32 = (dist_slot_1 >> 1).wrapping_sub(1 as u32); let base: u32 = (2 as u32 | dist_slot_1 & 1 as u32) << footer_bits; let price: u32 = rc_bittree_reverse_price( (&raw mut (*coder).dist_special as *mut probability) .offset(base as isize) .offset(-(dist_slot_1 as isize)) - .offset(-(1 as isize)), + .offset(-1), footer_bits, i_0.wrapping_sub(base), ) as u32; @@ -543,9 +540,9 @@ unsafe extern "C" fn backward( break; } } - (*coder).opts_current_index = (*coder).opts[0 as usize].pos_prev; - *len_res = (*coder).opts[0 as usize].pos_prev; - *back_res = (*coder).opts[0 as usize].back_prev; + (*coder).opts_current_index = (*coder).opts[0].pos_prev; + *len_res = (*coder).opts[0].pos_prev; + *back_res = (*coder).opts[0].back_prev; } #[inline] unsafe extern "C" fn helper1( @@ -569,18 +566,12 @@ unsafe extern "C" fn helper1( matches_count = (*coder).matches_count; } let buf_avail: u32 = if mf_avail(mf).wrapping_add(1 as u32) - < (2 as c_int - + (((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 8 as c_int)) + < (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - 1 as c_int) as u32 { (mf_avail(mf) as u32).wrapping_add(1 as u32) } else { - (2 as c_int - + (((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 3 as c_int) - + ((1 as c_int) << 8 as c_int)) + (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - 1 as c_int) as u32 }; if buf_avail < 2 as u32 { @@ -588,16 +579,14 @@ unsafe extern "C" fn helper1( *len_res = 1 as u32; return UINT32_MAX as u32; } - let buf: *const u8 = mf_ptr(mf).offset(-(1 as isize)); + let buf: *const u8 = mf_ptr(mf).offset(-1); let mut rep_lens: [u32; 4] = [0; 4]; let mut rep_max_index: u32 = 0 as u32; let mut i: u32 = 0 as u32; while i < REPS as u32 { - let buf_back: *const u8 = buf - .offset(-((*coder).reps[i as usize] as isize)) - .offset(-(1 as isize)); - if *buf.offset(0 as isize) as c_int != *buf_back.offset(0 as isize) as c_int - || *buf.offset(1 as isize) as c_int != *buf_back.offset(1 as isize) as c_int + let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); + if *buf.offset(0) as c_int != *buf_back.offset(0) as c_int + || *buf.offset(1) as c_int != *buf_back.offset(1) as c_int { rep_lens[i as usize] = 0 as u32; } else { @@ -623,9 +612,7 @@ unsafe extern "C" fn helper1( return UINT32_MAX as u32; } let current_byte: u8 = *buf; - let match_byte: u8 = *buf - .offset(-((*coder).reps[0 as usize] as isize)) - .offset(-(1 as isize)); + let match_byte: u8 = *buf.offset(-((*coder).reps[0] as isize)).offset(-1); if len_main < 2 as u32 && current_byte as c_int != match_byte as c_int && rep_lens[rep_max_index as usize] < 2 as u32 @@ -634,21 +621,19 @@ unsafe extern "C" fn helper1( *len_res = 1 as u32; return UINT32_MAX as u32; } - (*coder).opts[0 as usize].state = (*coder).state; + (*coder).opts[0].state = (*coder).state; let pos_state: u32 = position & (*coder).pos_mask; - (*coder).opts[1 as usize].price = + (*coder).opts[1].price = rc_bit_0_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) .wrapping_add(get_literal_price( coder, position, *buf.offset(-(1 as c_int) as isize) as u32, - !(((*coder).state as c_uint) < LIT_STATES as c_uint), + !(((*coder).state as u32) < LIT_STATES as u32), match_byte as u32, current_byte as u32, )); - make_literal( - (&raw mut (*coder).opts as *mut lzma_optimal).offset(1 as isize) as *mut lzma_optimal, - ); + make_literal((&raw mut (*coder).opts as *mut lzma_optimal).offset(1) as *mut lzma_optimal); let match_price: u32 = rc_bit_1_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) as u32; let rep_match_price: u32 = @@ -657,11 +642,10 @@ unsafe extern "C" fn helper1( let short_rep_price: u32 = rep_match_price .wrapping_add(get_short_rep_price(coder, (*coder).state, pos_state) as u32); - if short_rep_price < (*coder).opts[1 as usize].price { - (*coder).opts[1 as usize].price = short_rep_price; + if short_rep_price < (*coder).opts[1].price { + (*coder).opts[1].price = short_rep_price; make_short_rep( - (&raw mut (*coder).opts as *mut lzma_optimal).offset(1 as isize) - as *mut lzma_optimal, + (&raw mut (*coder).opts as *mut lzma_optimal).offset(1) as *mut lzma_optimal ); } } @@ -671,14 +655,14 @@ unsafe extern "C" fn helper1( rep_lens[rep_max_index as usize] }; if len_end < 2 as u32 { - *back_res = (*coder).opts[1 as usize].back_prev; + *back_res = (*coder).opts[1].back_prev; *len_res = 1 as u32; return UINT32_MAX as u32; } - (*coder).opts[1 as usize].pos_prev = 0 as u32; + (*coder).opts[1].pos_prev = 0 as u32; let mut i_0: u32 = 0 as u32; while i_0 < REPS as u32 { - (*coder).opts[0 as usize].backs[i_0 as usize] = (*coder).reps[i_0 as usize]; + (*coder).opts[0].backs[i_0 as usize] = (*coder).reps[i_0 as usize]; i_0 = i_0.wrapping_add(1); } let mut len: u32 = len_end; @@ -721,8 +705,8 @@ unsafe extern "C" fn helper1( } let normal_match_price: u32 = match_price.wrapping_add(rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as u32); - len = if rep_lens[0 as usize] >= 2 as u32 { - rep_lens[0 as usize].wrapping_add(1 as u32) + len = if rep_lens[0] >= 2 as u32 { + rep_lens[0].wrapping_add(1 as u32) } else { 2 as u32 }; @@ -772,13 +756,13 @@ unsafe extern "C" fn helper2( if (*coder).opts[cur as usize].prev_2 { state = (*coder).opts[(*coder).opts[cur as usize].pos_prev_2 as usize].state; if (*coder).opts[cur as usize].back_prev_2 < REPS as u32 { - state = (if (state as c_uint) < LIT_STATES as c_uint { + state = (if (state as u32) < LIT_STATES as u32 { STATE_LIT_LONGREP as c_int } else { STATE_NONLIT_REP as c_int }) as lzma_lzma_state; } else { - state = (if (state as c_uint) < LIT_STATES as c_uint { + state = (if (state as u32) < LIT_STATES as u32 { STATE_LIT_MATCH as c_int } else { STATE_NONLIT_MATCH as c_int @@ -787,30 +771,30 @@ unsafe extern "C" fn helper2( } else { state = (*coder).opts[pos_prev as usize].state; } - state = (if state as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { - STATE_LIT_LIT as c_uint - } else if state as c_uint <= STATE_LIT_SHORTREP as c_uint { - (state as c_uint).wrapping_sub(3 as c_uint) + state = (if state <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT + } else if state <= STATE_LIT_SHORTREP { + (state as u32).wrapping_sub(3) } else { - (state as c_uint).wrapping_sub(6 as c_uint) + (state as u32).wrapping_sub(6) }) as lzma_lzma_state; } else { state = (*coder).opts[pos_prev as usize].state; } if pos_prev == cur.wrapping_sub(1 as u32) { if (*coder).opts[cur as usize].back_prev == 0 as u32 { - state = (if (state as c_uint) < LIT_STATES as c_uint { + state = (if (state as u32) < LIT_STATES as u32 { STATE_LIT_SHORTREP as c_int } else { STATE_NONLIT_REP as c_int }) as lzma_lzma_state; } else { - state = (if state as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { - STATE_LIT_LIT as c_uint - } else if state as c_uint <= STATE_LIT_SHORTREP as c_uint { - (state as c_uint).wrapping_sub(3 as c_uint) + state = (if state <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT + } else if state <= STATE_LIT_SHORTREP { + (state as u32).wrapping_sub(3) } else { - (state as c_uint).wrapping_sub(6 as c_uint) + (state as u32).wrapping_sub(6) }) as lzma_lzma_state; } } else { @@ -820,7 +804,7 @@ unsafe extern "C" fn helper2( { pos_prev = (*coder).opts[cur as usize].pos_prev_2; pos = (*coder).opts[cur as usize].back_prev_2; - state = (if (state as c_uint) < LIT_STATES as c_uint { + state = (if (state as u32) < LIT_STATES as u32 { STATE_LIT_LONGREP as c_int } else { STATE_NONLIT_REP as c_int @@ -828,13 +812,13 @@ unsafe extern "C" fn helper2( } else { pos = (*coder).opts[cur as usize].back_prev; if pos < REPS as u32 { - state = (if (state as c_uint) < LIT_STATES as c_uint { + state = (if (state as u32) < LIT_STATES as u32 { STATE_LIT_LONGREP as c_int } else { STATE_NONLIT_REP as c_int }) as lzma_lzma_state; } else { - state = (if (state as c_uint) < LIT_STATES as c_uint { + state = (if (state as u32) < LIT_STATES as u32 { STATE_LIT_MATCH as c_int } else { STATE_NONLIT_MATCH as c_int @@ -842,7 +826,7 @@ unsafe extern "C" fn helper2( } } if pos < REPS as u32 { - *reps.offset(0 as isize) = (*coder).opts[pos_prev as usize].backs[pos as usize]; + *reps.offset(0) = (*coder).opts[pos_prev as usize].backs[pos as usize]; let mut i: u32 = 0; i = 1 as u32; while i <= pos { @@ -855,7 +839,7 @@ unsafe extern "C" fn helper2( i = i.wrapping_add(1); } } else { - *reps.offset(0 as isize) = pos.wrapping_sub(REPS as u32); + *reps.offset(0) = pos.wrapping_sub(REPS as u32); let mut i_0: u32 = 1 as u32; while i_0 < REPS as u32 { *reps.offset(i_0 as isize) = @@ -872,9 +856,7 @@ unsafe extern "C" fn helper2( } let cur_price: u32 = (*coder).opts[cur as usize].price; let current_byte: u8 = *buf; - let match_byte: u8 = *buf - .offset(-(*reps.offset(0 as isize) as isize)) - .offset(-(1 as isize)); + let match_byte: u8 = *buf.offset(-(*reps.offset(0) as isize)).offset(-1); let pos_state: u32 = position & (*coder).pos_mask; let cur_and_1_price: u32 = cur_price .wrapping_add(rc_bit_0_price((*coder).is_match[state as usize][pos_state as usize]) as u32) @@ -882,7 +864,7 @@ unsafe extern "C" fn helper2( coder, position, *buf.offset(-(1 as c_int) as isize) as u32, - !((state as c_uint) < LIT_STATES as c_uint), + !((state as u32) < LIT_STATES as u32), match_byte as u32, current_byte as u32, ) as u32); @@ -926,9 +908,7 @@ unsafe extern "C" fn helper2( nice_len }; if !next_is_literal && match_byte as c_int != current_byte as c_int { - let buf_back: *const u8 = buf - .offset(-(*reps.offset(0 as isize) as isize)) - .offset(-(1 as isize)); + let buf_back: *const u8 = buf.offset(-(*reps.offset(0) as isize)).offset(-1); let limit: u32 = if buf_avail_full < nice_len.wrapping_add(1 as u32) { buf_avail_full } else { @@ -938,12 +918,12 @@ unsafe extern "C" fn helper2( (lzma_memcmplen(buf, buf_back, 1 as u32, limit) as u32).wrapping_sub(1 as u32); if len_test >= 2 as u32 { let mut state_2: lzma_lzma_state = state; - state_2 = (if state_2 as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { - STATE_LIT_LIT as c_uint - } else if state_2 as c_uint <= STATE_LIT_SHORTREP as c_uint { - (state_2 as c_uint).wrapping_sub(3 as c_uint) + state_2 = (if state_2 <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT + } else if state_2 <= STATE_LIT_SHORTREP { + (state_2 as u32).wrapping_sub(3) } else { - (state_2 as c_uint).wrapping_sub(6 as c_uint) + (state_2 as u32).wrapping_sub(6) }) as lzma_lzma_state; let pos_state_next: u32 = position.wrapping_add(1 as u32) & (*coder).pos_mask; let next_rep_match_price: u32 = cur_and_1_price @@ -977,9 +957,9 @@ unsafe extern "C" fn helper2( while rep_index < REPS as u32 { let buf_back_0: *const u8 = buf .offset(-(*reps.offset(rep_index as isize) as isize)) - .offset(-(1 as isize)); - if !(*buf.offset(0 as isize) as c_int != *buf_back_0.offset(0 as isize) as c_int - || *buf.offset(1 as isize) as c_int != *buf_back_0.offset(1 as isize) as c_int) + .offset(-1); + if !(*buf.offset(0) as c_int != *buf_back_0.offset(0) as c_int + || *buf.offset(1) as c_int != *buf_back_0.offset(1) as c_int) { let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2 as u32, buf_avail); while len_end < cur.wrapping_add(len_test_0) { @@ -1025,7 +1005,7 @@ unsafe extern "C" fn helper2( len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1 as u32)); if len_test_2 >= 2 as u32 { let mut state_2_0: lzma_lzma_state = state; - state_2_0 = (if (state_2_0 as c_uint) < LIT_STATES as c_uint { + state_2_0 = (if (state_2_0 as u32) < LIT_STATES as u32 { STATE_LIT_LONGREP as c_int } else { STATE_NONLIT_REP as c_int @@ -1049,12 +1029,12 @@ unsafe extern "C" fn helper2( *buf_back_0.offset(len_test_0 as isize) as u32, *buf.offset(len_test_0 as isize) as u32, ) as u32); - state_2_0 = (if state_2_0 as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { - STATE_LIT_LIT as c_uint - } else if state_2_0 as c_uint <= STATE_LIT_SHORTREP as c_uint { - (state_2_0 as c_uint).wrapping_sub(3 as c_uint) + state_2_0 = (if state_2_0 <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT + } else if state_2_0 <= STATE_LIT_SHORTREP { + (state_2_0 as u32).wrapping_sub(3) } else { - (state_2_0 as c_uint).wrapping_sub(6 as c_uint) + (state_2_0 as u32).wrapping_sub(6) }) as lzma_lzma_state; pos_state_next_0 = position.wrapping_add(len_test_0).wrapping_add(1 as u32) & (*coder).pos_mask; @@ -1128,7 +1108,7 @@ unsafe extern "C" fn helper2( false_0 != 0; } if len_test_1 == (*coder).matches[i_2 as usize].len { - let buf_back_1: *const u8 = buf.offset(-(cur_back as isize)).offset(-(1 as isize)); + let buf_back_1: *const u8 = buf.offset(-(cur_back as isize)).offset(-1); let mut len_test_2_0: u32 = len_test_1.wrapping_add(1 as u32); let limit_1: u32 = if buf_avail_full < len_test_2_0.wrapping_add(nice_len) { buf_avail_full @@ -1141,7 +1121,7 @@ unsafe extern "C" fn helper2( len_test_2_0 = len_test_2_0.wrapping_sub(len_test_1.wrapping_add(1 as u32)); if len_test_2_0 >= 2 as u32 { let mut state_2_1: lzma_lzma_state = state; - state_2_1 = (if (state_2_1 as c_uint) < LIT_STATES as c_uint { + state_2_1 = (if (state_2_1 as u32) < LIT_STATES as u32 { STATE_LIT_MATCH as c_int } else { STATE_NONLIT_MATCH as c_int @@ -1160,12 +1140,12 @@ unsafe extern "C" fn helper2( *buf_back_1.offset(len_test_1 as isize) as u32, *buf.offset(len_test_1 as isize) as u32, ) as u32); - state_2_1 = (if state_2_1 as c_uint <= STATE_SHORTREP_LIT_LIT as c_uint { - STATE_LIT_LIT as c_uint - } else if state_2_1 as c_uint <= STATE_LIT_SHORTREP as c_uint { - (state_2_1 as c_uint).wrapping_sub(3 as c_uint) + state_2_1 = (if state_2_1 <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT + } else if state_2_1 <= STATE_LIT_SHORTREP { + (state_2_1 as u32).wrapping_sub(3) } else { - (state_2_1 as c_uint).wrapping_sub(6 as c_uint) + (state_2_1 as u32).wrapping_sub(6) }) as lzma_lzma_state; pos_state_next_1 = pos_state_next_1.wrapping_add(1 as u32) & (*coder).pos_mask; let next_rep_match_price_1: u32 = cur_and_len_literal_price_0 @@ -1227,7 +1207,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( return; } if (*mf).read_ahead == 0 as u32 { - if (*coder).match_price_count >= ((1 as c_int) << 7 as c_int) as u32 { + if (*coder).match_price_count >= ((1 as c_int) << 7) as u32 { fill_dist_prices(coder); } if (*coder).align_price_count >= ALIGN_SIZE as u32 { @@ -1258,17 +1238,17 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( len_end = helper2( coder, &raw mut reps as *mut u32, - mf_ptr(mf).offset(-(1 as isize)), + mf_ptr(mf).offset(-1), len_end, position.wrapping_add(cur), cur, (*mf).nice_len, if mf_avail(mf).wrapping_add(1 as u32) - < ((((1 as c_int) << 12 as c_int) - 1 as c_int) as u32).wrapping_sub(cur) + < ((((1 as c_int) << 12) - 1 as c_int) as u32).wrapping_sub(cur) { mf_avail(mf).wrapping_add(1 as u32) } else { - ((((1 as c_int) << 12 as c_int) - 1 as c_int) as u32).wrapping_sub(cur) + ((((1 as c_int) << 12) - 1 as c_int) as u32).wrapping_sub(cur) }, ); cur = cur.wrapping_add(1); diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index 7c70f9a3..ec7a2356 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -43,8 +43,8 @@ pub const false_0: c_int = 0 as c_int; pub const LZMA_LC_DEFAULT: c_int = 3 as c_int; pub const LZMA_LP_DEFAULT: c_int = 0 as c_int; pub const LZMA_PB_DEFAULT: c_int = 2 as c_int; -pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f as c_uint; -pub const LZMA_PRESET_EXTREME: c_uint = (1 as c_uint) << 31 as c_int; +pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f; +pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_preset( mut options: *mut lzma_options_lzma, @@ -65,7 +65,7 @@ pub unsafe extern "C" fn lzma_lzma_preset( 18 as u8, 20 as u8, 21 as u8, 22 as u8, 22 as u8, 23 as u8, 23 as u8, 24 as u8, 25 as u8, 26 as u8, ]; - (*options).dict_size = ((1 as c_uint) << dict_pow2[level as usize] as c_int) as u32; + (*options).dict_size = (1u32 << dict_pow2[level as usize] as c_int) as u32; if level <= 3 as u32 { (*options).mode = LZMA_MODE_FAST; (*options).mf = (if level == 0 as u32 { diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index 8e2eda56..c35c6cce 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -120,9 +120,8 @@ unsafe extern "C" fn arm_code( i = 0 as size_t; while i < size { if *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int == 0xeb as c_int { - let mut src: u32 = (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) - << 16 as c_int - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8 as c_int + let mut src: u32 = (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16 + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8 | *buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32; src <<= 2 as c_int; let mut dest: u32 = 0; @@ -135,8 +134,8 @@ unsafe extern "C" fn arm_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(8 as u32)); } dest >>= 2 as c_int; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 16 as c_int) as u8; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 8 as c_int) as u8; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 16) as u8; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 8) as u8; *buffer.offset(i.wrapping_add(0 as size_t) as isize) = dest as u8; } i = i.wrapping_add(4 as size_t); diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index de25b14a..2238a697 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -112,18 +112,18 @@ pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0 as isize) as u32; - num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; - num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; - num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; return num; } #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0 as isize) = num as u8; - *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; - *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; - *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; } unsafe extern "C" fn arm64_code( mut simple: *mut c_void, @@ -138,9 +138,9 @@ unsafe extern "C" fn arm64_code( while i < size { let mut pc: u32 = (now_pos as size_t).wrapping_add(i) as u32; let mut instr: u32 = read32le(buffer.offset(i as isize)); - if instr >> 26 as c_int == 0x25 as u32 { + if instr >> 26 == 0x25 as u32 { let src: u32 = instr; - instr = 0x94000000 as c_uint as u32; + instr = 0x94000000 as u32; pc >>= 2 as c_int; if !is_encoder { pc = (0 as u32).wrapping_sub(pc); @@ -148,19 +148,17 @@ unsafe extern "C" fn arm64_code( instr |= src.wrapping_add(pc) & 0x3ffffff as u32; write32le(buffer.offset(i as isize), instr); } else if instr & 0x9f000000 as u32 == 0x90000000 as u32 { - let src_0: u32 = - instr >> 29 as c_int & 3 as u32 | instr >> 3 as c_int & 0x1ffffc as u32; + let src_0: u32 = instr >> 29 & 3 as u32 | instr >> 3 & 0x1ffffc as u32; if !(src_0.wrapping_add(0x20000 as u32) & 0x1c0000 as u32 != 0) { - instr = (instr as c_uint & 0x9000001f as c_uint) as u32; + instr = (instr & 0x9000001f) as u32; pc >>= 12 as c_int; if !is_encoder { pc = (0 as u32).wrapping_sub(pc); } let dest: u32 = src_0.wrapping_add(pc); - instr |= (dest & 3 as u32) << 29 as c_int; - instr |= (dest & 0x3fffc as u32) << 3 as c_int; - instr = (instr as c_uint - | ((0 as u32).wrapping_sub(dest & 0x20000 as u32) & 0xe00000 as u32) as c_uint) + instr |= (dest & 3 as u32) << 29; + instr |= (dest & 0x3fffc as u32) << 3; + instr = (instr | ((0 as u32).wrapping_sub(dest & 0x20000 as u32) & 0xe00000 as u32)) as u32; write32le(buffer.offset(i as isize), instr); } @@ -200,7 +198,7 @@ pub unsafe extern "C" fn lzma_bcj_arm64_encode( mut buf: *mut u8, mut size: size_t, ) -> size_t { - start_offset = (start_offset as c_uint & !(3 as c_uint)) as u32; + start_offset = (start_offset & !3u32) as u32; return arm64_code(NULL, start_offset, true_0 != 0, buf, size); } #[no_mangle] @@ -217,6 +215,6 @@ pub unsafe extern "C" fn lzma_bcj_arm64_decode( mut buf: *mut u8, mut size: size_t, ) -> size_t { - start_offset = (start_offset as c_uint & !(3 as c_uint)) as u32; + start_offset = (start_offset & !3u32) as u32; return arm64_code(NULL, start_offset, false_0 != 0, buf, size); } diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index ab58ac8f..02a8dd1a 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -127,13 +127,11 @@ unsafe extern "C" fn armthumb_code( && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int & 0xf8 as c_int == 0xf8 as c_int { - let mut src: u32 = (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32 - & 7 as u32) - << 19 as c_int - | (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32) << 11 as c_int - | (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32 & 7 as u32) - << 8 as c_int - | *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; + let mut src: u32 = + (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32 & 7 as u32) << 19 + | (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32) << 11 + | (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32 & 7 as u32) << 8 + | *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; src <<= 1 as c_int; let mut dest: u32 = 0; if is_encoder { @@ -146,10 +144,10 @@ unsafe extern "C" fn armthumb_code( } dest >>= 1 as c_int; *buffer.offset(i.wrapping_add(1 as size_t) as isize) = - (0xf0 as u32 | dest >> 19 as c_int & 0x7 as u32) as u8; - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest >> 11 as c_int) as u8; + (0xf0 as u32 | dest >> 19 & 0x7 as u32) as u8; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest >> 11) as u8; *buffer.offset(i.wrapping_add(3 as size_t) as isize) = - (0xf8 as u32 | dest >> 8 as c_int & 0x7 as u32) as u8; + (0xf8 as u32 | dest >> 8 & 0x7 as u32) as u8; *buffer.offset(i.wrapping_add(2 as size_t) as isize) = dest as u8; i = i.wrapping_add(2 as size_t); } diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index fd132065..cd011027 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -131,7 +131,7 @@ unsafe extern "C" fn ia64_code( let mut slot: size_t = 0 as size_t; while slot < 3 as size_t { if !(mask >> slot & 1 as u32 == 0 as u32) { - let byte_pos: size_t = (bit_pos >> 3 as c_int) as size_t; + let byte_pos: size_t = (bit_pos >> 3) as size_t; let bit_res: u32 = bit_pos & 0x7 as u32; let mut instruction: u64 = 0 as u64; let mut j: size_t = 0 as size_t; @@ -143,12 +143,11 @@ unsafe extern "C" fn ia64_code( j = j.wrapping_add(1); } let mut inst_norm: u64 = instruction >> bit_res; - if inst_norm >> 37 as c_int & 0xf as u64 == 0x5 as u64 - && inst_norm >> 9 as c_int & 0x7 as u64 == 0 as u64 + if inst_norm >> 37 & 0xf as u64 == 0x5 as u64 + && inst_norm >> 9 & 0x7 as u64 == 0 as u64 { - let mut src: u32 = (inst_norm >> 13 as c_int & 0xfffff as u64) as u32; - src = - (src as u64 | (inst_norm >> 36 as c_int & 1 as u64) << 20 as c_int) as u32; + let mut src: u32 = (inst_norm >> 13 & 0xfffff as u64) as u32; + src = (src as u64 | (inst_norm >> 36 & 1 as u64) << 20) as u32; src <<= 4 as c_int; let mut dest: u32 = 0; if is_encoder { @@ -157,10 +156,10 @@ unsafe extern "C" fn ia64_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } dest >>= 4 as c_int; - inst_norm &= !((0x8fffff as u64) << 13 as c_int); - inst_norm |= ((dest & 0xfffff as u32) as u64) << 13 as c_int; - inst_norm |= ((dest & 0x100000 as u32) as u64) << 36 as c_int - 20 as c_int; - instruction &= ((1 as c_uint) << bit_res).wrapping_sub(1 as c_uint) as u64; + inst_norm &= !((0x8fffff as u64) << 13); + inst_norm |= ((dest & 0xfffff as u32) as u64) << 13; + inst_norm |= ((dest & 0x100000 as u32) as u64) << 36 - 20 as c_int; + instruction &= (1u32 << bit_res).wrapping_sub(1) as u64; instruction |= inst_norm << bit_res; let mut j_0: size_t = 0 as size_t; while j_0 < 6 as size_t { diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index 612aa661..7b12462f 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -119,14 +119,14 @@ unsafe extern "C" fn powerpc_code( let mut i: size_t = 0; i = 0 as size_t; while i < size { - if *buffer.offset(i as isize) as c_int >> 2 as c_int == 0x12 as c_int + if *buffer.offset(i as isize) as c_int >> 2 == 0x12 as c_int && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int & 3 as c_int == 1 as c_int { let src: u32 = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32 & 3 as u32) - << 24 as c_int - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 16 as c_int - | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 8 as c_int + << 24 + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 16 + | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 8 | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32 & !(3 as u32); let mut dest: u32 = 0; if is_encoder { @@ -135,9 +135,9 @@ unsafe extern "C" fn powerpc_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } *buffer.offset(i.wrapping_add(0 as size_t) as isize) = - (0x48 as u32 | dest >> 24 as c_int & 0x3 as u32) as u8; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 16 as c_int) as u8; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 8 as c_int) as u8; + (0x48 as u32 | dest >> 24 & 0x3 as u32) as u8; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 16) as u8; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 8) as u8; let ref mut fresh0 = *buffer.offset(i.wrapping_add(3 as size_t) as isize); *fresh0 = (*fresh0 as c_int & 0x3 as c_int) as u8; let ref mut fresh1 = *buffer.offset(i.wrapping_add(3 as size_t) as isize); diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 22c07bc0..26ec105e 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -112,33 +112,33 @@ pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn read32be(mut buf: *const u8) -> u32 { - let mut num: u32 = (*buf.offset(0 as isize) as u32) << 24 as c_int; - num |= (*buf.offset(1 as isize) as u32) << 16 as c_int; - num |= (*buf.offset(2 as isize) as u32) << 8 as c_int; - num |= *buf.offset(3 as isize) as u32; + let mut num: u32 = (*buf.offset(0) as u32) << 24; + num |= (*buf.offset(1) as u32) << 16; + num |= (*buf.offset(2) as u32) << 8; + num |= *buf.offset(3) as u32; return num; } #[inline] unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0 as isize) as u32; - num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; - num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; - num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; return num; } #[inline] unsafe extern "C" fn write32be(mut buf: *mut u8, mut num: u32) { - *buf.offset(0 as isize) = (num >> 24 as c_int) as u8; - *buf.offset(1 as isize) = (num >> 16 as c_int) as u8; - *buf.offset(2 as isize) = (num >> 8 as c_int) as u8; - *buf.offset(3 as isize) = num as u8; + *buf.offset(0) = (num >> 24) as u8; + *buf.offset(1) = (num >> 16) as u8; + *buf.offset(2) = (num >> 8) as u8; + *buf.offset(3) = num as u8; } #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0 as isize) = num as u8; - *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; - *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; - *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; } unsafe extern "C" fn riscv_encode( mut simple: *mut c_void, @@ -162,52 +162,49 @@ unsafe extern "C" fn riscv_encode( let b2: u32 = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; let b3: u32 = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); - let mut addr: u32 = (b1 & 0xf0 as u32) << 8 as c_int - | (b2 & 0xf as u32) << 16 as c_int - | (b2 & 0x10 as u32) << 7 as c_int - | (b2 & 0xe0 as u32) >> 4 as c_int - | (b3 & 0x7f as u32) << 4 as c_int - | (b3 & 0x80 as u32) << 13 as c_int; + let mut addr: u32 = (b1 & 0xf0 as u32) << 8 + | (b2 & 0xf as u32) << 16 + | (b2 & 0x10 as u32) << 7 + | (b2 & 0xe0 as u32) >> 4 + | (b3 & 0x7f as u32) << 4 + | (b3 & 0x80 as u32) << 13; addr = addr.wrapping_add(pc); *buffer.offset(i.wrapping_add(1 as size_t) as isize) = - (b1 & 0xf as u32 | addr >> 13 as c_int & 0xf0 as u32) as u8; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (addr >> 9 as c_int) as u8; - *buffer.offset(i.wrapping_add(3 as size_t) as isize) = (addr >> 1 as c_int) as u8; + (b1 & 0xf as u32 | addr >> 13 & 0xf0 as u32) as u8; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (addr >> 9) as u8; + *buffer.offset(i.wrapping_add(3 as size_t) as isize) = (addr >> 1) as u8; i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); } } else if inst & 0x7f as u32 == 0x17 as u32 { - inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8 as c_int; - inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16 as c_int; - inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32) << 24 as c_int; + inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8; + inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16; + inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32) << 24; if inst & 0xe80 as u32 != 0 { - let mut inst2: u32 = read32le(buffer.offset(i as isize).offset(4 as isize)); - if (inst << 8 as c_int ^ inst2.wrapping_sub(3 as u32)) & 0xf8003 as u32 != 0 { + let mut inst2: u32 = read32le(buffer.offset(i as isize).offset(4)); + if (inst << 8 ^ inst2.wrapping_sub(3 as u32)) & 0xf8003 as u32 != 0 { i = i.wrapping_add((6 as c_int - 2 as c_int) as size_t); current_block_22 = 12517898123489920830; } else { let mut addr_0: u32 = inst & 0xfffff000 as u32; - addr_0 = addr_0.wrapping_add( - (inst2 >> 20 as c_int).wrapping_sub(inst2 >> 19 as c_int & 0x1000 as u32), - ); + addr_0 = addr_0 + .wrapping_add((inst2 >> 20).wrapping_sub(inst2 >> 19 & 0x1000 as u32)); addr_0 = addr_0.wrapping_add(now_pos.wrapping_add(i as u32)); - inst = - (0x17 as c_int | (2 as c_int) << 7 as c_int) as u32 | inst2 << 12 as c_int; + inst = (0x17 as c_int | (2 as c_int) << 7) as u32 | inst2 << 12; write32le(buffer.offset(i as isize), inst); - write32be(buffer.offset(i as isize).offset(4 as isize), addr_0); + write32be(buffer.offset(i as isize).offset(4), addr_0); current_block_22 = 15125582407903384992; } } else { - let fake_rs1: u32 = inst >> 27 as c_int; - if inst.wrapping_sub(0x3117 as u32) << 18 as c_int >= fake_rs1 & 0x1d as u32 { + let fake_rs1: u32 = inst >> 27; + if inst.wrapping_sub(0x3117 as u32) << 18 >= fake_rs1 & 0x1d as u32 { i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); current_block_22 = 12517898123489920830; } else { - let fake_addr: u32 = - read32le(buffer.offset(i as isize).offset(4 as isize)) as u32; - let fake_inst2: u32 = inst >> 12 as c_int | fake_addr << 20 as c_int; - inst = 0x17 as u32 | fake_rs1 << 7 as c_int | fake_addr & 0xfffff000 as u32; + let fake_addr: u32 = read32le(buffer.offset(i as isize).offset(4)) as u32; + let fake_inst2: u32 = inst >> 12 | fake_addr << 20; + inst = 0x17 as u32 | fake_rs1 << 7 | fake_addr & 0xfffff000 as u32; write32le(buffer.offset(i as isize), inst); - write32le(buffer.offset(i as isize).offset(4 as isize), fake_inst2); + write32le(buffer.offset(i as isize).offset(4), fake_inst2); current_block_22 = 15125582407903384992; } } @@ -247,7 +244,7 @@ pub unsafe extern "C" fn lzma_bcj_riscv_encode( mut buf: *mut u8, mut size: size_t, ) -> size_t { - start_offset = (start_offset as c_uint & !(1 as c_uint)) as u32; + start_offset = (start_offset & !1u32) as u32; return riscv_encode(NULL, start_offset, true_0 != 0, buf, size); } unsafe extern "C" fn riscv_decode( @@ -272,48 +269,45 @@ unsafe extern "C" fn riscv_decode( let b2: u32 = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; let b3: u32 = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); - let mut addr: u32 = - (b1 & 0xf0 as u32) << 13 as c_int | b2 << 9 as c_int | b3 << 1 as c_int; + let mut addr: u32 = (b1 & 0xf0 as u32) << 13 | b2 << 9 | b3 << 1; addr = addr.wrapping_sub(pc); *buffer.offset(i.wrapping_add(1 as size_t) as isize) = - (b1 & 0xf as u32 | addr >> 8 as c_int & 0xf0 as u32) as u8; + (b1 & 0xf as u32 | addr >> 8 & 0xf0 as u32) as u8; *buffer.offset(i.wrapping_add(2 as size_t) as isize) = - (addr >> 16 as c_int & 0xf as u32 - | addr >> 7 as c_int & 0x10 as u32 - | addr << 4 as c_int & 0xe0 as u32) as u8; + (addr >> 16 & 0xf as u32 | addr >> 7 & 0x10 as u32 | addr << 4 & 0xe0 as u32) + as u8; *buffer.offset(i.wrapping_add(3 as size_t) as isize) = - (addr >> 4 as c_int & 0x7f as u32 | addr >> 13 as c_int & 0x80 as u32) as u8; + (addr >> 4 & 0x7f as u32 | addr >> 13 & 0x80 as u32) as u8; i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); } } else if inst & 0x7f as u32 == 0x17 as u32 { let mut inst2: u32 = 0; - inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8 as c_int; - inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16 as c_int; - inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32) << 24 as c_int; + inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8; + inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16; + inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32) << 24; if inst & 0xe80 as u32 != 0 { - inst2 = read32le(buffer.offset(i as isize).offset(4 as isize)); - if (inst << 8 as c_int ^ inst2.wrapping_sub(3 as u32)) & 0xf8003 as u32 != 0 { + inst2 = read32le(buffer.offset(i as isize).offset(4)); + if (inst << 8 ^ inst2.wrapping_sub(3 as u32)) & 0xf8003 as u32 != 0 { i = i.wrapping_add((6 as c_int - 2 as c_int) as size_t); current_block_23 = 12517898123489920830; } else { let mut addr_0: u32 = inst & 0xfffff000 as u32; - addr_0 = addr_0.wrapping_add(inst2 >> 20 as c_int); - inst = - (0x17 as c_int | (2 as c_int) << 7 as c_int) as u32 | inst2 << 12 as c_int; + addr_0 = addr_0.wrapping_add(inst2 >> 20); + inst = (0x17 as c_int | (2 as c_int) << 7) as u32 | inst2 << 12; inst2 = addr_0; current_block_23 = 6669252993407410313; } } else { - let inst2_rs1: u32 = inst >> 27 as c_int; - if inst.wrapping_sub(0x3117 as u32) << 18 as c_int >= inst2_rs1 & 0x1d as u32 { + let inst2_rs1: u32 = inst >> 27; + if inst.wrapping_sub(0x3117 as u32) << 18 >= inst2_rs1 & 0x1d as u32 { i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); current_block_23 = 12517898123489920830; } else { - let mut addr_1: u32 = read32be(buffer.offset(i as isize).offset(4 as isize)); + let mut addr_1: u32 = read32be(buffer.offset(i as isize).offset(4)); addr_1 = addr_1.wrapping_sub(now_pos.wrapping_add(i as u32)); - inst2 = inst >> 12 as c_int | addr_1 << 20 as c_int; + inst2 = inst >> 12 | addr_1 << 20; inst = 0x17 as u32 - | inst2_rs1 << 7 as c_int + | inst2_rs1 << 7 | addr_1.wrapping_add(0x800 as u32) & 0xfffff000 as u32; current_block_23 = 6669252993407410313; } @@ -322,7 +316,7 @@ unsafe extern "C" fn riscv_decode( 12517898123489920830 => {} _ => { write32le(buffer.offset(i as isize), inst); - write32le(buffer.offset(i as isize).offset(4 as isize), inst2); + write32le(buffer.offset(i as isize).offset(4), inst2); i = i.wrapping_add((8 as c_int - 2 as c_int) as size_t); } } @@ -356,6 +350,6 @@ pub unsafe extern "C" fn lzma_bcj_riscv_decode( mut buf: *mut u8, mut size: size_t, ) -> size_t { - start_offset = (start_offset as c_uint & !(1 as c_uint)) as u32; + start_offset = (start_offset & !1u32) as u32; return riscv_decode(NULL, start_offset, false_0 != 0, buf, size); } diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index e2ab785c..6b422c59 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -141,7 +141,7 @@ pub struct lzma_simple_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615 as c_ulonglong; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; @@ -158,10 +158,7 @@ unsafe extern "C" fn copy_or_code( ) -> lzma_ret { if (*coder).next.code.is_none() { lzma_bufcpy(in_0, in_pos, in_size, out, out_pos, out_size); - if (*coder).is_encoder as c_int != 0 - && action as c_uint == LZMA_FINISH as c_uint - && *in_pos == in_size - { + if (*coder).is_encoder as c_int != 0 && action == LZMA_FINISH && *in_pos == in_size { (*coder).end_was_reached = true_0 != 0; } } else { @@ -176,9 +173,9 @@ unsafe extern "C" fn copy_or_code( out_size, action, ) as lzma_ret; - if ret as c_uint == LZMA_STREAM_END as c_uint { + if ret == LZMA_STREAM_END { (*coder).end_was_reached = true_0 != 0; - } else if ret as c_uint != LZMA_OK as c_uint { + } else if ret != LZMA_OK { return ret; } } @@ -196,7 +193,7 @@ unsafe extern "C" fn call_filter( buffer, size, ) as size_t; - (*coder).now_pos = ((*coder).now_pos as size_t).wrapping_add(filtered) as u32 as u32; + (*coder).now_pos = ((*coder).now_pos as size_t).wrapping_add(filtered) as u32; return filtered; } unsafe extern "C" fn simple_code( @@ -211,7 +208,7 @@ unsafe extern "C" fn simple_code( mut action: lzma_action, ) -> lzma_ret { let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; - if action as c_uint == LZMA_SYNC_FLUSH as c_uint { + if action == LZMA_SYNC_FLUSH { return LZMA_OPTIONS_ERROR; } if (*coder).pos < (*coder).filtered { @@ -247,7 +244,7 @@ unsafe extern "C" fn simple_code( let ret: lzma_ret = copy_or_code( coder, allocator, in_0, in_pos, in_size, out, out_pos, out_size, action, ) as lzma_ret; - if ret as c_uint != LZMA_OK as c_uint { + if ret != LZMA_OK { return ret; } let size: size_t = (*out_pos).wrapping_sub(out_start); @@ -290,7 +287,7 @@ unsafe extern "C" fn simple_code( (*coder).allocated, action, ) as lzma_ret; - if ret_0 as c_uint != LZMA_OK as c_uint { + if ret_0 != LZMA_OK { return ret_0; } (*coder).filtered = call_filter(coder, &raw mut (*coder).buffer as *mut u8, (*coder).size); @@ -330,7 +327,7 @@ unsafe extern "C" fn simple_coder_update( return lzma_next_filter_update( &raw mut (*coder).next, allocator, - reversed_filters.offset(1 as isize), + reversed_filters.offset(1), ); } #[no_mangle] @@ -412,9 +409,9 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*coder).simple = NULL; } } - if !(*filters.offset(0 as isize)).options.is_null() { + if !(*filters.offset(0)).options.is_null() { let mut simple: *const lzma_options_bcj = - (*filters.offset(0 as isize)).options as *const lzma_options_bcj; + (*filters.offset(0)).options as *const lzma_options_bcj; (*coder).now_pos = (*simple).start_offset; if (*coder).now_pos & alignment.wrapping_sub(1 as u32) != 0 { return LZMA_OPTIONS_ERROR; @@ -427,9 +424,5 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*coder).pos = 0 as size_t; (*coder).filtered = 0 as size_t; (*coder).size = 0 as size_t; - return lzma_next_filter_init( - &raw mut (*coder).next, - allocator, - filters.offset(1 as isize), - ); + return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs index d47ac6b1..41d23276 100644 --- a/liblzma-rs/src/simple/simple_decoder.rs +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -41,10 +41,10 @@ pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; #[inline] unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0 as isize) as u32; - num |= (*buf.offset(1 as isize) as u32) << 8 as c_int; - num |= (*buf.offset(2 as isize) as u32) << 16 as c_int; - num |= (*buf.offset(3 as isize) as u32) << 24 as c_int; + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; return num; } #[no_mangle] diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index 6d548ad6..d4c3e7a0 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -30,10 +30,10 @@ pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0 as isize) = num as u8; - *buf.offset(1 as isize) = (num >> 8 as c_int) as u8; - *buf.offset(2 as isize) = (num >> 16 as c_int) as u8; - *buf.offset(3 as isize) = (num >> 24 as c_int) as u8; + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_size( diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index bbc1fdae..5eca34dc 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -126,10 +126,9 @@ unsafe extern "C" fn sparc_code( && *buffer.offset(i.wrapping_add(1 as size_t) as isize) as c_int & 0xc0 as c_int == 0xc0 as c_int { - let mut src: u32 = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32) - << 24 as c_int - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 16 as c_int - | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 8 as c_int + let mut src: u32 = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32) << 24 + | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 16 + | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 8 | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; src <<= 2 as c_int; let mut dest: u32 = 0; @@ -139,13 +138,12 @@ unsafe extern "C" fn sparc_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } dest >>= 2 as c_int; - dest = (0 as u32).wrapping_sub(dest >> 22 as c_int & 1 as u32) << 22 as c_int - & 0x3fffffff as u32 + dest = (0 as u32).wrapping_sub(dest >> 22 & 1 as u32) << 22 & 0x3fffffff as u32 | dest & 0x3fffff as u32 | 0x40000000 as u32; - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest >> 24 as c_int) as u8; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 16 as c_int) as u8; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 8 as c_int) as u8; + *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest >> 24) as u8; + *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 16) as u8; + *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 8) as u8; *buffer.offset(i.wrapping_add(3 as size_t) as isize) = dest as u8; } i = i.wrapping_add(4 as size_t); diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index ae7b48ec..5b724284 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -169,14 +169,12 @@ unsafe extern "C" fn x86_code( } b = *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize); if (b as c_int == 0 as c_int || b as c_int == 0xff as c_int) - && prev_mask >> 1 as c_int <= 4 as u32 - && prev_mask >> 1 as c_int != 3 as u32 + && prev_mask >> 1 <= 4 as u32 + && prev_mask >> 1 != 3 as u32 { - let mut src: u32 = (b as u32) << 24 as c_int - | (*buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) as u32) - << 16 as c_int - | (*buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) as u32) - << 8 as c_int + let mut src: u32 = (b as u32) << 24 + | (*buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) as u32) << 16 + | (*buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) as u32) << 8 | *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) as u32; let mut dest: u32 = 0; loop { @@ -196,7 +194,7 @@ unsafe extern "C" fn x86_code( if prev_mask == 0 as u32 { break; } - let i_0: u32 = MASK_TO_BIT_NUMBER[(prev_mask >> 1 as c_int) as usize]; + let i_0: u32 = MASK_TO_BIT_NUMBER[(prev_mask >> 1) as usize]; b = (dest >> (24 as u32).wrapping_sub(i_0.wrapping_mul(8 as u32))) as u8; if !(b as c_int == 0 as c_int || b as c_int == 0xff as c_int) { break; @@ -206,11 +204,9 @@ unsafe extern "C" fn x86_code( .wrapping_sub(1 as u32); } *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize) = - !(dest >> 24 as c_int & 1 as u32).wrapping_sub(1 as u32) as u8; - *buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) = - (dest >> 16 as c_int) as u8; - *buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) = - (dest >> 8 as c_int) as u8; + !(dest >> 24 & 1 as u32).wrapping_sub(1 as u32) as u8; + *buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) = (dest >> 16) as u8; + *buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) = (dest >> 8) as u8; *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) = dest as u8; buffer_pos = buffer_pos.wrapping_add(5 as size_t); prev_mask = 0 as u32; @@ -243,7 +239,7 @@ unsafe extern "C" fn x86_coder_init( 1 as u32, is_encoder, ) as lzma_ret; - if ret as c_uint == LZMA_OK as c_uint { + if ret == LZMA_OK { let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; let mut simple: *mut lzma_simple_x86 = (*coder).simple as *mut lzma_simple_x86; (*simple).prev_mask = 0 as u32; From b178d87a55b65470abfd75f424abeb70ec3b6907 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Feb 2026 16:35:39 +0900 Subject: [PATCH 04/51] fix: restore my_min intent, rename literal --- liblzma-rs/src/check/sha256.rs | 17 ++++++++--------- liblzma-rs/src/common/alone_decoder.rs | 2 +- liblzma-rs/src/common/alone_encoder.rs | 2 +- liblzma-rs/src/common/auto_decoder.rs | 2 +- liblzma-rs/src/common/block_buffer_decoder.rs | 2 +- liblzma-rs/src/common/block_buffer_encoder.rs | 2 +- liblzma-rs/src/common/block_decoder.rs | 2 +- liblzma-rs/src/common/block_encoder.rs | 2 +- liblzma-rs/src/common/block_header_decoder.rs | 2 +- liblzma-rs/src/common/block_header_encoder.rs | 2 +- liblzma-rs/src/common/block_util.rs | 2 +- liblzma-rs/src/common/common.rs | 2 +- liblzma-rs/src/common/easy_preset.rs | 2 +- liblzma-rs/src/common/file_info.rs | 2 +- liblzma-rs/src/common/filter_buffer_decoder.rs | 2 +- liblzma-rs/src/common/filter_buffer_encoder.rs | 2 +- liblzma-rs/src/common/filter_common.rs | 2 +- liblzma-rs/src/common/filter_encoder.rs | 2 +- liblzma-rs/src/common/index.rs | 4 ++-- liblzma-rs/src/common/index_decoder.rs | 2 +- liblzma-rs/src/common/index_hash.rs | 2 +- liblzma-rs/src/common/lzip_decoder.rs | 2 +- liblzma-rs/src/common/microlzma_decoder.rs | 2 +- liblzma-rs/src/common/microlzma_encoder.rs | 2 +- liblzma-rs/src/common/outqueue.rs | 4 ++-- liblzma-rs/src/common/stream_buffer_decoder.rs | 2 +- liblzma-rs/src/common/stream_buffer_encoder.rs | 14 ++++++-------- liblzma-rs/src/common/stream_decoder.rs | 5 +++-- liblzma-rs/src/common/stream_decoder_mt.rs | 7 ++++--- liblzma-rs/src/common/stream_encoder.rs | 5 +++-- liblzma-rs/src/common/stream_encoder_mt.rs | 2 +- liblzma-rs/src/common/stream_flags_common.rs | 2 +- liblzma-rs/src/common/stream_flags_decoder.rs | 2 +- liblzma-rs/src/common/string_conversion.rs | 4 ++-- liblzma-rs/src/common/vli_encoder.rs | 2 +- liblzma-rs/src/common/vli_size.rs | 2 +- liblzma-rs/src/delta/delta_common.rs | 4 ++-- liblzma-rs/src/delta/delta_decoder.rs | 3 ++- liblzma-rs/src/delta/delta_encoder.rs | 5 +++-- liblzma-rs/src/lz/lz_decoder.rs | 6 +++--- liblzma-rs/src/lz/lz_encoder.rs | 2 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 2 +- liblzma-rs/src/lzma/lzma_decoder.rs | 2 +- liblzma-rs/src/lzma/lzma_encoder.rs | 4 ++-- .../src/lzma/lzma_encoder_optimum_fast.rs | 3 ++- .../src/lzma/lzma_encoder_optimum_normal.rs | 3 ++- liblzma-rs/src/simple/simple_coder.rs | 2 +- 47 files changed, 78 insertions(+), 74 deletions(-) diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index 48c816b4..62021c18 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -628,15 +628,14 @@ pub unsafe extern "C" fn lzma_sha256_finish(mut check: *mut lzma_check_state) { (*check).buffer.u8_0[fresh9 as usize] = 0 as u8; } (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8 as u64); - (*check).buffer.u64_0[7] = - ((*check).state.sha256.size & 0xff as u64) << 56 - | ((*check).state.sha256.size & 0xff00 as u64) << 40 - | ((*check).state.sha256.size & 0xff0000 as u64) << 24 - | ((*check).state.sha256.size & 0xff000000 as u64) << 8 - | ((*check).state.sha256.size & 0xff00000000 as u64) >> 8 - | ((*check).state.sha256.size & 0xff0000000000 as u64) >> 24 - | ((*check).state.sha256.size & 0xff000000000000 as u64) >> 40 - | ((*check).state.sha256.size & 0xff00000000000000 as u64) >> 56; + (*check).buffer.u64_0[7] = ((*check).state.sha256.size & 0xff as u64) << 56 + | ((*check).state.sha256.size & 0xff00 as u64) << 40 + | ((*check).state.sha256.size & 0xff0000 as u64) << 24 + | ((*check).state.sha256.size & 0xff000000 as u64) << 8 + | ((*check).state.sha256.size & 0xff00000000 as u64) >> 8 + | ((*check).state.sha256.size & 0xff0000000000 as u64) >> 24 + | ((*check).state.sha256.size & 0xff000000000000 as u64) >> 40 + | ((*check).state.sha256.size & 0xff00000000000000 as u64) >> 56; process(check); let mut i: size_t = 0 as size_t; while i < 8 as size_t { diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index c0c9b783..2361d9df 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -210,7 +210,7 @@ pub type lzma_init_function = Option< pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index 76b73636..23b01d3f 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -211,7 +211,7 @@ pub const SEQ_HEADER: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 102e11a1..0e0dc049 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -153,7 +153,7 @@ pub struct lzma_auto_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index 06999e02..f522eb7b 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -124,7 +124,7 @@ pub struct lzma_block { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_decode( diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index cd6397c9..01b019c5 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -198,7 +198,7 @@ pub struct lzma_sha256_state { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index b67b2fd5..6fe975f0 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -232,7 +232,7 @@ pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 9eeb44ab..b5104ffb 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -233,7 +233,7 @@ pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 3454526c..e7f97924 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -94,7 +94,7 @@ pub struct lzma_block { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const false_0: c_int = 0 as c_int; #[inline] unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 63bfb24a..a9393fbd 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -88,7 +88,7 @@ pub struct lzma_block { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { *buf.offset(0) = num as u8; diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 37710664..064319e1 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -71,7 +71,7 @@ pub struct lzma_block { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index cbc7d5c4..e293b580 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -144,7 +144,7 @@ pub type lzma_init_function = Option< pub type lzma_filter_info = lzma_filter_info_s; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VERSION_MAJOR: c_int = 5 as c_int; diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index fa2a1c08..7a9b9ea9 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -51,7 +51,7 @@ pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 2bab0b08..7dda702e 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -220,7 +220,7 @@ pub const SEQ_PADDING_SEEK: C2RustUnnamed_0 = 1; pub const SEQ_MAGIC_BYTES: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index a3ee5096..06db2648 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -89,7 +89,7 @@ pub type lzma_code_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_decode( diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index 96031d55..b945d7c1 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -89,7 +89,7 @@ pub type lzma_code_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_encode( diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 6d80af9e..c2e6a925 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -178,7 +178,7 @@ pub struct lzma_filter_coder { pub type lzma_filter_find = Option *const lzma_filter_coder>; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index 72572e0d..b2584fc3 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -232,7 +232,7 @@ pub struct lzma_filter_coder { pub type lzma_filter_find = Option *const lzma_filter_coder>; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 6f9b215d..60d9cb86 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -202,8 +202,8 @@ pub type C2RustUnnamed_3 = c_uint; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; -pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; +pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index fdf8f9dc..303e1b5d 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -175,7 +175,7 @@ pub const SEQ_COUNT: C2RustUnnamed_0 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 882e01ab..6262dab8 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -113,7 +113,7 @@ pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; pub type lzma_index_hash = lzma_index_hash_s; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 2df6985a..68f21d43 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -225,7 +225,7 @@ pub type lzma_init_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index d5954096..dd2208d9 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -201,7 +201,7 @@ pub type lzma_init_function = Option< pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index 5abd860d..e0794cb8 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -196,7 +196,7 @@ pub struct lzma_microlzma_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index 3935799a..938c2c16 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -70,8 +70,8 @@ pub struct lzma_outq { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; -pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; +pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const false_0: c_int = 0 as c_int; pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index 1cc02404..9deb1a67 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -90,7 +90,7 @@ pub type lzma_code_function = Option< >; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; #[no_mangle] diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 644251fc..f2ec30b5 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -133,6 +133,8 @@ pub struct lzma_block { pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; +pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; pub const INDEX_BOUND: c_int = @@ -145,14 +147,10 @@ pub unsafe extern "C" fn lzma_stream_buffer_bound(mut uncompressed_size: size_t) if block_bound == 0 as size_t { return 0 as size_t; } - if (if 18446744073709551615_u64 < 18446744073709551615_u64.wrapping_div(2) { - 18446744073709551615_u64 - } else { - 18446744073709551615_u64.wrapping_div(2) - }) - .wrapping_sub(block_bound as u64) - < HEADERS_BOUND as u64 - { + + // Match C: my_min(SIZE_MAX, LZMA_VLI_MAX) - block_bound < HEADERS_BOUND. + let stream_bound_max: size_t = core::cmp::min(size_t::MAX, LZMA_VLI_MAX as size_t); + if stream_bound_max.wrapping_sub(block_bound) < HEADERS_BOUND as size_t { return 0 as size_t; } return block_bound.wrapping_add(HEADERS_BOUND as size_t); diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 0eabf1f2..2dde2a66 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -193,8 +193,9 @@ pub struct lzma_stream_coder { pub concatenated: bool, pub first_stream: bool, pub pos: size_t, - pub buffer: [u8; 1024], + pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; pub type lzma_index_hash = lzma_index_hash_s; #[derive(Copy, Clone)] #[repr(C)] @@ -261,7 +262,7 @@ pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index d43441a6..809c322d 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -379,8 +379,9 @@ pub struct lzma_stream_coder { pub first_stream: bool, pub out_was_filled: bool, pub pos: size_t, - pub buffer: [u8; 1024], + pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_outq { @@ -508,8 +509,8 @@ pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; -pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; +pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const SIG_SETMASK: c_int = 3 as c_int; pub const true_0: c_int = 1 as c_int; diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index a65ec88c..337f0e18 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -182,8 +182,9 @@ pub struct lzma_stream_coder { pub index: *mut lzma_index, pub buffer_pos: size_t, pub buffer_size: size_t, - pub buffer: [u8; 1024], + pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] @@ -249,7 +250,7 @@ pub struct lzma_stream_flags { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 6946de5a..aa4a3abf 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -522,7 +522,7 @@ pub struct lzma_options_easy { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const SIG_SETMASK: c_int = 3 as c_int; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index 432493b4..29d5185e 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -47,7 +47,7 @@ pub struct lzma_stream_flags { pub reserved_int1: u32, pub reserved_int2: u32, } -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4 as c_int; diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 4974d74a..8f775049 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -53,7 +53,7 @@ pub struct lzma_stream_flags { pub reserved_int1: u32, pub reserved_int2: u32, } -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index d6886fba..6db51d8a 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -154,8 +154,8 @@ pub const OPTMAP_TYPE_UINT32: C2RustUnnamed_2 = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; -pub const INT_MAX: c_int = 2147483647 as c_int; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; +pub const INT_MAX: c_int = c_int::MAX; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index 1f309fea..7a665b91 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -23,7 +23,7 @@ pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; #[no_mangle] diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index f4c4d224..3ef9b7b2 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -1,6 +1,6 @@ use crate::types::*; use core::ffi::{c_int, c_ulonglong}; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); #[no_mangle] pub unsafe extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index ee6647ee..e9f732da 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -124,11 +124,11 @@ pub struct lzma_delta_coder { pub next: lzma_next_coder, pub distance: size_t, pub pos: u8, - pub history: [u8; 256], + pub history: [u8; LZMA_DELTA_DIST_MAX as usize], } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index b1831527..0c9818f9 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -121,8 +121,9 @@ pub struct lzma_delta_coder { pub next: lzma_next_coder, pub distance: size_t, pub pos: u8, - pub history: [u8; 256], + pub history: [u8; LZMA_DELTA_DIST_MAX as usize], } +pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; unsafe extern "C" fn decode_buffer( diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index 99809a8a..13ba4d25 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -126,11 +126,12 @@ pub struct lzma_delta_coder { pub next: lzma_next_coder, pub distance: size_t, pub pos: u8, - pub history: [u8; 256], + pub history: [u8; LZMA_DELTA_DIST_MAX as usize], } +pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; unsafe extern "C" fn copy_and_encode( mut coder: *mut lzma_delta_coder, diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 902e4c40..cf927b80 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -155,12 +155,12 @@ pub struct lzma_coder { pub struct C2RustUnnamed { pub pos: size_t, pub size: size_t, - pub buffer: [u8; 4096], + pub buffer: [u8; LZMA_BUFFER_SIZE as usize], } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; -pub const UINTPTR_MAX: c_ulong = 18446744073709551615 as c_ulong; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; +pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 455b9616..9ab6a7dc 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -203,7 +203,7 @@ pub struct lzma_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 62397644..26bbca7b 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -265,7 +265,7 @@ pub const SEQ_INIT: C2RustUnnamed = 0; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 2fad638c..146318ff 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -273,7 +273,7 @@ pub struct lzma_length_decoder { pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index a879984f..2e1e9e52 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -291,7 +291,7 @@ pub struct lzma_lzma1_encoder_s { pub align_price_count: u32, pub opts_end_index: u32, pub opts_current_index: u32, - pub opts: [lzma_optimal; 4096], + pub opts: [lzma_optimal; OPTS as usize], } #[derive(Copy, Clone)] #[repr(C)] @@ -322,7 +322,7 @@ pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; #[inline] diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 251cb34a..4cbc4e5d 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -113,8 +113,9 @@ pub struct lzma_lzma1_encoder_s { pub align_price_count: u32, pub opts_end_index: u32, pub opts_current_index: u32, - pub opts: [lzma_optimal; 4096], + pub opts: [lzma_optimal; OPTS as usize], } +pub const OPTS: c_int = (1 as c_int) << 12; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index c9842948..9f67fd0a 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -115,8 +115,9 @@ pub struct lzma_lzma1_encoder_s { pub align_price_count: u32, pub opts_end_index: u32, pub opts_current_index: u32, - pub opts: [lzma_optimal; 4096], + pub opts: [lzma_optimal; OPTS as usize], } +pub const OPTS: c_int = (1 as c_int) << 12; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 6b422c59..23582b38 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -141,7 +141,7 @@ pub struct lzma_simple_coder { } pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); pub const NULL: *mut c_void = __DARWIN_NULL; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; +pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const true_0: c_int = 1 as c_int; pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; From 25d740bc250d17c61381d22a0a36d901563ac079 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Feb 2026 16:48:37 +0900 Subject: [PATCH 05/51] narrow unsafe scope across all modules --- liblzma-rs/src/check/check.rs | 69 +- liblzma-rs/src/check/crc32_fast.rs | 13 +- liblzma-rs/src/check/crc64_fast.rs | 13 +- liblzma-rs/src/check/sha256.rs | 34 +- liblzma-rs/src/common/alone_decoder.rs | 98 ++- liblzma-rs/src/common/alone_encoder.rs | 72 +- liblzma-rs/src/common/auto_decoder.rs | 98 ++- liblzma-rs/src/common/block_buffer_decoder.rs | 24 +- liblzma-rs/src/common/block_buffer_encoder.rs | 147 ++-- liblzma-rs/src/common/block_decoder.rs | 69 +- liblzma-rs/src/common/block_encoder.rs | 78 +-- liblzma-rs/src/common/block_header_decoder.rs | 54 +- liblzma-rs/src/common/block_header_encoder.rs | 55 +- liblzma-rs/src/common/block_util.rs | 22 +- liblzma-rs/src/common/common.rs | 167 ++--- liblzma-rs/src/common/easy_buffer_encoder.rs | 24 +- .../src/common/easy_decoder_memusage.rs | 12 +- liblzma-rs/src/common/easy_encoder.rs | 12 +- .../src/common/easy_encoder_memusage.rs | 12 +- liblzma-rs/src/common/easy_preset.rs | 13 +- liblzma-rs/src/common/file_info.rs | 190 +++-- .../src/common/filter_buffer_decoder.rs | 30 +- .../src/common/filter_buffer_encoder.rs | 30 +- liblzma-rs/src/common/filter_common.rs | 178 +++-- liblzma-rs/src/common/filter_decoder.rs | 54 +- liblzma-rs/src/common/filter_encoder.rs | 83 +-- liblzma-rs/src/common/filter_flags_decoder.rs | 20 +- liblzma-rs/src/common/filter_flags_encoder.rs | 25 +- liblzma-rs/src/common/hardware_cputhreads.rs | 8 +- liblzma-rs/src/common/hardware_physmem.rs | 8 +- liblzma-rs/src/common/index.rs | 354 +++++----- liblzma-rs/src/common/index_decoder.rs | 128 ++-- liblzma-rs/src/common/index_encoder.rs | 86 +-- liblzma-rs/src/common/index_hash.rs | 81 +-- liblzma-rs/src/common/lzip_decoder.rs | 168 +++-- liblzma-rs/src/common/microlzma_decoder.rs | 82 ++- liblzma-rs/src/common/microlzma_encoder.rs | 49 +- liblzma-rs/src/common/outqueue.rs | 111 ++- .../src/common/stream_buffer_decoder.rs | 28 +- .../src/common/stream_buffer_encoder.rs | 55 +- liblzma-rs/src/common/stream_decoder.rs | 135 ++-- liblzma-rs/src/common/stream_decoder_mt.rs | 515 +++++++------- liblzma-rs/src/common/stream_encoder.rs | 113 ++- liblzma-rs/src/common/stream_encoder_mt.rs | 449 ++++++------ liblzma-rs/src/common/stream_flags_common.rs | 22 +- liblzma-rs/src/common/stream_flags_decoder.rs | 72 +- liblzma-rs/src/common/stream_flags_encoder.rs | 75 +- liblzma-rs/src/common/string_conversion.rs | 453 ++++++------ liblzma-rs/src/common/vli_decoder.rs | 24 +- liblzma-rs/src/common/vli_encoder.rs | 16 +- liblzma-rs/src/common/vli_size.rs | 6 +- liblzma-rs/src/delta/delta_common.rs | 40 +- liblzma-rs/src/delta/delta_decoder.rs | 56 +- liblzma-rs/src/delta/delta_encoder.rs | 73 +- liblzma-rs/src/lib.rs | 4 - liblzma-rs/src/lz/lz_decoder.rs | 127 ++-- liblzma-rs/src/lz/lz_encoder.rs | 235 ++++--- liblzma-rs/src/lz/lz_encoder_mf.rs | 278 ++++---- liblzma-rs/src/lzma/fastpos_table.rs | 2 - liblzma-rs/src/lzma/lzma2_decoder.rs | 107 ++- liblzma-rs/src/lzma/lzma2_encoder.rs | 164 +++-- liblzma-rs/src/lzma/lzma_decoder.rs | 647 +++++++++--------- liblzma-rs/src/lzma/lzma_encoder.rs | 593 ++++++++-------- .../src/lzma/lzma_encoder_optimum_fast.rs | 115 ++-- .../src/lzma/lzma_encoder_optimum_normal.rs | 505 +++++++------- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 53 +- liblzma-rs/src/rangecoder/price_table.rs | 2 - liblzma-rs/src/simple/arm.rs | 86 +-- liblzma-rs/src/simple/arm64.rs | 121 ++-- liblzma-rs/src/simple/armthumb.rs | 105 ++- liblzma-rs/src/simple/ia64.rs | 100 ++- liblzma-rs/src/simple/powerpc.rs | 93 ++- liblzma-rs/src/simple/riscv.rs | 180 ++--- liblzma-rs/src/simple/simple_coder.rs | 133 ++-- liblzma-rs/src/simple/simple_decoder.rs | 36 +- liblzma-rs/src/simple/simple_encoder.rs | 28 +- liblzma-rs/src/simple/sparc.rs | 91 +-- liblzma-rs/src/simple/x86.rs | 171 +++-- liblzma-rs/src/tuklib/tuklib_cpucores.rs | 4 +- liblzma-rs/src/tuklib/tuklib_physmem.rs | 27 +- 80 files changed, 4258 insertions(+), 4652 deletions(-) diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index f49f904f..ffc2408e 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint}; +use core::ffi::c_uint; extern "C" { fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64; @@ -38,53 +38,51 @@ pub union C2RustUnnamed_0 { pub u64_0: [u64; 8], } pub const UINT32_MAX: c_uint = 4294967295; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; #[no_mangle] -pub unsafe extern "C" fn lzma_check_is_supported(mut type_0: lzma_check) -> lzma_bool { +pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { if type_0 > LZMA_CHECK_ID_MAX { - return false_0 as lzma_bool; + return false as lzma_bool; } - static mut available_checks: [lzma_bool; 16] = [ - true_0 as lzma_bool, - true_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, - true_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, - true_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, - false_0 as lzma_bool, + static available_checks: [lzma_bool; 16] = [ + true as lzma_bool, + true as lzma_bool, + false as lzma_bool, + false as lzma_bool, + true as lzma_bool, + false as lzma_bool, + false as lzma_bool, + false as lzma_bool, + false as lzma_bool, + false as lzma_bool, + true as lzma_bool, + false as lzma_bool, + false as lzma_bool, + false as lzma_bool, + false as lzma_bool, + false as lzma_bool, ]; return available_checks[type_0 as usize]; } #[no_mangle] -pub unsafe extern "C" fn lzma_check_size(mut type_0: lzma_check) -> u32 { +pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { if type_0 > LZMA_CHECK_ID_MAX { return UINT32_MAX as u32; } - static mut check_sizes: [u8; 16] = [ - 0 as u8, 4 as u8, 4 as u8, 4 as u8, 8 as u8, 8 as u8, 8 as u8, 16 as u8, 16 as u8, - 16 as u8, 32 as u8, 32 as u8, 32 as u8, 64 as u8, 64 as u8, 64 as u8, + static check_sizes: [u8; 16] = [ + 0, 4 as u8, 4 as u8, 4 as u8, 8 as u8, 8 as u8, 8 as u8, 16 as u8, 16 as u8, 16 as u8, + 32 as u8, 32 as u8, 32 as u8, 64 as u8, 64 as u8, 64 as u8, ]; return check_sizes[type_0 as usize] as u32; } #[no_mangle] -pub unsafe extern "C" fn lzma_check_init(mut check: *mut lzma_check_state, mut type_0: lzma_check) { +pub unsafe extern "C" fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check) { match type_0 { 1 => { - (*check).state.crc32 = 0 as u32; + (*check).state.crc32 = 0; } 4 => { - (*check).state.crc64 = 0 as u64; + (*check).state.crc64 = 0; } 10 => { lzma_sha256_init(check); @@ -94,10 +92,10 @@ pub unsafe extern "C" fn lzma_check_init(mut check: *mut lzma_check_state, mut t } #[no_mangle] pub unsafe extern "C" fn lzma_check_update( - mut check: *mut lzma_check_state, - mut type_0: lzma_check, - mut buf: *const u8, - mut size: size_t, + check: *mut lzma_check_state, + type_0: lzma_check, + buf: *const u8, + size: size_t, ) { match type_0 { 1 => { @@ -113,10 +111,7 @@ pub unsafe extern "C" fn lzma_check_update( }; } #[no_mangle] -pub unsafe extern "C" fn lzma_check_finish( - mut check: *mut lzma_check_state, - mut type_0: lzma_check, -) { +pub unsafe extern "C" fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check) { match type_0 { 1 => { (*check).buffer.u32_0[0] = (*check).state.crc32; diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index 441de40c..3196fe41 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -1,7 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_uint}; #[inline] -unsafe extern "C" fn aligned_read32ne(mut buf: *const u8) -> u32 { +unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { return *(buf as *const u32); } #[no_mangle] @@ -321,15 +320,15 @@ pub static mut lzma_crc32_table: [[u32; 256]; 8] = [ ]; unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mut crc: u32) -> u32 { crc = !crc; - if size > 8 as size_t { + if size > 8 { while buf as uintptr_t & 7 as uintptr_t != 0 { let fresh0 = buf; buf = buf.offset(1); crc = lzma_crc32_table[0][(*fresh0 as u32 ^ crc & 0xff) as usize] ^ crc >> 8; size = size.wrapping_sub(1); } - let limit: *const u8 = buf.offset((size & !(7 as size_t)) as isize); - size &= 7 as size_t; + let limit: *const u8 = buf.offset((size & !(7)) as isize); + size &= 7; while buf < limit { crc ^= aligned_read32ne(buf); buf = buf.offset(4); @@ -349,7 +348,7 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu loop { let fresh1 = size; size = size.wrapping_sub(1); - if !(fresh1 != 0 as size_t) { + if !(fresh1 != 0) { break; } let fresh2 = buf; @@ -359,6 +358,6 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu return !crc; } #[no_mangle] -pub unsafe extern "C" fn lzma_crc32(mut buf: *const u8, mut size: size_t, mut crc: u32) -> u32 { +pub unsafe extern "C" fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32 { return lzma_crc32_generic(buf, size, crc); } diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index ec6f5a1f..ffc1860a 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1,7 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong}; #[inline] -unsafe extern "C" fn aligned_read32ne(mut buf: *const u8) -> u32 { +unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { return *(buf as *const u32); } #[no_mangle] @@ -1041,15 +1040,15 @@ pub static mut lzma_crc64_table: [[u64; 256]; 4] = [ ]; unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mut crc: u64) -> u64 { crc = !crc; - if size > 4 as size_t { + if size > 4 { while buf as uintptr_t & 3 as uintptr_t != 0 { let fresh0 = buf; buf = buf.offset(1); crc = lzma_crc64_table[0][(*fresh0 as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; size = size.wrapping_sub(1); } - let limit: *const u8 = buf.offset((size & !(3 as size_t)) as isize); - size &= 3 as size_t; + let limit: *const u8 = buf.offset((size & !(3)) as isize); + size &= 3; while buf < limit { let tmp: u32 = crc as u32 ^ aligned_read32ne(buf) as u32; buf = buf.offset(4); @@ -1063,7 +1062,7 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu loop { let fresh1 = size; size = size.wrapping_sub(1); - if !(fresh1 != 0 as size_t) { + if !(fresh1 != 0) { break; } let fresh2 = buf; @@ -1073,6 +1072,6 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu return !crc; } #[no_mangle] -pub unsafe extern "C" fn lzma_crc64(mut buf: *const u8, mut size: size_t, mut crc: u64) -> u64 { +pub unsafe extern "C" fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64 { return lzma_crc64_generic(buf, size, crc); } diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index 62021c18..3b364b94 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -30,7 +30,7 @@ pub union C2RustUnnamed_0 { pub u64_0: [u64; 8], } #[inline] -unsafe extern "C" fn rotr_32(mut num: u32, mut amount: c_uint) -> u32 { +extern "C" fn rotr_32(num: u32, amount: c_uint) -> u32 { return num >> amount | num << 32u32.wrapping_sub(amount); } static mut SHA256_K: [u32; 64] = [ @@ -43,13 +43,13 @@ static mut SHA256_K: [u32; 64] = [ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, ]; -unsafe extern "C" fn transform(mut state: *mut u32, mut data: *const u32) { +unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { let mut W: [u32; 16] = [0; 16]; let mut T: [u32; 8] = [0; 8]; memcpy( &raw mut T as *mut u32 as *mut c_void, state as *const c_void, - ::core::mem::size_of::<[u32; 8]>() as size_t, + core::mem::size_of::<[u32; 8]>() as size_t, ); W[0] = (*data.offset(0) & 0xff) << 24 | (*data.offset(0) & 0xff00) << 8 @@ -568,14 +568,14 @@ unsafe extern "C" fn transform(mut state: *mut u32, mut data: *const u32) { let ref mut fresh7 = *state.offset(7); *fresh7 = (*fresh7).wrapping_add(T[7]); } -unsafe extern "C" fn process(mut check: *mut lzma_check_state) { +unsafe extern "C" fn process(check: *mut lzma_check_state) { transform( &raw mut (*check).state.sha256.state as *mut u32, &raw mut (*check).buffer.u32_0 as *mut u32 as *const u32, ); } #[no_mangle] -pub unsafe extern "C" fn lzma_sha256_init(mut check: *mut lzma_check_state) { +pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { static mut s: [u32; 8] = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, @@ -583,17 +583,17 @@ pub unsafe extern "C" fn lzma_sha256_init(mut check: *mut lzma_check_state) { memcpy( &raw mut (*check).state.sha256.state as *mut u32 as *mut c_void, &raw const s as *const u32 as *const c_void, - ::core::mem::size_of::<[u32; 8]>() as size_t, + core::mem::size_of::<[u32; 8]>() as size_t, ); - (*check).state.sha256.size = 0 as u64; + (*check).state.sha256.size = 0; } #[no_mangle] pub unsafe extern "C" fn lzma_sha256_update( mut buf: *const u8, mut size: size_t, - mut check: *mut lzma_check_state, + check: *mut lzma_check_state, ) { - while size > 0 as size_t { + while size > 0 { let copy_start: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; let mut copy_size: size_t = (64 as size_t).wrapping_sub(copy_start); if copy_size > size { @@ -607,27 +607,27 @@ pub unsafe extern "C" fn lzma_sha256_update( buf = buf.offset(copy_size as isize); size = size.wrapping_sub(copy_size); (*check).state.sha256.size = (*check).state.sha256.size.wrapping_add(copy_size as u64); - if (*check).state.sha256.size & 0x3f as u64 == 0 as u64 { + if (*check).state.sha256.size & 0x3f as u64 == 0 { process(check); } } } #[no_mangle] -pub unsafe extern "C" fn lzma_sha256_finish(mut check: *mut lzma_check_state) { +pub unsafe extern "C" fn lzma_sha256_finish(check: *mut lzma_check_state) { let mut pos: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; let fresh8 = pos; pos = pos.wrapping_add(1); (*check).buffer.u8_0[fresh8 as usize] = 0x80 as u8; while pos != (64 as c_int - 8 as c_int) as size_t { - if pos == 64 as size_t { + if pos == 64 { process(check); - pos = 0 as size_t; + pos = 0; } let fresh9 = pos; pos = pos.wrapping_add(1); - (*check).buffer.u8_0[fresh9 as usize] = 0 as u8; + (*check).buffer.u8_0[fresh9 as usize] = 0; } - (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8 as u64); + (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8); (*check).buffer.u64_0[7] = ((*check).state.sha256.size & 0xff as u64) << 56 | ((*check).state.sha256.size & 0xff00 as u64) << 40 | ((*check).state.sha256.size & 0xff0000 as u64) << 24 @@ -637,8 +637,8 @@ pub unsafe extern "C" fn lzma_sha256_finish(mut check: *mut lzma_check_state) { | ((*check).state.sha256.size & 0xff000000000000 as u64) >> 40 | ((*check).state.sha256.size & 0xff00000000000000 as u64) >> 56; process(check); - let mut i: size_t = 0 as size_t; - while i < 8 as size_t { + let mut i: size_t = 0; + while i < 8 { (*check).buffer.u32_0[i as usize] = ((*check).state.sha256.state[i as usize] & 0xff) << 24 | ((*check).state.sha256.state[i as usize] & 0xff00) << 8 | ((*check).state.sha256.state[i as usize] & 0xff0000) >> 8 diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 2361d9df..461b0612 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -207,29 +207,26 @@ pub type lzma_init_function = Option< *const lzma_filter_info, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; unsafe extern "C" fn alone_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; + let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; while *out_pos < out_size && ((*coder).sequence == SEQ_CODE || *in_pos < in_size) { - let mut current_block_42: u64; + let current_block_42: u64; match (*coder).sequence { 0 => { if lzma_lzma_lclppb_decode( @@ -244,15 +241,14 @@ unsafe extern "C" fn alone_decode( } 1 => { (*coder).options.dict_size = ((*coder).options.dict_size as size_t - | (*in_0.offset(*in_pos as isize) as size_t) - << (*coder).pos.wrapping_mul(8 as size_t)) + | (*in_0.offset(*in_pos as isize) as size_t) << (*coder).pos.wrapping_mul(8)) as u32; (*coder).pos = (*coder).pos.wrapping_add(1); - if (*coder).pos == 4 as size_t { + if (*coder).pos == 4 { if (*coder).picky as c_int != 0 && (*coder).options.dict_size != UINT32_MAX as u32 { - let mut d: u32 = (*coder).options.dict_size.wrapping_sub(1 as u32); + let mut d: u32 = (*coder).options.dict_size.wrapping_sub(1); d |= d >> 2; d |= d >> 3; d |= d >> 4; @@ -263,18 +259,18 @@ unsafe extern "C" fn alone_decode( return LZMA_FORMAT_ERROR; } } - (*coder).pos = 0 as size_t; + (*coder).pos = 0; (*coder).sequence = SEQ_UNCOMPRESSED_SIZE; } *in_pos = (*in_pos).wrapping_add(1); current_block_42 = 11048769245176032998; } 2 => { - (*coder).uncompressed_size |= (*in_0.offset(*in_pos as isize) as lzma_vli) - << (*coder).pos.wrapping_mul(8 as size_t); + (*coder).uncompressed_size |= + (*in_0.offset(*in_pos as isize) as lzma_vli) << (*coder).pos.wrapping_mul(8); *in_pos = (*in_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); - if (*coder).pos < 8 as size_t { + if (*coder).pos < 8 { current_block_42 = 11048769245176032998; } else { if (*coder).picky as c_int != 0 @@ -290,7 +286,7 @@ unsafe extern "C" fn alone_decode( &raw mut (*coder).options as *const c_void, ) .wrapping_add(LZMA_MEMUSAGE_BASE as u64); - (*coder).pos = 0 as size_t; + (*coder).pos = 0; (*coder).sequence = SEQ_CODER_INIT; current_block_42 = 14763689060501151050; } @@ -335,7 +331,7 @@ unsafe extern "C" fn alone_decode( lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }, ]; let ret_: lzma_ret = lzma_next_filter_init( @@ -353,24 +349,21 @@ unsafe extern "C" fn alone_decode( } return LZMA_OK; } -unsafe extern "C" fn alone_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; +unsafe extern "C" fn alone_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn alone_decoder_memconfig( - mut coder_ptr: *mut c_void, - mut memusage: *mut u64, - mut old_memlimit: *mut u64, - mut new_memlimit: u64, + coder_ptr: *mut c_void, + memusage: *mut u64, + old_memlimit: *mut u64, + new_memlimit: u64, ) -> lzma_ret { - let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; + let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; *memusage = (*coder).memusage; *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as u64 { + if new_memlimit != 0 { if new_memlimit < (*coder).memusage { return LZMA_MEMLIMIT_ERROR; } @@ -380,10 +373,10 @@ unsafe extern "C" fn alone_decoder_memconfig( } #[no_mangle] pub unsafe extern "C" fn lzma_alone_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut memlimit: u64, - mut picky: bool, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + memlimit: u64, + picky: bool, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -429,7 +422,7 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_alone_coder; if coder.is_null() { @@ -459,9 +452,9 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( ) as Option lzma_ret>; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -473,24 +466,17 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( } (*coder).sequence = SEQ_PROPERTIES; (*coder).picky = picky; - (*coder).pos = 0 as size_t; - (*coder).options.dict_size = 0 as u32; + (*coder).pos = 0; + (*coder).options.dict_size = 0; (*coder).options.preset_dict = ::core::ptr::null::(); - (*coder).options.preset_dict_size = 0 as u32; + (*coder).options.preset_dict_size = 0; (*coder).uncompressed_size = 0 as lzma_vli; - (*coder).memlimit = if 1 as u64 > memlimit { - 1 as u64 - } else { - memlimit - }; + (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_alone_decoder( - mut strm: *mut lzma_stream, - mut memlimit: u64, -) -> lzma_ret { +pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { return ret_; @@ -505,7 +491,7 @@ pub unsafe extern "C" fn lzma_alone_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index 23b01d3f..d69da6db 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -208,34 +208,33 @@ pub struct lzma_alone_coder { pub type C2RustUnnamed_0 = c_uint; pub const SEQ_CODE: C2RustUnnamed_0 = 1; pub const SEQ_HEADER: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0) = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; +extern "C" fn write32le(buf: *mut u8, num: u32) { + unsafe { + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; + } } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; -pub const ALONE_HEADER_SIZE: c_int = 1 as c_int + 4 as c_int + 8 as c_int; +pub const ALONE_HEADER_SIZE: c_int = 1 + 4 as c_int + 8 as c_int; unsafe extern "C" fn alone_encode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; + let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; while *out_pos < out_size { match (*coder).sequence { 0 => { @@ -270,18 +269,15 @@ unsafe extern "C" fn alone_encode( } return LZMA_OK; } -unsafe extern "C" fn alone_encoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; +unsafe extern "C" fn alone_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn alone_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut options: *const lzma_options_lzma, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_options_lzma, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -323,7 +319,7 @@ unsafe extern "C" fn alone_encoder_init( let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_alone_coder; if coder.is_null() { @@ -348,9 +344,9 @@ unsafe extern "C" fn alone_encoder_init( alone_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -361,14 +357,14 @@ unsafe extern "C" fn alone_encoder_init( }; } (*coder).sequence = SEQ_HEADER; - (*coder).header_pos = 0 as size_t; + (*coder).header_pos = 0; if lzma_lzma_lclppb_encode(options, &raw mut (*coder).header as *mut u8) { return LZMA_OPTIONS_ERROR; } if (*options).dict_size < LZMA_DICT_SIZE_MIN as u32 { return LZMA_OPTIONS_ERROR; } - let mut d: u32 = (*options).dict_size.wrapping_sub(1 as u32); + let mut d: u32 = (*options).dict_size.wrapping_sub(1); d |= d >> 2; d |= d >> 3; d |= d >> 4; @@ -381,7 +377,7 @@ unsafe extern "C" fn alone_encoder_init( memset( (&raw mut (*coder).header as *mut u8).offset(1).offset(4) as *mut c_void, 0xff as c_int, - 8 as size_t, + 8, ); let filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { @@ -399,7 +395,7 @@ unsafe extern "C" fn alone_encoder_init( lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }, ]; return lzma_next_filter_init( @@ -410,8 +406,8 @@ unsafe extern "C" fn alone_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_alone_encoder( - mut strm: *mut lzma_stream, - mut options: *const lzma_options_lzma, + strm: *mut lzma_stream, + options: *const lzma_options_lzma, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -426,7 +422,7 @@ pub unsafe extern "C" fn lzma_alone_encoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 0e0dc049..0d283c8a 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -151,10 +151,7 @@ pub struct lzma_auto_coder { pub flags: u32, pub sequence: C2RustUnnamed_0, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; @@ -170,18 +167,18 @@ pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_CONCATENATED | LZMA_FAIL_FAST; unsafe extern "C" fn auto_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; - let mut current_block_28: u64; + let coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; + let current_block_28: u64; match (*coder).sequence { 0 => { if *in_pos >= in_size { @@ -238,7 +235,7 @@ unsafe extern "C" fn auto_decode( out_size, action, ) as lzma_ret; - if ret != LZMA_STREAM_END || (*coder).flags & LZMA_CONCATENATED as u32 == 0 as u32 { + if ret != LZMA_STREAM_END || (*coder).flags & LZMA_CONCATENATED as u32 == 0 { return ret; } (*coder).sequence = SEQ_FINISH; @@ -254,29 +251,28 @@ unsafe extern "C" fn auto_decode( LZMA_OK as c_int }) as lzma_ret; } -unsafe extern "C" fn auto_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; +unsafe extern "C" fn auto_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free(coder as *mut c_void, allocator); } -unsafe extern "C" fn auto_decoder_get_check(mut coder_ptr: *const c_void) -> lzma_check { - let mut coder: *const lzma_auto_coder = coder_ptr as *const lzma_auto_coder; - return (if (*coder).next.get_check.is_none() { - LZMA_CHECK_NONE - } else { - (*coder).next.get_check.expect("non-null function pointer")((*coder).next.coder) - }) as lzma_check; +extern "C" fn auto_decoder_get_check(coder_ptr: *const c_void) -> lzma_check { + return unsafe { + let coder: *const lzma_auto_coder = coder_ptr as *const lzma_auto_coder; + (if (*coder).next.get_check.is_none() { + LZMA_CHECK_NONE + } else { + (*coder).next.get_check.expect("non-null function pointer")((*coder).next.coder) + }) as lzma_check + }; } unsafe extern "C" fn auto_decoder_memconfig( - mut coder_ptr: *mut c_void, - mut memusage: *mut u64, - mut old_memlimit: *mut u64, - mut new_memlimit: u64, + coder_ptr: *mut c_void, + memusage: *mut u64, + old_memlimit: *mut u64, + new_memlimit: u64, ) -> lzma_ret { - let mut coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; + let coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; let mut ret: lzma_ret = LZMA_OK; if (*coder).next.memconfig.is_some() { ret = (*coder).next.memconfig.expect("non-null function pointer")( @@ -289,20 +285,20 @@ unsafe extern "C" fn auto_decoder_memconfig( *memusage = LZMA_MEMUSAGE_BASE as u64; *old_memlimit = (*coder).memlimit; ret = LZMA_OK; - if new_memlimit != 0 as u64 && new_memlimit < *memusage { + if new_memlimit != 0 && new_memlimit < *memusage { ret = LZMA_MEMLIMIT_ERROR; } } - if ret == LZMA_OK && new_memlimit != 0 as u64 { + if ret == LZMA_OK && new_memlimit != 0 { (*coder).memlimit = new_memlimit; } return ret; } unsafe extern "C" fn auto_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut memlimit: u64, - mut flags: u32, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + memlimit: u64, + flags: u32, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -340,10 +336,8 @@ unsafe extern "C" fn auto_decoder_init( } let mut coder: *mut lzma_auto_coder = (*next).coder as *mut lzma_auto_coder; if coder.is_null() { - coder = lzma_alloc( - ::core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_auto_coder; + coder = lzma_alloc(core::mem::size_of::() as size_t, allocator) + as *mut lzma_auto_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -374,9 +368,9 @@ unsafe extern "C" fn auto_decoder_init( ) as Option lzma_ret>; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -386,20 +380,16 @@ unsafe extern "C" fn auto_decoder_init( set_out_limit: None, }; } - (*coder).memlimit = if 1 as u64 > memlimit { - 1 as u64 - } else { - memlimit - }; + (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).flags = flags; (*coder).sequence = SEQ_INIT; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_auto_decoder( - mut strm: *mut lzma_stream, - mut memlimit: u64, - mut flags: u32, + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -415,7 +405,7 @@ pub unsafe extern "C" fn lzma_auto_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index f522eb7b..8e13e2ae 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_block_decoder_init( @@ -122,20 +122,18 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_decode( - mut block: *mut lzma_block, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { if in_pos.is_null() || in_0.is_null() && *in_pos != in_size @@ -147,9 +145,9 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( return LZMA_PROG_ERROR; } let mut block_decoder: lzma_next_coder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 01b019c5..8583b8a0 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; @@ -196,26 +196,22 @@ pub struct lzma_sha256_state { pub state: [u32; 8], pub size: u64, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; +pub const LZMA_VLI_BYTES_MAX: c_int = 9; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_CHECK_SIZE_MAX: c_int = 64 as c_int; +pub const LZMA_CHECK_SIZE_MAX: c_int = 64; pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) & !3; pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; -pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3 as c_int; -pub const HEADERS_BOUND: c_int = 1 as c_int +pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3; +pub const HEADERS_BOUND: c_int = 1 + 1 as c_int + 2 as c_int * LZMA_VLI_BYTES_MAX + 3 as c_int @@ -223,42 +219,42 @@ pub const HEADERS_BOUND: c_int = 1 as c_int + LZMA_CHECK_SIZE_MAX + 3 as c_int & !(3 as c_int); -unsafe extern "C" fn lzma2_bound(mut uncompressed_size: u64) -> u64 { +extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { if uncompressed_size > COMPRESSED_SIZE_MAX as u64 { - return 0 as u64; + return 0; } let overhead: u64 = uncompressed_size .wrapping_add(LZMA2_CHUNK_MAX as u64) - .wrapping_sub(1 as u64) + .wrapping_sub(1) .wrapping_div(LZMA2_CHUNK_MAX as u64) .wrapping_mul(LZMA2_HEADER_UNCOMPRESSED as u64) - .wrapping_add(1 as u64); + .wrapping_add(1); if (COMPRESSED_SIZE_MAX as u64).wrapping_sub(overhead) < uncompressed_size { - return 0 as u64; + return 0; } return uncompressed_size.wrapping_add(overhead); } #[no_mangle] -pub unsafe extern "C" fn lzma_block_buffer_bound64(mut uncompressed_size: u64) -> u64 { +pub extern "C" fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { let mut lzma2_size: u64 = lzma2_bound(uncompressed_size); - if lzma2_size == 0 as u64 { - return 0 as u64; + if lzma2_size == 0 { + return 0; } - lzma2_size = lzma2_size.wrapping_add(3 as u64) & !(3 as u64); + lzma2_size = lzma2_size.wrapping_add(3) & !(3); return (HEADERS_BOUND as u64).wrapping_add(lzma2_size); } #[no_mangle] -pub unsafe extern "C" fn lzma_block_buffer_bound(mut uncompressed_size: size_t) -> size_t { - let mut ret: u64 = lzma_block_buffer_bound64(uncompressed_size as u64); +pub extern "C" fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t { + let ret: u64 = lzma_block_buffer_bound64(uncompressed_size as u64); return ret as size_t; } unsafe extern "C" fn block_encode_uncompressed( - mut block: *mut lzma_block, - mut in_0: *const u8, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + block: *mut lzma_block, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { let mut lzma2: lzma_options_lzma = lzma_options_lzma { dict_size: LZMA_DICT_SIZE_MIN as u32, @@ -283,17 +279,17 @@ unsafe extern "C" fn block_encode_uncompressed( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), }; let mut filters: [lzma_filter; 2] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 2]; filters[0].id = LZMA_FILTER_LZMA2 as lzma_vli; filters[0].options = &raw mut lzma2 as *mut c_void; filters[1].id = LZMA_VLI_UNKNOWN as lzma_vli; - let mut filters_orig: *mut lzma_filter = (*block).filters; + let filters_orig: *mut lzma_filter = (*block).filters; (*block).filters = &raw mut filters as *mut lzma_filter; if lzma_block_header_size(block) != LZMA_OK { (*block).filters = filters_orig; @@ -311,7 +307,7 @@ unsafe extern "C" fn block_encode_uncompressed( } (*block).filters = filters_orig; *out_pos = (*out_pos).wrapping_add((*block).header_size as size_t); - let mut in_pos: size_t = 0 as size_t; + let mut in_pos: size_t = 0; let mut control: u8 = 0x1 as u8; while in_pos < in_size { let fresh1 = *out_pos; @@ -325,10 +321,10 @@ unsafe extern "C" fn block_encode_uncompressed( }; let fresh2 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1 as size_t) >> 8) as u8; + *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1) >> 8) as u8; let fresh3 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1 as size_t) & 0xff as size_t) as u8; + *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1) & 0xff as size_t) as u8; memcpy( out.offset(*out_pos as isize) as *mut c_void, in_0.offset(in_pos as isize) as *const c_void, @@ -339,16 +335,16 @@ unsafe extern "C" fn block_encode_uncompressed( } let fresh4 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh4 as isize) = 0 as u8; + *out.offset(fresh4 as isize) = 0; return LZMA_OK; } unsafe extern "C" fn block_encode_normal( - mut block: *mut lzma_block, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { let ret_: lzma_ret = lzma_block_header_size(block) as lzma_ret; @@ -364,9 +360,9 @@ unsafe extern "C" fn block_encode_normal( out_size = (*out_pos as lzma_vli).wrapping_add((*block).compressed_size) as size_t; } let mut raw_encoder: lzma_next_coder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -378,7 +374,7 @@ unsafe extern "C" fn block_encode_normal( let mut ret: lzma_ret = lzma_raw_encoder_init(&raw mut raw_encoder, allocator, (*block).filters); if ret == LZMA_OK { - let mut in_pos: size_t = 0 as size_t; + let mut in_pos: size_t = 0; ret = raw_encoder.code.expect("non-null function pointer")( raw_encoder.coder, allocator, @@ -409,24 +405,24 @@ unsafe extern "C" fn block_encode_normal( return ret; } unsafe extern "C" fn block_buffer_encode( - mut block: *mut lzma_block, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, mut out_size: size_t, - mut try_to_compress: bool, + try_to_compress: bool, ) -> lzma_ret { if block.is_null() - || in_0.is_null() && in_size != 0 as size_t + || in_0.is_null() && in_size != 0 || out.is_null() || out_pos.is_null() || *out_pos > out_size { return LZMA_PROG_ERROR; } - if (*block).version > 1 as u32 { + if (*block).version > 1 { return LZMA_OPTIONS_ERROR; } if (*block).check > LZMA_CHECK_ID_MAX @@ -437,7 +433,7 @@ unsafe extern "C" fn block_buffer_encode( if lzma_check_is_supported((*block).check) == 0 { return LZMA_UNSUPPORTED_CHECK; } - out_size = out_size.wrapping_sub(out_size.wrapping_sub(*out_pos) & 3 as size_t); + out_size = out_size.wrapping_sub(out_size.wrapping_sub(*out_pos) & 3); let check_size: size_t = lzma_check_size((*block).check) as size_t; if out_size.wrapping_sub(*out_pos) <= check_size { return LZMA_BUF_ERROR; @@ -463,13 +459,13 @@ unsafe extern "C" fn block_buffer_encode( } } let mut i: size_t = (*block).compressed_size as size_t; - while i & 3 as size_t != 0 { + while i & 3 != 0 { let fresh0 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0 as u8; + *out.offset(fresh0 as isize) = 0; i = i.wrapping_add(1); } - if check_size > 0 as size_t { + if check_size > 0 { let mut check: lzma_check_state = lzma_check_state { buffer: C2RustUnnamed { u8_0: [0; 64] }, state: C2RustUnnamed_0 { crc32: 0 }, @@ -493,33 +489,26 @@ unsafe extern "C" fn block_buffer_encode( } #[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_encode( - mut block: *mut lzma_block, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { return block_buffer_encode( - block, - allocator, - in_0, - in_size, - out, - out_pos, - out_size, - true_0 != 0, + block, allocator, in_0, in_size, out, out_pos, out_size, true, ); } #[no_mangle] pub unsafe extern "C" fn lzma_block_uncomp_encode( - mut block: *mut lzma_block, - mut in_0: *const u8, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + block: *mut lzma_block, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { return block_buffer_encode( block, @@ -529,6 +518,6 @@ pub unsafe extern "C" fn lzma_block_uncomp_encode( out, out_pos, out_size, - false_0 != 0, + false, ); } diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 6fe975f0..25d76902 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; fn lzma_end(strm: *mut lzma_stream); @@ -230,31 +230,27 @@ pub type C2RustUnnamed_2 = c_uint; pub const SEQ_CHECK: C2RustUnnamed_2 = 2; pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[inline] -unsafe extern "C" fn is_size_valid(mut size: lzma_vli, mut reference: lzma_vli) -> bool { +extern "C" fn is_size_valid(size: lzma_vli, reference: lzma_vli) -> bool { return reference == LZMA_VLI_UNKNOWN as lzma_vli || reference == size; } unsafe extern "C" fn block_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; + let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; 's_177: { - let mut current_block_40: u64; + let current_block_40: u64; match (*coder).sequence { 0 => { let in_start: size_t = *in_pos; @@ -318,7 +314,7 @@ unsafe extern "C" fn block_decode( return LZMA_DATA_ERROR; } } - if !(*coder).ignore_check && out_used > 0 as size_t { + if !(*coder).ignore_check && out_used > 0 { lzma_check_update( &raw mut (*coder).check, (*(*coder).block).check, @@ -401,19 +397,16 @@ unsafe extern "C" fn block_decode( } return LZMA_PROG_ERROR; } -unsafe extern "C" fn block_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; +unsafe extern "C" fn block_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free(coder as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_block_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut block: *mut lzma_block, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -461,7 +454,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( let mut coder: *mut lzma_block_coder = (*next).coder as *mut lzma_block_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_block_coder; if coder.is_null() { @@ -486,9 +479,9 @@ pub unsafe extern "C" fn lzma_block_decoder_init( block_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -514,19 +507,19 @@ pub unsafe extern "C" fn lzma_block_decoder_init( } else { (*block).uncompressed_size }; - (*coder).check_pos = 0 as size_t; + (*coder).check_pos = 0; lzma_check_init(&raw mut (*coder).check, (*block).check); - (*coder).ignore_check = if (*block).version >= 1 as u32 { - (*block).ignore_check as c_int + (*coder).ignore_check = if (*block).version >= 1 { + (*block).ignore_check as c_int != 0 } else { - false_0 - } != 0; + false + }; return lzma_raw_decoder_init(&raw mut (*coder).next, allocator, (*block).filters); } #[no_mangle] pub unsafe extern "C" fn lzma_block_decoder( - mut strm: *mut lzma_stream, - mut block: *mut lzma_block, + strm: *mut lzma_stream, + block: *mut lzma_block, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -539,7 +532,7 @@ pub unsafe extern "C" fn lzma_block_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index b5104ffb..643984d7 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_end(strm: *mut lzma_stream); @@ -231,38 +231,35 @@ pub type C2RustUnnamed_2 = c_uint; pub const SEQ_CHECK: C2RustUnnamed_2 = 2; pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_CHECK_SIZE_MAX: c_int = 64 as c_int; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const LZMA_CHECK_SIZE_MAX: c_int = 64; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) & !3; unsafe extern "C" fn block_encode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; + let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; if (LZMA_VLI_MAX as lzma_vli).wrapping_sub((*coder).uncompressed_size) < in_size.wrapping_sub(*in_pos) as lzma_vli { return LZMA_DATA_ERROR; } 's_142: { - let mut current_block_34: u64; + let current_block_34: u64; match (*coder).sequence { 0 => { let in_start: size_t = *in_pos; @@ -289,7 +286,7 @@ unsafe extern "C" fn block_encode( (*coder).compressed_size.wrapping_add(out_used as lzma_vli); (*coder).uncompressed_size = (*coder).uncompressed_size.wrapping_add(in_used as lzma_vli); - if in_used > 0 as size_t { + if in_used > 0 { lzma_check_update( &raw mut (*coder).check, (*(*coder).block).check, @@ -321,7 +318,7 @@ unsafe extern "C" fn block_encode( if *out_pos >= out_size { return LZMA_OK; } - *out.offset(*out_pos as isize) = 0 as u8; + *out.offset(*out_pos as isize) = 0; *out_pos = (*out_pos).wrapping_add(1); (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); } @@ -354,21 +351,18 @@ unsafe extern "C" fn block_encode( } return LZMA_PROG_ERROR; } -unsafe extern "C" fn block_encoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; +unsafe extern "C" fn block_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn block_encoder_update( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter, - mut reversed_filters: *const lzma_filter, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + _filters: *const lzma_filter, + reversed_filters: *const lzma_filter, ) -> lzma_ret { - let mut coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; + let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; if (*coder).sequence != SEQ_CODE { return LZMA_PROG_ERROR; } @@ -376,9 +370,9 @@ unsafe extern "C" fn block_encoder_update( } #[no_mangle] pub unsafe extern "C" fn lzma_block_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut block: *mut lzma_block, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -420,7 +414,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( if block.is_null() { return LZMA_PROG_ERROR; } - if (*block).version > 1 as u32 { + if (*block).version > 1 { return LZMA_OPTIONS_ERROR; } if (*block).check > LZMA_CHECK_ID_MAX { @@ -432,7 +426,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( let mut coder: *mut lzma_block_coder = (*next).coder as *mut lzma_block_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_block_coder; if coder.is_null() { @@ -474,9 +468,9 @@ pub unsafe extern "C" fn lzma_block_encoder_init( ) -> lzma_ret, >; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -490,14 +484,14 @@ pub unsafe extern "C" fn lzma_block_encoder_init( (*coder).block = block; (*coder).compressed_size = 0 as lzma_vli; (*coder).uncompressed_size = 0 as lzma_vli; - (*coder).pos = 0 as size_t; + (*coder).pos = 0; lzma_check_init(&raw mut (*coder).check, (*block).check); return lzma_raw_encoder_init(&raw mut (*coder).next, allocator, (*block).filters); } #[no_mangle] pub unsafe extern "C" fn lzma_block_encoder( - mut strm: *mut lzma_stream, - mut block: *mut lzma_block, + strm: *mut lzma_stream, + block: *mut lzma_block, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -510,8 +504,8 @@ pub unsafe extern "C" fn lzma_block_encoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index e7f97924..873beba3 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn lzma_vli_decode( vli: *mut lzma_vli, @@ -92,61 +92,57 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0) as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - return num; +extern "C" fn read32le(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; + num + }; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; +pub const LZMA_FILTERS_MAX: c_int = 4; #[no_mangle] pub unsafe extern "C" fn lzma_block_header_decode( - mut block: *mut lzma_block, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const u8, ) -> lzma_ret { if block.is_null() || (*block).filters.is_null() || in_0.is_null() { return LZMA_PROG_ERROR; } - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i <= LZMA_FILTERS_MAX as size_t { (*(*block).filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN as lzma_vli; let ref mut fresh0 = (*(*block).filters.offset(i as isize)).options; - *fresh0 = NULL; + *fresh0 = core::ptr::null_mut(); i = i.wrapping_add(1); } - if (*block).version > 1 as u32 { - (*block).version = 1 as u32; + if (*block).version > 1 { + (*block).version = 1; } - (*block).ignore_check = false_0 as lzma_bool; - if (*in_0.offset(0) as u32) - .wrapping_add(1 as u32) - .wrapping_mul(4 as u32) - != (*block).header_size + (*block).ignore_check = false as lzma_bool; + if (*in_0.offset(0) as u32).wrapping_add(1).wrapping_mul(4) != (*block).header_size || (*block).check > LZMA_CHECK_ID_MAX { return LZMA_PROG_ERROR; } - let in_size: size_t = (*block).header_size.wrapping_sub(4 as u32) as size_t; - if lzma_crc32(in_0, in_size, 0 as u32) != read32le(in_0.offset(in_size as isize)) { + let in_size: size_t = (*block).header_size.wrapping_sub(4) as size_t; + if lzma_crc32(in_0, in_size, 0) != read32le(in_0.offset(in_size as isize)) { return LZMA_DATA_ERROR; } if *in_0.offset(1) as c_int & 0x3c as c_int != 0 { return LZMA_OPTIONS_ERROR; } - let mut in_pos: size_t = 2 as size_t; + let mut in_pos: size_t = 2; if *in_0.offset(1) as c_int & 0x40 as c_int != 0 { let ret_: lzma_ret = lzma_vli_decode( &raw mut (*block).compressed_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), in_0, &raw mut in_pos, in_size, @@ -163,7 +159,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( if *in_0.offset(1) as c_int & 0x80 as c_int != 0 { let ret__0: lzma_ret = lzma_vli_decode( &raw mut (*block).uncompressed_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), in_0, &raw mut in_pos, in_size, @@ -175,7 +171,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( (*block).uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; } let filter_count: size_t = (u32::from(*in_0.offset(1)) & 3).wrapping_add(1) as size_t; - let mut i_0: size_t = 0 as size_t; + let mut i_0: size_t = 0; while i_0 < filter_count { let ret: lzma_ret = lzma_filter_flags_decode( (*block).filters.offset(i_0 as isize) as *mut lzma_filter, diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index a9393fbd..a0531244 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; fn lzma_vli_encode( @@ -86,35 +86,35 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0) = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; +extern "C" fn write32le(buf: *mut u8, num: u32) { + unsafe { + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; + } } pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; +pub const LZMA_FILTERS_MAX: c_int = 4; #[no_mangle] -pub unsafe extern "C" fn lzma_block_header_size(mut block: *mut lzma_block) -> lzma_ret { - if (*block).version > 1 as u32 { +pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { + if (*block).version > 1 { return LZMA_OPTIONS_ERROR; } let mut size: u32 = (1 as c_int + 1 as c_int + 4 as c_int) as u32; if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { let add: u32 = lzma_vli_size((*block).compressed_size) as u32; - if add == 0 as u32 || (*block).compressed_size == 0 as lzma_vli { + if add == 0 || (*block).compressed_size == 0 as lzma_vli { return LZMA_PROG_ERROR; } size = size.wrapping_add(add); } if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { let add_0: u32 = lzma_vli_size((*block).uncompressed_size) as u32; - if add_0 == 0 as u32 { + if add_0 == 0 { return LZMA_PROG_ERROR; } size = size.wrapping_add(add_0); @@ -124,7 +124,7 @@ pub unsafe extern "C" fn lzma_block_header_size(mut block: *mut lzma_block) -> l { return LZMA_PROG_ERROR; } - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while (*(*block).filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { if i == LZMA_FILTERS_MAX as size_t { return LZMA_PROG_ERROR; @@ -138,13 +138,13 @@ pub unsafe extern "C" fn lzma_block_header_size(mut block: *mut lzma_block) -> l size = size.wrapping_add(add_1); i = i.wrapping_add(1); } - (*block).header_size = size.wrapping_add(3 as u32) & !(3 as u32); + (*block).header_size = size.wrapping_add(3) & !(3); return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_block_header_encode( - mut block: *const lzma_block, - mut out: *mut u8, + block: *const lzma_block, + out: *mut u8, ) -> lzma_ret { if lzma_block_unpadded_size(block) == 0 as lzma_vli || !((*block).uncompressed_size <= LZMA_VLI_MAX as lzma_vli @@ -152,14 +152,14 @@ pub unsafe extern "C" fn lzma_block_header_encode( { return LZMA_PROG_ERROR; } - let out_size: size_t = (*block).header_size.wrapping_sub(4 as u32) as size_t; - *out.offset(0) = out_size.wrapping_div(4 as size_t) as u8; - *out.offset(1) = 0 as u8; - let mut out_pos: size_t = 2 as size_t; + let out_size: size_t = (*block).header_size.wrapping_sub(4) as size_t; + *out.offset(0) = out_size.wrapping_div(4) as u8; + *out.offset(1) = 0; + let mut out_pos: size_t = 2; if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { let ret_: lzma_ret = lzma_vli_encode( (*block).compressed_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), out, &raw mut out_pos, out_size, @@ -173,7 +173,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { let ret__0: lzma_ret = lzma_vli_encode( (*block).uncompressed_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), out, &raw mut out_pos, out_size, @@ -189,7 +189,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( { return LZMA_PROG_ERROR; } - let mut filter_count: size_t = 0 as size_t; + let mut filter_count: size_t = 0; loop { if filter_count == LZMA_FILTERS_MAX as size_t { return LZMA_PROG_ERROR; @@ -209,15 +209,12 @@ pub unsafe extern "C" fn lzma_block_header_encode( } } let ref mut fresh2 = *out.offset(1); - *fresh2 = (*fresh2 as size_t | filter_count.wrapping_sub(1 as size_t)) as u8; + *fresh2 = (*fresh2 as size_t | filter_count.wrapping_sub(1)) as u8; memset( out.offset(out_pos as isize) as *mut c_void, 0 as c_int, out_size.wrapping_sub(out_pos), ); - write32le( - out.offset(out_size as isize), - lzma_crc32(out, out_size, 0 as u32), - ); + write32le(out.offset(out_size as isize), lzma_crc32(out, out_size, 0)); return LZMA_OK; } diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 064319e1..bb0990c2 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn lzma_check_size(check: lzma_check) -> u32; } @@ -69,23 +69,21 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_BLOCK_HEADER_SIZE_MIN: c_int = 8 as c_int; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MIN: c_int = 8; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] -unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { +extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); } #[no_mangle] pub unsafe extern "C" fn lzma_block_compressed_size( - mut block: *mut lzma_block, - mut unpadded_size: lzma_vli, + block: *mut lzma_block, + unpadded_size: lzma_vli, ) -> lzma_ret { if lzma_block_unpadded_size(block) == 0 as lzma_vli { return LZMA_PROG_ERROR; @@ -106,12 +104,12 @@ pub unsafe extern "C" fn lzma_block_compressed_size( return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_block_unpadded_size(mut block: *const lzma_block) -> lzma_vli { +pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli { if block.is_null() - || (*block).version > 1 as u32 + || (*block).version > 1 || (*block).header_size < LZMA_BLOCK_HEADER_SIZE_MIN as u32 || (*block).header_size > LZMA_BLOCK_HEADER_SIZE_MAX as u32 - || (*block).header_size & 3 as u32 != 0 + || (*block).header_size & 3 != 0 || !((*block).compressed_size <= LZMA_VLI_MAX as lzma_vli || (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli) || (*block).compressed_size == 0 as lzma_vli @@ -132,7 +130,7 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(mut block: *const lzma_block) return unpadded_size; } #[no_mangle] -pub unsafe extern "C" fn lzma_block_total_size(mut block: *const lzma_block) -> lzma_vli { +pub unsafe extern "C" fn lzma_block_total_size(block: *const lzma_block) -> lzma_vli { let mut unpadded_size: lzma_vli = lzma_block_unpadded_size(block); if unpadded_size != LZMA_VLI_UNKNOWN as lzma_vli { unpadded_size = vli_ceil4(unpadded_size); diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index e293b580..08a3586f 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -142,16 +142,12 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; -pub const LZMA_VERSION_MAJOR: c_int = 5 as c_int; -pub const LZMA_VERSION_MINOR: c_int = 8 as c_int; -pub const LZMA_VERSION_PATCH: c_int = 2 as c_int; +pub const LZMA_VERSION_MAJOR: c_int = 5; +pub const LZMA_VERSION_MINOR: c_int = 8; +pub const LZMA_VERSION_PATCH: c_int = 2; pub const LZMA_VERSION_STABILITY: c_int = LZMA_VERSION_STABILITY_STABLE; -pub const LZMA_VERSION_STABILITY_STABLE: c_int = 2 as c_int; +pub const LZMA_VERSION_STABILITY_STABLE: c_int = 2; pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR as u32) .wrapping_mul(10000000) .wrapping_add((LZMA_VERSION_MINOR as u32).wrapping_mul(10000)) @@ -160,28 +156,24 @@ pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR as u32) pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_TIMED_OUT: c_uint = 101; #[no_mangle] -pub unsafe extern "C" fn lzma_version_number() -> u32 { +pub extern "C" fn lzma_version_number() -> u32 { return LZMA_VERSION as u32; } #[no_mangle] -pub unsafe extern "C" fn lzma_version_string() -> *const c_char { +pub extern "C" fn lzma_version_string() -> *const c_char { return b"5.8.2\0" as *const u8 as *const c_char; } #[no_mangle] pub unsafe extern "C" fn lzma_alloc( mut size: size_t, - mut allocator: *const lzma_allocator, + allocator: *const lzma_allocator, ) -> *mut c_void { - if size == 0 as size_t { - size = 1 as size_t; + if size == 0 { + size = 1; } - let mut ptr: *mut c_void = ::core::ptr::null_mut::(); + let mut ptr: *mut c_void = core::ptr::null_mut(); if !allocator.is_null() && (*allocator).alloc.is_some() { - ptr = (*allocator).alloc.expect("non-null function pointer")( - (*allocator).opaque, - 1 as size_t, - size, - ); + ptr = (*allocator).alloc.expect("non-null function pointer")((*allocator).opaque, 1, size); } else { ptr = malloc(size); } @@ -190,28 +182,24 @@ pub unsafe extern "C" fn lzma_alloc( #[no_mangle] pub unsafe extern "C" fn lzma_alloc_zero( mut size: size_t, - mut allocator: *const lzma_allocator, + allocator: *const lzma_allocator, ) -> *mut c_void { - if size == 0 as size_t { - size = 1 as size_t; + if size == 0 { + size = 1; } - let mut ptr: *mut c_void = ::core::ptr::null_mut::(); + let mut ptr: *mut c_void = core::ptr::null_mut(); if !allocator.is_null() && (*allocator).alloc.is_some() { - ptr = (*allocator).alloc.expect("non-null function pointer")( - (*allocator).opaque, - 1 as size_t, - size, - ); + ptr = (*allocator).alloc.expect("non-null function pointer")((*allocator).opaque, 1, size); if !ptr.is_null() { memset(ptr, 0 as c_int, size); } } else { - ptr = calloc(1 as size_t, size); + ptr = calloc(1, size); } return ptr; } #[no_mangle] -pub unsafe extern "C" fn lzma_free(mut ptr: *mut c_void, mut allocator: *const lzma_allocator) { +pub unsafe extern "C" fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator) { if !allocator.is_null() && (*allocator).free.is_some() { (*allocator).free.expect("non-null function pointer")((*allocator).opaque, ptr); } else { @@ -220,12 +208,12 @@ pub unsafe extern "C" fn lzma_free(mut ptr: *mut c_void, mut allocator: *const l } #[no_mangle] pub unsafe extern "C" fn lzma_bufcpy( - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> size_t { let in_avail: size_t = in_size.wrapping_sub(*in_pos); let out_avail: size_t = out_size.wrapping_sub(*out_pos); @@ -234,7 +222,7 @@ pub unsafe extern "C" fn lzma_bufcpy( } else { out_avail }; - if copy_size > 0 as size_t { + if copy_size > 0 { memcpy( out.offset(*out_pos as isize) as *mut c_void, in_0.offset(*in_pos as isize) as *const c_void, @@ -247,9 +235,9 @@ pub unsafe extern "C" fn lzma_bufcpy( } #[no_mangle] pub unsafe extern "C" fn lzma_next_filter_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { if ::core::mem::transmute::((*filters.offset(0)).init) != (*next).init @@ -269,9 +257,9 @@ pub unsafe extern "C" fn lzma_next_filter_init( } #[no_mangle] pub unsafe extern "C" fn lzma_next_filter_update( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut reversed_filters: *const lzma_filter, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + reversed_filters: *const lzma_filter, ) -> lzma_ret { if (*reversed_filters.offset(0)).id != (*next).id { return LZMA_PROG_ERROR; @@ -288,19 +276,19 @@ pub unsafe extern "C" fn lzma_next_filter_update( } #[no_mangle] pub unsafe extern "C" fn lzma_next_end( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, ) { - if (*next).init != ::core::ptr::null_mut::() as uintptr_t { + if (*next).init != 0 { if (*next).end.is_some() { (*next).end.expect("non-null function pointer")((*next).coder, allocator); } else { lzma_free((*next).coder, allocator); } *next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -312,22 +300,22 @@ pub unsafe extern "C" fn lzma_next_end( } } #[no_mangle] -pub unsafe extern "C" fn lzma_strm_init(mut strm: *mut lzma_stream) -> lzma_ret { +pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { if strm.is_null() { return LZMA_PROG_ERROR; } if (*strm).internal.is_null() { (*strm).internal = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, (*strm).allocator, ) as *mut lzma_internal; if (*strm).internal.is_null() { return LZMA_MEM_ERROR; } (*(*strm).internal).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -340,21 +328,18 @@ pub unsafe extern "C" fn lzma_strm_init(mut strm: *mut lzma_stream) -> lzma_ret memset( &raw mut (*(*strm).internal).supported_actions as *mut bool as *mut c_void, 0 as c_int, - ::core::mem::size_of::<[bool; 5]>() as size_t, + core::mem::size_of::<[bool; 5]>() as size_t, ); (*(*strm).internal).sequence = ISEQ_RUN; - (*(*strm).internal).allow_buf_error = false_0 != 0; - (*strm).total_in = 0 as u64; - (*strm).total_out = 0 as u64; + (*(*strm).internal).allow_buf_error = false; + (*strm).total_in = 0; + (*strm).total_out = 0; return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_code( - mut strm: *mut lzma_stream, - mut action: lzma_action, -) -> lzma_ret { - if (*strm).next_in.is_null() && (*strm).avail_in != 0 as size_t - || (*strm).next_out.is_null() && (*strm).avail_out != 0 as size_t +pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret { + if (*strm).next_in.is_null() && (*strm).avail_in != 0 + || (*strm).next_out.is_null() && (*strm).avail_out != 0 || (*strm).internal.is_null() || (*(*strm).internal).next.code.is_none() || action > LZMA_FULL_BARRIER @@ -366,9 +351,9 @@ pub unsafe extern "C" fn lzma_code( || !(*strm).reserved_ptr2.is_null() || !(*strm).reserved_ptr3.is_null() || !(*strm).reserved_ptr4.is_null() - || (*strm).reserved_int2 != 0 as u64 - || (*strm).reserved_int3 != 0 as size_t - || (*strm).reserved_int4 != 0 as size_t + || (*strm).reserved_int2 != 0 + || (*strm).reserved_int3 != 0 + || (*strm).reserved_int4 != 0 || (*strm).reserved_enum1 != LZMA_RESERVED_ENUM || (*strm).reserved_enum2 != LZMA_RESERVED_ENUM { @@ -413,8 +398,8 @@ pub unsafe extern "C" fn lzma_code( 5 => return LZMA_STREAM_END, 6 | _ => return LZMA_PROG_ERROR, } - let mut in_pos: size_t = 0 as size_t; - let mut out_pos: size_t = 0 as size_t; + let mut in_pos: size_t = 0; + let mut out_pos: size_t = 0; let mut ret: lzma_ret = (*(*strm).internal) .next .code @@ -429,38 +414,38 @@ pub unsafe extern "C" fn lzma_code( (*strm).avail_out, action, ); - if in_pos > 0 as size_t { + if in_pos > 0 { (*strm).next_in = (*strm).next_in.offset(in_pos as isize); (*strm).avail_in = (*strm).avail_in.wrapping_sub(in_pos); (*strm).total_in = (*strm).total_in.wrapping_add(in_pos as u64); } - if out_pos > 0 as size_t { + if out_pos > 0 { (*strm).next_out = (*strm).next_out.offset(out_pos as isize); (*strm).avail_out = (*strm).avail_out.wrapping_sub(out_pos); (*strm).total_out = (*strm).total_out.wrapping_add(out_pos as u64); } (*(*strm).internal).avail_in = (*strm).avail_in; - let mut current_block_49: u64; + let current_block_49: u64; match ret { 0 => { - if out_pos == 0 as size_t && in_pos == 0 as size_t { + if out_pos == 0 && in_pos == 0 { if (*(*strm).internal).allow_buf_error { ret = LZMA_BUF_ERROR; } else { - (*(*strm).internal).allow_buf_error = true_0 != 0; + (*(*strm).internal).allow_buf_error = true; } } else { - (*(*strm).internal).allow_buf_error = false_0 != 0; + (*(*strm).internal).allow_buf_error = false; } current_block_49 = 12556861819962772176; } 101 => { - (*(*strm).internal).allow_buf_error = false_0 != 0; + (*(*strm).internal).allow_buf_error = false; ret = LZMA_OK; current_block_49 = 12556861819962772176; } 12 => { - (*(*strm).internal).allow_buf_error = false_0 != 0; + (*(*strm).internal).allow_buf_error = false; if (*(*strm).internal).sequence == ISEQ_FINISH { (*(*strm).internal).sequence = ISEQ_RUN; } @@ -487,25 +472,25 @@ pub unsafe extern "C" fn lzma_code( } match current_block_49 { 16143107162343188004 => { - (*(*strm).internal).allow_buf_error = false_0 != 0; + (*(*strm).internal).allow_buf_error = false; } _ => {} } return ret; } #[no_mangle] -pub unsafe extern "C" fn lzma_end(mut strm: *mut lzma_stream) { +pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { if !strm.is_null() && !(*strm).internal.is_null() { lzma_next_end(&raw mut (*(*strm).internal).next, (*strm).allocator); lzma_free((*strm).internal as *mut c_void, (*strm).allocator); - (*strm).internal = ::core::ptr::null_mut::(); + (*strm).internal = core::ptr::null_mut(); } } #[no_mangle] pub unsafe extern "C" fn lzma_get_progress( - mut strm: *mut lzma_stream, - mut progress_in: *mut u64, - mut progress_out: *mut u64, + strm: *mut lzma_stream, + progress_in: *mut u64, + progress_out: *mut u64, ) { if (*(*strm).internal).next.get_progress.is_some() { (*(*strm).internal) @@ -522,7 +507,7 @@ pub unsafe extern "C" fn lzma_get_progress( }; } #[no_mangle] -pub unsafe extern "C" fn lzma_get_check(mut strm: *const lzma_stream) -> lzma_check { +pub unsafe extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { if (*(*strm).internal).next.get_check.is_none() { return LZMA_CHECK_NONE; } @@ -532,7 +517,7 @@ pub unsafe extern "C" fn lzma_get_check(mut strm: *const lzma_stream) -> lzma_ch .expect("non-null function pointer")((*(*strm).internal).next.coder); } #[no_mangle] -pub unsafe extern "C" fn lzma_memusage(mut strm: *const lzma_stream) -> u64 { +pub unsafe extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { let mut memusage: u64 = 0; let mut old_memlimit: u64 = 0; if strm.is_null() @@ -545,15 +530,15 @@ pub unsafe extern "C" fn lzma_memusage(mut strm: *const lzma_stream) -> u64 { (*(*strm).internal).next.coder, &raw mut memusage, &raw mut old_memlimit, - 0 as u64, + 0, ) != LZMA_OK { - return 0 as u64; + return 0; } return memusage; } #[no_mangle] -pub unsafe extern "C" fn lzma_memlimit_get(mut strm: *const lzma_stream) -> u64 { +pub unsafe extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { let mut old_memlimit: u64 = 0; let mut memusage: u64 = 0; if strm.is_null() @@ -566,16 +551,16 @@ pub unsafe extern "C" fn lzma_memlimit_get(mut strm: *const lzma_stream) -> u64 (*(*strm).internal).next.coder, &raw mut memusage, &raw mut old_memlimit, - 0 as u64, + 0, ) != LZMA_OK { - return 0 as u64; + return 0; } return old_memlimit; } #[no_mangle] pub unsafe extern "C" fn lzma_memlimit_set( - mut strm: *mut lzma_stream, + strm: *mut lzma_stream, mut new_memlimit: u64, ) -> lzma_ret { let mut old_memlimit: u64 = 0; @@ -584,8 +569,8 @@ pub unsafe extern "C" fn lzma_memlimit_set( { return LZMA_PROG_ERROR; } - if new_memlimit == 0 as u64 { - new_memlimit = 1 as u64; + if new_memlimit == 0 { + new_memlimit = 1; } return (*(*strm).internal) .next diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 80d2a173..59c155e0 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_stream_buffer_encode( filters: *mut lzma_filter, @@ -95,19 +95,19 @@ pub struct lzma_options_easy { } #[no_mangle] pub unsafe extern "C" fn lzma_easy_buffer_encode( - mut preset: u32, - mut check: lzma_check, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + preset: u32, + check: lzma_check, + allocator: *const lzma_allocator, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, @@ -132,8 +132,8 @@ pub unsafe extern "C" fn lzma_easy_buffer_encode( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), }, }; if lzma_easy_preset(&raw mut opt_easy, preset) { diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index d31c76eb..9b60a387 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -54,11 +54,11 @@ pub struct lzma_options_easy { } pub const UINT32_MAX: c_uint = 4294967295; #[no_mangle] -pub unsafe extern "C" fn lzma_easy_decoder_memusage(mut preset: u32) -> u64 { +pub extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, @@ -83,12 +83,12 @@ pub unsafe extern "C" fn lzma_easy_decoder_memusage(mut preset: u32) -> u64 { reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), }, }; - if lzma_easy_preset(&raw mut opt_easy, preset) { + if unsafe { lzma_easy_preset(&raw mut opt_easy, preset) } { return UINT32_MAX as u64; } - return lzma_raw_decoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter); + return unsafe { lzma_raw_decoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter) }; } diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index c47e200f..019a2e27 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -171,14 +171,14 @@ pub struct lzma_options_easy { } #[no_mangle] pub unsafe extern "C" fn lzma_easy_encoder( - mut strm: *mut lzma_stream, - mut preset: u32, - mut check: lzma_check, + strm: *mut lzma_stream, + preset: u32, + check: lzma_check, ) -> lzma_ret { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, @@ -203,8 +203,8 @@ pub unsafe extern "C" fn lzma_easy_encoder( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), }, }; if lzma_easy_preset(&raw mut opt_easy, preset) { diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index 4319134a..377e2261 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -54,11 +54,11 @@ pub struct lzma_options_easy { } pub const UINT32_MAX: c_uint = 4294967295; #[no_mangle] -pub unsafe extern "C" fn lzma_easy_encoder_memusage(mut preset: u32) -> u64 { +pub extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, @@ -83,12 +83,12 @@ pub unsafe extern "C" fn lzma_easy_encoder_memusage(mut preset: u32) -> u64 { reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), }, }; - if lzma_easy_preset(&raw mut opt_easy, preset) { + if unsafe { lzma_easy_preset(&raw mut opt_easy, preset) } { return UINT32_MAX as u64; } - return lzma_raw_encoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter); + return unsafe { lzma_raw_encoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter) }; } diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index 7a9b9ea9..4b94c994 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; } @@ -52,20 +52,15 @@ pub struct lzma_options_easy { pub opt_lzma: lzma_options_lzma, } pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; #[no_mangle] -pub unsafe extern "C" fn lzma_easy_preset( - mut opt_easy: *mut lzma_options_easy, - mut preset: u32, -) -> bool { +pub unsafe extern "C" fn lzma_easy_preset(opt_easy: *mut lzma_options_easy, preset: u32) -> bool { if lzma_lzma_preset(&raw mut (*opt_easy).opt_lzma, preset) != 0 { - return true_0 != 0; + return true; } (*opt_easy).filters[0].id = LZMA_FILTER_LZMA2 as lzma_vli; (*opt_easy).filters[0].options = &raw mut (*opt_easy).opt_lzma as *mut c_void; (*opt_easy).filters[1].id = LZMA_VLI_UNKNOWN as lzma_vli; - return false_0 != 0; + return false; } diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 7dda702e..8ba0c0f6 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -218,19 +218,15 @@ pub const SEQ_FOOTER: C2RustUnnamed_0 = 3; pub const SEQ_PADDING_DECODE: C2RustUnnamed_0 = 2; pub const SEQ_PADDING_SEEK: C2RustUnnamed_0 = 1; pub const SEQ_MAGIC_BYTES: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; unsafe extern "C" fn fill_temp( - mut coder: *mut lzma_file_info_coder, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + coder: *mut lzma_file_info_coder, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> bool { (*coder).file_cur_pos = (*coder).file_cur_pos.wrapping_add(lzma_bufcpy( in_0, @@ -243,11 +239,11 @@ unsafe extern "C" fn fill_temp( return (*coder).temp_pos < (*coder).temp_size; } unsafe extern "C" fn seek_to_pos( - mut coder: *mut lzma_file_info_coder, - mut target_pos: u64, - mut in_start: size_t, - mut in_pos: *mut size_t, - mut in_size: size_t, + coder: *mut lzma_file_info_coder, + target_pos: u64, + in_start: size_t, + in_pos: *mut size_t, + in_size: size_t, ) -> bool { let pos_min: u64 = (*coder) .file_cur_pos @@ -258,35 +254,35 @@ unsafe extern "C" fn seek_to_pos( let mut external_seek_needed: bool = false; if target_pos >= pos_min && target_pos <= pos_max { *in_pos = (*in_pos).wrapping_add(target_pos.wrapping_sub((*coder).file_cur_pos) as size_t); - external_seek_needed = false_0 != 0; + external_seek_needed = false; } else { *(*coder).external_seek_pos = target_pos; - external_seek_needed = true_0 != 0; + external_seek_needed = true; *in_pos = in_size; } (*coder).file_cur_pos = target_pos; return external_seek_needed; } unsafe extern "C" fn reverse_seek( - mut coder: *mut lzma_file_info_coder, - mut in_start: size_t, - mut in_pos: *mut size_t, - mut in_size: size_t, + coder: *mut lzma_file_info_coder, + in_start: size_t, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { if (*coder).file_target_pos < (2 as c_int * LZMA_STREAM_HEADER_SIZE) as u64 { return LZMA_DATA_ERROR; } - (*coder).temp_pos = 0 as size_t; + (*coder).temp_pos = 0; if (*coder) .file_target_pos .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64) - < ::core::mem::size_of::<[u8; 8192]>() as u64 + < core::mem::size_of::<[u8; 8192]>() as u64 { (*coder).temp_size = (*coder) .file_target_pos .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64) as size_t; } else { - (*coder).temp_size = ::core::mem::size_of::<[u8; 8192]>() as usize as size_t; + (*coder).temp_size = core::mem::size_of::<[u8; 8192]>() as usize as size_t; } if seek_to_pos( coder, @@ -301,9 +297,9 @@ unsafe extern "C" fn reverse_seek( } return LZMA_OK; } -unsafe extern "C" fn get_padding_size(mut buf: *const u8, mut buf_size: size_t) -> size_t { - let mut padding: size_t = 0 as size_t; - while buf_size > 0 as size_t && { +unsafe extern "C" fn get_padding_size(buf: *const u8, mut buf_size: size_t) -> size_t { + let mut padding: size_t = 0; + while buf_size > 0 && { buf_size = buf_size.wrapping_sub(1); *buf.offset(buf_size as isize) as c_int == 0 as c_int } { @@ -311,19 +307,19 @@ unsafe extern "C" fn get_padding_size(mut buf: *const u8, mut buf_size: size_t) } return padding; } -unsafe extern "C" fn hide_format_error(mut ret: lzma_ret) -> lzma_ret { +extern "C" fn hide_format_error(mut ret: lzma_ret) -> lzma_ret { if ret == LZMA_FORMAT_ERROR { ret = LZMA_DATA_ERROR; } return ret; } unsafe extern "C" fn decode_index( - mut coder: *mut lzma_file_info_coder, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut update_file_cur_pos: bool, + coder: *mut lzma_file_info_coder, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + update_file_cur_pos: bool, ) -> lzma_ret { let in_start: size_t = *in_pos; let ret: lzma_ret = (*coder) @@ -335,9 +331,9 @@ unsafe extern "C" fn decode_index( in_0, in_pos, in_size, - ::core::ptr::null_mut::(), - ::core::ptr::null_mut::(), - 0 as size_t, + core::ptr::null_mut(), + core::ptr::null_mut(), + 0, LZMA_RUN, ) as lzma_ret; (*coder).index_remaining = (*coder) @@ -351,17 +347,17 @@ unsafe extern "C" fn decode_index( return ret; } unsafe extern "C" fn file_info_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + _out: *mut u8, + _out_pos: *mut size_t, + _out_size: size_t, + _action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; + let coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; let in_start: size_t = *in_pos; if (*coder).file_size.wrapping_sub((*coder).file_cur_pos) < in_size.wrapping_sub(in_start) as u64 @@ -386,7 +382,7 @@ unsafe extern "C" fn file_info_decode( if ret_ != LZMA_OK { return ret_; } - if (*coder).file_size > LZMA_VLI_MAX as u64 || (*coder).file_size & 3 as u64 != 0 { + if (*coder).file_size > LZMA_VLI_MAX as u64 || (*coder).file_size & 3 != 0 { return LZMA_DATA_ERROR; } (*coder).file_target_pos = (*coder).file_size; @@ -496,8 +492,8 @@ unsafe extern "C" fn file_info_decode( .wrapping_sub((*coder).footer_flags.backward_size) as size_t; } else { - (*coder).temp_pos = 0 as size_t; - (*coder).temp_size = 0 as size_t; + (*coder).temp_pos = 0; + (*coder).temp_size = 0; if seek_to_pos(coder, (*coder).file_target_pos, in_start, in_pos, in_size) { return LZMA_SEEK_NEEDED; } @@ -508,7 +504,7 @@ unsafe extern "C" fn file_info_decode( } match current_block_142 { 9376024032952078885 => { - let mut memused: u64 = 0 as u64; + let mut memused: u64 = 0; if !(*coder).combined_index.is_null() { memused = lzma_index_memused((*coder).combined_index); if memused > (*coder).memlimit { @@ -533,21 +529,21 @@ unsafe extern "C" fn file_info_decode( match current_block_142 { 16203797167131938757 => { let mut ret: lzma_ret = LZMA_OK; - if (*coder).temp_size != 0 as size_t { + if (*coder).temp_size != 0 { ret = decode_index( coder, allocator, &raw mut (*coder).temp as *mut u8, &raw mut (*coder).temp_pos, (*coder).temp_size, - false_0 != 0, + false, ); } else { let mut in_stop: size_t = in_size; if in_size.wrapping_sub(*in_pos) as lzma_vli > (*coder).index_remaining { in_stop = (*in_pos).wrapping_add((*coder).index_remaining as size_t); } - ret = decode_index(coder, allocator, in_0, in_pos, in_stop, true_0 != 0); + ret = decode_index(coder, allocator, in_0, in_pos, in_stop, true); } match ret { 0 => { @@ -569,7 +565,7 @@ unsafe extern "C" fn file_info_decode( return LZMA_DATA_ERROR; } (*coder).file_target_pos = (*coder).file_target_pos.wrapping_sub(seek_amount); - if (*coder).file_target_pos == 0 as u64 { + if (*coder).file_target_pos == 0 { (*coder).header_flags = (*coder).first_header_flags; (*coder).sequence = SEQ_HEADER_COMPARE; current_block_142 = 13014351284863956202; @@ -578,7 +574,7 @@ unsafe extern "C" fn file_info_decode( (*coder).file_target_pos = (*coder) .file_target_pos .wrapping_add(LZMA_STREAM_HEADER_SIZE as u64); - if (*coder).temp_size != 0 as size_t + if (*coder).temp_size != 0 && ((*coder).temp_size as lzma_vli) .wrapping_sub((*coder).footer_flags.backward_size) >= seek_amount @@ -654,14 +650,14 @@ unsafe extern "C" fn file_info_decode( } } (*coder).combined_index = (*coder).this_index; - (*coder).this_index = ::core::ptr::null_mut::(); - if (*coder).file_target_pos == 0 as u64 { + (*coder).this_index = core::ptr::null_mut(); + if (*coder).file_target_pos == 0 { *(*coder).dest_index = (*coder).combined_index; - (*coder).combined_index = ::core::ptr::null_mut::(); + (*coder).combined_index = core::ptr::null_mut(); *in_pos = in_size; return LZMA_STREAM_END; } - (*coder).sequence = (if (*coder).temp_size > 0 as size_t { + (*coder).sequence = (if (*coder).temp_size > 0 { SEQ_PADDING_DECODE as c_int } else { SEQ_PADDING_SEEK as c_int @@ -672,14 +668,14 @@ unsafe extern "C" fn file_info_decode( } } unsafe extern "C" fn file_info_decoder_memconfig( - mut coder_ptr: *mut c_void, - mut memusage: *mut u64, - mut old_memlimit: *mut u64, - mut new_memlimit: u64, + coder_ptr: *mut c_void, + memusage: *mut u64, + old_memlimit: *mut u64, + new_memlimit: u64, ) -> lzma_ret { - let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; - let mut combined_index_memusage: u64 = 0 as u64; - let mut this_index_memusage: u64 = 0 as u64; + let coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; + let mut combined_index_memusage: u64 = 0; + let mut this_index_memusage: u64 = 0; if !(*coder).combined_index.is_null() { combined_index_memusage = lzma_index_memused((*coder).combined_index); } @@ -694,18 +690,18 @@ unsafe extern "C" fn file_info_decoder_memconfig( (*coder).index_decoder.coder, &raw mut this_index_memusage, &raw mut dummy, - 0 as u64, + 0, ) != LZMA_OK { return LZMA_PROG_ERROR; } } *memusage = combined_index_memusage.wrapping_add(this_index_memusage); - if *memusage == 0 as u64 { + if *memusage == 0 { *memusage = lzma_index_memusage(1 as lzma_vli, 0 as lzma_vli); } *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as u64 { + if new_memlimit != 0 { if new_memlimit < *memusage { return LZMA_MEMLIMIT_ERROR; } @@ -731,22 +727,22 @@ unsafe extern "C" fn file_info_decoder_memconfig( return LZMA_OK; } unsafe extern "C" fn file_info_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, ) { - let mut coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; + let coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; lzma_next_end(&raw mut (*coder).index_decoder, allocator); lzma_index_end((*coder).this_index, allocator); lzma_index_end((*coder).combined_index, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma_file_info_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut seek_pos: *mut u64, - mut dest_index: *mut *mut lzma_index, - mut memlimit: u64, - mut file_size: u64, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + seek_pos: *mut u64, + dest_index: *mut *mut lzma_index, + memlimit: u64, + file_size: u64, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -803,7 +799,7 @@ unsafe extern "C" fn lzma_file_info_decoder_init( let mut coder: *mut lzma_file_info_coder = (*next).coder as *mut lzma_file_info_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_file_info_coder; if coder.is_null() { @@ -833,9 +829,9 @@ unsafe extern "C" fn lzma_file_info_decoder_init( ) as Option lzma_ret>; (*coder).index_decoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -844,35 +840,31 @@ unsafe extern "C" fn lzma_file_info_decoder_init( update: None, set_out_limit: None, }; - (*coder).this_index = ::core::ptr::null_mut::(); - (*coder).combined_index = ::core::ptr::null_mut::(); + (*coder).this_index = core::ptr::null_mut(); + (*coder).combined_index = core::ptr::null_mut(); } (*coder).sequence = SEQ_MAGIC_BYTES; - (*coder).file_cur_pos = 0 as u64; - (*coder).file_target_pos = 0 as u64; + (*coder).file_cur_pos = 0; + (*coder).file_target_pos = 0; (*coder).file_size = file_size; lzma_index_end((*coder).this_index, allocator); - (*coder).this_index = ::core::ptr::null_mut::(); + (*coder).this_index = core::ptr::null_mut(); lzma_index_end((*coder).combined_index, allocator); - (*coder).combined_index = ::core::ptr::null_mut::(); + (*coder).combined_index = core::ptr::null_mut(); (*coder).stream_padding = 0 as lzma_vli; (*coder).dest_index = dest_index; (*coder).external_seek_pos = seek_pos; - (*coder).memlimit = if 1 as u64 > memlimit { - 1 as u64 - } else { - memlimit - }; - (*coder).temp_pos = 0 as size_t; + (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; + (*coder).temp_pos = 0; (*coder).temp_size = LZMA_STREAM_HEADER_SIZE as size_t; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_file_info_decoder( - mut strm: *mut lzma_stream, - mut dest_index: *mut *mut lzma_index, - mut memlimit: u64, - mut file_size: u64, + strm: *mut lzma_stream, + dest_index: *mut *mut lzma_index, + memlimit: u64, + file_size: u64, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -890,7 +882,7 @@ pub unsafe extern "C" fn lzma_file_info_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index 06db2648..b9739b49 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_raw_decoder_init( @@ -87,20 +87,18 @@ pub type lzma_code_function = Option< lzma_action, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_decode( - mut filters: *const lzma_filter, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + filters: *const lzma_filter, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { if in_0.is_null() || in_pos.is_null() @@ -112,9 +110,9 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( return LZMA_PROG_ERROR; } let mut next: lzma_next_coder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -150,7 +148,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( ret = LZMA_DATA_ERROR; } else { let mut tmp: [u8; 1] = [0; 1]; - let mut tmp_pos: size_t = 0 as size_t; + let mut tmp_pos: size_t = 0; next.code.expect("non-null function pointer")( next.coder, allocator, @@ -159,10 +157,10 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( in_size, &raw mut tmp as *mut u8, &raw mut tmp_pos, - 1 as size_t, + 1, LZMA_FINISH, ); - if tmp_pos == 1 as size_t { + if tmp_pos == 1 { ret = LZMA_BUF_ERROR; } else { ret = LZMA_DATA_ERROR; diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index b945d7c1..b94539b0 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_raw_encoder_init( @@ -87,31 +87,25 @@ pub type lzma_code_function = Option< lzma_action, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_encode( - mut filters: *const lzma_filter, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + filters: *const lzma_filter, + allocator: *const lzma_allocator, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { - if in_0.is_null() && in_size != 0 as size_t - || out.is_null() - || out_pos.is_null() - || *out_pos > out_size - { + if in_0.is_null() && in_size != 0 || out.is_null() || out_pos.is_null() || *out_pos > out_size { return LZMA_PROG_ERROR; } let mut next: lzma_next_coder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -125,7 +119,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( return ret_; } let out_start: size_t = *out_pos; - let mut in_pos: size_t = 0 as size_t; + let mut in_pos: size_t = 0; let mut ret: lzma_ret = next.code.expect("non-null function pointer")( next.coder, allocator, diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index c2e6a925..ed797b02 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; @@ -176,13 +176,9 @@ pub struct lzma_filter_coder { pub memusage: Option u64>, } pub type lzma_filter_find = Option *const lzma_filter_coder>; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; +pub const LZMA_FILTERS_MAX: c_int = 4; pub const LZMA_FILTER_X86: c_ulonglong = 0x4; pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; @@ -199,87 +195,87 @@ pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; static mut features: [C2RustUnnamed; 13] = [ C2RustUnnamed { id: LZMA_FILTER_LZMA1 as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: false_0 != 0, - last_ok: true_0 != 0, - changes_size: true_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: false, + last_ok: true, + changes_size: true, }, C2RustUnnamed { id: LZMA_FILTER_LZMA1EXT as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: false_0 != 0, - last_ok: true_0 != 0, - changes_size: true_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: false, + last_ok: true, + changes_size: true, }, C2RustUnnamed { id: LZMA_FILTER_LZMA2 as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: false_0 != 0, - last_ok: true_0 != 0, - changes_size: true_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: false, + last_ok: true, + changes_size: true, }, C2RustUnnamed { id: LZMA_FILTER_X86 as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_FILTER_POWERPC as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_FILTER_IA64 as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_FILTER_ARM as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_FILTER_ARMTHUMB as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_FILTER_ARM64 as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_FILTER_SPARC as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_FILTER_RISCV as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_FILTER_DELTA as lzma_vli, - options_size: ::core::mem::size_of::() as size_t, - non_last_ok: true_0 != 0, - last_ok: false_0 != 0, - changes_size: false_0 != 0, + options_size: core::mem::size_of::() as size_t, + non_last_ok: true, + last_ok: false, + changes_size: false, }, C2RustUnnamed { id: LZMA_VLI_UNKNOWN as lzma_vli, @@ -291,21 +287,21 @@ static mut features: [C2RustUnnamed; 13] = [ ]; #[no_mangle] pub unsafe extern "C" fn lzma_filters_copy( - mut src: *const lzma_filter, - mut real_dest: *mut lzma_filter, - mut allocator: *const lzma_allocator, + src: *const lzma_filter, + real_dest: *mut lzma_filter, + allocator: *const lzma_allocator, ) -> lzma_ret { - let mut current_block: u64; + let current_block: u64; if src.is_null() || real_dest.is_null() { return LZMA_PROG_ERROR; } let mut dest: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5]; let mut ret: lzma_ret = LZMA_OK; let mut i: size_t = 0; - i = 0 as size_t; + i = 0; 's_15: loop { if !((*src.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { current_block = 7175849428784450219; @@ -318,10 +314,10 @@ pub unsafe extern "C" fn lzma_filters_copy( } else { dest[i as usize].id = (*src.offset(i as isize)).id; if (*src.offset(i as isize)).options.is_null() { - dest[i as usize].options = NULL; + dest[i as usize].options = core::ptr::null_mut(); } else { let mut j: size_t = 0; - j = 0 as size_t; + j = 0; while (*src.offset(i as isize)).id != features[j as usize].id { if features[j as usize].id == LZMA_VLI_UNKNOWN as lzma_vli { ret = LZMA_OPTIONS_ERROR; @@ -349,7 +345,7 @@ pub unsafe extern "C" fn lzma_filters_copy( } match current_block { 6392083060350426025 => { - while i > 0 as size_t { + while i > 0 { i = i.wrapping_sub(1); lzma_free(dest[i as usize].options, allocator); } @@ -357,12 +353,12 @@ pub unsafe extern "C" fn lzma_filters_copy( } _ => { dest[i as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; - dest[i as usize].options = NULL; + dest[i as usize].options = core::ptr::null_mut(); memcpy( real_dest as *mut c_void, &raw mut dest as *mut lzma_filter as *const c_void, - i.wrapping_add(1 as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + i.wrapping_add(1) + .wrapping_mul(core::mem::size_of::() as size_t), ); return LZMA_OK; } @@ -370,39 +366,39 @@ pub unsafe extern "C" fn lzma_filters_copy( } #[no_mangle] pub unsafe extern "C" fn lzma_filters_free( - mut filters: *mut lzma_filter, - mut allocator: *const lzma_allocator, + filters: *mut lzma_filter, + allocator: *const lzma_allocator, ) { if filters.is_null() { return; } - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { if i == LZMA_FILTERS_MAX as size_t { break; } lzma_free((*filters.offset(i as isize)).options, allocator); let ref mut fresh0 = (*filters.offset(i as isize)).options; - *fresh0 = NULL; + *fresh0 = core::ptr::null_mut(); (*filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN as lzma_vli; i = i.wrapping_add(1); } } #[no_mangle] pub unsafe extern "C" fn lzma_validate_chain( - mut filters: *const lzma_filter, - mut count: *mut size_t, + filters: *const lzma_filter, + count: *mut size_t, ) -> lzma_ret { if filters.is_null() || (*filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_PROG_ERROR; } - let mut changes_size_count: size_t = 0 as size_t; - let mut non_last_ok: bool = true_0 != 0; - let mut last_ok: bool = false_0 != 0; - let mut i: size_t = 0 as size_t; + let mut changes_size_count: size_t = 0; + let mut non_last_ok: bool = true; + let mut last_ok: bool = false; + let mut i: size_t = 0; loop { let mut j: size_t = 0; - j = 0 as size_t; + j = 0; while (*filters.offset(i as isize)).id != features[j as usize].id { if features[j as usize].id == LZMA_VLI_UNKNOWN as lzma_vli { return LZMA_OPTIONS_ERROR; @@ -421,7 +417,7 @@ pub unsafe extern "C" fn lzma_validate_chain( break; } } - if i > LZMA_FILTERS_MAX as size_t || !last_ok || changes_size_count > 3 as size_t { + if i > LZMA_FILTERS_MAX as size_t || !last_ok || changes_size_count > 3 { return LZMA_OPTIONS_ERROR; } *count = i; @@ -429,11 +425,11 @@ pub unsafe extern "C" fn lzma_validate_chain( } #[no_mangle] pub unsafe extern "C" fn lzma_raw_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut options: *const lzma_filter, - mut coder_find: lzma_filter_find, - mut is_encoder: bool, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_filter, + coder_find: lzma_filter_find, + is_encoder: bool, ) -> lzma_ret { let mut count: size_t = 0; let ret_: lzma_ret = lzma_validate_chain(options, &raw mut count) as lzma_ret; @@ -443,12 +439,12 @@ pub unsafe extern "C" fn lzma_raw_coder_init( let mut filters: [lzma_filter_info; 5] = [lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5]; if is_encoder { - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < count { - let j: size_t = count.wrapping_sub(i).wrapping_sub(1 as size_t); + let j: size_t = count.wrapping_sub(i).wrapping_sub(1); let fc: *const lzma_filter_coder = coder_find.expect("non-null function pointer")((*options.offset(i as isize)).id) as *const lzma_filter_coder; @@ -461,7 +457,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( i = i.wrapping_add(1); } } else { - let mut i_0: size_t = 0 as size_t; + let mut i_0: size_t = 0; while i_0 < count { let fc_0: *const lzma_filter_coder = coder_find.expect("non-null function pointer")((*options.offset(i_0 as isize)).id) @@ -487,15 +483,15 @@ pub unsafe extern "C" fn lzma_raw_coder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_raw_coder_memusage( - mut coder_find: lzma_filter_find, - mut filters: *const lzma_filter, + coder_find: lzma_filter_find, + filters: *const lzma_filter, ) -> u64 { let mut tmp: size_t = 0; if lzma_validate_chain(filters, &raw mut tmp) != LZMA_OK { return UINT64_MAX as u64; } - let mut total: u64 = 0 as u64; - let mut i: size_t = 0 as size_t; + let mut total: u64 = 0; + let mut i: size_t = 0; loop { let fc: *const lzma_filter_coder = coder_find.expect("non-null function pointer")((*filters.offset(i as isize)).id) diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index e433e5b1..0a47e8c9 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -252,10 +252,6 @@ pub struct lzma_filter_coder { pub memusage: Option u64>, } pub type lzma_filter_find = Option *const lzma_filter_coder>; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_FILTER_X86: c_ulonglong = 0x4; pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; @@ -268,7 +264,7 @@ pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; -static mut decoders: [lzma_filter_decoder; 12] = [ +static decoders: [lzma_filter_decoder; 12] = [ lzma_filter_decoder { id: LZMA_FILTER_LZMA1 as lzma_vli, init: Some( @@ -522,44 +518,44 @@ static mut decoders: [lzma_filter_decoder; 12] = [ ), }, ]; -unsafe extern "C" fn decoder_find(mut id: lzma_vli) -> *const lzma_filter_decoder { - let mut i: size_t = 0 as size_t; +extern "C" fn decoder_find(id: lzma_vli) -> *const lzma_filter_decoder { + let mut i: size_t = 0; while i - < (::core::mem::size_of::<[lzma_filter_decoder; 12]>() as usize) - .wrapping_div(::core::mem::size_of::() as usize) + < (core::mem::size_of::<[lzma_filter_decoder; 12]>() as usize) + .wrapping_div(core::mem::size_of::() as usize) { if decoders[i as usize].id == id { - return (&raw const decoders as *const lzma_filter_decoder).offset(i as isize); + return decoders.as_ptr().wrapping_add(i as usize); } i = i.wrapping_add(1); } return ::core::ptr::null::(); } -unsafe extern "C" fn coder_find(mut id: lzma_vli) -> *const lzma_filter_coder { +extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { return decoder_find(id) as *const lzma_filter_coder; } #[no_mangle] -pub unsafe extern "C" fn lzma_filter_decoder_is_supported(mut id: lzma_vli) -> lzma_bool { - return (decoder_find(id) != NULL as *const lzma_filter_decoder) as c_int as lzma_bool; +pub extern "C" fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { + return !decoder_find(id).is_null() as lzma_bool; } #[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut options: *const lzma_filter, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_filter, ) -> lzma_ret { return lzma_raw_coder_init( next, allocator, options, Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), - false_0 != 0, + false, ); } #[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder( - mut strm: *mut lzma_stream, - mut options: *const lzma_filter, + strm: *mut lzma_stream, + options: *const lzma_filter, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -574,12 +570,12 @@ pub unsafe extern "C" fn lzma_raw_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_raw_decoder_memusage(mut filters: *const lzma_filter) -> u64 { +pub unsafe extern "C" fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { return lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, @@ -587,18 +583,18 @@ pub unsafe extern "C" fn lzma_raw_decoder_memusage(mut filters: *const lzma_filt } #[no_mangle] pub unsafe extern "C" fn lzma_properties_decode( - mut filter: *mut lzma_filter, - mut allocator: *const lzma_allocator, - mut props: *const u8, - mut props_size: size_t, + filter: *mut lzma_filter, + allocator: *const lzma_allocator, + props: *const u8, + props_size: size_t, ) -> lzma_ret { - (*filter).options = NULL; + (*filter).options = core::ptr::null_mut(); let fd: *const lzma_filter_decoder = decoder_find((*filter).id) as *const lzma_filter_decoder; if fd.is_null() { return LZMA_OPTIONS_ERROR; } if (*fd).props_decode.is_none() { - return (if props_size == 0 as size_t { + return (if props_size == 0 { LZMA_OK as c_int } else { LZMA_OPTIONS_ERROR as c_int diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index b2584fc3..b81f3ac5 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -230,10 +230,7 @@ pub struct lzma_filter_coder { pub memusage: Option u64>, } pub type lzma_filter_find = Option *const lzma_filter_coder>; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_X86: c_ulonglong = 0x4; @@ -248,7 +245,7 @@ pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; -static mut encoders: [lzma_filter_encoder; 12] = [ +static encoders: [lzma_filter_encoder; 12] = [ lzma_filter_encoder { id: LZMA_FILTER_LZMA1 as lzma_vli, init: Some( @@ -262,7 +259,7 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: Some(lzma_lzma_encoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), block_size: None, props_size_get: None, - props_size_fixed: 5 as u32, + props_size_fixed: 5, props_encode: Some( lzma_lzma_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), @@ -280,7 +277,7 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: Some(lzma_lzma_encoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), block_size: None, props_size_get: None, - props_size_fixed: 5 as u32, + props_size_fixed: 5, props_encode: Some( lzma_lzma_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), @@ -298,7 +295,7 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: Some(lzma_lzma2_encoder_memusage as unsafe extern "C" fn(*const c_void) -> u64), block_size: Some(lzma_lzma2_block_size as unsafe extern "C" fn(*const c_void) -> u64), props_size_get: None, - props_size_fixed: 1 as u32, + props_size_fixed: 1, props_encode: Some( lzma_lzma2_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), @@ -476,36 +473,36 @@ static mut encoders: [lzma_filter_encoder; 12] = [ memusage: Some(lzma_delta_coder_memusage as unsafe extern "C" fn(*const c_void) -> u64), block_size: None, props_size_get: None, - props_size_fixed: 1 as u32, + props_size_fixed: 1, props_encode: Some( lzma_delta_props_encode as unsafe extern "C" fn(*const c_void, *mut u8) -> lzma_ret, ), }, ]; -unsafe extern "C" fn encoder_find(mut id: lzma_vli) -> *const lzma_filter_encoder { - let mut i: size_t = 0 as size_t; +extern "C" fn encoder_find(id: lzma_vli) -> *const lzma_filter_encoder { + let mut i: size_t = 0; while i - < (::core::mem::size_of::<[lzma_filter_encoder; 12]>() as usize) - .wrapping_div(::core::mem::size_of::() as usize) + < (core::mem::size_of::<[lzma_filter_encoder; 12]>() as usize) + .wrapping_div(core::mem::size_of::() as usize) { if encoders[i as usize].id == id { - return (&raw const encoders as *const lzma_filter_encoder).offset(i as isize); + return encoders.as_ptr().wrapping_add(i as usize); } i = i.wrapping_add(1); } return ::core::ptr::null::(); } -unsafe extern "C" fn coder_find(mut id: lzma_vli) -> *const lzma_filter_coder { +extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { return encoder_find(id) as *const lzma_filter_coder; } #[no_mangle] -pub unsafe extern "C" fn lzma_filter_encoder_is_supported(mut id: lzma_vli) -> lzma_bool { - return (encoder_find(id) != NULL as *const lzma_filter_encoder) as c_int as lzma_bool; +pub extern "C" fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { + return !encoder_find(id).is_null() as lzma_bool; } #[no_mangle] pub unsafe extern "C" fn lzma_filters_update( - mut strm: *mut lzma_stream, - mut filters: *const lzma_filter, + strm: *mut lzma_stream, + filters: *const lzma_filter, ) -> lzma_ret { if (*(*strm).internal).next.update.is_none() { return LZMA_PROG_ERROR; @@ -513,17 +510,17 @@ pub unsafe extern "C" fn lzma_filters_update( if lzma_raw_encoder_memusage(filters) == UINT64_MAX as u64 { return LZMA_OPTIONS_ERROR; } - let mut count: size_t = 1 as size_t; + let mut count: size_t = 1; while (*filters.offset(count as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { count = count.wrapping_add(1); } let mut reversed_filters: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5]; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < count { - reversed_filters[count.wrapping_sub(i).wrapping_sub(1 as size_t) as usize] = + reversed_filters[count.wrapping_sub(i).wrapping_sub(1) as usize] = *filters.offset(i as isize); i = i.wrapping_add(1); } @@ -540,22 +537,22 @@ pub unsafe extern "C" fn lzma_filters_update( } #[no_mangle] pub unsafe extern "C" fn lzma_raw_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, ) -> lzma_ret { return lzma_raw_coder_init( next, allocator, filters, Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), - true_0 != 0, + true, ); } #[no_mangle] pub unsafe extern "C" fn lzma_raw_encoder( - mut strm: *mut lzma_stream, - mut filters: *const lzma_filter, + strm: *mut lzma_stream, + filters: *const lzma_filter, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -572,25 +569,25 @@ pub unsafe extern "C" fn lzma_raw_encoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_raw_encoder_memusage(mut filters: *const lzma_filter) -> u64 { +pub unsafe extern "C" fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64 { return lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, ); } #[no_mangle] -pub unsafe extern "C" fn lzma_mt_block_size(mut filters: *const lzma_filter) -> u64 { +pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { if filters.is_null() { return UINT64_MAX as u64; } - let mut max: u64 = 0 as u64; - let mut i: size_t = 0 as size_t; + let mut max: u64 = 0; + let mut i: size_t = 0; while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { let fe: *const lzma_filter_encoder = encoder_find((*filters.offset(i as isize)).id) as *const lzma_filter_encoder; @@ -607,16 +604,12 @@ pub unsafe extern "C" fn lzma_mt_block_size(mut filters: *const lzma_filter) -> } i = i.wrapping_add(1); } - return if max == 0 as u64 { - UINT64_MAX as u64 - } else { - max - }; + return if max == 0 { UINT64_MAX as u64 } else { max }; } #[no_mangle] pub unsafe extern "C" fn lzma_properties_size( - mut size: *mut u32, - mut filter: *const lzma_filter, + size: *mut u32, + filter: *const lzma_filter, ) -> lzma_ret { let fe: *const lzma_filter_encoder = encoder_find((*filter).id) as *const lzma_filter_encoder; if fe.is_null() { @@ -634,8 +627,8 @@ pub unsafe extern "C" fn lzma_properties_size( } #[no_mangle] pub unsafe extern "C" fn lzma_properties_encode( - mut filter: *const lzma_filter, - mut props: *mut u8, + filter: *const lzma_filter, + props: *mut u8, ) -> lzma_ret { let fe: *const lzma_filter_encoder = encoder_find((*filter).id) as *const lzma_filter_encoder; if fe.is_null() { diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 2db89bff..861b9192 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_vli_decode( vli: *mut lzma_vli, @@ -49,21 +49,19 @@ pub struct lzma_filter { pub id: lzma_vli, pub options: *mut c_void, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_decode( - mut filter: *mut lzma_filter, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + filter: *mut lzma_filter, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { - (*filter).options = NULL; + (*filter).options = core::ptr::null_mut(); let ret_: lzma_ret = lzma_vli_decode( &raw mut (*filter).id, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), in_0, in_pos, in_size, @@ -77,7 +75,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( let mut props_size: lzma_vli = 0; let ret__0: lzma_ret = lzma_vli_decode( &raw mut props_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), in_0, in_pos, in_size, diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index 40934be2..6c38a80b 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_vli_encode( vli: lzma_vli, @@ -42,8 +42,8 @@ pub struct lzma_filter { pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_size( - mut size: *mut u32, - mut filter: *const lzma_filter, + size: *mut u32, + filter: *const lzma_filter, ) -> lzma_ret { if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { return LZMA_PROG_ERROR; @@ -58,21 +58,16 @@ pub unsafe extern "C" fn lzma_filter_flags_size( } #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_encode( - mut filter: *const lzma_filter, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + filter: *const lzma_filter, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { return LZMA_PROG_ERROR; } - let ret_: lzma_ret = lzma_vli_encode( - (*filter).id, - ::core::ptr::null_mut::(), - out, - out_pos, - out_size, - ) as lzma_ret; + let ret_: lzma_ret = + lzma_vli_encode((*filter).id, core::ptr::null_mut(), out, out_pos, out_size) as lzma_ret; if ret_ != LZMA_OK { return ret_; } @@ -83,7 +78,7 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( } let ret__1: lzma_ret = lzma_vli_encode( props_size as lzma_vli, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), out, out_pos, out_size, diff --git a/liblzma-rs/src/common/hardware_cputhreads.rs b/liblzma-rs/src/common/hardware_cputhreads.rs index 27939b19..b93c2ceb 100644 --- a/liblzma-rs/src/common/hardware_cputhreads.rs +++ b/liblzma-rs/src/common/hardware_cputhreads.rs @@ -1,8 +1,6 @@ -use crate::types::*; -extern "C" { - fn tuklib_cpucores() -> u32; -} +use crate::tuklib::tuklib_cpucores::tuklib_cpucores; + #[no_mangle] -pub unsafe extern "C" fn lzma_cputhreads() -> u32 { +pub extern "C" fn lzma_cputhreads() -> u32 { return tuklib_cpucores(); } diff --git a/liblzma-rs/src/common/hardware_physmem.rs b/liblzma-rs/src/common/hardware_physmem.rs index 9403d84f..73e1b228 100644 --- a/liblzma-rs/src/common/hardware_physmem.rs +++ b/liblzma-rs/src/common/hardware_physmem.rs @@ -1,8 +1,6 @@ -use crate::types::*; -extern "C" { - fn tuklib_physmem() -> u64; -} +use crate::tuklib::tuklib_physmem::tuklib_physmem; + #[no_mangle] -pub unsafe extern "C" fn lzma_physmem() -> u64 { +pub extern "C" fn lzma_physmem() -> u64 { return tuklib_physmem(); } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 60d9cb86..eb2033c7 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulong, c_ulonglong, c_void}; extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_vli_size(vli: lzma_vli) -> u32; @@ -199,59 +199,52 @@ pub struct index_cat_info { } pub type C2RustUnnamed_2 = c_uint; pub type C2RustUnnamed_3 = c_uint; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn bsr32(mut n: u32) -> u32 { - return n.leading_zeros() as i32 as u32 ^ 31 as u32; +extern "C" fn bsr32(n: u32) -> u32 { + return n.leading_zeros() as i32 as u32 ^ 31; } #[inline] -unsafe extern "C" fn ctz32(mut n: u32) -> u32 { +extern "C" fn ctz32(n: u32) -> u32 { return n.trailing_zeros() as i32 as u32; } pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] -unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { +extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); } #[inline] -unsafe extern "C" fn index_size_unpadded( - mut count: lzma_vli, - mut index_list_size: lzma_vli, -) -> lzma_vli { - return ((1 as u32).wrapping_add(lzma_vli_size(count)) as lzma_vli) +extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { + return (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) .wrapping_add(index_list_size) .wrapping_add(4 as lzma_vli); } #[inline] -unsafe extern "C" fn index_size(mut count: lzma_vli, mut index_list_size: lzma_vli) -> lzma_vli { +extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { return vli_ceil4(index_size_unpadded(count, index_list_size)); } -pub const INDEX_GROUP_SIZE: c_int = 512 as c_int; +pub const INDEX_GROUP_SIZE: c_int = 512; pub const PREALLOC_MAX: usize = (SIZE_MAX as usize) - .wrapping_sub(::core::mem::size_of::() as usize) - .wrapping_div(::core::mem::size_of::() as usize); -unsafe extern "C" fn index_tree_init(mut tree: *mut index_tree) { - (*tree).root = ::core::ptr::null_mut::(); - (*tree).leftmost = ::core::ptr::null_mut::(); - (*tree).rightmost = ::core::ptr::null_mut::(); - (*tree).count = 0 as u32; + .wrapping_sub(core::mem::size_of::() as usize) + .wrapping_div(core::mem::size_of::() as usize); +unsafe extern "C" fn index_tree_init(tree: *mut index_tree) { + (*tree).root = core::ptr::null_mut(); + (*tree).leftmost = core::ptr::null_mut(); + (*tree).rightmost = core::ptr::null_mut(); + (*tree).count = 0; } unsafe extern "C" fn index_tree_node_end( - mut node: *mut index_tree_node, - mut allocator: *const lzma_allocator, - mut free_func: Option ()>, + node: *mut index_tree_node, + allocator: *const lzma_allocator, + free_func: Option ()>, ) { if !(*node).left.is_null() { index_tree_node_end((*node).left, allocator, free_func); @@ -262,18 +255,18 @@ unsafe extern "C" fn index_tree_node_end( free_func.expect("non-null function pointer")(node as *mut c_void, allocator); } unsafe extern "C" fn index_tree_end( - mut tree: *mut index_tree, - mut allocator: *const lzma_allocator, - mut free_func: Option ()>, + tree: *mut index_tree, + allocator: *const lzma_allocator, + free_func: Option ()>, ) { if !(*tree).root.is_null() { index_tree_node_end((*tree).root, allocator, free_func); } } -unsafe extern "C" fn index_tree_append(mut tree: *mut index_tree, mut node: *mut index_tree_node) { +unsafe extern "C" fn index_tree_append(tree: *mut index_tree, mut node: *mut index_tree_node) { (*node).parent = (*tree).rightmost; - (*node).left = ::core::ptr::null_mut::(); - (*node).right = ::core::ptr::null_mut::(); + (*node).left = core::ptr::null_mut(); + (*node).right = core::ptr::null_mut(); (*tree).count = (*tree).count.wrapping_add(1); if (*tree).root.is_null() { (*tree).root = node; @@ -283,17 +276,17 @@ unsafe extern "C" fn index_tree_append(mut tree: *mut index_tree, mut node: *mut } (*(*tree).rightmost).right = node; (*tree).rightmost = node; - let mut up: u32 = (*tree).count ^ (1 as u32) << bsr32((*tree).count); - if up != 0 as u32 { - up = ctz32((*tree).count).wrapping_add(2 as u32); + let mut up: u32 = (*tree).count ^ (1) << bsr32((*tree).count); + if up != 0 { + up = ctz32((*tree).count).wrapping_add(2); loop { node = (*node).parent; up = up.wrapping_sub(1); - if !(up > 0 as u32) { + if !(up > 0) { break; } } - let mut pivot: *mut index_tree_node = (*node).right; + let pivot: *mut index_tree_node = (*node).right; if (*node).parent.is_null() { (*tree).root = pivot; } else { @@ -321,10 +314,7 @@ unsafe extern "C" fn index_tree_next(mut node: *const index_tree_node) -> *mut c } return (*node).parent as *mut c_void; } -unsafe extern "C" fn index_tree_locate( - mut tree: *const index_tree, - mut target: lzma_vli, -) -> *mut c_void { +unsafe extern "C" fn index_tree_locate(tree: *const index_tree, target: lzma_vli) -> *mut c_void { let mut result: *const index_tree_node = ::core::ptr::null::(); let mut node: *const index_tree_node = (*tree).root; while !node.is_null() { @@ -338,23 +328,22 @@ unsafe extern "C" fn index_tree_locate( return result as *mut c_void; } unsafe extern "C" fn index_stream_init( - mut compressed_base: lzma_vli, - mut uncompressed_base: lzma_vli, - mut stream_number: u32, - mut block_number_base: lzma_vli, - mut allocator: *const lzma_allocator, + compressed_base: lzma_vli, + uncompressed_base: lzma_vli, + stream_number: u32, + block_number_base: lzma_vli, + allocator: *const lzma_allocator, ) -> *mut index_stream { - let mut s: *mut index_stream = - lzma_alloc(::core::mem::size_of::() as size_t, allocator) - as *mut index_stream; + let s: *mut index_stream = + lzma_alloc(core::mem::size_of::() as size_t, allocator) as *mut index_stream; if s.is_null() { - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } (*s).node.uncompressed_base = uncompressed_base; (*s).node.compressed_base = compressed_base; - (*s).node.parent = ::core::ptr::null_mut::(); - (*s).node.left = ::core::ptr::null_mut::(); - (*s).node.right = ::core::ptr::null_mut::(); + (*s).node.parent = core::ptr::null_mut(); + (*s).node.left = core::ptr::null_mut(); + (*s).node.right = core::ptr::null_mut(); (*s).number = stream_number; (*s).block_number_base = block_number_base; index_tree_init(&raw mut (*s).groups); @@ -364,8 +353,8 @@ unsafe extern "C" fn index_stream_init( (*s).stream_padding = 0 as lzma_vli; return s; } -unsafe extern "C" fn index_stream_end(mut node: *mut c_void, mut allocator: *const lzma_allocator) { - let mut s: *mut index_stream = node as *mut index_stream; +unsafe extern "C" fn index_stream_end(node: *mut c_void, allocator: *const lzma_allocator) { + let s: *mut index_stream = node as *mut index_stream; index_tree_end( &raw mut (*s).groups, allocator, @@ -373,9 +362,9 @@ unsafe extern "C" fn index_stream_end(mut node: *mut c_void, mut allocator: *con ); lzma_free(s as *mut c_void, allocator); } -unsafe extern "C" fn index_init_plain(mut allocator: *const lzma_allocator) -> *mut lzma_index { - let mut i: *mut lzma_index = - lzma_alloc(::core::mem::size_of::() as size_t, allocator) as *mut lzma_index; +unsafe extern "C" fn index_init_plain(allocator: *const lzma_allocator) -> *mut lzma_index { + let i: *mut lzma_index = + lzma_alloc(core::mem::size_of::() as size_t, allocator) as *mut lzma_index; if !i.is_null() { index_tree_init(&raw mut (*i).streams); (*i).uncompressed_size = 0 as lzma_vli; @@ -383,35 +372,27 @@ unsafe extern "C" fn index_init_plain(mut allocator: *const lzma_allocator) -> * (*i).record_count = 0 as lzma_vli; (*i).index_list_size = 0 as lzma_vli; (*i).prealloc = INDEX_GROUP_SIZE as size_t; - (*i).checks = 0 as u32; + (*i).checks = 0; } return i; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_init(mut allocator: *const lzma_allocator) -> *mut lzma_index { - let mut i: *mut lzma_index = index_init_plain(allocator); +pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index { + let i: *mut lzma_index = index_init_plain(allocator); if i.is_null() { - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } - let mut s: *mut index_stream = index_stream_init( - 0 as lzma_vli, - 0 as lzma_vli, - 1 as u32, - 0 as lzma_vli, - allocator, - ); + let s: *mut index_stream = + index_stream_init(0 as lzma_vli, 0 as lzma_vli, 1, 0 as lzma_vli, allocator); if s.is_null() { lzma_free(i as *mut c_void, allocator); - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } index_tree_append(&raw mut (*i).streams, &raw mut (*s).node); return i; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_end( - mut i: *mut lzma_index, - mut allocator: *const lzma_allocator, -) { +pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { if !i.is_null() { index_tree_end( &raw mut (*i).streams, @@ -424,23 +405,23 @@ pub unsafe extern "C" fn lzma_index_end( } } #[no_mangle] -pub unsafe extern "C" fn lzma_index_prealloc(mut i: *mut lzma_index, mut records: lzma_vli) { +pub unsafe extern "C" fn lzma_index_prealloc(i: *mut lzma_index, mut records: lzma_vli) { if records > PREALLOC_MAX as lzma_vli { records = PREALLOC_MAX as lzma_vli; } (*i).prealloc = records as size_t; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_memusage(mut streams: lzma_vli, mut blocks: lzma_vli) -> u64 { +pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64 { let alloc_overhead: size_t = - (4 as size_t).wrapping_mul(::core::mem::size_of::<*mut c_void>() as size_t); - let stream_base: size_t = (::core::mem::size_of::() as size_t) - .wrapping_add(::core::mem::size_of::() as size_t) + (4 as size_t).wrapping_mul(core::mem::size_of::<*mut c_void>() as size_t); + let stream_base: size_t = (core::mem::size_of::() as size_t) + .wrapping_add(core::mem::size_of::() as size_t) .wrapping_add((2 as size_t).wrapping_mul(alloc_overhead)); - let group_base: size_t = (::core::mem::size_of::() as size_t) + let group_base: size_t = (core::mem::size_of::() as size_t) .wrapping_add( (INDEX_GROUP_SIZE as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::() as size_t), ) .wrapping_add(alloc_overhead); let groups: lzma_vli = blocks @@ -449,8 +430,8 @@ pub unsafe extern "C" fn lzma_index_memusage(mut streams: lzma_vli, mut blocks: .wrapping_div(INDEX_GROUP_SIZE as lzma_vli); let streams_mem: u64 = (streams as u64).wrapping_mul(stream_base as u64); let groups_mem: u64 = (groups as u64).wrapping_mul(group_base as u64); - let index_base: u64 = (::core::mem::size_of::() as usize) - .wrapping_add(alloc_overhead as usize) as u64; + let index_base: u64 = + (core::mem::size_of::() as usize).wrapping_add(alloc_overhead as usize) as u64; let limit: u64 = (UINT64_MAX as u64).wrapping_sub(index_base); if streams == 0 as lzma_vli || streams > UINT32_MAX as lzma_vli @@ -466,38 +447,38 @@ pub unsafe extern "C" fn lzma_index_memusage(mut streams: lzma_vli, mut blocks: .wrapping_add(groups_mem); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_memused(mut i: *const lzma_index) -> u64 { +pub unsafe extern "C" fn lzma_index_memused(i: *const lzma_index) -> u64 { return lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_block_count(mut i: *const lzma_index) -> lzma_vli { +pub unsafe extern "C" fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli { return (*i).record_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_stream_count(mut i: *const lzma_index) -> lzma_vli { +pub unsafe extern "C" fn lzma_index_stream_count(i: *const lzma_index) -> lzma_vli { return (*i).streams.count as lzma_vli; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_size(mut i: *const lzma_index) -> lzma_vli { +pub unsafe extern "C" fn lzma_index_size(i: *const lzma_index) -> lzma_vli { return index_size((*i).record_count, (*i).index_list_size); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_total_size(mut i: *const lzma_index) -> lzma_vli { +pub unsafe extern "C" fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { return (*i).total_size; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_stream_size(mut i: *const lzma_index) -> lzma_vli { +pub unsafe extern "C" fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { return (LZMA_STREAM_HEADER_SIZE as lzma_vli) .wrapping_add((*i).total_size) .wrapping_add(index_size((*i).record_count, (*i).index_list_size)) .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli); } unsafe extern "C" fn index_file_size( - mut compressed_base: lzma_vli, - mut unpadded_sum: lzma_vli, - mut record_count: lzma_vli, - mut index_list_size: lzma_vli, - mut stream_padding: lzma_vli, + compressed_base: lzma_vli, + unpadded_sum: lzma_vli, + record_count: lzma_vli, + index_list_size: lzma_vli, + stream_padding: lzma_vli, ) -> lzma_vli { let mut file_size: lzma_vli = compressed_base .wrapping_add((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) @@ -513,9 +494,9 @@ unsafe extern "C" fn index_file_size( return file_size; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_file_size(mut i: *const lzma_index) -> lzma_vli { - let mut s: *const index_stream = (*i).streams.rightmost as *const index_stream; - let mut g: *const index_group = (*s).groups.rightmost as *const index_group; +pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli { + let s: *const index_stream = (*i).streams.rightmost as *const index_stream; + let g: *const index_group = (*s).groups.rightmost as *const index_group; return index_file_size( (*s).node.compressed_base, if g.is_null() { @@ -530,28 +511,28 @@ pub unsafe extern "C" fn lzma_index_file_size(mut i: *const lzma_index) -> lzma_ ); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_uncompressed_size(mut i: *const lzma_index) -> lzma_vli { +pub unsafe extern "C" fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { return (*i).uncompressed_size; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_checks(mut i: *const lzma_index) -> u32 { +pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { let mut checks: u32 = (*i).checks; - let mut s: *const index_stream = (*i).streams.rightmost as *const index_stream; + let s: *const index_stream = (*i).streams.rightmost as *const index_stream; if (*s).stream_flags.version != UINT32_MAX as u32 { checks = (checks | 1u32 << (*s).stream_flags.check) as u32; } return checks; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_padding_size(mut i: *const lzma_index) -> u32 { +pub unsafe extern "C" fn lzma_index_padding_size(i: *const lzma_index) -> u32 { return ((4 as lzma_vli) .wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) & 3 as lzma_vli) as u32; } #[no_mangle] pub unsafe extern "C" fn lzma_index_stream_flags( - mut i: *mut lzma_index, - mut stream_flags: *const lzma_stream_flags, + i: *mut lzma_index, + stream_flags: *const lzma_stream_flags, ) -> lzma_ret { if i.is_null() || stream_flags.is_null() { return LZMA_PROG_ERROR; @@ -560,14 +541,14 @@ pub unsafe extern "C" fn lzma_index_stream_flags( if ret_ != LZMA_OK { return ret_; } - let mut s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; + let s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; (*s).stream_flags = *stream_flags; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_index_stream_padding( - mut i: *mut lzma_index, - mut stream_padding: lzma_vli, + i: *mut lzma_index, + stream_padding: lzma_vli, ) -> lzma_ret { if i.is_null() || stream_padding > LZMA_VLI_MAX as lzma_vli @@ -575,7 +556,7 @@ pub unsafe extern "C" fn lzma_index_stream_padding( { return LZMA_PROG_ERROR; } - let mut s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; + let s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; let old_stream_padding: lzma_vli = (*s).stream_padding; (*s).stream_padding = 0 as lzma_vli; if lzma_index_file_size(i).wrapping_add(stream_padding) > LZMA_VLI_MAX as lzma_vli { @@ -587,10 +568,10 @@ pub unsafe extern "C" fn lzma_index_stream_padding( } #[no_mangle] pub unsafe extern "C" fn lzma_index_append( - mut i: *mut lzma_index, - mut allocator: *const lzma_allocator, - mut unpadded_size: lzma_vli, - mut uncompressed_size: lzma_vli, + i: *mut lzma_index, + allocator: *const lzma_allocator, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, ) -> lzma_ret { if i.is_null() || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli @@ -599,7 +580,7 @@ pub unsafe extern "C" fn lzma_index_append( { return LZMA_PROG_ERROR; } - let mut s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; + let s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; let mut g: *mut index_group = (*s).groups.rightmost as *mut index_group; let compressed_base: lzma_vli = if g.is_null() { 0 as lzma_vli @@ -640,20 +621,20 @@ pub unsafe extern "C" fn lzma_index_append( { return LZMA_DATA_ERROR; } - if !g.is_null() && (*g).last.wrapping_add(1 as size_t) < (*g).allocated { + if !g.is_null() && (*g).last.wrapping_add(1) < (*g).allocated { (*g).last = (*g).last.wrapping_add(1); } else { g = lzma_alloc( - (::core::mem::size_of::() as size_t).wrapping_add( + (core::mem::size_of::() as size_t).wrapping_add( (*i).prealloc - .wrapping_mul(::core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::() as size_t), ), allocator, ) as *mut index_group; if g.is_null() { return LZMA_MEM_ERROR; } - (*g).last = 0 as size_t; + (*g).last = 0; (*g).allocated = (*i).prealloc; (*i).prealloc = INDEX_GROUP_SIZE as size_t; (*g).node.uncompressed_base = uncompressed_base; @@ -677,12 +658,9 @@ pub unsafe extern "C" fn lzma_index_append( .wrapping_add(index_list_size_add as lzma_vli); return LZMA_OK; } -unsafe extern "C" fn index_cat_helper( - mut info: *const index_cat_info, - mut this: *mut index_stream, -) { - let mut left: *mut index_stream = (*this).node.left as *mut index_stream; - let mut right: *mut index_stream = (*this).node.right as *mut index_stream; +unsafe extern "C" fn index_cat_helper(info: *const index_cat_info, this: *mut index_stream) { + let left: *mut index_stream = (*this).node.left as *mut index_stream; + let right: *mut index_stream = (*this).node.right as *mut index_stream; if !left.is_null() { index_cat_helper(info, left); } @@ -702,9 +680,9 @@ unsafe extern "C" fn index_cat_helper( } #[no_mangle] pub unsafe extern "C" fn lzma_index_cat( - mut dest: *mut lzma_index, - mut src: *mut lzma_index, - mut allocator: *const lzma_allocator, + dest: *mut lzma_index, + src: *mut lzma_index, + allocator: *const lzma_allocator, ) -> lzma_ret { if dest.is_null() || src.is_null() { return LZMA_PROG_ERROR; @@ -725,14 +703,14 @@ pub unsafe extern "C" fn lzma_index_cat( if vli_ceil4(dest_size.wrapping_add(src_size)) > LZMA_BACKWARD_SIZE_MAX as lzma_vli { return LZMA_DATA_ERROR; } - let mut s: *mut index_stream = (*dest).streams.rightmost as *mut index_stream; - let mut g: *mut index_group = (*s).groups.rightmost as *mut index_group; - if !g.is_null() && (*g).last.wrapping_add(1 as size_t) < (*g).allocated { - let mut newg: *mut index_group = lzma_alloc( - (::core::mem::size_of::() as size_t).wrapping_add( + let s: *mut index_stream = (*dest).streams.rightmost as *mut index_stream; + let g: *mut index_group = (*s).groups.rightmost as *mut index_group; + if !g.is_null() && (*g).last.wrapping_add(1) < (*g).allocated { + let newg: *mut index_group = lzma_alloc( + (core::mem::size_of::() as size_t).wrapping_add( (*g).last - .wrapping_add(1 as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + .wrapping_add(1) + .wrapping_mul(core::mem::size_of::() as size_t), ), allocator, ) as *mut index_group; @@ -740,7 +718,7 @@ pub unsafe extern "C" fn lzma_index_cat( return LZMA_MEM_ERROR; } (*newg).node = (*g).node; - (*newg).allocated = (*g).last.wrapping_add(1 as size_t); + (*newg).allocated = (*g).last.wrapping_add(1); (*newg).last = (*g).last; (*newg).number_base = (*g).number_base; memcpy( @@ -748,7 +726,7 @@ pub unsafe extern "C" fn lzma_index_cat( &raw mut (*g).records as *mut index_record as *const c_void, (*newg) .allocated - .wrapping_mul(::core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::() as size_t), ); if !(*g).node.parent.is_null() { (*(*g).node.parent).right = &raw mut (*newg).node; @@ -780,13 +758,13 @@ pub unsafe extern "C" fn lzma_index_cat( return LZMA_OK; } unsafe extern "C" fn index_dup_stream( - mut src: *const index_stream, - mut allocator: *const lzma_allocator, + src: *const index_stream, + allocator: *const lzma_allocator, ) -> *mut index_stream { if (*src).record_count > PREALLOC_MAX as lzma_vli { - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } - let mut dest: *mut index_stream = index_stream_init( + let dest: *mut index_stream = index_stream_init( (*src).node.compressed_base, (*src).node.uncompressed_base, (*src).number, @@ -794,7 +772,7 @@ unsafe extern "C" fn index_dup_stream( allocator, ); if dest.is_null() { - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } (*dest).record_count = (*src).record_count; (*dest).index_list_size = (*src).index_list_size; @@ -803,17 +781,17 @@ unsafe extern "C" fn index_dup_stream( if (*src).groups.leftmost.is_null() { return dest; } - let mut destg: *mut index_group = lzma_alloc( - (::core::mem::size_of::() as lzma_vli).wrapping_add( + let destg: *mut index_group = lzma_alloc( + (core::mem::size_of::() as lzma_vli).wrapping_add( (*src) .record_count - .wrapping_mul(::core::mem::size_of::() as lzma_vli), + .wrapping_mul(core::mem::size_of::() as lzma_vli), ) as size_t, allocator, ) as *mut index_group; if destg.is_null() { index_stream_end(dest as *mut c_void, allocator); - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } (*destg).node.uncompressed_base = 0 as lzma_vli; (*destg).node.compressed_base = 0 as lzma_vli; @@ -821,17 +799,17 @@ unsafe extern "C" fn index_dup_stream( (*destg).allocated = (*src).record_count as size_t; (*destg).last = (*src).record_count.wrapping_sub(1 as lzma_vli) as size_t; let mut srcg: *const index_group = (*src).groups.leftmost as *const index_group; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; loop { memcpy( (&raw mut (*destg).records as *mut index_record).offset(i as isize) as *mut c_void, &raw const (*srcg).records as *const index_record as *const c_void, (*srcg) .last - .wrapping_add(1 as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + .wrapping_add(1) + .wrapping_mul(core::mem::size_of::() as size_t), ); - i = i.wrapping_add((*srcg).last.wrapping_add(1 as size_t)); + i = i.wrapping_add((*srcg).last.wrapping_add(1)); srcg = index_tree_next(&raw const (*srcg).node) as *const index_group; if srcg.is_null() { break; @@ -842,12 +820,12 @@ unsafe extern "C" fn index_dup_stream( } #[no_mangle] pub unsafe extern "C" fn lzma_index_dup( - mut src: *const lzma_index, - mut allocator: *const lzma_allocator, + src: *const lzma_index, + allocator: *const lzma_allocator, ) -> *mut lzma_index { - let mut dest: *mut lzma_index = index_init_plain(allocator); + let dest: *mut lzma_index = index_init_plain(allocator); if dest.is_null() { - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } (*dest).uncompressed_size = (*src).uncompressed_size; (*dest).total_size = (*src).total_size; @@ -855,10 +833,10 @@ pub unsafe extern "C" fn lzma_index_dup( (*dest).index_list_size = (*src).index_list_size; let mut srcstream: *const index_stream = (*src).streams.leftmost as *const index_stream; loop { - let mut deststream: *mut index_stream = index_dup_stream(srcstream, allocator); + let deststream: *mut index_stream = index_dup_stream(srcstream, allocator); if deststream.is_null() { lzma_index_end(dest, allocator); - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } index_tree_append(&raw mut (*dest).streams, &raw mut (*deststream).node); srcstream = index_tree_next(&raw const (*srcstream).node) as *const index_stream; @@ -868,12 +846,11 @@ pub unsafe extern "C" fn lzma_index_dup( } return dest; } -unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { - let mut i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; - let mut stream: *const index_stream = +unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { + let i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; + let stream: *const index_stream = (*iter).internal[ITER_STREAM as usize].p as *const index_stream; - let mut group: *const index_group = - (*iter).internal[ITER_GROUP as usize].p as *const index_group; + let group: *const index_group = (*iter).internal[ITER_GROUP as usize].p as *const index_group; let record: size_t = (*iter).internal[ITER_RECORD as usize].s; if group.is_null() { (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_LEFTMOST as size_t; @@ -903,7 +880,7 @@ unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { .wrapping_add((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli); (*iter).stream.uncompressed_size = 0 as lzma_vli; } else { - let mut g: *const index_group = (*stream).groups.rightmost as *const index_group; + let g: *const index_group = (*stream).groups.rightmost as *const index_group; (*iter).stream.compressed_size = ((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) .wrapping_add(index_size( (*stream).record_count, @@ -923,20 +900,20 @@ unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { .block .number_in_stream .wrapping_add((*stream).block_number_base); - (*iter).block.compressed_stream_offset = if record == 0 as size_t { + (*iter).block.compressed_stream_offset = if record == 0 { (*group).node.compressed_base } else { vli_ceil4( (*(&raw const (*group).records as *const index_record) - .offset(record.wrapping_sub(1 as size_t) as isize)) + .offset(record.wrapping_sub(1) as isize)) .unpadded_sum, ) }; - (*iter).block.uncompressed_stream_offset = if record == 0 as size_t { + (*iter).block.uncompressed_stream_offset = if record == 0 { (*group).node.uncompressed_base } else { (*(&raw const (*group).records as *const index_record) - .offset(record.wrapping_sub(1 as size_t) as isize)) + .offset(record.wrapping_sub(1) as isize)) .uncompressed_sum }; (*iter).block.uncompressed_size = (*(&raw const (*group).records as *const index_record) @@ -963,29 +940,26 @@ unsafe extern "C" fn iter_set_info(mut iter: *mut lzma_index_iter) { } } #[no_mangle] -pub unsafe extern "C" fn lzma_index_iter_init( - mut iter: *mut lzma_index_iter, - mut i: *const lzma_index, -) { +pub unsafe extern "C" fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index) { (*iter).internal[ITER_INDEX as usize].p = i as *const c_void; lzma_index_iter_rewind(iter); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_iter_rewind(mut iter: *mut lzma_index_iter) { +pub unsafe extern "C" fn lzma_index_iter_rewind(iter: *mut lzma_index_iter) { (*iter).internal[ITER_STREAM as usize].p = ::core::ptr::null::(); (*iter).internal[ITER_GROUP as usize].p = ::core::ptr::null::(); - (*iter).internal[ITER_RECORD as usize].s = 0 as size_t; + (*iter).internal[ITER_RECORD as usize].s = 0; (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NORMAL as size_t; } #[no_mangle] pub unsafe extern "C" fn lzma_index_iter_next( - mut iter: *mut lzma_index_iter, - mut mode: lzma_index_iter_mode, + iter: *mut lzma_index_iter, + mode: lzma_index_iter_mode, ) -> lzma_bool { if mode > LZMA_INDEX_ITER_NONEMPTY_BLOCK { - return true_0 as lzma_bool; + return true as lzma_bool; } - let mut i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; + let i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; let mut stream: *const index_stream = (*iter).internal[ITER_STREAM as usize].p as *const index_stream; let mut group: *const index_group = ::core::ptr::null::(); @@ -1013,16 +987,16 @@ pub unsafe extern "C" fn lzma_index_iter_next( while (*stream).groups.leftmost.is_null() { stream = index_tree_next(&raw const (*stream).node) as *const index_stream; if stream.is_null() { - return true_0 as lzma_bool; + return true as lzma_bool; } } } group = (*stream).groups.leftmost as *const index_group; - record = 0 as size_t; + record = 0; } else if !group.is_null() && record < (*group).last { record = record.wrapping_add(1); } else { - record = 0 as size_t; + record = 0; if !group.is_null() { group = index_tree_next(&raw const (*group).node) as *const index_group; } @@ -1030,7 +1004,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( loop { stream = index_tree_next(&raw const (*stream).node) as *const index_stream; if stream.is_null() { - return true_0 as lzma_bool; + return true as lzma_bool; } if !(mode >= LZMA_INDEX_ITER_BLOCK && (*stream).groups.leftmost.is_null()) { break; @@ -1042,7 +1016,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( if !(mode == LZMA_INDEX_ITER_NONEMPTY_BLOCK) { break; } - if record == 0 as size_t { + if record == 0 { if !((*group).node.uncompressed_base == (*(&raw const (*group).records as *const index_record).offset(0)) .uncompressed_sum) @@ -1050,7 +1024,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( break; } } else if !((*(&raw const (*group).records as *const index_record) - .offset(record.wrapping_sub(1 as size_t) as isize)) + .offset(record.wrapping_sub(1) as isize)) .uncompressed_sum == (*(&raw const (*group).records as *const index_record).offset(record as isize)) .uncompressed_sum) @@ -1062,31 +1036,31 @@ pub unsafe extern "C" fn lzma_index_iter_next( (*iter).internal[ITER_GROUP as usize].p = group as *const c_void; (*iter).internal[ITER_RECORD as usize].s = record; iter_set_info(iter); - return false_0 as lzma_bool; + return false as lzma_bool; } #[no_mangle] pub unsafe extern "C" fn lzma_index_iter_locate( - mut iter: *mut lzma_index_iter, + iter: *mut lzma_index_iter, mut target: lzma_vli, ) -> lzma_bool { - let mut i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; + let i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; if (*i).uncompressed_size <= target { - return true_0 as lzma_bool; + return true as lzma_bool; } - let mut stream: *const index_stream = + let stream: *const index_stream = index_tree_locate(&raw const (*i).streams, target) as *const index_stream; target = target.wrapping_sub((*stream).node.uncompressed_base); - let mut group: *const index_group = + let group: *const index_group = index_tree_locate(&raw const (*stream).groups, target) as *const index_group; - let mut left: size_t = 0 as size_t; + let mut left: size_t = 0; let mut right: size_t = (*group).last; while left < right { - let pos: size_t = left.wrapping_add(right.wrapping_sub(left).wrapping_div(2 as size_t)); + let pos: size_t = left.wrapping_add(right.wrapping_sub(left).wrapping_div(2)); if (*(&raw const (*group).records as *const index_record).offset(pos as isize)) .uncompressed_sum <= target { - left = pos.wrapping_add(1 as size_t); + left = pos.wrapping_add(1); } else { right = pos; } @@ -1095,5 +1069,5 @@ pub unsafe extern "C" fn lzma_index_iter_locate( (*iter).internal[ITER_GROUP as usize].p = group as *const c_void; (*iter).internal[ITER_RECORD as usize].s = left; iter_set_info(iter); - return false_0 as lzma_bool; + return false as lzma_bool; } diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 303e1b5d..ecd543a4 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -173,27 +173,24 @@ pub const SEQ_UNPADDED: C2RustUnnamed_0 = 3; pub const SEQ_MEMUSAGE: C2RustUnnamed_0 = 2; pub const SEQ_COUNT: C2RustUnnamed_0 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; -pub const INDEX_INDICATOR: c_int = 0 as c_int; +pub const INDEX_INDICATOR: c_int = 0; unsafe extern "C" fn index_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + _out: *mut u8, + _out_pos: *mut size_t, + _out_size: size_t, + _action: lzma_action, ) -> lzma_ret { let mut current_block: u64; - let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; + let coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; let in_start: size_t = *in_pos; let mut ret: lzma_ret = LZMA_OK; while *in_pos < in_size { @@ -218,7 +215,7 @@ unsafe extern "C" fn index_decode( if ret != LZMA_STREAM_END { break; } - (*coder).pos = 0 as size_t; + (*coder).pos = 0; (*coder).sequence = SEQ_MEMUSAGE; current_block = 7642845755631126846; } @@ -226,7 +223,7 @@ unsafe extern "C" fn index_decode( current_block = 7642845755631126846; } 3 | 4 => { - let mut size: *mut lzma_vli = if (*coder).sequence == SEQ_UNPADDED { + let size: *mut lzma_vli = if (*coder).sequence == SEQ_UNPADDED { &raw mut (*coder).unpadded_size } else { &raw mut (*coder).uncompressed_size @@ -236,7 +233,7 @@ unsafe extern "C" fn index_decode( break; } ret = LZMA_OK; - (*coder).pos = 0 as size_t; + (*coder).pos = 0; if (*coder).sequence == SEQ_UNPADDED { if (*coder).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || (*coder).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli @@ -278,7 +275,7 @@ unsafe extern "C" fn index_decode( } match current_block { 8340016495055110192 => { - if (*coder).pos > 0 as size_t { + if (*coder).pos > 0 { (*coder).pos = (*coder).pos.wrapping_sub(1); let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); @@ -318,44 +315,41 @@ unsafe extern "C" fn index_decode( } let fresh2 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if (*coder).crc32 >> (*coder).pos.wrapping_mul(8 as size_t) & 0xff as u32 + if (*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff as u32 != *in_0.offset(fresh2 as isize) as u32 { return LZMA_DATA_ERROR; } (*coder).pos = (*coder).pos.wrapping_add(1); - if !((*coder).pos < 4 as size_t) { + if !((*coder).pos < 4) { break; } } *(*coder).index_ptr = (*coder).index; - (*coder).index = ::core::ptr::null_mut::(); + (*coder).index = core::ptr::null_mut(); return LZMA_STREAM_END; } let in_used: size_t = (*in_pos).wrapping_sub(in_start); - if in_used > 0 as size_t { + if in_used > 0 { (*coder).crc32 = lzma_crc32(in_0.offset(in_start as isize), in_used, (*coder).crc32); } return ret; } -unsafe extern "C" fn index_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; +unsafe extern "C" fn index_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; lzma_index_end((*coder).index, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn index_decoder_memconfig( - mut coder_ptr: *mut c_void, - mut memusage: *mut u64, - mut old_memlimit: *mut u64, - mut new_memlimit: u64, + coder_ptr: *mut c_void, + memusage: *mut u64, + old_memlimit: *mut u64, + new_memlimit: u64, ) -> lzma_ret { - let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; + let coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; *memusage = lzma_index_memusage(1 as lzma_vli, (*coder).count); *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as u64 { + if new_memlimit != 0 { if new_memlimit < *memusage { return LZMA_MEMLIMIT_ERROR; } @@ -364,34 +358,30 @@ unsafe extern "C" fn index_decoder_memconfig( return LZMA_OK; } unsafe extern "C" fn index_decoder_reset( - mut coder: *mut lzma_index_coder, - mut allocator: *const lzma_allocator, - mut i: *mut *mut lzma_index, - mut memlimit: u64, + coder: *mut lzma_index_coder, + allocator: *const lzma_allocator, + i: *mut *mut lzma_index, + memlimit: u64, ) -> lzma_ret { (*coder).index_ptr = i; - *i = ::core::ptr::null_mut::(); + *i = core::ptr::null_mut(); (*coder).index = lzma_index_init(allocator); if (*coder).index.is_null() { return LZMA_MEM_ERROR; } (*coder).sequence = SEQ_INDICATOR; - (*coder).memlimit = if 1 as u64 > memlimit { - 1 as u64 - } else { - memlimit - }; + (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).count = 0 as lzma_vli; - (*coder).pos = 0 as size_t; - (*coder).crc32 = 0 as u32; + (*coder).pos = 0; + (*coder).crc32 = 0; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_index_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut i: *mut *mut lzma_index, - mut memlimit: u64, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + i: *mut *mut lzma_index, + memlimit: u64, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -440,7 +430,7 @@ pub unsafe extern "C" fn lzma_index_decoder_init( let mut coder: *mut lzma_index_coder = (*next).coder as *mut lzma_index_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_index_coder; if coder.is_null() { @@ -469,7 +459,7 @@ pub unsafe extern "C" fn lzma_index_decoder_init( as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, ) as Option lzma_ret>; - (*coder).index = ::core::ptr::null_mut::(); + (*coder).index = core::ptr::null_mut(); } else { lzma_index_end((*coder).index, allocator); } @@ -477,12 +467,12 @@ pub unsafe extern "C" fn lzma_index_decoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_index_decoder( - mut strm: *mut lzma_stream, - mut i: *mut *mut lzma_index, - mut memlimit: u64, + strm: *mut lzma_stream, + i: *mut *mut lzma_index, + memlimit: u64, ) -> lzma_ret { if !i.is_null() { - *i = ::core::ptr::null_mut::(); + *i = core::ptr::null_mut(); } let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -498,21 +488,21 @@ pub unsafe extern "C" fn lzma_index_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_index_buffer_decode( - mut i: *mut *mut lzma_index, - mut memlimit: *mut u64, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + i: *mut *mut lzma_index, + memlimit: *mut u64, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { if !i.is_null() { - *i = ::core::ptr::null_mut::(); + *i = core::ptr::null_mut(); } if i.is_null() || memlimit.is_null() || in_0.is_null() || in_pos.is_null() || *in_pos > in_size { @@ -521,8 +511,8 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( let mut coder: lzma_index_coder = lzma_index_coder { sequence: SEQ_INDICATOR, memlimit: 0, - index: ::core::ptr::null_mut::(), - index_ptr: ::core::ptr::null_mut::<*mut lzma_index>(), + index: core::ptr::null_mut(), + index_ptr: core::ptr::null_mut(), count: 0, unpadded_size: 0, uncompressed_size: 0, @@ -540,9 +530,9 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( in_0, in_pos, in_size, - ::core::ptr::null_mut::(), - ::core::ptr::null_mut::(), - 0 as size_t, + core::ptr::null_mut(), + core::ptr::null_mut(), + 0, LZMA_RUN, ); if ret == LZMA_STREAM_END { diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index b84da787..b7c71933 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_void}; +use core::ffi::{c_int, c_uint, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -242,23 +242,20 @@ pub const SEQ_UNCOMPRESSED: C2RustUnnamed_3 = 3; pub const SEQ_UNPADDED: C2RustUnnamed_3 = 2; pub const SEQ_COUNT: C2RustUnnamed_3 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_3 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; -pub const true_0: c_int = 1 as c_int; -pub const INDEX_INDICATOR: c_int = 0 as c_int; +pub const INDEX_INDICATOR: c_int = 0; unsafe extern "C" fn index_encode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + _allocator: *const lzma_allocator, + _in_0: *const u8, + _in_pos: *mut size_t, + _in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + _action: lzma_action, ) -> lzma_ret { let mut current_block: u64; - let mut coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; + let coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; let out_start: size_t = *out_pos; let mut ret: lzma_ret = LZMA_OK; while *out_pos < out_size { @@ -276,7 +273,7 @@ unsafe extern "C" fn index_encode( break; } ret = LZMA_OK; - (*coder).pos = 0 as size_t; + (*coder).pos = 0; (*coder).sequence = SEQ_NEXT; continue; } @@ -294,11 +291,11 @@ unsafe extern "C" fn index_encode( current_block = 10048703153582371463; } 5 => { - if (*coder).pos > 0 as size_t { + if (*coder).pos > 0 { (*coder).pos = (*coder).pos.wrapping_sub(1); let fresh0 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0 as u8; + *out.offset(fresh0 as isize) = 0; continue; } else { (*coder).crc32 = lzma_crc32( @@ -327,7 +324,7 @@ unsafe extern "C" fn index_encode( break; } ret = LZMA_OK; - (*coder).pos = 0 as size_t; + (*coder).pos = 0; (*coder).sequence += 1; } _ => { @@ -335,12 +332,11 @@ unsafe extern "C" fn index_encode( if *out_pos == out_size { return LZMA_OK; } - *out.offset(*out_pos as isize) = ((*coder).crc32 - >> (*coder).pos.wrapping_mul(8 as size_t) - & 0xff as u32) as u8; + *out.offset(*out_pos as isize) = + ((*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff as u32) as u8; *out_pos = (*out_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); - if !((*coder).pos < 4 as size_t) { + if !((*coder).pos < 4) { break; } } @@ -349,32 +345,26 @@ unsafe extern "C" fn index_encode( } } let out_used: size_t = (*out_pos).wrapping_sub(out_start); - if out_used > 0 as size_t { + if out_used > 0 { (*coder).crc32 = lzma_crc32(out.offset(out_start as isize), out_used, (*coder).crc32); } return ret; } -unsafe extern "C" fn index_encoder_end( - mut coder: *mut c_void, - mut allocator: *const lzma_allocator, -) { +unsafe extern "C" fn index_encoder_end(coder: *mut c_void, allocator: *const lzma_allocator) { lzma_free(coder, allocator); } -unsafe extern "C" fn index_encoder_reset( - mut coder: *mut lzma_index_coder, - mut i: *const lzma_index, -) { +unsafe extern "C" fn index_encoder_reset(coder: *mut lzma_index_coder, i: *const lzma_index) { lzma_index_iter_init(&raw mut (*coder).iter, i); (*coder).sequence = SEQ_INDICATOR; (*coder).index = i; - (*coder).pos = 0 as size_t; - (*coder).crc32 = 0 as u32; + (*coder).pos = 0; + (*coder).crc32 = 0; } #[no_mangle] pub unsafe extern "C" fn lzma_index_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut i: *const lzma_index, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + i: *const lzma_index, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -418,7 +408,7 @@ pub unsafe extern "C" fn lzma_index_encoder_init( } if (*next).coder.is_null() { (*next).coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ); if (*next).coder.is_null() { @@ -447,8 +437,8 @@ pub unsafe extern "C" fn lzma_index_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_index_encoder( - mut strm: *mut lzma_stream, - mut i: *const lzma_index, + strm: *mut lzma_stream, + i: *const lzma_index, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -461,16 +451,16 @@ pub unsafe extern "C" fn lzma_index_encoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_index_buffer_encode( - mut i: *const lzma_index, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + i: *const lzma_index, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { if i.is_null() || out.is_null() || out_pos.is_null() || *out_pos > out_size { return LZMA_PROG_ERROR; @@ -531,8 +521,8 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( &raw mut coder as *mut c_void, ::core::ptr::null::(), ::core::ptr::null::(), - ::core::ptr::null_mut::(), - 0 as size_t, + core::ptr::null_mut(), + 0, out, out_pos, out_size, diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 6262dab8..f926c24e 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -111,37 +111,32 @@ pub const SEQ_UNPADDED: C2RustUnnamed_1 = 2; pub const SEQ_COUNT: C2RustUnnamed_1 = 1; pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; pub type lzma_index_hash = lzma_index_hash_s; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; -pub const INDEX_INDICATOR: c_int = 0 as c_int; +pub const INDEX_INDICATOR: c_int = 0; #[inline] -unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { +extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); } #[inline] -unsafe extern "C" fn index_size_unpadded( - mut count: lzma_vli, - mut index_list_size: lzma_vli, -) -> lzma_vli { - return ((1 as u32).wrapping_add(lzma_vli_size(count)) as lzma_vli) +extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { + return (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) .wrapping_add(index_list_size) .wrapping_add(4 as lzma_vli); } #[inline] -unsafe extern "C" fn index_size(mut count: lzma_vli, mut index_list_size: lzma_vli) -> lzma_vli { +extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { return vli_ceil4(index_size_unpadded(count, index_list_size)); } #[inline] -unsafe extern "C" fn index_stream_size( - mut blocks_size: lzma_vli, - mut count: lzma_vli, - mut index_list_size: lzma_vli, +extern "C" fn index_stream_size( + blocks_size: lzma_vli, + count: lzma_vli, + index_list_size: lzma_vli, ) -> lzma_vli { return (LZMA_STREAM_HEADER_SIZE as lzma_vli) .wrapping_add(blocks_size) @@ -151,15 +146,13 @@ unsafe extern "C" fn index_stream_size( #[no_mangle] pub unsafe extern "C" fn lzma_index_hash_init( mut index_hash: *mut lzma_index_hash, - mut allocator: *const lzma_allocator, + allocator: *const lzma_allocator, ) -> *mut lzma_index_hash { if index_hash.is_null() { - index_hash = lzma_alloc( - ::core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_index_hash; + index_hash = lzma_alloc(core::mem::size_of::() as size_t, allocator) + as *mut lzma_index_hash; if index_hash.is_null() { - return ::core::ptr::null_mut::(); + return core::ptr::null_mut(); } } (*index_hash).sequence = SEQ_BLOCK; @@ -173,30 +166,30 @@ pub unsafe extern "C" fn lzma_index_hash_init( (*index_hash).records.index_list_size = 0 as lzma_vli; (*index_hash).unpadded_size = 0 as lzma_vli; (*index_hash).uncompressed_size = 0 as lzma_vli; - (*index_hash).pos = 0 as size_t; - (*index_hash).crc32 = 0 as u32; + (*index_hash).pos = 0; + (*index_hash).crc32 = 0; lzma_check_init(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); lzma_check_init(&raw mut (*index_hash).records.check, LZMA_CHECK_SHA256); return index_hash; } #[no_mangle] pub unsafe extern "C" fn lzma_index_hash_end( - mut index_hash: *mut lzma_index_hash, - mut allocator: *const lzma_allocator, + index_hash: *mut lzma_index_hash, + allocator: *const lzma_allocator, ) { lzma_free(index_hash as *mut c_void, allocator); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_hash_size(mut index_hash: *const lzma_index_hash) -> lzma_vli { +pub unsafe extern "C" fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { return index_size( (*index_hash).blocks.count, (*index_hash).blocks.index_list_size, ); } unsafe extern "C" fn hash_append( - mut info: *mut lzma_index_hash_info, - mut unpadded_size: lzma_vli, - mut uncompressed_size: lzma_vli, + info: *mut lzma_index_hash_info, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, ) { (*info).blocks_size = (*info).blocks_size.wrapping_add(vli_ceil4(unpadded_size)); (*info).uncompressed_size = (*info).uncompressed_size.wrapping_add(uncompressed_size); @@ -209,14 +202,14 @@ unsafe extern "C" fn hash_append( &raw mut (*info).check, LZMA_CHECK_SHA256, &raw const sizes as *const lzma_vli as *const u8, - ::core::mem::size_of::<[lzma_vli; 2]>() as size_t, + core::mem::size_of::<[lzma_vli; 2]>() as size_t, ); } #[no_mangle] pub unsafe extern "C" fn lzma_index_hash_append( - mut index_hash: *mut lzma_index_hash, - mut unpadded_size: lzma_vli, - mut uncompressed_size: lzma_vli, + index_hash: *mut lzma_index_hash, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, ) -> lzma_ret { if index_hash.is_null() || (*index_hash).sequence != SEQ_BLOCK @@ -249,10 +242,10 @@ pub unsafe extern "C" fn lzma_index_hash_append( } #[no_mangle] pub unsafe extern "C" fn lzma_index_hash_decode( - mut index_hash: *mut lzma_index_hash, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + index_hash: *mut lzma_index_hash, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { let mut current_block: u64; if *in_pos >= in_size { @@ -286,7 +279,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( return LZMA_DATA_ERROR; } ret = LZMA_OK; - (*index_hash).pos = 0 as size_t; + (*index_hash).pos = 0; (*index_hash).sequence = (if (*index_hash).remaining == 0 as lzma_vli { SEQ_PADDING_INIT as c_int } else { @@ -295,7 +288,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( continue; } 2 | 3 => { - let mut size: *mut lzma_vli = if (*index_hash).sequence == SEQ_UNPADDED { + let size: *mut lzma_vli = if (*index_hash).sequence == SEQ_UNPADDED { &raw mut (*index_hash).unpadded_size } else { &raw mut (*index_hash).uncompressed_size @@ -305,7 +298,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( break; } ret = LZMA_OK; - (*index_hash).pos = 0 as size_t; + (*index_hash).pos = 0; if (*index_hash).sequence == SEQ_UNPADDED { if (*index_hash).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || (*index_hash).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli @@ -354,7 +347,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( } match current_block { 12753679906265593574 => { - if (*index_hash).pos > 0 as size_t { + if (*index_hash).pos > 0 { (*index_hash).pos = (*index_hash).pos.wrapping_sub(1); let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); @@ -398,20 +391,20 @@ pub unsafe extern "C" fn lzma_index_hash_decode( } let fresh2 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8 as size_t) & 0xff as u32 + if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8) & 0xff as u32 != *in_0.offset(fresh2 as isize) as u32 { return LZMA_DATA_ERROR; } (*index_hash).pos = (*index_hash).pos.wrapping_add(1); - if !((*index_hash).pos < 4 as size_t) { + if !((*index_hash).pos < 4) { break; } } return LZMA_STREAM_END; } let in_used: size_t = (*in_pos).wrapping_sub(in_start); - if in_used > 0 as size_t { + if in_used > 0 { (*index_hash).crc32 = lzma_crc32(in_0.offset(in_start as isize), in_used, (*index_hash).crc32); } diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 68f21d43..1fb5c271 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -223,30 +223,30 @@ pub type lzma_init_function = Option< *const lzma_filter_info, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0) as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - return num; +extern "C" fn read32le(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; + num + }; } #[inline] -unsafe extern "C" fn read64le(mut buf: *const u8) -> u64 { - let mut num: u64 = *buf.offset(0) as u64; - num |= (*buf.offset(1) as u64) << 8; - num |= (*buf.offset(2) as u64) << 16; - num |= (*buf.offset(3) as u64) << 24; - num |= (*buf.offset(4) as u64) << 32; - num |= (*buf.offset(5) as u64) << 40; - num |= (*buf.offset(6) as u64) << 48; - num |= (*buf.offset(7) as u64) << 56; - return num; +extern "C" fn read64le(buf: *const u8) -> u64 { + return unsafe { + let mut num: u64 = *buf.offset(0) as u64; + num |= (*buf.offset(1) as u64) << 8; + num |= (*buf.offset(2) as u64) << 16; + num |= (*buf.offset(3) as u64) << 24; + num |= (*buf.offset(4) as u64) << 32; + num |= (*buf.offset(5) as u64) << 40; + num |= (*buf.offset(6) as u64) << 48; + num |= (*buf.offset(7) as u64) << 56; + num + }; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; @@ -263,29 +263,29 @@ pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_IGNORE_CHECK | LZMA_CONCATENATED | LZMA_FAIL_FAST; -pub const LZIP_V0_FOOTER_SIZE: c_int = 12 as c_int; -pub const LZIP_V1_FOOTER_SIZE: c_int = 20 as c_int; -pub const LZIP_LC: c_int = 3 as c_int; -pub const LZIP_LP: c_int = 0 as c_int; -pub const LZIP_PB: c_int = 2 as c_int; +pub const LZIP_V0_FOOTER_SIZE: c_int = 12; +pub const LZIP_V1_FOOTER_SIZE: c_int = 20; +pub const LZIP_LC: c_int = 3; +pub const LZIP_LP: c_int = 0; +pub const LZIP_PB: c_int = 2; unsafe extern "C" fn lzip_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; + let coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; loop { let mut current_block_80: u64; match (*coder).sequence { 0 => { let lzip_id_string: [u8; 4] = [0x4c as u8, 0x5a as u8, 0x49 as u8, 0x50 as u8]; - while (*coder).pos < ::core::mem::size_of::<[u8; 4]>() as usize { + while (*coder).pos < core::mem::size_of::<[u8; 4]>() as usize { if *in_pos >= in_size { return (if !(*coder).first_member && action == LZMA_FINISH { LZMA_STREAM_END as c_int @@ -305,10 +305,10 @@ unsafe extern "C" fn lzip_decode( *in_pos = (*in_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); } - (*coder).pos = 0 as size_t; - (*coder).crc32 = 0 as u32; - (*coder).uncompressed_size = 0 as u64; - (*coder).member_size = ::core::mem::size_of::<[u8; 4]>() as u64; + (*coder).pos = 0; + (*coder).crc32 = 0; + (*coder).uncompressed_size = 0; + (*coder).member_size = core::mem::size_of::<[u8; 4]>() as u64; (*coder).sequence = SEQ_VERSION; current_block_80 = 11220331375136032509; } @@ -337,7 +337,7 @@ unsafe extern "C" fn lzip_decode( let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); (*coder).version = *in_0.offset(fresh0 as isize) as u32; - if (*coder).version > 1 as u32 { + if (*coder).version > 1 { return LZMA_OPTIONS_ERROR; } (*coder).member_size = (*coder).member_size.wrapping_add(1); @@ -360,14 +360,11 @@ unsafe extern "C" fn lzip_decode( (*coder).member_size = (*coder).member_size.wrapping_add(1); let b2log: u32 = ds & 0x1f as u32; let fracnum: u32 = ds >> 5; - if b2log < 12 as u32 - || b2log > 29 as u32 - || b2log == 12 as u32 && fracnum > 0 as u32 - { + if b2log < 12 || b2log > 29 || b2log == 12 && fracnum > 0 { return LZMA_DATA_ERROR; } (*coder).options.dict_size = - ((1 as u32) << b2log).wrapping_sub(fracnum << b2log.wrapping_sub(4 as u32)); + (1u32 << b2log).wrapping_sub(fracnum << b2log.wrapping_sub(4)); (*coder).options.preset_dict = ::core::ptr::null::(); (*coder).options.lc = LZIP_LC as u32; (*coder).options.lp = LZIP_LP as u32; @@ -402,7 +399,7 @@ unsafe extern "C" fn lzip_decode( lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }, ]; let ret_: lzma_ret = lzma_next_filter_init( @@ -413,7 +410,7 @@ unsafe extern "C" fn lzip_decode( if ret_ != LZMA_OK { return ret_; } - (*coder).crc32 = 0 as u32; + (*coder).crc32 = 0; (*coder).sequence = SEQ_LZMA_STREAM; current_block_80 = 13394712405657322686; } @@ -443,7 +440,7 @@ unsafe extern "C" fn lzip_decode( .wrapping_add((*in_pos).wrapping_sub(in_start) as u64); (*coder).uncompressed_size = (*coder).uncompressed_size.wrapping_add(out_used as u64); - if !(*coder).ignore_check && out_used > 0 as size_t { + if !(*coder).ignore_check && out_used > 0 { (*coder).crc32 = lzma_crc32(out.offset(out_start as isize), out_used, (*coder).crc32); } @@ -454,7 +451,7 @@ unsafe extern "C" fn lzip_decode( } _ => {} } - let footer_size: size_t = (if (*coder).version == 0 as u32 { + let footer_size: size_t = (if (*coder).version == 0 { LZIP_V0_FOOTER_SIZE } else { LZIP_V1_FOOTER_SIZE @@ -470,7 +467,7 @@ unsafe extern "C" fn lzip_decode( if (*coder).pos < footer_size { return LZMA_OK; } - (*coder).pos = 0 as size_t; + (*coder).pos = 0; (*coder).member_size = (*coder).member_size.wrapping_add(footer_size as u64); if !(*coder).ignore_check && (*coder).crc32 @@ -483,7 +480,7 @@ unsafe extern "C" fn lzip_decode( { return LZMA_DATA_ERROR; } - if (*coder).version > 0 as u32 { + if (*coder).version > 0 { if (*coder).member_size != read64le((&raw mut (*coder).buffer as *mut u8).offset(12) as *mut u8) { @@ -493,31 +490,28 @@ unsafe extern "C" fn lzip_decode( if !(*coder).concatenated { return LZMA_STREAM_END; } - (*coder).first_member = false_0 != 0; + (*coder).first_member = false; (*coder).sequence = SEQ_ID_STRING; } } -unsafe extern "C" fn lzip_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; +unsafe extern "C" fn lzip_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; lzma_next_end(&raw mut (*coder).lzma_decoder, allocator); lzma_free(coder as *mut c_void, allocator); } -unsafe extern "C" fn lzip_decoder_get_check(mut coder_ptr: *const c_void) -> lzma_check { +extern "C" fn lzip_decoder_get_check(_coder_ptr: *const c_void) -> lzma_check { return LZMA_CHECK_CRC32; } unsafe extern "C" fn lzip_decoder_memconfig( - mut coder_ptr: *mut c_void, - mut memusage: *mut u64, - mut old_memlimit: *mut u64, - mut new_memlimit: u64, + coder_ptr: *mut c_void, + memusage: *mut u64, + old_memlimit: *mut u64, + new_memlimit: u64, ) -> lzma_ret { - let mut coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; + let coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; *memusage = (*coder).memusage; *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as u64 { + if new_memlimit != 0 { if new_memlimit < (*coder).memusage { return LZMA_MEMLIMIT_ERROR; } @@ -527,10 +521,10 @@ unsafe extern "C" fn lzip_decoder_memconfig( } #[no_mangle] pub unsafe extern "C" fn lzma_lzip_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut memlimit: u64, - mut flags: u32, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + memlimit: u64, + flags: u32, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -568,10 +562,8 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( } let mut coder: *mut lzma_lzip_coder = (*next).coder as *mut lzma_lzip_coder; if coder.is_null() { - coder = lzma_alloc( - ::core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_lzip_coder; + coder = lzma_alloc(core::mem::size_of::() as size_t, allocator) + as *mut lzma_lzip_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -602,9 +594,9 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( ) as Option lzma_ret>; (*coder).lzma_decoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -615,24 +607,20 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( }; } (*coder).sequence = SEQ_ID_STRING; - (*coder).memlimit = if 1 as u64 > memlimit { - 1 as u64 - } else { - memlimit - }; + (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; - (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as u32 != 0 as u32; - (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as u32 != 0 as u32; - (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0 as u32; - (*coder).first_member = true_0 != 0; - (*coder).pos = 0 as size_t; + (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as u32 != 0; + (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as u32 != 0; + (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0; + (*coder).first_member = true; + (*coder).pos = 0; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_lzip_decoder( - mut strm: *mut lzma_stream, - mut memlimit: u64, - mut flags: u32, + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -648,7 +636,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index dd2208d9..e391d274 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; @@ -198,27 +198,23 @@ pub type lzma_init_function = Option< *const lzma_filter_info, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; unsafe extern "C" fn microlzma_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, + out: *mut u8, + out_pos: *mut size_t, mut out_size: size_t, - mut action: lzma_action, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; + let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; if in_size.wrapping_sub(*in_pos) as u64 > (*coder).comp_size { @@ -236,7 +232,7 @@ unsafe extern "C" fn microlzma_decode( let mut options: lzma_options_lzma = lzma_options_lzma { dict_size: (*coder).dict_size, preset_dict: ::core::ptr::null::(), - preset_dict_size: 0 as u32, + preset_dict_size: 0, lc: 0, lp: 0, pb: 0, @@ -244,7 +240,7 @@ unsafe extern "C" fn microlzma_decode( nice_len: 0, mf: 0 as lzma_match_finder, depth: 0, - ext_flags: 0 as u32, + ext_flags: 0, ext_size_low: UINT32_MAX as u32, ext_size_high: UINT32_MAX as u32, reserved_int4: 0, @@ -256,8 +252,8 @@ unsafe extern "C" fn microlzma_decode( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), }; if (*coder).uncomp_size_is_exact { options.ext_size_low = (*coder).uncomp_size as u32; @@ -286,7 +282,7 @@ unsafe extern "C" fn microlzma_decode( lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }, ]; let ret_: lzma_ret = lzma_next_filter_init( @@ -297,14 +293,14 @@ unsafe extern "C" fn microlzma_decode( if ret_ != LZMA_OK { return ret_; } - let dummy_in: u8 = 0 as u8; - let mut dummy_in_pos: size_t = 0 as size_t; + let dummy_in: u8 = 0; + let mut dummy_in_pos: size_t = 0; if (*coder).lzma.code.expect("non-null function pointer")( (*coder).lzma.coder, allocator, &raw const dummy_in, &raw mut dummy_in_pos, - 1 as size_t, + 1, out, out_pos, out_size, @@ -313,7 +309,7 @@ unsafe extern "C" fn microlzma_decode( { return LZMA_PROG_ERROR; } - (*coder).props_decoded = true_0 != 0; + (*coder).props_decoded = true; } let mut ret: lzma_ret = (*coder).lzma.code.expect("non-null function pointer")( (*coder).lzma.coder, @@ -330,7 +326,7 @@ unsafe extern "C" fn microlzma_decode( .comp_size .wrapping_sub((*in_pos).wrapping_sub(in_start) as u64); if (*coder).uncomp_size_is_exact { - if ret == LZMA_STREAM_END && (*coder).comp_size != 0 as u64 { + if ret == LZMA_STREAM_END && (*coder).comp_size != 0 { ret = LZMA_DATA_ERROR; } } else { @@ -346,20 +342,20 @@ unsafe extern "C" fn microlzma_decode( return ret; } unsafe extern "C" fn microlzma_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, ) { - let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; + let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; lzma_next_end(&raw mut (*coder).lzma, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn microlzma_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut comp_size: u64, - mut uncomp_size: u64, - mut uncomp_size_is_exact: bool, - mut dict_size: u32, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + comp_size: u64, + uncomp_size: u64, + uncomp_size_is_exact: bool, + dict_size: u32, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -413,7 +409,7 @@ unsafe extern "C" fn microlzma_decoder_init( let mut coder: *mut lzma_microlzma_coder = (*next).coder as *mut lzma_microlzma_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_microlzma_coder; if coder.is_null() { @@ -438,9 +434,9 @@ unsafe extern "C" fn microlzma_decoder_init( microlzma_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*coder).lzma = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -457,16 +453,16 @@ unsafe extern "C" fn microlzma_decoder_init( (*coder).uncomp_size = uncomp_size as lzma_vli; (*coder).uncomp_size_is_exact = uncomp_size_is_exact; (*coder).dict_size = dict_size; - (*coder).props_decoded = false_0 != 0; + (*coder).props_decoded = false; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_microlzma_decoder( - mut strm: *mut lzma_stream, - mut comp_size: u64, - mut uncomp_size: u64, - mut uncomp_size_is_exact: lzma_bool, - mut dict_size: u32, + strm: *mut lzma_stream, + comp_size: u64, + uncomp_size: u64, + uncomp_size_is_exact: lzma_bool, + dict_size: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -484,7 +480,7 @@ pub unsafe extern "C" fn lzma_microlzma_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index e0794cb8..edc98636 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -194,24 +194,21 @@ pub struct lzma_microlzma_coder { pub lzma: lzma_next_coder, pub props: u8, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; unsafe extern "C" fn microlzma_encode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; + let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; let out_start: size_t = *out_pos; let in_start: size_t = *in_pos; let mut uncomp_size: u64 = 0; @@ -248,17 +245,17 @@ unsafe extern "C" fn microlzma_encode( return ret; } unsafe extern "C" fn microlzma_encoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, ) { - let mut coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; + let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; lzma_next_end(&raw mut (*coder).lzma, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn microlzma_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut options: *const lzma_options_lzma, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_options_lzma, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -300,7 +297,7 @@ unsafe extern "C" fn microlzma_encoder_init( let mut coder: *mut lzma_microlzma_coder = (*next).coder as *mut lzma_microlzma_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_microlzma_coder; if coder.is_null() { @@ -325,9 +322,9 @@ unsafe extern "C" fn microlzma_encoder_init( microlzma_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ) as lzma_end_function; (*coder).lzma = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -356,7 +353,7 @@ unsafe extern "C" fn microlzma_encoder_init( lzma_filter_info_s { id: 0, init: None, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }, ]; return lzma_next_filter_init( @@ -367,8 +364,8 @@ unsafe extern "C" fn microlzma_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_microlzma_encoder( - mut strm: *mut lzma_stream, - mut options: *const lzma_options_lzma, + strm: *mut lzma_stream, + options: *const lzma_options_lzma, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -383,6 +380,6 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index 938c2c16..cad6fa6e 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulong, c_ulonglong, c_void}; extern "C" { fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); @@ -68,36 +68,30 @@ pub struct lzma_outq { pub bufs_allocated: u32, pub bufs_limit: u32, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const false_0: c_int = 0 as c_int; -pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; +pub const LZMA_THREADS_MAX: c_int = 16384; #[inline] -unsafe extern "C" fn lzma_outq_outbuf_memusage(mut buf_size: size_t) -> u64 { - return (::core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; +extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { + return (core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; } #[no_mangle] -pub unsafe extern "C" fn lzma_outq_memusage(mut buf_size_max: u64, mut threads: u32) -> u64 { +pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { let limit: u64 = (UINT64_MAX as u64) .wrapping_div((2 as c_int * 16384 as c_int) as u64) - .wrapping_div(2 as u64); + .wrapping_div(2); if threads > LZMA_THREADS_MAX as u32 || buf_size_max > limit { return UINT64_MAX as u64; } - return ((2 as u32).wrapping_mul(threads) as u64) + return ((2u32).wrapping_mul(threads) as u64) .wrapping_mul(lzma_outq_outbuf_memusage(buf_size_max as size_t)); } -unsafe extern "C" fn move_head_to_cache( - mut outq: *mut lzma_outq, - mut allocator: *const lzma_allocator, -) { - let mut buf: *mut lzma_outbuf = (*outq).head; +unsafe extern "C" fn move_head_to_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator) { + let buf: *mut lzma_outbuf = (*outq).head; (*outq).head = (*buf).next; if (*outq).head.is_null() { - (*outq).tail = ::core::ptr::null_mut::(); + (*outq).tail = core::ptr::null_mut(); } if !(*outq).cache.is_null() && (*(*outq).cache).allocated != (*buf).allocated { lzma_outq_clear_cache(outq, allocator); @@ -110,10 +104,10 @@ unsafe extern "C" fn move_head_to_cache( .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); } unsafe extern "C" fn free_one_cached_buffer( - mut outq: *mut lzma_outq, - mut allocator: *const lzma_allocator, + outq: *mut lzma_outq, + allocator: *const lzma_allocator, ) { - let mut buf: *mut lzma_outbuf = (*outq).cache; + let buf: *mut lzma_outbuf = (*outq).cache; (*outq).cache = (*buf).next; (*outq).bufs_allocated = (*outq).bufs_allocated.wrapping_sub(1); (*outq).mem_allocated = (*outq) @@ -123,8 +117,8 @@ unsafe extern "C" fn free_one_cached_buffer( } #[no_mangle] pub unsafe extern "C" fn lzma_outq_clear_cache( - mut outq: *mut lzma_outq, - mut allocator: *const lzma_allocator, + outq: *mut lzma_outq, + allocator: *const lzma_allocator, ) { while !(*outq).cache.is_null() { free_one_cached_buffer(outq, allocator); @@ -132,9 +126,9 @@ pub unsafe extern "C" fn lzma_outq_clear_cache( } #[no_mangle] pub unsafe extern "C" fn lzma_outq_clear_cache2( - mut outq: *mut lzma_outq, - mut allocator: *const lzma_allocator, - mut keep_size: size_t, + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + keep_size: size_t, ) { if (*outq).cache.is_null() { return; @@ -148,14 +142,14 @@ pub unsafe extern "C" fn lzma_outq_clear_cache2( } #[no_mangle] pub unsafe extern "C" fn lzma_outq_init( - mut outq: *mut lzma_outq, - mut allocator: *const lzma_allocator, - mut threads: u32, + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + threads: u32, ) -> lzma_ret { if threads > LZMA_THREADS_MAX as u32 { return LZMA_OPTIONS_ERROR; } - let bufs_limit: u32 = (2 as u32).wrapping_mul(threads); + let bufs_limit: u32 = (2u32).wrapping_mul(threads); while !(*outq).head.is_null() { move_head_to_cache(outq, allocator); } @@ -163,14 +157,11 @@ pub unsafe extern "C" fn lzma_outq_init( free_one_cached_buffer(outq, allocator); } (*outq).bufs_limit = bufs_limit; - (*outq).read_pos = 0 as size_t; + (*outq).read_pos = 0; return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_outq_end( - mut outq: *mut lzma_outq, - mut allocator: *const lzma_allocator, -) { +pub unsafe extern "C" fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator) { while !(*outq).head.is_null() { move_head_to_cache(outq, allocator); } @@ -178,14 +169,14 @@ pub unsafe extern "C" fn lzma_outq_end( } #[no_mangle] pub unsafe extern "C" fn lzma_outq_prealloc_buf( - mut outq: *mut lzma_outq, - mut allocator: *const lzma_allocator, - mut size: size_t, + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + size: size_t, ) -> lzma_ret { if !(*outq).cache.is_null() && (*(*outq).cache).allocated == size { return LZMA_OK; } - if size > (SIZE_MAX as usize).wrapping_sub(::core::mem::size_of::() as usize) { + if size > (SIZE_MAX as usize).wrapping_sub(core::mem::size_of::() as usize) { return LZMA_MEM_ERROR; } let alloc_size: size_t = lzma_outq_outbuf_memusage(size) as size_t; @@ -194,7 +185,7 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( if (*outq).cache.is_null() { return LZMA_MEM_ERROR; } - (*(*outq).cache).next = ::core::ptr::null_mut::(); + (*(*outq).cache).next = core::ptr::null_mut(); (*(*outq).cache).allocated = size; (*outq).bufs_allocated = (*outq).bufs_allocated.wrapping_add(1); (*outq).mem_allocated = (*outq).mem_allocated.wrapping_add(alloc_size as u64); @@ -202,12 +193,12 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( } #[no_mangle] pub unsafe extern "C" fn lzma_outq_get_buf( - mut outq: *mut lzma_outq, - mut worker: *mut c_void, + outq: *mut lzma_outq, + worker: *mut c_void, ) -> *mut lzma_outbuf { - let mut buf: *mut lzma_outbuf = (*outq).cache; + let buf: *mut lzma_outbuf = (*outq).cache; (*outq).cache = (*buf).next; - (*buf).next = ::core::ptr::null_mut::(); + (*buf).next = core::ptr::null_mut(); if !(*outq).tail.is_null() { (*(*outq).tail).next = buf; } else { @@ -215,10 +206,10 @@ pub unsafe extern "C" fn lzma_outq_get_buf( } (*outq).tail = buf; (*buf).worker = worker; - (*buf).finished = false_0 != 0; + (*buf).finished = false; (*buf).finish_ret = LZMA_STREAM_END; - (*buf).pos = 0 as size_t; - (*buf).decoder_in_pos = 0 as size_t; + (*buf).pos = 0; + (*buf).decoder_in_pos = 0; (*buf).unpadded_size = 0 as lzma_vli; (*buf).uncompressed_size = 0 as lzma_vli; (*outq).bufs_in_use = (*outq).bufs_in_use.wrapping_add(1); @@ -228,26 +219,26 @@ pub unsafe extern "C" fn lzma_outq_get_buf( return buf; } #[no_mangle] -pub unsafe extern "C" fn lzma_outq_is_readable(mut outq: *const lzma_outq) -> bool { +pub unsafe extern "C" fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool { if (*outq).head.is_null() { - return false_0 != 0; + return false; } return (*outq).read_pos < (*(*outq).head).pos || (*(*outq).head).finished as c_int != 0; } #[no_mangle] pub unsafe extern "C" fn lzma_outq_read( - mut outq: *mut lzma_outq, - mut allocator: *const lzma_allocator, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut unpadded_size: *mut lzma_vli, - mut uncompressed_size: *mut lzma_vli, + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + unpadded_size: *mut lzma_vli, + uncompressed_size: *mut lzma_vli, ) -> lzma_ret { - if (*outq).bufs_in_use == 0 as u32 { + if (*outq).bufs_in_use == 0 { return LZMA_OK; } - let mut buf: *mut lzma_outbuf = (*outq).head; + let buf: *mut lzma_outbuf = (*outq).head; lzma_bufcpy( &raw mut (*buf).buf as *mut u8, &raw mut (*outq).read_pos, @@ -267,16 +258,16 @@ pub unsafe extern "C" fn lzma_outq_read( } let finish_ret: lzma_ret = (*buf).finish_ret; move_head_to_cache(outq, allocator); - (*outq).read_pos = 0 as size_t; + (*outq).read_pos = 0; return finish_ret; } #[no_mangle] pub unsafe extern "C" fn lzma_outq_enable_partial_output( - mut outq: *mut lzma_outq, - mut enable_partial_output: Option ()>, + outq: *mut lzma_outq, + enable_partial_output: Option ()>, ) { if !(*outq).head.is_null() && !(*(*outq).head).finished && !(*(*outq).head).worker.is_null() { enable_partial_output.expect("non-null function pointer")((*(*outq).head).worker); - (*(*outq).head).worker = NULL; + (*(*outq).head).worker = core::ptr::null_mut(); } } diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index 9deb1a67..c5e111dc 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_stream_decoder_init( @@ -88,22 +88,20 @@ pub type lzma_code_function = Option< lzma_action, ) -> lzma_ret, >; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; #[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_decode( - mut memlimit: *mut u64, - mut flags: u32, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + memlimit: *mut u64, + flags: u32, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { if in_pos.is_null() || in_0.is_null() && *in_pos != in_size @@ -118,9 +116,9 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( return LZMA_PROG_ERROR; } let mut stream_decoder: lzma_next_coder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -162,7 +160,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( stream_decoder.coder, memlimit, &raw mut memusage, - 0 as u64, + 0, ); } } diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index f2ec30b5..5fa163aa 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -130,45 +130,42 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; -pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; -pub const UINT64_MAX: c_ulonglong = 18446744073709551615; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); +pub const LZMA_VLI_BYTES_MAX: c_int = 9; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; pub const INDEX_BOUND: c_int = 1 as c_int + 1 as c_int + 2 as c_int * LZMA_VLI_BYTES_MAX + 4 as c_int + 3 as c_int & !(3 as c_int); -pub const HEADERS_BOUND: c_int = 2 as c_int * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; +pub const HEADERS_BOUND: c_int = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; +pub const LZMA_VLI_MAX: lzma_vli = u64::MAX / 2; #[no_mangle] -pub unsafe extern "C" fn lzma_stream_buffer_bound(mut uncompressed_size: size_t) -> size_t { - let block_bound: size_t = lzma_block_buffer_bound(uncompressed_size) as size_t; - if block_bound == 0 as size_t { - return 0 as size_t; +pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { + let block_bound: size_t = unsafe { lzma_block_buffer_bound(uncompressed_size) } as size_t; + if block_bound == 0 { + return 0; } // Match C: my_min(SIZE_MAX, LZMA_VLI_MAX) - block_bound < HEADERS_BOUND. let stream_bound_max: size_t = core::cmp::min(size_t::MAX, LZMA_VLI_MAX as size_t); if stream_bound_max.wrapping_sub(block_bound) < HEADERS_BOUND as size_t { - return 0 as size_t; + return 0; } return block_bound.wrapping_add(HEADERS_BOUND as size_t); } #[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_encode( - mut filters: *mut lzma_filter, - mut check: lzma_check, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos_ptr: *mut size_t, + filters: *mut lzma_filter, + check: lzma_check, + allocator: *const lzma_allocator, + in_0: *const u8, + in_size: size_t, + out: *mut u8, + out_pos_ptr: *mut size_t, mut out_size: size_t, ) -> lzma_ret { if filters.is_null() || check > LZMA_CHECK_ID_MAX - || in_0.is_null() && in_size != 0 as size_t + || in_0.is_null() && in_size != 0 || out.is_null() || out_pos_ptr.is_null() || *out_pos_ptr > out_size @@ -184,7 +181,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( } out_size = out_size.wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); let mut stream_flags: lzma_stream_flags = lzma_stream_flags { - version: 0 as u32, + version: 0, backward_size: 0, check: check, reserved_enum1: LZMA_RESERVED_ENUM, @@ -207,16 +204,16 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( } out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); let mut block: lzma_block = lzma_block { - version: 0 as u32, + version: 0, header_size: 0, check: check, compressed_size: 0, uncompressed_size: 0, filters: filters, raw_check: [0; 64], - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), - reserved_ptr3: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), + reserved_ptr3: core::ptr::null_mut(), reserved_int1: 0, reserved_int2: 0, reserved_int3: 0, @@ -238,7 +235,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( reserved_bool7: 0, reserved_bool8: 0, }; - if in_size > 0 as size_t { + if in_size > 0 { let ret_: lzma_ret = lzma_block_buffer_encode( &raw mut block, allocator, @@ -252,12 +249,12 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( return ret_; } } - let mut i: *mut lzma_index = lzma_index_init(allocator); + let i: *mut lzma_index = lzma_index_init(allocator); if i.is_null() { return LZMA_MEM_ERROR; } let mut ret: lzma_ret = LZMA_OK; - if in_size > 0 as size_t { + if in_size > 0 { ret = lzma_index_append( i, allocator, diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 2dde2a66..fda6d293 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; #[repr(C)] pub struct lzma_index_hash_s { _opaque: [u8; 0], @@ -195,7 +195,7 @@ pub struct lzma_stream_coder { pub pos: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub type lzma_index_hash = lzma_index_hash_s; #[derive(Copy, Clone)] #[repr(C)] @@ -260,11 +260,7 @@ pub const SEQ_BLOCK_RUN: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; @@ -272,7 +268,7 @@ pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; pub const LZMA_IGNORE_CHECK: c_uint = 0x10; pub const LZMA_CONCATENATED: c_uint = 0x8; pub const LZMA_FAIL_FAST: c_uint = 0x20; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_TELL_UNSUPPORTED_CHECK @@ -280,31 +276,31 @@ pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_IGNORE_CHECK | LZMA_CONCATENATED | LZMA_FAIL_FAST; -pub const INDEX_INDICATOR: c_int = 0 as c_int; +pub const INDEX_INDICATOR: c_int = 0; unsafe extern "C" fn stream_decoder_reset( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, ) -> lzma_ret { (*coder).index_hash = lzma_index_hash_init((*coder).index_hash, allocator); if (*coder).index_hash.is_null() { return LZMA_MEM_ERROR; } (*coder).sequence = SEQ_STREAM_HEADER; - (*coder).pos = 0 as size_t; + (*coder).pos = 0; return LZMA_OK; } unsafe extern "C" fn stream_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; loop { let mut current_block_100: u64; match (*coder).sequence { @@ -320,7 +316,7 @@ unsafe extern "C" fn stream_decode( if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { return LZMA_OK; } - (*coder).pos = 0 as size_t; + (*coder).pos = 0; let ret: lzma_ret = lzma_stream_header_decode( &raw mut (*coder).stream_flags, &raw mut (*coder).buffer as *mut u8, @@ -332,7 +328,7 @@ unsafe extern "C" fn stream_decode( ret }) as lzma_ret; } - (*coder).first_stream = false_0 != 0; + (*coder).first_stream = false; (*coder).block_options.check = (*coder).stream_flags.check; (*coder).sequence = SEQ_BLOCK_HEADER; if (*coder).tell_no_check as c_int != 0 @@ -384,15 +380,15 @@ unsafe extern "C" fn stream_decode( if *in_pos >= in_size { return LZMA_OK; } - if (*coder).pos == 0 as size_t { + if (*coder).pos == 0 { if *in_0.offset(*in_pos as isize) as c_int == INDEX_INDICATOR { (*coder).sequence = SEQ_INDEX; current_block_100 = 16789764818708874114; } else { (*coder).block_options.header_size = (*in_0.offset(*in_pos as isize) as u32) - .wrapping_add(1 as u32) - .wrapping_mul(4 as u32); + .wrapping_add(1) + .wrapping_mul(4); current_block_100 = 13242334135786603907; } } else { @@ -412,7 +408,7 @@ unsafe extern "C" fn stream_decode( if (*coder).pos < (*coder).block_options.header_size as size_t { return LZMA_OK; } - (*coder).pos = 0 as size_t; + (*coder).pos = 0; (*coder).sequence = SEQ_BLOCK_INIT; current_block_100 = 3500765272169221397; } @@ -430,7 +426,7 @@ unsafe extern "C" fn stream_decode( if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { return LZMA_OK; } - (*coder).pos = 0 as size_t; + (*coder).pos = 0; let mut footer_flags: lzma_stream_flags = lzma_stream_flags { version: 0, backward_size: 0, @@ -486,7 +482,7 @@ unsafe extern "C" fn stream_decode( if action != LZMA_FINISH { return LZMA_OK; } - return (if (*coder).pos == 0 as size_t { + return (if (*coder).pos == 0 { LZMA_STREAM_END as c_int } else { LZMA_DATA_ERROR as c_int @@ -496,9 +492,9 @@ unsafe extern "C" fn stream_decode( break; } *in_pos = (*in_pos).wrapping_add(1); - (*coder).pos = (*coder).pos.wrapping_add(1 as size_t) & 3 as size_t; + (*coder).pos = (*coder).pos.wrapping_add(1) & 3; } - if (*coder).pos != 0 as size_t { + if (*coder).pos != 0 { *in_pos = (*in_pos).wrapping_add(1); return LZMA_DATA_ERROR; } @@ -509,10 +505,10 @@ unsafe extern "C" fn stream_decode( current_block_100 = 16789764818708874114; } 3500765272169221397 => { - (*coder).block_options.version = 1 as u32; + (*coder).block_options.version = 1; let mut filters: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5]; (*coder).block_options.filters = &raw mut filters as *mut lzma_filter; let ret_: lzma_ret = lzma_block_header_decode( @@ -542,7 +538,7 @@ unsafe extern "C" fn stream_decode( } } lzma_filters_free(&raw mut filters as *mut lzma_filter, allocator); - (*coder).block_options.filters = ::core::ptr::null_mut::(); + (*coder).block_options.filters = core::ptr::null_mut(); if ret_0 != LZMA_OK { return ret_0; } @@ -584,29 +580,28 @@ unsafe extern "C" fn stream_decode( } } } -unsafe extern "C" fn stream_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; +unsafe extern "C" fn stream_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; lzma_next_end(&raw mut (*coder).block_decoder, allocator); lzma_index_hash_end((*coder).index_hash, allocator); lzma_free(coder as *mut c_void, allocator); } -unsafe extern "C" fn stream_decoder_get_check(mut coder_ptr: *const c_void) -> lzma_check { - let mut coder: *const lzma_stream_coder = coder_ptr as *const lzma_stream_coder; - return (*coder).stream_flags.check; +extern "C" fn stream_decoder_get_check(coder_ptr: *const c_void) -> lzma_check { + return unsafe { + let coder: *const lzma_stream_coder = coder_ptr as *const lzma_stream_coder; + (*coder).stream_flags.check + }; } unsafe extern "C" fn stream_decoder_memconfig( - mut coder_ptr: *mut c_void, - mut memusage: *mut u64, - mut old_memlimit: *mut u64, - mut new_memlimit: u64, + coder_ptr: *mut c_void, + memusage: *mut u64, + old_memlimit: *mut u64, + new_memlimit: u64, ) -> lzma_ret { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; *memusage = (*coder).memusage; *old_memlimit = (*coder).memlimit; - if new_memlimit != 0 as u64 { + if new_memlimit != 0 { if new_memlimit < (*coder).memusage { return LZMA_MEMLIMIT_ERROR; } @@ -616,10 +611,10 @@ unsafe extern "C" fn stream_decoder_memconfig( } #[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut memlimit: u64, - mut flags: u32, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + memlimit: u64, + flags: u32, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -658,7 +653,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_stream_coder; if coder.is_null() { @@ -691,9 +686,9 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( ) as Option lzma_ret>; (*coder).block_decoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -702,27 +697,23 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( update: None, set_out_limit: None, }; - (*coder).index_hash = ::core::ptr::null_mut::(); + (*coder).index_hash = core::ptr::null_mut(); } - (*coder).memlimit = if 1 as u64 > memlimit { - 1 as u64 - } else { - memlimit - }; + (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; - (*coder).tell_no_check = flags & LZMA_TELL_NO_CHECK as u32 != 0 as u32; - (*coder).tell_unsupported_check = flags & LZMA_TELL_UNSUPPORTED_CHECK as u32 != 0 as u32; - (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as u32 != 0 as u32; - (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as u32 != 0 as u32; - (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0 as u32; - (*coder).first_stream = true_0 != 0; + (*coder).tell_no_check = flags & LZMA_TELL_NO_CHECK as u32 != 0; + (*coder).tell_unsupported_check = flags & LZMA_TELL_UNSUPPORTED_CHECK as u32 != 0; + (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as u32 != 0; + (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as u32 != 0; + (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0; + (*coder).first_stream = true; return stream_decoder_reset(coder, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder( - mut strm: *mut lzma_stream, - mut memlimit: u64, - mut flags: u32, + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -738,7 +729,7 @@ pub unsafe extern "C" fn lzma_stream_decoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 809c322d..ec899579 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_char, c_int, c_long, c_uint, c_ulong, c_ulonglong, c_void}; pub enum lzma_index_hash_s {} extern "C" { fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; @@ -381,7 +381,7 @@ pub struct lzma_stream_coder { pub pos: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_outq { @@ -507,125 +507,120 @@ pub const SEQ_BLOCK_THR_INIT: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const SIG_SETMASK: c_int = 3 as c_int; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; -pub const MYTHREAD_RET_VALUE: *mut c_void = NULL; +pub const SIG_SETMASK: c_int = 3; +pub const MYTHREAD_RET_VALUE: *mut c_void = core::ptr::null_mut(); #[inline] -unsafe extern "C" fn mythread_sigmask( - mut how: c_int, - mut set: *const sigset_t, - mut oset: *mut sigset_t, -) { - let mut ret: c_int = pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t); +extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { + let _ret: c_int = unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; } #[inline] -unsafe extern "C" fn mythread_create( - mut thread: *mut mythread, - mut func: Option *mut c_void>, - mut arg: *mut c_void, +extern "C" fn mythread_create( + thread: *mut mythread, + func: Option *mut c_void>, + arg: *mut c_void, ) -> c_int { let mut old: sigset_t = 0; let mut all: sigset_t = 0; all = !(0 as sigset_t); mythread_sigmask(SIG_SETMASK, &raw mut all, &raw mut old); - let ret: c_int = pthread_create( - thread as *mut pthread_t, - ::core::ptr::null::(), - func as Option *mut c_void>, - arg as *mut c_void, - ) as c_int; - mythread_sigmask( - SIG_SETMASK, - &raw mut old, - ::core::ptr::null_mut::(), - ); + let ret: c_int = unsafe { + pthread_create( + thread as *mut pthread_t, + ::core::ptr::null::(), + func as Option *mut c_void>, + arg as *mut c_void, + ) as c_int + }; + mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); return ret; } #[inline] -unsafe extern "C" fn mythread_join(mut thread: mythread) -> c_int { - return pthread_join(thread as pthread_t, ::core::ptr::null_mut::<*mut c_void>()); +extern "C" fn mythread_join(thread: mythread) -> c_int { + return unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) }; } #[inline] -unsafe extern "C" fn mythread_mutex_init(mut mutex: *mut mythread_mutex) -> c_int { - return pthread_mutex_init( - mutex as *mut pthread_mutex_t, - ::core::ptr::null::(), - ); +extern "C" fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { + return unsafe { + pthread_mutex_init( + mutex as *mut pthread_mutex_t, + ::core::ptr::null::(), + ) + }; } #[inline] -unsafe extern "C" fn mythread_mutex_destroy(mut mutex: *mut mythread_mutex) { - let mut ret: c_int = pthread_mutex_destroy(mutex as *mut pthread_mutex_t); +extern "C" fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_destroy(mutex as *mut pthread_mutex_t) }; } #[inline] -unsafe extern "C" fn mythread_mutex_lock(mut mutex: *mut mythread_mutex) { - let mut ret: c_int = pthread_mutex_lock(mutex as *mut pthread_mutex_t); +extern "C" fn mythread_mutex_lock(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_lock(mutex as *mut pthread_mutex_t) }; } #[inline] -unsafe extern "C" fn mythread_mutex_unlock(mut mutex: *mut mythread_mutex) { - let mut ret: c_int = pthread_mutex_unlock(mutex as *mut pthread_mutex_t); +extern "C" fn mythread_mutex_unlock(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_unlock(mutex as *mut pthread_mutex_t) }; } #[inline] -unsafe extern "C" fn mythread_cond_init(mut mycond: *mut mythread_cond) -> c_int { - (*mycond).clk_id = _CLOCK_REALTIME; - return pthread_cond_init( - &raw mut (*mycond).cond, - ::core::ptr::null::(), - ); +extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { + return unsafe { + (*mycond).clk_id = _CLOCK_REALTIME; + pthread_cond_init( + &raw mut (*mycond).cond, + ::core::ptr::null::(), + ) + }; } #[inline] -unsafe extern "C" fn mythread_cond_destroy(mut cond: *mut mythread_cond) { - let mut ret: c_int = pthread_cond_destroy(&raw mut (*cond).cond); +extern "C" fn mythread_cond_destroy(cond: *mut mythread_cond) { + let _ret: c_int = unsafe { pthread_cond_destroy(&raw mut (*cond).cond) }; } #[inline] -unsafe extern "C" fn mythread_cond_signal(mut cond: *mut mythread_cond) { - let mut ret: c_int = pthread_cond_signal(&raw mut (*cond).cond); +extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { + let _ret: c_int = unsafe { pthread_cond_signal(&raw mut (*cond).cond) }; } #[inline] -unsafe extern "C" fn mythread_cond_wait( - mut cond: *mut mythread_cond, - mut mutex: *mut mythread_mutex, -) { - let mut ret: c_int = pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t); +extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { + pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) + }; } #[inline] -unsafe extern "C" fn mythread_cond_timedwait( - mut cond: *mut mythread_cond, - mut mutex: *mut mythread_mutex, - mut condtime: *const mythread_condtime, +extern "C" fn mythread_cond_timedwait( + cond: *mut mythread_cond, + mutex: *mut mythread_mutex, + condtime: *const mythread_condtime, ) -> c_int { - let mut ret: c_int = pthread_cond_timedwait( - &raw mut (*cond).cond, - mutex as *mut pthread_mutex_t, - condtime as *const timespec, - ); + let ret: c_int = unsafe { + pthread_cond_timedwait( + &raw mut (*cond).cond, + mutex as *mut pthread_mutex_t, + condtime as *const timespec, + ) + }; return ret; } #[inline] -unsafe extern "C" fn mythread_condtime_set( - mut condtime: *mut mythread_condtime, - mut cond: *const mythread_cond, - mut timeout_ms: u32, +extern "C" fn mythread_condtime_set( + condtime: *mut mythread_condtime, + cond: *const mythread_cond, + timeout_ms: u32, ) { - (*condtime).tv_sec = timeout_ms.wrapping_div(1000 as u32) as time_t as __darwin_time_t; - (*condtime).tv_nsec = timeout_ms - .wrapping_rem(1000 as u32) - .wrapping_mul(1000000 as u32) as c_long; - let mut now: timespec = timespec { - tv_sec: 0, - tv_nsec: 0, - }; - let mut ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); - (*condtime).tv_sec += now.tv_sec; - (*condtime).tv_nsec += now.tv_nsec; - if (*condtime).tv_nsec >= 1000000000 as c_long { - (*condtime).tv_nsec -= 1000000000 as c_long; - (*condtime).tv_sec += 1; + unsafe { + (*condtime).tv_sec = timeout_ms.wrapping_div(1000) as time_t as __darwin_time_t; + (*condtime).tv_nsec = timeout_ms.wrapping_rem(1000).wrapping_mul(1000000) as c_long; + let mut now: timespec = timespec { + tv_sec: 0, + tv_nsec: 0, + }; + let _ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); + (*condtime).tv_sec += now.tv_sec; + (*condtime).tv_nsec += now.tv_nsec; + if (*condtime).tv_nsec >= 1000000000 as c_long { + (*condtime).tv_nsec -= 1000000000 as c_long; + (*condtime).tv_sec += 1; + } } } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; @@ -635,8 +630,8 @@ pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; pub const LZMA_IGNORE_CHECK: c_uint = 0x10; pub const LZMA_CONCATENATED: c_uint = 0x8; pub const LZMA_FAIL_FAST: c_uint = 0x20; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; -pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; +pub const LZMA_THREADS_MAX: c_int = 16384; pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_TELL_UNSUPPORTED_CHECK @@ -644,25 +639,25 @@ pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_IGNORE_CHECK | LZMA_CONCATENATED | LZMA_FAIL_FAST; -pub const INDEX_INDICATOR: c_int = 0 as c_int; +pub const INDEX_INDICATOR: c_int = 0; #[inline] -unsafe extern "C" fn vli_ceil4(mut vli: lzma_vli) -> lzma_vli { +extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); } #[inline] -unsafe extern "C" fn lzma_outq_has_buf(mut outq: *const lzma_outq) -> bool { - return (*outq).bufs_in_use < (*outq).bufs_limit; +extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { + return unsafe { (*outq).bufs_in_use < (*outq).bufs_limit }; } #[inline] -unsafe extern "C" fn lzma_outq_is_empty(mut outq: *const lzma_outq) -> bool { - return (*outq).bufs_in_use == 0 as u32; +extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { + return unsafe { (*outq).bufs_in_use == 0 }; } #[inline] -unsafe extern "C" fn lzma_outq_outbuf_memusage(mut buf_size: size_t) -> u64 { - return (::core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; +extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { + return (core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; } -unsafe extern "C" fn worker_enable_partial_update(mut thr_ptr: *mut c_void) { - let mut thr: *mut worker_thread = thr_ptr as *mut worker_thread; +unsafe extern "C" fn worker_enable_partial_update(thr_ptr: *mut c_void) { + let thr: *mut worker_thread = thr_ptr as *mut worker_thread; let mut mythread_i_325: c_uint = 0; while if mythread_i_325 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); @@ -674,15 +669,15 @@ unsafe extern "C" fn worker_enable_partial_update(mut thr_ptr: *mut c_void) { { let mut mythread_j_325: c_uint = 0; while mythread_j_325 == 0 { - (*thr).partial_update_enabled = true_0 != 0; + (*thr).partial_update_enabled = true; mythread_cond_signal(&raw mut (*thr).cond); mythread_j_325 = 1; } mythread_i_325 = 1; } } -unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { - let mut thr: *mut worker_thread = thr_ptr as *mut worker_thread; +unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { + let thr: *mut worker_thread = thr_ptr as *mut worker_thread; let mut in_filled: size_t = 0; let mut partial_update_enabled: bool = false; let mut ret: lzma_ret = LZMA_OK; @@ -713,7 +708,7 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { } } mythread_mutex_unlock(&raw mut (*thr).mutex); - let chunk_size: size_t = 16384 as size_t; + let chunk_size: size_t = 16384; if in_filled.wrapping_sub((*thr).in_pos) > chunk_size { in_filled = (*thr).in_pos.wrapping_add(chunk_size); } @@ -733,7 +728,7 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { ); if ret == LZMA_OK { if partial_update_enabled { - (*thr).partial_update_started = true_0 != 0; + (*thr).partial_update_started = true; let mut mythread_i_415: c_uint = 0; while if mythread_i_415 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); @@ -777,7 +772,7 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { } if ret == LZMA_STREAM_END { lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); - (*thr).in_0 = ::core::ptr::null_mut::(); + (*thr).in_0 = core::ptr::null_mut(); } let mut mythread_i_458: c_uint = 0; while if mythread_i_458 != 0 { @@ -796,13 +791,13 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { (*(*thr).coder).progress_out = (*(*thr).coder) .progress_out .wrapping_add((*thr).out_pos as u64); - (*thr).progress_in = 0 as size_t; - (*thr).progress_out = 0 as size_t; + (*thr).progress_in = 0; + (*thr).progress_out = 0; (*(*thr).outbuf).pos = (*thr).out_pos; (*(*thr).outbuf).decoder_in_pos = (*thr).in_pos; - (*(*thr).outbuf).finished = true_0 != 0; + (*(*thr).outbuf).finished = true; (*(*thr).outbuf).finish_ret = ret; - (*thr).outbuf = ::core::ptr::null_mut::(); + (*thr).outbuf = core::ptr::null_mut(); if ret != LZMA_STREAM_END && (*(*thr).coder).thread_error == LZMA_OK { (*(*thr).coder).thread_error = ret; } @@ -825,11 +820,8 @@ unsafe extern "C" fn worker_decoder(mut thr_ptr: *mut c_void) -> *mut c_void { } } } -unsafe extern "C" fn threads_end( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, -) { - let mut i: u32 = 0 as u32; +unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) { + let mut i: u32 = 0; while i < (*coder).threads_initialized { let mut mythread_i_502: c_uint = 0; while if mythread_i_502 != 0 { @@ -850,20 +842,20 @@ unsafe extern "C" fn threads_end( } i = i.wrapping_add(1); } - let mut i_0: u32 = 0 as u32; + let mut i_0: u32 = 0; while i_0 < (*coder).threads_initialized { mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); i_0 = i_0.wrapping_add(1); } lzma_free((*coder).threads as *mut c_void, allocator); - (*coder).threads_initialized = 0 as u32; - (*coder).threads = ::core::ptr::null_mut::(); - (*coder).threads_free = ::core::ptr::null_mut::(); - (*coder).mem_in_use = 0 as u64; - (*coder).mem_cached = 0 as u64; + (*coder).threads_initialized = 0; + (*coder).threads = core::ptr::null_mut(); + (*coder).threads_free = core::ptr::null_mut(); + (*coder).mem_in_use = 0; + (*coder).mem_cached = 0; } -unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder) { - let mut i: u32 = 0 as u32; +unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder) { + let mut i: u32 = 0; while i < (*coder).threads_initialized { let mut mythread_i_538: c_uint = 0; while if mythread_i_538 != 0 { @@ -885,35 +877,35 @@ unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder) { } } unsafe extern "C" fn initialize_new_thread( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, ) -> lzma_ret { if (*coder).threads.is_null() { (*coder).threads = lzma_alloc( ((*coder).threads_max as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::() as size_t), allocator, ) as *mut worker_thread; if (*coder).threads.is_null() { return LZMA_MEM_ERROR; } } - let mut thr: *mut worker_thread = (*coder) + let thr: *mut worker_thread = (*coder) .threads .offset((*coder).threads_initialized as isize) as *mut worker_thread; if !(mythread_mutex_init(&raw mut (*thr).mutex) != 0) { if !(mythread_cond_init(&raw mut (*thr).cond) != 0) { (*thr).state = THR_IDLE; - (*thr).in_0 = ::core::ptr::null_mut::(); - (*thr).in_size = 0 as size_t; + (*thr).in_0 = core::ptr::null_mut(); + (*thr).in_size = 0; (*thr).allocator = allocator; (*thr).coder = coder as *mut lzma_stream_coder; - (*thr).outbuf = ::core::ptr::null_mut::(); + (*thr).outbuf = core::ptr::null_mut(); (*thr).block_decoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -922,7 +914,7 @@ unsafe extern "C" fn initialize_new_thread( update: None, set_out_limit: None, }; - (*thr).mem_filters = 0 as u64; + (*thr).mem_filters = 0; if mythread_create( &raw mut (*thr).thread_id, Some(worker_decoder as unsafe extern "C" fn(*mut c_void) -> *mut c_void), @@ -941,8 +933,8 @@ unsafe extern "C" fn initialize_new_thread( return LZMA_MEM_ERROR; } unsafe extern "C" fn get_thread( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, ) -> lzma_ret { let mut mythread_i_608: c_uint = 0; while if mythread_i_608 != 0 { @@ -972,25 +964,25 @@ unsafe extern "C" fn get_thread( return ret_; } } - (*(*coder).thr).in_filled = 0 as size_t; - (*(*coder).thr).in_pos = 0 as size_t; - (*(*coder).thr).out_pos = 0 as size_t; - (*(*coder).thr).progress_in = 0 as size_t; - (*(*coder).thr).progress_out = 0 as size_t; - (*(*coder).thr).partial_update_enabled = false_0 != 0; - (*(*coder).thr).partial_update_started = false_0 != 0; + (*(*coder).thr).in_filled = 0; + (*(*coder).thr).in_pos = 0; + (*(*coder).thr).out_pos = 0; + (*(*coder).thr).progress_in = 0; + (*(*coder).thr).progress_out = 0; + (*(*coder).thr).partial_update_enabled = false; + (*(*coder).thr).partial_update_started = false; return LZMA_OK; } unsafe extern "C" fn read_output_and_wait( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut input_is_possible: *mut bool, - mut waiting_allowed: bool, - mut wait_abs: *mut mythread_condtime, - mut has_blocked: *mut bool, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + input_is_possible: *mut bool, + waiting_allowed: bool, + wait_abs: *mut mythread_condtime, + has_blocked: *mut bool, ) -> lzma_ret { let mut ret: lzma_ret = LZMA_OK; let mut mythread_i_654: c_uint = 0; @@ -1013,8 +1005,8 @@ unsafe extern "C" fn read_output_and_wait( out, out_pos, out_size, - ::core::ptr::null_mut::(), - ::core::ptr::null_mut::(), + core::ptr::null_mut(), + core::ptr::null_mut(), ); if ret == LZMA_STREAM_END { lzma_outq_enable_partial_output( @@ -1033,7 +1025,7 @@ unsafe extern "C" fn read_output_and_wait( break; } if *out_pos == out_size && *out_pos != out_start { - (*coder).out_was_filled = true_0 != 0; + (*coder).out_was_filled = true; } if (*coder).thread_error != LZMA_OK { if (*coder).fail_fast { @@ -1053,7 +1045,7 @@ unsafe extern "C" fn read_output_and_wait( && ((*coder).threads_initialized < (*coder).threads_max || !(*coder).threads_free.is_null()) { - *input_is_possible = true_0 != 0; + *input_is_possible = true; break; } else { if !waiting_allowed { @@ -1072,9 +1064,9 @@ unsafe extern "C" fn read_output_and_wait( break; } } - if (*coder).timeout != 0 as u32 { + if (*coder).timeout != 0 { if !*has_blocked { - *has_blocked = true_0 != 0; + *has_blocked = true; mythread_condtime_set( wait_abs, &raw mut (*coder).cond, @@ -1108,22 +1100,22 @@ unsafe extern "C" fn read_output_and_wait( return ret; } unsafe extern "C" fn decode_block_header( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { if *in_pos >= in_size { return LZMA_OK; } - if (*coder).pos == 0 as size_t { + if (*coder).pos == 0 { if *in_0.offset(*in_pos as isize) as c_int == INDEX_INDICATOR { return LZMA_RET_INTERNAL2; } (*coder).block_options.header_size = (*in_0.offset(*in_pos as isize) as u32) - .wrapping_add(1 as u32) - .wrapping_mul(4 as u32); + .wrapping_add(1) + .wrapping_mul(4); } lzma_bufcpy( in_0, @@ -1136,8 +1128,8 @@ unsafe extern "C" fn decode_block_header( if (*coder).pos < (*coder).block_options.header_size as size_t { return LZMA_OK; } - (*coder).pos = 0 as size_t; - (*coder).block_options.version = 1 as u32; + (*coder).pos = 0; + (*coder).block_options.version = 1; (*coder).block_options.filters = &raw mut (*coder).filters as *mut lzma_filter; let ret_: lzma_ret = lzma_block_header_decode( &raw mut (*coder).block_options, @@ -1150,47 +1142,49 @@ unsafe extern "C" fn decode_block_header( (*coder).block_options.ignore_check = (*coder).ignore_check as lzma_bool; return LZMA_STREAM_END; } -unsafe extern "C" fn comp_blk_size(mut coder: *const lzma_stream_coder) -> size_t { - return vli_ceil4((*coder).block_options.compressed_size) - .wrapping_add(lzma_check_size((*coder).stream_flags.check) as lzma_vli) - as size_t; +extern "C" fn comp_blk_size(coder: *const lzma_stream_coder) -> size_t { + return unsafe { + vli_ceil4((*coder).block_options.compressed_size) + .wrapping_add(lzma_check_size((*coder).stream_flags.check) as lzma_vli) + as size_t + }; } -unsafe extern "C" fn is_direct_mode_needed(mut size: lzma_vli) -> bool { +extern "C" fn is_direct_mode_needed(size: lzma_vli) -> bool { return size == LZMA_VLI_UNKNOWN as lzma_vli || size > SIZE_MAX.wrapping_div(3 as c_ulong) as lzma_vli; } unsafe extern "C" fn stream_decoder_reset( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, ) -> lzma_ret { (*coder).index_hash = lzma_index_hash_init((*coder).index_hash, allocator); if (*coder).index_hash.is_null() { return LZMA_MEM_ERROR; } (*coder).sequence = SEQ_STREAM_HEADER; - (*coder).pos = 0 as size_t; + (*coder).pos = 0; return LZMA_OK; } unsafe extern "C" fn stream_decode_mt( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; let mut wait_abs: mythread_condtime = timespec { tv_sec: 0, tv_nsec: 0, }; - let mut has_blocked: bool = false_0 != 0; + let mut has_blocked: bool = false; let waiting_allowed: bool = action == LZMA_FINISH || *in_pos == in_size && !(*coder).out_was_filled; - (*coder).out_was_filled = false_0 != 0; + (*coder).out_was_filled = false; loop { let mut current_block_239: u64; match (*coder).sequence { @@ -1210,7 +1204,7 @@ unsafe extern "C" fn stream_decode_mt( if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { return LZMA_OK; } - (*coder).pos = 0 as size_t; + (*coder).pos = 0; let ret: lzma_ret = lzma_stream_header_decode( &raw mut (*coder).stream_flags, &raw mut (*coder).buffer as *mut u8, @@ -1222,7 +1216,7 @@ unsafe extern "C" fn stream_decode_mt( ret }) as lzma_ret; } - (*coder).first_stream = false_0 != 0; + (*coder).first_stream = false; (*coder).block_options.check = (*coder).stream_flags.check; (*coder).sequence = SEQ_BLOCK_HEADER; if (*coder).tell_no_check as c_int != 0 @@ -1259,7 +1253,7 @@ unsafe extern "C" fn stream_decode_mt( out, out_pos, out_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), 1 as c_int != 0, &raw mut wait_abs, &raw mut has_blocked, @@ -1278,7 +1272,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut (*coder).block_options, ) as lzma_ret; lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); - (*coder).block_options.filters = ::core::ptr::null_mut::(); + (*coder).block_options.filters = core::ptr::null_mut(); if ret_3 != LZMA_OK { return ret_3; } @@ -1296,7 +1290,7 @@ unsafe extern "C" fn stream_decode_mt( out, out_pos, out_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), 1 as c_int != 0, &raw mut wait_abs, &raw mut has_blocked, @@ -1327,7 +1321,7 @@ unsafe extern "C" fn stream_decode_mt( out, out_pos, out_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), 1 as c_int != 0, &raw mut wait_abs, &raw mut has_blocked, @@ -1399,7 +1393,7 @@ unsafe extern "C" fn stream_decode_mt( out, out_pos, out_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), waiting_allowed, &raw mut wait_abs, &raw mut has_blocked, @@ -1460,7 +1454,7 @@ unsafe extern "C" fn stream_decode_mt( out, out_pos, out_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), 1 as c_int != 0, &raw mut wait_abs, &raw mut has_blocked, @@ -1495,7 +1489,7 @@ unsafe extern "C" fn stream_decode_mt( current_block_239 = 11639917216603986996; } else { lzma_next_end(&raw mut (*coder).block_decoder, allocator); - (*coder).mem_direct_mode = 0 as u64; + (*coder).mem_direct_mode = 0; let ret_1: lzma_ret = lzma_index_hash_append( (*coder).index_hash, lzma_block_unpadded_size(&raw mut (*coder).block_options), @@ -1529,7 +1523,7 @@ unsafe extern "C" fn stream_decode_mt( if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { return LZMA_OK; } - (*coder).pos = 0 as size_t; + (*coder).pos = 0; let mut footer_flags: lzma_stream_flags = lzma_stream_flags { version: 0, backward_size: 0, @@ -1585,7 +1579,7 @@ unsafe extern "C" fn stream_decode_mt( if action != LZMA_FINISH { return LZMA_OK; } - return (if (*coder).pos == 0 as size_t { + return (if (*coder).pos == 0 { LZMA_STREAM_END as c_int } else { LZMA_DATA_ERROR as c_int @@ -1596,9 +1590,9 @@ unsafe extern "C" fn stream_decode_mt( } *in_pos = (*in_pos).wrapping_add(1); (*coder).progress_in = (*coder).progress_in.wrapping_add(1); - (*coder).pos = (*coder).pos.wrapping_add(1 as size_t) & 3 as size_t; + (*coder).pos = (*coder).pos.wrapping_add(1) & 3; } - if (*coder).pos != 0 as size_t { + if (*coder).pos != 0 { *in_pos = (*in_pos).wrapping_add(1); (*coder).progress_in = (*coder).progress_in.wrapping_add(1); return LZMA_DATA_ERROR; @@ -1610,7 +1604,7 @@ unsafe extern "C" fn stream_decode_mt( current_block_239 = 11639917216603986996; } 11441799814184323368 => { - let mut block_can_start: bool = false_0 != 0; + let mut block_can_start: bool = false; let ret__1: lzma_ret = read_output_and_wait( coder, allocator, @@ -1632,9 +1626,9 @@ unsafe extern "C" fn stream_decode_mt( if !block_can_start { return LZMA_OK; } - let mut mem_in_use: u64 = 0 as u64; - let mut mem_cached: u64 = 0 as u64; - let mut thr: *mut worker_thread = ::core::ptr::null_mut::(); + let mut mem_in_use: u64 = 0; + let mut mem_cached: u64 = 0; + let mut thr: *mut worker_thread = core::ptr::null_mut(); let mut mythread_i_1347: c_uint = 0; while if mythread_i_1347 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); @@ -1667,7 +1661,7 @@ unsafe extern "C" fn stream_decode_mt( (*coder).block_options.uncompressed_size as size_t, ); } - let mut mem_freed: u64 = 0 as u64; + let mut mem_freed: u64 = 0; if !thr.is_null() && mem_in_use .wrapping_add(mem_cached) @@ -1680,7 +1674,7 @@ unsafe extern "C" fn stream_decode_mt( while !thr.is_null() { lzma_next_end(&raw mut (*thr).block_decoder, allocator); mem_freed = mem_freed.wrapping_add((*thr).mem_filters); - (*thr).mem_filters = 0 as u64; + (*thr).mem_filters = 0; thr = (*thr).next; } } @@ -1725,7 +1719,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut (*(*coder).thr).block_options, ); lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); - (*(*coder).thr).block_options.filters = ::core::ptr::null_mut::(); + (*(*coder).thr).block_options.filters = core::ptr::null_mut(); if ret_2 != LZMA_OK { (*coder).pending_error = ret_2; (*coder).sequence = SEQ_ERROR; @@ -1830,7 +1824,7 @@ unsafe extern "C" fn stream_decode_mt( out, out_pos, out_size, - ::core::ptr::null_mut::(), + core::ptr::null_mut(), waiting_allowed as c_int != 0 && *in_pos == in_size, &raw mut wait_abs, &raw mut has_blocked, @@ -1844,7 +1838,7 @@ unsafe extern "C" fn stream_decode_mt( if (*(*coder).thr).in_filled < (*(*coder).thr).in_size { return LZMA_OK; } - (*coder).thr = ::core::ptr::null_mut::(); + (*coder).thr = core::ptr::null_mut(); (*coder).sequence = SEQ_BLOCK_HEADER; } } @@ -1853,10 +1847,10 @@ unsafe extern "C" fn stream_decode_mt( } } unsafe extern "C" fn stream_decoder_mt_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, ) { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; threads_end(coder, allocator); lzma_outq_end(&raw mut (*coder).outq, allocator); lzma_next_end(&raw mut (*coder).block_decoder, allocator); @@ -1864,17 +1858,19 @@ unsafe extern "C" fn stream_decoder_mt_end( lzma_index_hash_end((*coder).index_hash, allocator); lzma_free(coder as *mut c_void, allocator); } -unsafe extern "C" fn stream_decoder_mt_get_check(mut coder_ptr: *const c_void) -> lzma_check { - let mut coder: *const lzma_stream_coder = coder_ptr as *const lzma_stream_coder; - return (*coder).stream_flags.check; +extern "C" fn stream_decoder_mt_get_check(coder_ptr: *const c_void) -> lzma_check { + return unsafe { + let coder: *const lzma_stream_coder = coder_ptr as *const lzma_stream_coder; + (*coder).stream_flags.check + }; } unsafe extern "C" fn stream_decoder_mt_memconfig( - mut coder_ptr: *mut c_void, - mut memusage: *mut u64, - mut old_memlimit: *mut u64, - mut new_memlimit: u64, + coder_ptr: *mut c_void, + memusage: *mut u64, + old_memlimit: *mut u64, + new_memlimit: u64, ) -> lzma_ret { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; let mut mythread_i_1829: c_uint = 0; while if mythread_i_1829 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); @@ -1899,7 +1895,7 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( *memusage = LZMA_MEMUSAGE_BASE as u64; } *old_memlimit = (*coder).memlimit_stop; - if new_memlimit != 0 as u64 { + if new_memlimit != 0 { if new_memlimit < *memusage { return LZMA_MEMLIMIT_ERROR; } @@ -1908,11 +1904,11 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( return LZMA_OK; } unsafe extern "C" fn stream_decoder_mt_get_progress( - mut coder_ptr: *mut c_void, - mut progress_in: *mut u64, - mut progress_out: *mut u64, + coder_ptr: *mut c_void, + progress_in: *mut u64, + progress_out: *mut u64, ) { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; let mut mythread_i_1862: c_uint = 0; while if mythread_i_1862 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); @@ -1926,7 +1922,7 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( while mythread_j_1862 == 0 { *progress_in = (*coder).progress_in; *progress_out = (*coder).progress_out; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < (*coder).threads_initialized as size_t { let mut mythread_i_1867: c_uint = 0; while if mythread_i_1867 != 0 { @@ -1957,12 +1953,12 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( } } unsafe extern "C" fn stream_decoder_mt_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut options: *const lzma_mt, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_mt, ) -> lzma_ret { - let mut coder: *mut lzma_stream_coder = ::core::ptr::null_mut::(); - if (*options).threads == 0 as u32 || (*options).threads > LZMA_THREADS_MAX as u32 { + let mut coder: *mut lzma_stream_coder = core::ptr::null_mut(); + if (*options).threads == 0 || (*options).threads > LZMA_THREADS_MAX as u32 { return LZMA_OPTIONS_ERROR; } if (*options).flags & !(LZMA_SUPPORTED_FLAGS as u32) != 0 { @@ -2008,7 +2004,7 @@ unsafe extern "C" fn stream_decoder_mt_init( coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_stream_coder; if coder.is_null() { @@ -2058,12 +2054,12 @@ unsafe extern "C" fn stream_decoder_mt_init( memset( &raw mut (*coder).outq as *mut c_void, 0 as c_int, - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, ); (*coder).block_decoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -2072,47 +2068,46 @@ unsafe extern "C" fn stream_decoder_mt_init( update: None, set_out_limit: None, }; - (*coder).mem_direct_mode = 0 as u64; - (*coder).index_hash = ::core::ptr::null_mut::(); - (*coder).threads = ::core::ptr::null_mut::(); - (*coder).threads_free = ::core::ptr::null_mut::(); - (*coder).threads_initialized = 0 as u32; + (*coder).mem_direct_mode = 0; + (*coder).index_hash = core::ptr::null_mut(); + (*coder).threads = core::ptr::null_mut(); + (*coder).threads_free = core::ptr::null_mut(); + (*coder).threads_initialized = 0; } lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); threads_end(coder, allocator); - (*coder).mem_in_use = 0 as u64; - (*coder).mem_cached = 0 as u64; - (*coder).mem_next_block = 0 as u64; - (*coder).progress_in = 0 as u64; - (*coder).progress_out = 0 as u64; + (*coder).mem_in_use = 0; + (*coder).mem_cached = 0; + (*coder).mem_next_block = 0; + (*coder).progress_in = 0; + (*coder).progress_out = 0; (*coder).sequence = SEQ_STREAM_HEADER; (*coder).thread_error = LZMA_OK; (*coder).pending_error = LZMA_OK; - (*coder).thr = ::core::ptr::null_mut::(); + (*coder).thr = core::ptr::null_mut(); (*coder).timeout = (*options).timeout; - (*coder).memlimit_threading = if 1 as u64 > (*options).memlimit_threading { - 1 as u64 + (*coder).memlimit_threading = if 1 > (*options).memlimit_threading { + 1 } else { (*options).memlimit_threading }; - (*coder).memlimit_stop = if 1 as u64 > (*options).memlimit_stop { - 1 as u64 + (*coder).memlimit_stop = if 1 > (*options).memlimit_stop { + 1 } else { (*options).memlimit_stop }; if (*coder).memlimit_threading > (*coder).memlimit_stop { (*coder).memlimit_threading = (*coder).memlimit_stop; } - (*coder).tell_no_check = (*options).flags & LZMA_TELL_NO_CHECK as u32 != 0 as u32; - (*coder).tell_unsupported_check = - (*options).flags & LZMA_TELL_UNSUPPORTED_CHECK as u32 != 0 as u32; - (*coder).tell_any_check = (*options).flags & LZMA_TELL_ANY_CHECK as u32 != 0 as u32; - (*coder).ignore_check = (*options).flags & LZMA_IGNORE_CHECK as u32 != 0 as u32; - (*coder).concatenated = (*options).flags & LZMA_CONCATENATED as u32 != 0 as u32; - (*coder).fail_fast = (*options).flags & LZMA_FAIL_FAST as u32 != 0 as u32; - (*coder).first_stream = true_0 != 0; - (*coder).out_was_filled = false_0 != 0; - (*coder).pos = 0 as size_t; + (*coder).tell_no_check = (*options).flags & LZMA_TELL_NO_CHECK as u32 != 0; + (*coder).tell_unsupported_check = (*options).flags & LZMA_TELL_UNSUPPORTED_CHECK as u32 != 0; + (*coder).tell_any_check = (*options).flags & LZMA_TELL_ANY_CHECK as u32 != 0; + (*coder).ignore_check = (*options).flags & LZMA_IGNORE_CHECK as u32 != 0; + (*coder).concatenated = (*options).flags & LZMA_CONCATENATED as u32 != 0; + (*coder).fail_fast = (*options).flags & LZMA_FAIL_FAST as u32 != 0; + (*coder).first_stream = true; + (*coder).out_was_filled = false; + (*coder).pos = 0; (*coder).threads_max = (*options).threads; let ret_: lzma_ret = lzma_outq_init(&raw mut (*coder).outq, allocator, (*coder).threads_max) as lzma_ret; @@ -2123,8 +2118,8 @@ unsafe extern "C" fn stream_decoder_mt_init( } #[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder_mt( - mut strm: *mut lzma_stream, - mut options: *const lzma_mt, + strm: *mut lzma_stream, + options: *const lzma_mt, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -2139,7 +2134,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_mt( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 337f0e18..2447c119 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -184,7 +184,7 @@ pub struct lzma_stream_coder { pub buffer_size: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024 as c_int; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] @@ -248,16 +248,12 @@ pub struct lzma_stream_flags { pub reserved_int1: u32, pub reserved_int2: u32, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; unsafe extern "C" fn block_encoder_init( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, ) -> lzma_ret { (*coder).block_options.compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).block_options.uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; @@ -272,17 +268,17 @@ unsafe extern "C" fn block_encoder_init( ); } unsafe extern "C" fn stream_encode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; while *out_pos < out_size { match (*coder).sequence { 0 | 2 | 5 => { @@ -300,7 +296,7 @@ unsafe extern "C" fn stream_encode( if (*coder).sequence == SEQ_STREAM_FOOTER { return LZMA_STREAM_END; } - (*coder).buffer_pos = 0 as size_t; + (*coder).buffer_pos = 0; (*coder).sequence += 1; } 1 => { @@ -328,7 +324,7 @@ unsafe extern "C" fn stream_encode( return ret__0; } } - (*coder).block_encoder_is_initialized = false_0 != 0; + (*coder).block_encoder_is_initialized = false; if lzma_block_header_encode( &raw mut (*coder).block_options, &raw mut (*coder).buffer as *mut u8, @@ -386,8 +382,8 @@ unsafe extern "C" fn stream_encode( (*coder).index_encoder.coder, allocator, ::core::ptr::null::(), - ::core::ptr::null_mut::(), - 0 as size_t, + core::ptr::null_mut(), + 0, out, out_pos, out_size, @@ -397,7 +393,7 @@ unsafe extern "C" fn stream_encode( return ret_0; } let stream_flags: lzma_stream_flags = lzma_stream_flags { - version: 0 as u32, + version: 0, backward_size: lzma_index_size((*coder).index), check: (*coder).block_options.check, reserved_enum1: LZMA_RESERVED_ENUM, @@ -430,11 +426,8 @@ unsafe extern "C" fn stream_encode( } return LZMA_OK; } -unsafe extern "C" fn stream_encoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; +unsafe extern "C" fn stream_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; lzma_next_end(&raw mut (*coder).block_encoder, allocator); lzma_next_end(&raw mut (*coder).index_encoder, allocator); lzma_index_end((*coder).index, allocator); @@ -442,17 +435,17 @@ unsafe extern "C" fn stream_encoder_end( lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn stream_encoder_update( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter, - mut reversed_filters: *const lzma_filter, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + reversed_filters: *const lzma_filter, ) -> lzma_ret { - let mut current_block: u64; - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let current_block: u64; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; let mut ret: lzma_ret = LZMA_OK; let mut temp: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5]; let ret_: lzma_ret = lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator) as lzma_ret; @@ -460,14 +453,14 @@ unsafe extern "C" fn stream_encoder_update( return ret_; } if (*coder).sequence <= SEQ_BLOCK_INIT { - (*coder).block_encoder_is_initialized = false_0 != 0; + (*coder).block_encoder_is_initialized = false; (*coder).block_options.filters = &raw mut temp as *mut lzma_filter; ret = block_encoder_init(coder, allocator); (*coder).block_options.filters = &raw mut (*coder).filters as *mut lzma_filter; if ret != LZMA_OK { current_block = 9913398440939854562; } else { - (*coder).block_encoder_is_initialized = true_0 != 0; + (*coder).block_encoder_is_initialized = true; current_block = 8236137900636309791; } } else if (*coder).sequence <= SEQ_BLOCK_ENCODE { @@ -499,17 +492,17 @@ unsafe extern "C" fn stream_encoder_update( memcpy( &raw mut (*coder).filters as *mut lzma_filter as *mut c_void, &raw mut temp as *mut lzma_filter as *const c_void, - ::core::mem::size_of::<[lzma_filter; 5]>() as size_t, + core::mem::size_of::<[lzma_filter; 5]>() as size_t, ); return LZMA_OK; } }; } unsafe extern "C" fn stream_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter, - mut check: lzma_check, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + check: lzma_check, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -558,7 +551,7 @@ unsafe extern "C" fn stream_encoder_init( let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_stream_coder; if coder.is_null() { @@ -601,9 +594,9 @@ unsafe extern "C" fn stream_encoder_init( >; (*coder).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).block_encoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -613,9 +606,9 @@ unsafe extern "C" fn stream_encoder_init( set_out_limit: None, }; (*coder).index_encoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -624,10 +617,10 @@ unsafe extern "C" fn stream_encoder_init( update: None, set_out_limit: None, }; - (*coder).index = ::core::ptr::null_mut::(); + (*coder).index = core::ptr::null_mut(); } (*coder).sequence = SEQ_STREAM_HEADER; - (*coder).block_options.version = 0 as u32; + (*coder).block_options.version = 0; (*coder).block_options.check = check; lzma_index_end((*coder).index, allocator); (*coder).index = lzma_index_init(allocator); @@ -635,7 +628,7 @@ unsafe extern "C" fn stream_encoder_init( return LZMA_MEM_ERROR; } let mut stream_flags: lzma_stream_flags = lzma_stream_flags { - version: 0 as u32, + version: 0, backward_size: 0, check: check, reserved_enum1: LZMA_RESERVED_ENUM, @@ -659,7 +652,7 @@ unsafe extern "C" fn stream_encoder_init( if ret_ != LZMA_OK { return ret_; } - (*coder).buffer_pos = 0 as size_t; + (*coder).buffer_pos = 0; (*coder).buffer_size = LZMA_STREAM_HEADER_SIZE as size_t; return stream_encoder_update( coder as *mut c_void, @@ -670,9 +663,9 @@ unsafe extern "C" fn stream_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder( - mut strm: *mut lzma_stream, - mut filters: *const lzma_filter, - mut check: lzma_check, + strm: *mut lzma_stream, + filters: *const lzma_filter, + check: lzma_check, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -688,10 +681,10 @@ pub unsafe extern "C" fn lzma_stream_encoder( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FULL_FLUSH as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FULL_BARRIER as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FULL_FLUSH as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FULL_BARRIER as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index aa4a3abf..e2f2a5e5 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_char, c_int, c_long, c_uint, c_ulonglong, c_void}; pub enum lzma_index_s {} extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; @@ -520,140 +520,135 @@ pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const SIG_SETMASK: c_int = 3 as c_int; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; -pub const MYTHREAD_RET_VALUE: *mut c_void = NULL; +pub const SIG_SETMASK: c_int = 3; +pub const MYTHREAD_RET_VALUE: *mut c_void = core::ptr::null_mut(); #[inline] -unsafe extern "C" fn mythread_sigmask( - mut how: c_int, - mut set: *const sigset_t, - mut oset: *mut sigset_t, -) { - let mut ret: c_int = pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t); +extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { + let _ret: c_int = unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; } #[inline] -unsafe extern "C" fn mythread_create( - mut thread: *mut mythread, - mut func: Option *mut c_void>, - mut arg: *mut c_void, +extern "C" fn mythread_create( + thread: *mut mythread, + func: Option *mut c_void>, + arg: *mut c_void, ) -> c_int { let mut old: sigset_t = 0; let mut all: sigset_t = 0; all = !(0 as sigset_t); mythread_sigmask(SIG_SETMASK, &raw mut all, &raw mut old); - let ret: c_int = pthread_create( - thread as *mut pthread_t, - ::core::ptr::null::(), - func as Option *mut c_void>, - arg as *mut c_void, - ) as c_int; - mythread_sigmask( - SIG_SETMASK, - &raw mut old, - ::core::ptr::null_mut::(), - ); + let ret: c_int = unsafe { + pthread_create( + thread as *mut pthread_t, + ::core::ptr::null::(), + func as Option *mut c_void>, + arg as *mut c_void, + ) as c_int + }; + mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); return ret; } #[inline] -unsafe extern "C" fn mythread_join(mut thread: mythread) -> c_int { - return pthread_join(thread as pthread_t, ::core::ptr::null_mut::<*mut c_void>()); +extern "C" fn mythread_join(thread: mythread) -> c_int { + return unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) }; } #[inline] -unsafe extern "C" fn mythread_mutex_init(mut mutex: *mut mythread_mutex) -> c_int { - return pthread_mutex_init( - mutex as *mut pthread_mutex_t, - ::core::ptr::null::(), - ); +extern "C" fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { + return unsafe { + pthread_mutex_init( + mutex as *mut pthread_mutex_t, + ::core::ptr::null::(), + ) + }; } #[inline] -unsafe extern "C" fn mythread_mutex_destroy(mut mutex: *mut mythread_mutex) { - let mut ret: c_int = pthread_mutex_destroy(mutex as *mut pthread_mutex_t); +extern "C" fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_destroy(mutex as *mut pthread_mutex_t) }; } #[inline] -unsafe extern "C" fn mythread_mutex_lock(mut mutex: *mut mythread_mutex) { - let mut ret: c_int = pthread_mutex_lock(mutex as *mut pthread_mutex_t); +extern "C" fn mythread_mutex_lock(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_lock(mutex as *mut pthread_mutex_t) }; } #[inline] -unsafe extern "C" fn mythread_mutex_unlock(mut mutex: *mut mythread_mutex) { - let mut ret: c_int = pthread_mutex_unlock(mutex as *mut pthread_mutex_t); +extern "C" fn mythread_mutex_unlock(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_unlock(mutex as *mut pthread_mutex_t) }; } #[inline] -unsafe extern "C" fn mythread_cond_init(mut mycond: *mut mythread_cond) -> c_int { - (*mycond).clk_id = _CLOCK_REALTIME; - return pthread_cond_init( - &raw mut (*mycond).cond, - ::core::ptr::null::(), - ); +extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { + return unsafe { + (*mycond).clk_id = _CLOCK_REALTIME; + pthread_cond_init( + &raw mut (*mycond).cond, + ::core::ptr::null::(), + ) + }; } #[inline] -unsafe extern "C" fn mythread_cond_destroy(mut cond: *mut mythread_cond) { - let mut ret: c_int = pthread_cond_destroy(&raw mut (*cond).cond); +extern "C" fn mythread_cond_destroy(cond: *mut mythread_cond) { + let _ret: c_int = unsafe { pthread_cond_destroy(&raw mut (*cond).cond) }; } #[inline] -unsafe extern "C" fn mythread_cond_signal(mut cond: *mut mythread_cond) { - let mut ret: c_int = pthread_cond_signal(&raw mut (*cond).cond); +extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { + let _ret: c_int = unsafe { pthread_cond_signal(&raw mut (*cond).cond) }; } #[inline] -unsafe extern "C" fn mythread_cond_wait( - mut cond: *mut mythread_cond, - mut mutex: *mut mythread_mutex, -) { - let mut ret: c_int = pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t); +extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { + pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) + }; } #[inline] -unsafe extern "C" fn mythread_cond_timedwait( - mut cond: *mut mythread_cond, - mut mutex: *mut mythread_mutex, - mut condtime: *const mythread_condtime, +extern "C" fn mythread_cond_timedwait( + cond: *mut mythread_cond, + mutex: *mut mythread_mutex, + condtime: *const mythread_condtime, ) -> c_int { - let mut ret: c_int = pthread_cond_timedwait( - &raw mut (*cond).cond, - mutex as *mut pthread_mutex_t, - condtime as *const timespec, - ); + let ret: c_int = unsafe { + pthread_cond_timedwait( + &raw mut (*cond).cond, + mutex as *mut pthread_mutex_t, + condtime as *const timespec, + ) + }; return ret; } #[inline] -unsafe extern "C" fn mythread_condtime_set( - mut condtime: *mut mythread_condtime, - mut cond: *const mythread_cond, - mut timeout_ms: u32, +extern "C" fn mythread_condtime_set( + condtime: *mut mythread_condtime, + cond: *const mythread_cond, + timeout_ms: u32, ) { - (*condtime).tv_sec = timeout_ms.wrapping_div(1000 as u32) as time_t as __darwin_time_t; - (*condtime).tv_nsec = timeout_ms - .wrapping_rem(1000 as u32) - .wrapping_mul(1000000 as u32) as c_long; - let mut now: timespec = timespec { - tv_sec: 0, - tv_nsec: 0, - }; - let mut ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); - (*condtime).tv_sec += now.tv_sec; - (*condtime).tv_nsec += now.tv_nsec; - if (*condtime).tv_nsec >= 1000000000 as c_long { - (*condtime).tv_nsec -= 1000000000 as c_long; - (*condtime).tv_sec += 1; + unsafe { + (*condtime).tv_sec = timeout_ms.wrapping_div(1000) as time_t as __darwin_time_t; + (*condtime).tv_nsec = timeout_ms.wrapping_rem(1000).wrapping_mul(1000000) as c_long; + let mut now: timespec = timespec { + tv_sec: 0, + tv_nsec: 0, + }; + let _ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); + (*condtime).tv_sec += now.tv_sec; + (*condtime).tv_nsec += now.tv_nsec; + if (*condtime).tv_nsec >= 1000000000 as c_long { + (*condtime).tv_nsec -= 1000000000 as c_long; + (*condtime).tv_sec += 1; + } } } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12 as c_int; -pub const LZMA_THREADS_MAX: c_int = 16384 as c_int; +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; +pub const LZMA_THREADS_MAX: c_int = 16384; pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; #[inline] -unsafe extern "C" fn lzma_outq_has_buf(mut outq: *const lzma_outq) -> bool { - return (*outq).bufs_in_use < (*outq).bufs_limit; +extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { + return unsafe { (*outq).bufs_in_use < (*outq).bufs_limit }; } #[inline] -unsafe extern "C" fn lzma_outq_is_empty(mut outq: *const lzma_outq) -> bool { - return (*outq).bufs_in_use == 0 as u32; +extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { + return unsafe { (*outq).bufs_in_use == 0 }; } pub const BLOCK_SIZE_MAX: c_ulonglong = UINT64_MAX.wrapping_div(LZMA_THREADS_MAX as u64); -unsafe extern "C" fn worker_error(mut thr: *mut worker_thread, mut ret: lzma_ret) { +unsafe extern "C" fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { let mut mythread_i_207: c_uint = 0; while if mythread_i_207 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); @@ -675,21 +670,21 @@ unsafe extern "C" fn worker_error(mut thr: *mut worker_thread, mut ret: lzma_ret } } unsafe extern "C" fn worker_encode( - mut thr: *mut worker_thread, - mut out_pos: *mut size_t, + thr: *mut worker_thread, + out_pos: *mut size_t, mut state: worker_state, ) -> worker_state { (*thr).block_options = lzma_block { - version: 0 as u32, + version: 0, header_size: 0, check: (*(*thr).coder).stream_flags.check, compressed_size: (*(*thr).outbuf).allocated as lzma_vli, uncompressed_size: (*(*thr).coder).block_size as lzma_vli, filters: &raw mut (*thr).filters as *mut lzma_filter, raw_check: [0; 64], - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), - reserved_ptr3: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), + reserved_ptr3: core::ptr::null_mut(), reserved_int1: 0, reserved_int2: 0, reserved_int3: 0, @@ -725,8 +720,8 @@ unsafe extern "C" fn worker_encode( worker_error(thr, ret); return THR_STOP; } - let mut in_pos: size_t = 0 as size_t; - let mut in_size: size_t = 0 as size_t; + let mut in_pos: size_t = 0; + let mut in_size: size_t = 0; *out_pos = (*thr).block_options.header_size as size_t; let out_size: size_t = (*(*thr).outbuf).allocated; loop { @@ -760,7 +755,7 @@ unsafe extern "C" fn worker_encode( } else { LZMA_RUN as c_int }) as lzma_action; - static mut in_chunk_max: size_t = 16384 as size_t; + static mut in_chunk_max: size_t = 16384; let mut in_limit: size_t = in_size; if in_size.wrapping_sub(in_pos) > in_chunk_max { in_limit = in_pos.wrapping_add(in_chunk_max); @@ -819,7 +814,7 @@ unsafe extern "C" fn worker_encode( if state >= THR_STOP { return state; } - *out_pos = 0 as size_t; + *out_pos = 0; ret = lzma_block_uncomp_encode( &raw mut (*thr).block_options, (*thr).in_0, @@ -842,8 +837,8 @@ unsafe extern "C" fn worker_encode( (*(*thr).outbuf).uncompressed_size = (*thr).block_options.uncompressed_size; return THR_FINISH; } -unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { - let mut thr: *mut worker_thread = thr_ptr as *mut worker_thread; +unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { + let thr: *mut worker_thread = thr_ptr as *mut worker_thread; let mut state: worker_state = THR_IDLE; loop { let mut mythread_i_370: c_uint = 0; @@ -872,7 +867,7 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { } mythread_i_370 = 1; } - let mut out_pos: size_t = 0 as size_t; + let mut out_pos: size_t = 0; if state <= THR_FINISH { state = worker_encode(thr, &raw mut out_pos, state); } @@ -911,15 +906,15 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { while mythread_j_408 == 0 { if state == THR_FINISH { (*(*thr).outbuf).pos = out_pos; - (*(*thr).outbuf).finished = true_0 != 0; + (*(*thr).outbuf).finished = true; } (*(*thr).coder).progress_in = (*(*thr).coder) .progress_in .wrapping_add((*(*thr).outbuf).uncompressed_size as u64); (*(*thr).coder).progress_out = (*(*thr).coder).progress_out.wrapping_add(out_pos as u64); - (*thr).progress_in = 0 as u64; - (*thr).progress_out = 0 as u64; + (*thr).progress_in = 0; + (*thr).progress_out = 0; (*thr).next = (*(*thr).coder).threads_free; (*(*thr).coder).threads_free = thr; mythread_cond_signal(&raw mut (*(*thr).coder).cond); @@ -938,8 +933,8 @@ unsafe extern "C" fn worker_start(mut thr_ptr: *mut c_void) -> *mut c_void { lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); return MYTHREAD_RET_VALUE; } -unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder, mut wait_for_threads: bool) { - let mut i: u32 = 0 as u32; +unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_threads: bool) { + let mut i: u32 = 0; while i < (*coder).threads_initialized { let mut mythread_i_449: c_uint = 0; while if mythread_i_449 != 0 { @@ -963,7 +958,7 @@ unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder, mut wait_fo if !wait_for_threads { return; } - let mut i_0: u32 = 0 as u32; + let mut i_0: u32 = 0; while i_0 < (*coder).threads_initialized { let mut mythread_i_460: c_uint = 0; while if mythread_i_460 != 0 { @@ -989,11 +984,8 @@ unsafe extern "C" fn threads_stop(mut coder: *mut lzma_stream_coder, mut wait_fo i_0 = i_0.wrapping_add(1); } } -unsafe extern "C" fn threads_end( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, -) { - let mut i: u32 = 0 as u32; +unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) { + let mut i: u32 = 0; while i < (*coder).threads_initialized { let mut mythread_i_477: c_uint = 0; while if mythread_i_477 != 0 { @@ -1014,18 +1006,18 @@ unsafe extern "C" fn threads_end( } i = i.wrapping_add(1); } - let mut i_0: u32 = 0 as u32; + let mut i_0: u32 = 0; while i_0 < (*coder).threads_initialized { - let mut ret: c_int = mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); + let _ret: c_int = mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); i_0 = i_0.wrapping_add(1); } lzma_free((*coder).threads as *mut c_void, allocator); } unsafe extern "C" fn initialize_new_thread( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, ) -> lzma_ret { - let mut thr: *mut worker_thread = (*coder) + let thr: *mut worker_thread = (*coder) .threads .offset((*coder).threads_initialized as isize) as *mut worker_thread; @@ -1038,12 +1030,12 @@ unsafe extern "C" fn initialize_new_thread( (*thr).state = THR_IDLE; (*thr).allocator = allocator; (*thr).coder = coder; - (*thr).progress_in = 0 as u64; - (*thr).progress_out = 0 as u64; + (*thr).progress_in = 0; + (*thr).progress_out = 0; (*thr).block_encoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -1072,8 +1064,8 @@ unsafe extern "C" fn initialize_new_thread( return LZMA_MEM_ERROR; } unsafe extern "C" fn get_thread( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, ) -> lzma_ret { if !lzma_outq_has_buf(&raw mut (*coder).outq) { return LZMA_OK; @@ -1136,8 +1128,9 @@ unsafe extern "C" fn get_thread( let mut mythread_j_578: c_uint = 0; while mythread_j_578 == 0 { (*(*coder).thr).state = THR_RUN; - (*(*coder).thr).in_size = 0 as size_t; - (*(*coder).thr).outbuf = lzma_outq_get_buf(&raw mut (*coder).outq, NULL); + (*(*coder).thr).in_size = 0; + (*(*coder).thr).outbuf = + lzma_outq_get_buf(&raw mut (*coder).outq, core::ptr::null_mut()); lzma_filters_free( &raw mut (*(*coder).thr).filters as *mut lzma_filter, allocator, @@ -1145,7 +1138,7 @@ unsafe extern "C" fn get_thread( memcpy( &raw mut (*(*coder).thr).filters as *mut lzma_filter as *mut c_void, &raw mut (*coder).filters_cache as *mut lzma_filter as *const c_void, - ::core::mem::size_of::<[lzma_filter; 5]>() as size_t, + core::mem::size_of::<[lzma_filter; 5]>() as size_t, ); (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN as lzma_vli; mythread_cond_signal(&raw mut (*(*coder).thr).cond); @@ -1156,12 +1149,12 @@ unsafe extern "C" fn get_thread( return LZMA_OK; } unsafe extern "C" fn stream_encode_in( - mut coder: *mut lzma_stream_coder, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut action: lzma_action, + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + action: lzma_action, ) -> lzma_ret { while *in_pos < in_size || !(*coder).thr.is_null() && action != LZMA_RUN { if (*coder).thr.is_null() { @@ -1181,7 +1174,7 @@ unsafe extern "C" fn stream_encode_in( ); let finish: bool = thr_in_size == (*coder).block_size || *in_pos == in_size && action != LZMA_RUN; - let mut block_error: bool = false_0 != 0; + let mut block_error: bool = false; let mut mythread_i_628: c_uint = 0; while if mythread_i_628 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); @@ -1194,7 +1187,7 @@ unsafe extern "C" fn stream_encode_in( let mut mythread_j_628: c_uint = 0; while mythread_j_628 == 0 { if (*(*coder).thr).state == THR_IDLE { - block_error = true_0 != 0; + block_error = true; } else { (*(*coder).thr).in_size = thr_in_size; if finish { @@ -1227,22 +1220,22 @@ unsafe extern "C" fn stream_encode_in( return ret_0; } if finish { - (*coder).thr = ::core::ptr::null_mut::(); + (*coder).thr = core::ptr::null_mut(); } } return LZMA_OK; } unsafe extern "C" fn wait_for_work( - mut coder: *mut lzma_stream_coder, - mut wait_abs: *mut mythread_condtime, - mut has_blocked: *mut bool, - mut has_input: bool, + coder: *mut lzma_stream_coder, + wait_abs: *mut mythread_condtime, + has_blocked: *mut bool, + has_input: bool, ) -> bool { - if (*coder).timeout != 0 as u32 && !*has_blocked { - *has_blocked = true_0 != 0; + if (*coder).timeout != 0 && !*has_blocked { + *has_blocked = true; mythread_condtime_set(wait_abs, &raw mut (*coder).cond, (*coder).timeout); } - let mut timed_out: bool = false_0 != 0; + let mut timed_out: bool = false; let mut mythread_i_689: c_uint = 0; while if mythread_i_689 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); @@ -1261,7 +1254,7 @@ unsafe extern "C" fn wait_for_work( && (*coder).thread_error == LZMA_OK && !timed_out { - if (*coder).timeout != 0 as u32 { + if (*coder).timeout != 0 { timed_out = mythread_cond_timedwait( &raw mut (*coder).cond, &raw mut (*coder).mutex, @@ -1278,17 +1271,17 @@ unsafe extern "C" fn wait_for_work( return timed_out; } unsafe extern "C" fn stream_encode_mt( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; 's_270: { let mut current_block_53: u64; match (*coder).sequence { @@ -1296,15 +1289,15 @@ unsafe extern "C" fn stream_encode_mt( lzma_bufcpy( &raw mut (*coder).header as *mut u8, &raw mut (*coder).header_pos, - ::core::mem::size_of::<[u8; 12]>() as size_t, + core::mem::size_of::<[u8; 12]>() as size_t, out, out_pos, out_size, ); - if (*coder).header_pos < ::core::mem::size_of::<[u8; 12]>() as usize { + if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() as usize { return LZMA_OK; } - (*coder).header_pos = 0 as size_t; + (*coder).header_pos = 0; (*coder).sequence = SEQ_BLOCK; current_block_53 = 18046538441878631153; } @@ -1326,7 +1319,7 @@ unsafe extern "C" fn stream_encode_mt( let mut unpadded_size: lzma_vli = 0 as lzma_vli; let mut uncompressed_size: lzma_vli = 0 as lzma_vli; let mut ret: lzma_ret = LZMA_OK; - let mut has_blocked: bool = false_0 != 0; + let mut has_blocked: bool = false; let mut wait_abs: mythread_condtime = timespec { tv_sec: 0 as __darwin_time_t, tv_nsec: 0, @@ -1368,7 +1361,7 @@ unsafe extern "C" fn stream_encode_mt( uncompressed_size, ); if ret != LZMA_OK { - threads_stop(coder, false_0 != 0); + threads_stop(coder, false); return ret; } if *out_pos < out_size { @@ -1376,12 +1369,12 @@ unsafe extern "C" fn stream_encode_mt( } } if ret != LZMA_OK { - threads_stop(coder, false_0 != 0); + threads_stop(coder, false); return ret; } ret = stream_encode_in(coder, allocator, in_0, in_pos, in_size, action); if ret != LZMA_OK { - threads_stop(coder, false_0 != 0); + threads_stop(coder, false); return ret; } if *in_pos == in_size { @@ -1439,8 +1432,8 @@ unsafe extern "C" fn stream_encode_mt( (*coder).index_encoder.coder, allocator, ::core::ptr::null::(), - ::core::ptr::null_mut::(), - 0 as size_t, + core::ptr::null_mut(), + 0, out, out_pos, out_size, @@ -1464,12 +1457,12 @@ unsafe extern "C" fn stream_encode_mt( lzma_bufcpy( &raw mut (*coder).header as *mut u8, &raw mut (*coder).header_pos, - ::core::mem::size_of::<[u8; 12]>() as size_t, + core::mem::size_of::<[u8; 12]>() as size_t, out, out_pos, out_size, ); - return (if (*coder).header_pos < ::core::mem::size_of::<[u8; 12]>() as usize { + return (if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() as usize { LZMA_OK as c_int } else { LZMA_STREAM_END as c_int @@ -1478,10 +1471,10 @@ unsafe extern "C" fn stream_encode_mt( return LZMA_PROG_ERROR; } unsafe extern "C" fn stream_encoder_mt_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, ) { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; threads_end(coder, allocator); lzma_outq_end(&raw mut (*coder).outq, allocator); lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); @@ -1496,12 +1489,12 @@ unsafe extern "C" fn stream_encoder_mt_end( lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn stream_encoder_mt_update( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter, - mut reversed_filters: *const lzma_filter, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + _reversed_filters: *const lzma_filter, ) -> lzma_ret { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; if (*coder).sequence > SEQ_BLOCK { return LZMA_PROG_ERROR; } @@ -1513,7 +1506,7 @@ unsafe extern "C" fn stream_encoder_mt_update( } let mut temp: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5]; let ret_: lzma_ret = lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator) as lzma_ret; @@ -1528,22 +1521,22 @@ unsafe extern "C" fn stream_encoder_mt_update( memcpy( &raw mut (*coder).filters as *mut lzma_filter as *mut c_void, &raw mut temp as *mut lzma_filter as *const c_void, - ::core::mem::size_of::<[lzma_filter; 5]>() as size_t, + core::mem::size_of::<[lzma_filter; 5]>() as size_t, ); return LZMA_OK; } unsafe extern "C" fn get_options( - mut options: *const lzma_mt, - mut opt_easy: *mut lzma_options_easy, - mut filters: *mut *const lzma_filter, - mut block_size: *mut u64, - mut outbuf_size_max: *mut u64, + options: *const lzma_mt, + opt_easy: *mut lzma_options_easy, + filters: *mut *const lzma_filter, + block_size: *mut u64, + outbuf_size_max: *mut u64, ) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; } - if (*options).flags != 0 as u32 - || (*options).threads == 0 as u32 + if (*options).flags != 0 + || (*options).threads == 0 || (*options).threads > LZMA_THREADS_MAX as u32 { return LZMA_OPTIONS_ERROR; @@ -1556,7 +1549,7 @@ unsafe extern "C" fn get_options( } *filters = &raw mut (*opt_easy).filters as *mut lzma_filter; } - if (*options).block_size > 0 as u64 { + if (*options).block_size > 0 { *block_size = (*options).block_size; } else { *block_size = lzma_mt_block_size(*filters); @@ -1565,17 +1558,17 @@ unsafe extern "C" fn get_options( return LZMA_OPTIONS_ERROR; } *outbuf_size_max = lzma_block_buffer_bound64(*block_size); - if *outbuf_size_max == 0 as u64 { + if *outbuf_size_max == 0 { return LZMA_MEM_ERROR; } return LZMA_OK; } unsafe extern "C" fn get_progress( - mut coder_ptr: *mut c_void, - mut progress_in: *mut u64, - mut progress_out: *mut u64, + coder_ptr: *mut c_void, + progress_in: *mut u64, + progress_out: *mut u64, ) { - let mut coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; + let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; let mut mythread_i_1010: c_uint = 0; while if mythread_i_1010 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); @@ -1589,7 +1582,7 @@ unsafe extern "C" fn get_progress( while mythread_j_1010 == 0 { *progress_in = (*coder).progress_in; *progress_out = (*coder).progress_out; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < (*coder).threads_initialized as size_t { let mut mythread_i_1015: c_uint = 0; while if mythread_i_1015 != 0 { @@ -1618,9 +1611,9 @@ unsafe extern "C" fn get_progress( } } unsafe extern "C" fn stream_encoder_mt_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut options: *const lzma_mt, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_mt, ) -> lzma_ret { if ::core::mem::transmute::< Option< @@ -1662,7 +1655,7 @@ unsafe extern "C" fn stream_encoder_mt_init( let mut easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, @@ -1687,8 +1680,8 @@ unsafe extern "C" fn stream_encoder_mt_init( reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), }, }; let mut filters: *const lzma_filter = ::core::ptr::null::(); @@ -1716,7 +1709,7 @@ unsafe extern "C" fn stream_encoder_mt_init( let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_stream_coder; if coder.is_null() { @@ -1725,13 +1718,13 @@ unsafe extern "C" fn stream_encoder_mt_init( (*next).coder = coder as *mut c_void; if mythread_mutex_init(&raw mut (*coder).mutex) != 0 { lzma_free(coder as *mut c_void, allocator); - (*next).coder = NULL; + (*next).coder = core::ptr::null_mut(); return LZMA_MEM_ERROR; } if mythread_cond_init(&raw mut (*coder).cond) != 0 { mythread_mutex_destroy(&raw mut (*coder).mutex); lzma_free(coder as *mut c_void, allocator); - (*next).coder = NULL; + (*next).coder = core::ptr::null_mut(); return LZMA_MEM_ERROR; } (*next).code = Some( @@ -1774,9 +1767,9 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN as lzma_vli; (*coder).index_encoder = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -1785,30 +1778,30 @@ unsafe extern "C" fn stream_encoder_mt_init( update: None, set_out_limit: None, }; - (*coder).index = ::core::ptr::null_mut::(); + (*coder).index = core::ptr::null_mut(); memset( &raw mut (*coder).outq as *mut c_void, 0 as c_int, - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, ); - (*coder).threads = ::core::ptr::null_mut::(); - (*coder).threads_max = 0 as u32; - (*coder).threads_initialized = 0 as u32; + (*coder).threads = core::ptr::null_mut(); + (*coder).threads_max = 0; + (*coder).threads_initialized = 0; } (*coder).sequence = SEQ_STREAM_HEADER; (*coder).block_size = block_size as size_t; (*coder).outbuf_alloc_size = outbuf_size_max as size_t; (*coder).thread_error = LZMA_OK; - (*coder).thr = ::core::ptr::null_mut::(); + (*coder).thr = core::ptr::null_mut(); if (*coder).threads_max != (*options).threads { threads_end(coder, allocator); - (*coder).threads = ::core::ptr::null_mut::(); - (*coder).threads_max = 0 as u32; - (*coder).threads_initialized = 0 as u32; - (*coder).threads_free = ::core::ptr::null_mut::(); + (*coder).threads = core::ptr::null_mut(); + (*coder).threads_max = 0; + (*coder).threads_initialized = 0; + (*coder).threads_free = core::ptr::null_mut(); (*coder).threads = lzma_alloc( ((*options).threads as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::() as size_t), allocator, ) as *mut worker_thread; if (*coder).threads.is_null() { @@ -1816,7 +1809,7 @@ unsafe extern "C" fn stream_encoder_mt_init( } (*coder).threads_max = (*options).threads; } else { - threads_stop(coder, true_0 != 0); + threads_stop(coder, true); } let ret__0: lzma_ret = lzma_outq_init(&raw mut (*coder).outq, allocator, (*options).threads) as lzma_ret; @@ -1842,7 +1835,7 @@ unsafe extern "C" fn stream_encoder_mt_init( if (*coder).index.is_null() { return LZMA_MEM_ERROR; } - (*coder).stream_flags.version = 0 as u32; + (*coder).stream_flags.version = 0; (*coder).stream_flags.check = (*options).check; let ret__2: lzma_ret = lzma_stream_header_encode( &raw mut (*coder).stream_flags, @@ -1851,15 +1844,15 @@ unsafe extern "C" fn stream_encoder_mt_init( if ret__2 != LZMA_OK { return ret__2; } - (*coder).header_pos = 0 as size_t; - (*coder).progress_in = 0 as u64; + (*coder).header_pos = 0; + (*coder).progress_in = 0; (*coder).progress_out = LZMA_STREAM_HEADER_SIZE as u64; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder_mt( - mut strm: *mut lzma_stream, - mut options: *const lzma_mt, + strm: *mut lzma_stream, + options: *const lzma_mt, ) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; if ret_ != LZMA_OK { @@ -1874,18 +1867,18 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( lzma_end(strm); return ret__0; } - (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FULL_FLUSH as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FULL_BARRIER as usize] = true_0 != 0; - (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true_0 != 0; + (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FULL_FLUSH as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FULL_BARRIER as usize] = true; + (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(mut options: *const lzma_mt) -> u64 { +pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64 { let mut easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, @@ -1910,8 +1903,8 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(mut options: *const lzm reserved_enum2: LZMA_RESERVED_ENUM, reserved_enum3: LZMA_RESERVED_ENUM, reserved_enum4: LZMA_RESERVED_ENUM, - reserved_ptr1: ::core::ptr::null_mut::(), - reserved_ptr2: ::core::ptr::null_mut::(), + reserved_ptr1: core::ptr::null_mut(), + reserved_ptr2: core::ptr::null_mut(), }, }; let mut filters: *const lzma_filter = ::core::ptr::null::(); @@ -1938,10 +1931,10 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(mut options: *const lzm return UINT64_MAX as u64; } let mut total_memusage: u64 = (LZMA_MEMUSAGE_BASE as u64) - .wrapping_add(::core::mem::size_of::() as u64) + .wrapping_add(core::mem::size_of::() as u64) .wrapping_add( ((*options).threads as usize) - .wrapping_mul(::core::mem::size_of::() as usize) as u64, + .wrapping_mul(core::mem::size_of::() as usize) as u64, ); if (UINT64_MAX as u64).wrapping_sub(total_memusage) < inbuf_memusage { return UINT64_MAX as u64; diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index 29d5185e..aff79731 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong}; +use core::ffi::{c_int, c_ulonglong}; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; @@ -50,26 +50,28 @@ pub struct lzma_stream_flags { pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4 as c_int; +pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4; pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; #[inline] -unsafe extern "C" fn is_backward_size_valid(mut options: *const lzma_stream_flags) -> bool { - return (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli - && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli - && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli; +extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { + return unsafe { + (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli + && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli + && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli + }; } #[no_mangle] pub static mut lzma_header_magic: [u8; 6] = [ - 0xfd as u8, 0x37 as u8, 0x7a as u8, 0x58 as u8, 0x5a as u8, 0 as u8, + 0xfd as u8, 0x37 as u8, 0x7a as u8, 0x58 as u8, 0x5a as u8, 0, ]; #[no_mangle] pub static mut lzma_footer_magic: [u8; 2] = [0x59 as u8, 0x5a as u8]; #[no_mangle] pub unsafe extern "C" fn lzma_stream_flags_compare( - mut a: *const lzma_stream_flags, - mut b: *const lzma_stream_flags, + a: *const lzma_stream_flags, + b: *const lzma_stream_flags, ) -> lzma_ret { - if (*a).version != 0 as u32 || (*b).version != 0 as u32 { + if (*a).version != 0 || (*b).version != 0 { return LZMA_OPTIONS_ERROR; } if (*a).check > LZMA_CHECK_ID_MAX || (*b).check > LZMA_CHECK_ID_MAX { diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 8f775049..3d7f862d 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; @@ -54,50 +54,50 @@ pub struct lzma_stream_flags { pub reserved_int2: u32, } pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0) as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - return num; +extern "C" fn read32le(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; + num + }; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2 as c_int; -unsafe extern "C" fn stream_flags_decode( - mut options: *mut lzma_stream_flags, - mut in_0: *const u8, -) -> bool { - if *in_0.offset(0) as c_int != 0 as c_int || *in_0.offset(1) as c_int & 0xf0 as c_int != 0 { - return true_0 != 0; - } - (*options).version = 0 as u32; - (*options).check = (*in_0.offset(1) as c_int & 0xf as c_int) as lzma_check; - return false_0 != 0; +pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2; +extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> bool { + return unsafe { + if *in_0.offset(0) as c_int != 0 as c_int || *in_0.offset(1) as c_int & 0xf0 as c_int != 0 + { + return true; + } + (*options).version = 0; + (*options).check = (*in_0.offset(1) as c_int & 0xf as c_int) as lzma_check; + false + }; } #[no_mangle] pub unsafe extern "C" fn lzma_stream_header_decode( - mut options: *mut lzma_stream_flags, - mut in_0: *const u8, + options: *mut lzma_stream_flags, + in_0: *const u8, ) -> lzma_ret { if memcmp( in_0 as *const c_void, &raw const lzma_header_magic as *const u8 as *const c_void, - ::core::mem::size_of::<[u8; 6]>() as size_t, + core::mem::size_of::<[u8; 6]>() as size_t, ) != 0 as c_int { return LZMA_FORMAT_ERROR; } let crc: u32 = lzma_crc32( - in_0.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize), + in_0.offset(core::mem::size_of::<[u8; 6]>() as usize as isize), LZMA_STREAM_FLAGS_SIZE as size_t, - 0 as u32, + 0, ) as u32; if crc != read32le( - in_0.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize) + in_0.offset(core::mem::size_of::<[u8; 6]>() as usize as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize), ) { @@ -105,7 +105,7 @@ pub unsafe extern "C" fn lzma_stream_header_decode( } if stream_flags_decode( options, - in_0.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize), + in_0.offset(core::mem::size_of::<[u8; 6]>() as usize as isize), ) { return LZMA_OPTIONS_ERROR; } @@ -114,34 +114,34 @@ pub unsafe extern "C" fn lzma_stream_header_decode( } #[no_mangle] pub unsafe extern "C" fn lzma_stream_footer_decode( - mut options: *mut lzma_stream_flags, - mut in_0: *const u8, + options: *mut lzma_stream_flags, + in_0: *const u8, ) -> lzma_ret { if memcmp( - in_0.offset((::core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize) + in_0.offset((core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *const c_void, &raw const lzma_footer_magic as *const u8 as *const c_void, - ::core::mem::size_of::<[u8; 2]>() as size_t, + core::mem::size_of::<[u8; 2]>() as size_t, ) != 0 as c_int { return LZMA_FORMAT_ERROR; } let crc: u32 = lzma_crc32( - in_0.offset(::core::mem::size_of::() as usize as isize), - (::core::mem::size_of::() as size_t).wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), - 0 as u32, + in_0.offset(core::mem::size_of::() as usize as isize), + (core::mem::size_of::() as size_t).wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), + 0, ) as u32; if crc != read32le(in_0) { return LZMA_DATA_ERROR; } if stream_flags_decode( options, - in_0.offset((::core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize), + in_0.offset((core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize), ) { return LZMA_OPTIONS_ERROR; } (*options).backward_size = - read32le(in_0.offset(::core::mem::size_of::() as usize as isize)) as lzma_vli; + read32le(in_0.offset(core::mem::size_of::() as usize as isize)) as lzma_vli; (*options).backward_size = (*options) .backward_size .wrapping_add(1 as lzma_vli) diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 935581bb..94f8e67e 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; @@ -53,62 +53,63 @@ pub struct lzma_stream_flags { pub reserved_int1: u32, pub reserved_int2: u32, } -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0) = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; +extern "C" fn write32le(buf: *mut u8, num: u32) { + unsafe { + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; + } } pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4 as c_int; +pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4; pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; -pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2 as c_int; +pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2; #[inline] -unsafe extern "C" fn is_backward_size_valid(mut options: *const lzma_stream_flags) -> bool { - return (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli - && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli - && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli; +extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { + return unsafe { + (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli + && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli + && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli + }; } -unsafe extern "C" fn stream_flags_encode( - mut options: *const lzma_stream_flags, - mut out: *mut u8, -) -> bool { - if (*options).check > LZMA_CHECK_ID_MAX { - return true_0 != 0; - } - *out.offset(0) = 0 as u8; - *out.offset(1) = (*options).check as u8; - return false_0 != 0; +extern "C" fn stream_flags_encode(options: *const lzma_stream_flags, out: *mut u8) -> bool { + return unsafe { + if (*options).check > LZMA_CHECK_ID_MAX { + return true; + } + *out.offset(0) = 0; + *out.offset(1) = (*options).check as u8; + false + }; } #[no_mangle] pub unsafe extern "C" fn lzma_stream_header_encode( - mut options: *const lzma_stream_flags, - mut out: *mut u8, + options: *const lzma_stream_flags, + out: *mut u8, ) -> lzma_ret { - if (*options).version != 0 as u32 { + if (*options).version != 0 { return LZMA_OPTIONS_ERROR; } memcpy( out as *mut c_void, &raw const lzma_header_magic as *const u8 as *const c_void, - ::core::mem::size_of::<[u8; 6]>() as size_t, + core::mem::size_of::<[u8; 6]>() as size_t, ); if stream_flags_encode( options, - out.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize), + out.offset(core::mem::size_of::<[u8; 6]>() as usize as isize), ) { return LZMA_PROG_ERROR; } let crc: u32 = lzma_crc32( - out.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize), + out.offset(core::mem::size_of::<[u8; 6]>() as usize as isize), LZMA_STREAM_FLAGS_SIZE as size_t, - 0 as u32, + 0, ) as u32; write32le( - out.offset(::core::mem::size_of::<[u8; 6]>() as usize as isize) + out.offset(core::mem::size_of::<[u8; 6]>() as usize as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize), crc, ); @@ -116,10 +117,10 @@ pub unsafe extern "C" fn lzma_stream_header_encode( } #[no_mangle] pub unsafe extern "C" fn lzma_stream_footer_encode( - mut options: *const lzma_stream_flags, - mut out: *mut u8, + options: *const lzma_stream_flags, + out: *mut u8, ) -> lzma_ret { - if (*options).version != 0 as u32 { + if (*options).version != 0 { return LZMA_OPTIONS_ERROR; } if !is_backward_size_valid(options) { @@ -138,14 +139,14 @@ pub unsafe extern "C" fn lzma_stream_footer_encode( let crc: u32 = lzma_crc32( out.offset(4), (4 as c_int + LZMA_STREAM_FLAGS_SIZE) as size_t, - 0 as u32, + 0, ) as u32; write32le(out, crc); memcpy( out.offset((2 as c_int * 4) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut c_void, &raw const lzma_footer_magic as *const u8 as *const c_void, - ::core::mem::size_of::<[u8; 2]>() as size_t, + core::mem::size_of::<[u8; 2]>() as size_t, ); return LZMA_OK; } diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 6db51d8a..0dde3d36 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_char, c_int, c_long, c_uint, c_ulonglong, c_void}; extern "C" { fn memchr(__s: *const c_void, __c: c_int, __n: size_t) -> *mut c_void; fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; @@ -151,15 +151,11 @@ pub struct lzma_str { } pub type C2RustUnnamed_2 = c_uint; pub const OPTMAP_TYPE_UINT32: C2RustUnnamed_2 = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const INT_MAX: c_int = c_int::MAX; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: c_int = 4 as c_int; +pub const LZMA_FILTERS_MAX: c_int = 4; pub const LZMA_STR_ALL_FILTERS: c_uint = 0x1; pub const LZMA_STR_NO_VALIDATION: c_uint = 0x2; pub const LZMA_STR_ENCODER: c_uint = 0x10; @@ -175,52 +171,49 @@ pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; -pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; -pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; +pub const LZMA_DELTA_DIST_MIN: c_int = 1; +pub const LZMA_DELTA_DIST_MAX: c_int = 256; pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; pub const LZMA_DICT_SIZE_DEFAULT: c_uint = 1u32 << 23; -pub const LZMA_LCLP_MIN: c_int = 0 as c_int; -pub const LZMA_LCLP_MAX: c_int = 4 as c_int; -pub const LZMA_PB_MIN: c_int = 0 as c_int; -pub const LZMA_PB_MAX: c_int = 4 as c_int; +pub const LZMA_LCLP_MIN: c_int = 0; +pub const LZMA_LCLP_MAX: c_int = 4; +pub const LZMA_PB_MIN: c_int = 0; +pub const LZMA_PB_MAX: c_int = 4; pub const LZMA_PRESET_DEFAULT: c_uint = 6; pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; -pub const STR_ALLOC_SIZE: c_int = 800 as c_int; -unsafe extern "C" fn str_init( - mut str: *mut lzma_str, - mut allocator: *const lzma_allocator, -) -> lzma_ret { +pub const STR_ALLOC_SIZE: c_int = 800; +unsafe extern "C" fn str_init(str: *mut lzma_str, allocator: *const lzma_allocator) -> lzma_ret { (*str).buf = lzma_alloc(STR_ALLOC_SIZE as size_t, allocator) as *mut c_char; if (*str).buf.is_null() { return LZMA_MEM_ERROR; } - (*str).pos = 0 as size_t; + (*str).pos = 0; return LZMA_OK; } -unsafe extern "C" fn str_free(mut str: *mut lzma_str, mut allocator: *const lzma_allocator) { +unsafe extern "C" fn str_free(str: *mut lzma_str, allocator: *const lzma_allocator) { lzma_free((*str).buf as *mut c_void, allocator); } -unsafe extern "C" fn str_is_full(mut str: *const lzma_str) -> bool { +unsafe extern "C" fn str_is_full(str: *const lzma_str) -> bool { return (*str).pos == (STR_ALLOC_SIZE - 1 as c_int) as size_t; } unsafe extern "C" fn str_finish( - mut dest: *mut *mut c_char, - mut str: *mut lzma_str, - mut allocator: *const lzma_allocator, + dest: *mut *mut c_char, + str: *mut lzma_str, + allocator: *const lzma_allocator, ) -> lzma_ret { if str_is_full(str) { lzma_free((*str).buf as *mut c_void, allocator); - *dest = ::core::ptr::null_mut::(); + *dest = core::ptr::null_mut(); return LZMA_PROG_ERROR; } *(*str).buf.offset((*str).pos as isize) = '\0' as i32 as c_char; *dest = (*str).buf; return LZMA_OK; } -unsafe extern "C" fn str_append_str(mut str: *mut lzma_str, mut s: *const c_char) { +unsafe extern "C" fn str_append_str(str: *mut lzma_str, s: *const c_char) { let len: size_t = strlen(s) as size_t; let limit: size_t = ((STR_ALLOC_SIZE - 1 as c_int) as size_t).wrapping_sub((*str).pos); let copy_size: size_t = if len < limit { len } else { limit }; @@ -231,8 +224,8 @@ unsafe extern "C" fn str_append_str(mut str: *mut lzma_str, mut s: *const c_char ); (*str).pos = (*str).pos.wrapping_add(copy_size); } -unsafe extern "C" fn str_append_u32(mut str: *mut lzma_str, mut v: u32, mut use_byte_suffix: bool) { - if v == 0 as u32 { +unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) { + if v == 0 { str_append_str(str, b"0\0" as *const u8 as *const c_char); } else { static mut suffixes: [[c_char; 4]; 4] = unsafe { @@ -243,12 +236,12 @@ unsafe extern "C" fn str_append_u32(mut str: *mut lzma_str, mut v: u32, mut use_ ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"GiB\0"), ] }; - let mut suf: size_t = 0 as size_t; + let mut suf: size_t = 0; if use_byte_suffix { - while v & 1023 as u32 == 0 as u32 + while v & 1023 == 0 && suf - < (::core::mem::size_of::<[[c_char; 4]; 4]>() as usize) - .wrapping_div(::core::mem::size_of::<[c_char; 4]>() as usize) + < (core::mem::size_of::<[[c_char; 4]; 4]>() as usize) + .wrapping_div(core::mem::size_of::<[c_char; 4]>() as usize) .wrapping_sub(1 as usize) { v >>= 10 as c_int; @@ -257,14 +250,12 @@ unsafe extern "C" fn str_append_u32(mut str: *mut lzma_str, mut v: u32, mut use_ } let mut buf: [c_char; 16] = ::core::mem::transmute::<[u8; 16], [c_char; 16]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); - let mut pos: size_t = - (::core::mem::size_of::<[c_char; 16]>() as size_t).wrapping_sub(1 as size_t); + let mut pos: size_t = (core::mem::size_of::<[c_char; 16]>() as size_t).wrapping_sub(1); loop { pos = pos.wrapping_sub(1); - buf[pos as usize] = - ('0' as i32 as u32).wrapping_add(v.wrapping_rem(10 as u32)) as c_char; - v = v.wrapping_div(10 as u32); - if !(v != 0 as u32) { + buf[pos as usize] = ('0' as i32 as u32).wrapping_add(v.wrapping_rem(10)) as c_char; + v = v.wrapping_div(10); + if !(v != 0) { break; } } @@ -276,7 +267,7 @@ unsafe extern "C" fn str_append_u32(mut str: *mut lzma_str, mut v: u32, mut use_ ); }; } -pub const NAME_LEN_MAX: c_int = 11 as c_int; +pub const NAME_LEN_MAX: c_int = 11; pub const OPTMAP_USE_NAME_VALUE_MAP: c_int = 0x1 as c_int; pub const OPTMAP_USE_BYTE_SUFFIX: c_int = 0x2 as c_int; pub const OPTMAP_NO_STRFY_ZERO: c_int = 0x4 as c_int; @@ -285,35 +276,37 @@ static mut bcj_optmap: [option_map; 1] = unsafe { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"start\0\0\0\0\0\0\0"), type_0: 0, flags: (OPTMAP_NO_STRFY_ZERO | OPTMAP_USE_BYTE_SUFFIX) as u8, - offset: 0 as c_ulong as u16, + offset: 0, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: 0 as u32, + min: 0, max: UINT32_MAX as u32, }, }, }] }; -unsafe extern "C" fn parse_bcj( +extern "C" fn parse_bcj( str: *mut *const c_char, - mut str_end: *const c_char, - mut filter_options: *mut c_void, + str_end: *const c_char, + filter_options: *mut c_void, ) -> *const c_char { - return parse_options( - str, - str_end, - filter_options, - &raw const bcj_optmap as *const option_map, - (::core::mem::size_of::<[option_map; 1]>() as size_t) - .wrapping_div(::core::mem::size_of::() as size_t), - ); + return unsafe { + parse_options( + str, + str_end, + filter_options, + &raw const bcj_optmap as *const option_map, + (core::mem::size_of::<[option_map; 1]>() as size_t) + .wrapping_div(core::mem::size_of::() as size_t), + ) + }; } static mut delta_optmap: [option_map; 1] = unsafe { [option_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dist\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 4 as c_ulong as u16, + offset: 4, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: LZMA_DELTA_DIST_MIN as u32, @@ -322,29 +315,31 @@ static mut delta_optmap: [option_map; 1] = unsafe { }, }] }; -unsafe extern "C" fn parse_delta( +extern "C" fn parse_delta( str: *mut *const c_char, - mut str_end: *const c_char, - mut filter_options: *mut c_void, + str_end: *const c_char, + filter_options: *mut c_void, ) -> *const c_char { - let mut opts: *mut lzma_options_delta = filter_options as *mut lzma_options_delta; - (*opts).type_0 = LZMA_DELTA_TYPE_BYTE; - (*opts).dist = LZMA_DELTA_DIST_MIN as u32; - return parse_options( - str, - str_end, - filter_options, - &raw const delta_optmap as *const option_map, - (::core::mem::size_of::<[option_map; 1]>() as size_t) - .wrapping_div(::core::mem::size_of::() as size_t), - ); + return unsafe { + let opts: *mut lzma_options_delta = filter_options as *mut lzma_options_delta; + (*opts).type_0 = LZMA_DELTA_TYPE_BYTE; + (*opts).dist = LZMA_DELTA_DIST_MIN as u32; + parse_options( + str, + str_end, + filter_options, + &raw const delta_optmap as *const option_map, + (core::mem::size_of::<[option_map; 1]>() as size_t) + .wrapping_div(core::mem::size_of::() as size_t), + ) + }; } pub const LZMA12_PRESET_STR: [c_char; 7] = unsafe { ::core::mem::transmute::<[u8; 7], [c_char; 7]>(*b"0-9[e]\0") }; unsafe extern "C" fn parse_lzma12_preset( str: *mut *const c_char, - mut str_end: *const c_char, - mut preset: *mut u32, + str_end: *const c_char, + preset: *mut u32, ) -> *const c_char { if !(**str as c_int >= '0' as i32 && **str as c_int <= '9' as i32) { return b"Unsupported preset\0" as *const u8 as *const c_char; @@ -368,21 +363,21 @@ unsafe extern "C" fn parse_lzma12_preset( } unsafe extern "C" fn set_lzma12_preset( str: *mut *const c_char, - mut str_end: *const c_char, - mut filter_options: *mut c_void, + str_end: *const c_char, + filter_options: *mut c_void, ) -> *const c_char { let mut preset: u32 = 0; - let mut errmsg: *const c_char = parse_lzma12_preset(str, str_end, &raw mut preset); + let errmsg: *const c_char = parse_lzma12_preset(str, str_end, &raw mut preset); if !errmsg.is_null() { return errmsg; } - let mut opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; + let opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; if lzma_lzma_preset(opts, preset) != 0 { return b"Unsupported preset\0" as *const u8 as *const c_char; } return ::core::ptr::null::(); } -static mut lzma12_mode_map: [name_value_map; 3] = unsafe { +static lzma12_mode_map: [name_value_map; 3] = unsafe { [ name_value_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"fast\0\0\0\0\0\0\0\0"), @@ -394,11 +389,11 @@ static mut lzma12_mode_map: [name_value_map; 3] = unsafe { }, name_value_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), - value: 0 as u32, + value: 0, }, ] }; -static mut lzma12_mf_map: [name_value_map; 6] = unsafe { +static lzma12_mf_map: [name_value_map; 6] = unsafe { [ name_value_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"hc3\0\0\0\0\0\0\0\0\0"), @@ -422,7 +417,7 @@ static mut lzma12_mf_map: [name_value_map; 6] = unsafe { }, name_value_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), - value: 0 as u32, + value: 0, }, ] }; @@ -437,18 +432,18 @@ static mut lzma12_optmap: [option_map; 9] = [option_map { }; 9]; unsafe extern "C" fn parse_lzma12( str: *mut *const c_char, - mut str_end: *const c_char, - mut filter_options: *mut c_void, + str_end: *const c_char, + filter_options: *mut c_void, ) -> *const c_char { - let mut opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; - let preset_ret: bool = lzma_lzma_preset(opts, LZMA_PRESET_DEFAULT as u32) != 0; - let mut errmsg: *const c_char = parse_options( + let opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; + let _preset_ret: bool = lzma_lzma_preset(opts, LZMA_PRESET_DEFAULT as u32) != 0; + let errmsg: *const c_char = parse_options( str, str_end, filter_options, &raw const lzma12_optmap as *const option_map, - (::core::mem::size_of::<[option_map; 9]>() as size_t) - .wrapping_div(::core::mem::size_of::() as size_t), + (core::mem::size_of::<[option_map; 9]>() as size_t) + .wrapping_div(core::mem::size_of::() as size_t), ); if !errmsg.is_null() { return errmsg; @@ -462,7 +457,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { [ C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma1\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_LZMA1 as lzma_vli, parse: Some( parse_lzma12 @@ -473,13 +468,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const lzma12_optmap as *const option_map, - strfy_encoder: 9 as u8, - strfy_decoder: 5 as u8, - allow_null: false_0 != 0, + strfy_encoder: 9, + strfy_decoder: 5, + allow_null: false, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma2\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_LZMA2 as lzma_vli, parse: Some( parse_lzma12 @@ -490,13 +485,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const lzma12_optmap as *const option_map, - strfy_encoder: 9 as u8, - strfy_decoder: 2 as u8, - allow_null: false_0 != 0, + strfy_encoder: 9, + strfy_decoder: 2, + allow_null: false, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"x86\0\0\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_X86 as lzma_vli, parse: Some( parse_bcj @@ -507,13 +502,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: true_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: true, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm\0\0\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARM as lzma_vli, parse: Some( parse_bcj @@ -524,13 +519,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: true_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: true, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"armthumb\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARMTHUMB as lzma_vli, parse: Some( parse_bcj @@ -541,13 +536,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: true_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: true, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm64\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARM64 as lzma_vli, parse: Some( parse_bcj @@ -558,13 +553,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: true_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: true, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"riscv\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_RISCV as lzma_vli, parse: Some( parse_bcj @@ -575,13 +570,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: true_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: true, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"powerpc\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_POWERPC as lzma_vli, parse: Some( parse_bcj @@ -592,13 +587,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: true_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: true, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"ia64\0\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_IA64 as lzma_vli, parse: Some( parse_bcj @@ -609,13 +604,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: true_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: true, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"sparc\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_SPARC as lzma_vli, parse: Some( parse_bcj @@ -626,13 +621,13 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const bcj_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: true_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: true, }, C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"delta\0\0\0\0\0\0\0"), - opts_size: ::core::mem::size_of::() as u32, + opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_DELTA as lzma_vli, parse: Some( parse_delta @@ -643,16 +638,16 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { ) -> *const c_char, ), optmap: &raw const delta_optmap as *const option_map, - strfy_encoder: 1 as u8, - strfy_decoder: 1 as u8, - allow_null: false_0 != 0, + strfy_encoder: 1, + strfy_decoder: 1, + allow_null: false, }, ] }; unsafe extern "C" fn parse_options( str: *mut *const c_char, - mut str_end: *const c_char, - mut filter_options: *mut c_void, + str_end: *const c_char, + filter_options: *mut c_void, optmap: *const option_map, optmap_size: size_t, ) -> *const c_char { @@ -666,7 +661,7 @@ unsafe extern "C" fn parse_options( if name_eq_value_end.is_null() { name_eq_value_end = str_end; } - let mut equals_sign: *const c_char = memchr( + let equals_sign: *const c_char = memchr( *str as *const c_void, '=' as i32, name_eq_value_end.offset_from(*str) as c_long as size_t, @@ -679,7 +674,7 @@ unsafe extern "C" fn parse_options( if name_len > NAME_LEN_MAX as size_t { return b"Unknown option name\0" as *const u8 as *const c_char; } - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; loop { if i == optmap_size { return b"Unknown option name\0" as *const u8 as *const c_char; @@ -697,11 +692,11 @@ unsafe extern "C" fn parse_options( } *str = equals_sign.offset(1); let value_len: size_t = name_eq_value_end.offset_from(*str) as c_long as size_t; - if value_len == 0 as size_t { + if value_len == 0 { return b"Option value cannot be empty\0" as *const u8 as *const c_char; } if (*optmap.offset(i as isize)).type_0 as c_int == OPTMAP_TYPE_LZMA_PRESET as c_int { - let mut errmsg: *const c_char = + let errmsg: *const c_char = set_lzma12_preset(str, name_eq_value_end, filter_options); if !errmsg.is_null() { return errmsg; @@ -712,8 +707,8 @@ unsafe extern "C" fn parse_options( if value_len > NAME_LEN_MAX as size_t { return b"Invalid option value\0" as *const u8 as *const c_char; } - let mut map: *const name_value_map = (*optmap.offset(i as isize)).u.map; - let mut j: size_t = 0 as size_t; + let map: *const name_value_map = (*optmap.offset(i as isize)).u.map; + let mut j: size_t = 0; loop { if (*map.offset(j as isize)).name[0] as c_int == '\0' as i32 { return b"Invalid option value\0" as *const u8 as *const c_char; @@ -738,12 +733,12 @@ unsafe extern "C" fn parse_options( as *const c_char; } else { let mut p: *const c_char = *str; - v = 0 as u32; + v = 0; loop { - if v > (UINT32_MAX as u32).wrapping_div(10 as u32) { + if v > (UINT32_MAX as u32).wrapping_div(10) { return b"Value out of range\0" as *const u8 as *const c_char; } - v = v.wrapping_mul(10 as u32); + v = v.wrapping_mul(10); let add: u32 = (*p as c_int - '0' as i32) as u32; if (UINT32_MAX as u32).wrapping_sub(add) < v { return b"Value out of range\0" as *const u8 as *const c_char; @@ -758,7 +753,7 @@ unsafe extern "C" fn parse_options( } } if p < name_eq_value_end { - let mut multiplier_start: *const c_char = p; + let multiplier_start: *const c_char = p; if (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_BYTE_SUFFIX == 0 as c_int { @@ -769,13 +764,13 @@ unsafe extern "C" fn parse_options( let mut shift: u32 = 0; match *p as c_int { 107 | 75 => { - shift = 10 as u32; + shift = 10; } 109 | 77 => { - shift = 20 as u32; + shift = 20; } 103 | 71 => { - shift = 30 as u32; + shift = 30; } _ => { *str = multiplier_start; @@ -807,7 +802,7 @@ unsafe extern "C" fn parse_options( return b"Value out of range\0" as *const u8 as *const c_char; } } - let mut ptr: *mut c_void = (filter_options as *mut c_char) + let ptr: *mut c_void = (filter_options as *mut c_char) .offset((*optmap.offset(i as isize)).offset as isize) as *mut c_void; match (*optmap.offset(i as isize)).type_0 as c_int { @@ -829,10 +824,10 @@ unsafe extern "C" fn parse_options( } unsafe extern "C" fn parse_filter( str: *mut *const c_char, - mut str_end: *const c_char, - mut filter: *mut lzma_filter, - mut allocator: *const lzma_allocator, - mut only_xz: bool, + str_end: *const c_char, + filter: *mut lzma_filter, + allocator: *const lzma_allocator, + only_xz: bool, ) -> *const c_char { let mut name_end: *const c_char = str_end; let mut opts_start: *const c_char = str_end; @@ -850,10 +845,10 @@ unsafe extern "C" fn parse_filter( if name_len > NAME_LEN_MAX as size_t { return b"Unknown filter name\0" as *const u8 as *const c_char; } - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i - < (::core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) - .wrapping_div(::core::mem::size_of::() as usize) + < (core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) + .wrapping_div(core::mem::size_of::() as usize) { if memcmp( *str as *const c_void, @@ -869,13 +864,13 @@ unsafe extern "C" fn parse_filter( return b"This filter cannot be used in the .xz format\0" as *const u8 as *const c_char; } - let mut options: *mut c_void = + let options: *mut c_void = lzma_alloc_zero(filter_name_map[i as usize].opts_size as size_t, allocator); if options.is_null() { return b"Memory allocation failed\0" as *const u8 as *const c_char; } *str = opts_start; - let mut errmsg: *const c_char = + let errmsg: *const c_char = filter_name_map[i as usize] .parse .expect("non-null function pointer")(str, str_end, options); @@ -893,9 +888,9 @@ unsafe extern "C" fn parse_filter( } unsafe extern "C" fn str_to_filters( str: *mut *const c_char, - mut filters: *mut lzma_filter, - mut flags: u32, - mut allocator: *const lzma_allocator, + filters: *mut lzma_filter, + flags: u32, + allocator: *const lzma_allocator, ) -> *const c_char { let mut current_block: u64; let mut errmsg: *const c_char = ::core::ptr::null::(); @@ -918,7 +913,7 @@ unsafe extern "C" fn str_to_filters( let mut str_end: *const c_char = memchr(*str as *const c_void, ' ' as i32, str_len) as *const c_char; if !str_end.is_null() { - let mut i: size_t = 1 as size_t; + let mut i: size_t = 1; while *str_end.offset(i as isize) as c_int != '\0' as i32 { if *str_end.offset(i as isize) as c_int != ' ' as i32 { return b"Unsupported preset\0" as *const u8 as *const c_char; @@ -933,8 +928,8 @@ unsafe extern "C" fn str_to_filters( if !errmsg.is_null() { return errmsg; } - let mut opts: *mut lzma_options_lzma = lzma_alloc( - ::core::mem::size_of::() as size_t, + let opts: *mut lzma_options_lzma = lzma_alloc( + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_options_lzma; if opts.is_null() { @@ -949,15 +944,15 @@ unsafe extern "C" fn str_to_filters( *fresh0 = opts as *mut c_void; (*filters.offset(1)).id = LZMA_VLI_UNKNOWN as lzma_vli; let ref mut fresh1 = (*filters.offset(1)).options; - *fresh1 = NULL; + *fresh1 = core::ptr::null_mut(); return ::core::ptr::null::(); } - let only_xz: bool = flags & LZMA_STR_ALL_FILTERS as u32 == 0 as u32; + let only_xz: bool = flags & LZMA_STR_ALL_FILTERS as u32 == 0; let mut temp_filters: [lzma_filter; 5] = [lzma_filter { id: 0, - options: ::core::ptr::null_mut::(), + options: core::ptr::null_mut(), }; 5]; - let mut i_0: size_t = 0 as size_t; + let mut i_0: size_t = 0; loop { if i_0 == LZMA_FILTERS_MAX as size_t { errmsg = b"The maximum number of filters is four\0" as *const u8 as *const c_char; @@ -1009,8 +1004,8 @@ unsafe extern "C" fn str_to_filters( match current_block { 15090052786889560393 => { temp_filters[i_0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; - temp_filters[i_0 as usize].options = NULL; - if flags & LZMA_STR_NO_VALIDATION as u32 == 0 as u32 { + temp_filters[i_0 as usize].options = core::ptr::null_mut(); + if flags & LZMA_STR_NO_VALIDATION as u32 == 0 { let mut dummy: size_t = 0; let ret: lzma_ret = lzma_validate_chain(&raw mut temp_filters as *mut lzma_filter, &raw mut dummy) @@ -1031,8 +1026,8 @@ unsafe extern "C" fn str_to_filters( memcpy( filters as *mut c_void, &raw mut temp_filters as *mut lzma_filter as *const c_void, - i_0.wrapping_add(1 as size_t) - .wrapping_mul(::core::mem::size_of::() as size_t), + i_0.wrapping_add(1) + .wrapping_mul(core::mem::size_of::() as size_t), ); return ::core::ptr::null::(); } @@ -1043,7 +1038,7 @@ unsafe extern "C" fn str_to_filters( loop { let fresh2 = i_0; i_0 = i_0.wrapping_sub(1); - if !(fresh2 > 0 as size_t) { + if !(fresh2 > 0) { break; } lzma_free(temp_filters[i_0 as usize].options, allocator); @@ -1052,25 +1047,25 @@ unsafe extern "C" fn str_to_filters( } #[no_mangle] pub unsafe extern "C" fn lzma_str_to_filters( - mut str: *const c_char, - mut error_pos: *mut c_int, - mut filters: *mut lzma_filter, - mut flags: u32, - mut allocator: *const lzma_allocator, + str: *const c_char, + error_pos: *mut c_int, + filters: *mut lzma_filter, + flags: u32, + allocator: *const lzma_allocator, ) -> *const c_char { if !error_pos.is_null() { *error_pos = 0 as c_int; } if str.is_null() || filters.is_null() { - return b"Unexpected NULL pointer argument(s) to lzma_str_to_filters()\0" as *const u8 - as *const c_char; + return b"Unexpected core::ptr::null_mut() pointer argument(s) to lzma_str_to_filters()\0" + as *const u8 as *const c_char; } let supported_flags: u32 = LZMA_STR_ALL_FILTERS as u32 | LZMA_STR_NO_VALIDATION as u32; if flags & !supported_flags != 0 { return b"Unsupported flags to lzma_str_to_filters()\0" as *const u8 as *const c_char; } let mut used: *const c_char = str; - let mut errmsg: *const c_char = str_to_filters(&raw mut used, filters, flags, allocator); + let errmsg: *const c_char = str_to_filters(&raw mut used, filters, flags, allocator); if !error_pos.is_null() { let n: size_t = used.offset_from(str) as c_long as size_t; *error_pos = if n > INT_MAX as size_t { @@ -1082,17 +1077,17 @@ pub unsafe extern "C" fn lzma_str_to_filters( return errmsg; } unsafe extern "C" fn strfy_filter( - mut dest: *mut lzma_str, + dest: *mut lzma_str, mut delimiter: *const c_char, - mut optmap: *const option_map, - mut optmap_count: size_t, - mut filter_options: *const c_void, + optmap: *const option_map, + optmap_count: size_t, + filter_options: *const c_void, ) { - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < optmap_count { if !((*optmap.offset(i as isize)).type_0 as c_int == OPTMAP_TYPE_LZMA_PRESET as c_int) { let mut v: u32 = 0; - let mut ptr: *const c_void = (filter_options as *const c_char) + let ptr: *const c_void = (filter_options as *const c_char) .offset((*optmap.offset(i as isize)).offset as isize) as *const c_void; match (*optmap.offset(i as isize)).type_0 as c_int { @@ -1106,8 +1101,7 @@ unsafe extern "C" fn strfy_filter( v = *(ptr as *const u32); } } - if !(v == 0 as u32 - && (*optmap.offset(i as isize)).flags as c_int & OPTMAP_NO_STRFY_ZERO != 0) + if !(v == 0 && (*optmap.offset(i as isize)).flags as c_int & OPTMAP_NO_STRFY_ZERO != 0) { str_append_str(dest, delimiter); delimiter = b",\0" as *const u8 as *const c_char; @@ -1117,8 +1111,8 @@ unsafe extern "C" fn strfy_filter( ); str_append_str(dest, b"=\0" as *const u8 as *const c_char); if (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_NAME_VALUE_MAP != 0 { - let mut map: *const name_value_map = (*optmap.offset(i as isize)).u.map; - let mut j: size_t = 0 as size_t; + let map: *const name_value_map = (*optmap.offset(i as isize)).u.map; + let mut j: size_t = 0; loop { if (*map.offset(j as isize)).name[0] as c_int == '\0' as i32 { str_append_str(dest, b"UNKNOWN\0" as *const u8 as *const c_char); @@ -1147,15 +1141,15 @@ unsafe extern "C" fn strfy_filter( } #[no_mangle] pub unsafe extern "C" fn lzma_str_from_filters( - mut output_str: *mut *mut c_char, - mut filters: *const lzma_filter, - mut flags: u32, - mut allocator: *const lzma_allocator, + output_str: *mut *mut c_char, + filters: *const lzma_filter, + flags: u32, + allocator: *const lzma_allocator, ) -> lzma_ret { if output_str.is_null() { return LZMA_PROG_ERROR; } - *output_str = ::core::ptr::null_mut::(); + *output_str = core::ptr::null_mut(); if filters.is_null() { return LZMA_PROG_ERROR; } @@ -1170,7 +1164,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( return LZMA_OPTIONS_ERROR; } let mut dest: lzma_str = lzma_str { - buf: ::core::ptr::null_mut::(), + buf: core::ptr::null_mut(), pos: 0, }; let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; @@ -1178,29 +1172,29 @@ pub unsafe extern "C" fn lzma_str_from_filters( return ret_; } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; - let mut opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { + let opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { b"=\0" as *const u8 as *const c_char } else { b":\0" as *const u8 as *const c_char }; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { if i == LZMA_FILTERS_MAX as size_t { str_free(&raw mut dest, allocator); return LZMA_OPTIONS_ERROR; } - if i > 0 as size_t && flags & LZMA_STR_NO_SPACES as u32 == 0 { + if i > 0 && flags & LZMA_STR_NO_SPACES as u32 == 0 { str_append_str(&raw mut dest, b" \0" as *const u8 as *const c_char); } if flags & LZMA_STR_GETOPT_LONG as u32 != 0 - || i > 0 as size_t && flags & LZMA_STR_NO_SPACES as u32 != 0 + || i > 0 && flags & LZMA_STR_NO_SPACES as u32 != 0 { str_append_str(&raw mut dest, b"--\0" as *const u8 as *const c_char); } - let mut j: size_t = 0 as size_t; + let mut j: size_t = 0; loop { - if j == (::core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) - .wrapping_div(::core::mem::size_of::() as usize) + if j == (core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) + .wrapping_div(core::mem::size_of::() as usize) { str_free(&raw mut dest, allocator); return LZMA_OPTIONS_ERROR; @@ -1246,15 +1240,15 @@ pub unsafe extern "C" fn lzma_str_from_filters( } #[no_mangle] pub unsafe extern "C" fn lzma_str_list_filters( - mut output_str: *mut *mut c_char, - mut filter_id: lzma_vli, - mut flags: u32, - mut allocator: *const lzma_allocator, + output_str: *mut *mut c_char, + filter_id: lzma_vli, + flags: u32, + allocator: *const lzma_allocator, ) -> lzma_ret { if output_str.is_null() { return LZMA_PROG_ERROR; } - *output_str = ::core::ptr::null_mut::(); + *output_str = core::ptr::null_mut(); let supported_flags: u32 = LZMA_STR_ALL_FILTERS as u32 | LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32 @@ -1263,7 +1257,7 @@ pub unsafe extern "C" fn lzma_str_list_filters( return LZMA_OPTIONS_ERROR; } let mut dest: lzma_str = lzma_str { - buf: ::core::ptr::null_mut::(), + buf: core::ptr::null_mut(), pos: 0, }; let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; @@ -1271,33 +1265,33 @@ pub unsafe extern "C" fn lzma_str_list_filters( return ret_; } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; - let mut filter_delim: *const c_char = if show_opts as c_int != 0 { + let filter_delim: *const c_char = if show_opts as c_int != 0 { b"\n\0" as *const u8 as *const c_char } else { b" \0" as *const u8 as *const c_char }; - let mut opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { + let opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { b"=\0" as *const u8 as *const c_char } else { b":\0" as *const u8 as *const c_char }; - let mut first_filter_printed: bool = false_0 != 0; - let mut i: size_t = 0 as size_t; + let mut first_filter_printed: bool = false; + let mut i: size_t = 0; while i - < (::core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) - .wrapping_div(::core::mem::size_of::() as usize) + < (core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) + .wrapping_div(core::mem::size_of::() as usize) { if !(filter_id != LZMA_VLI_UNKNOWN as lzma_vli && filter_id != filter_name_map[i as usize].id) { if !(filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START as lzma_vli - && flags & LZMA_STR_ALL_FILTERS as u32 == 0 as u32 + && flags & LZMA_STR_ALL_FILTERS as u32 == 0 && filter_id == LZMA_VLI_UNKNOWN as lzma_vli) { if first_filter_printed { str_append_str(&raw mut dest, filter_delim); } - first_filter_printed = true_0 != 0; + first_filter_printed = true; if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { str_append_str(&raw mut dest, b"--\0" as *const u8 as *const c_char); } @@ -1308,14 +1302,14 @@ pub unsafe extern "C" fn lzma_str_list_filters( .name as *const c_char, ); if show_opts { - let mut optmap: *const option_map = filter_name_map[i as usize].optmap; + let optmap: *const option_map = filter_name_map[i as usize].optmap; let mut d: *const c_char = opt_delim; let end: size_t = (if flags & LZMA_STR_ENCODER as u32 != 0 { filter_name_map[i as usize].strfy_encoder as c_int } else { filter_name_map[i as usize].strfy_decoder as c_int }) as size_t; - let mut j: size_t = 0 as size_t; + let mut j: size_t = 0; while j < end { str_append_str(&raw mut dest, d); d = b",\0" as *const u8 as *const c_char; @@ -1332,10 +1326,10 @@ pub unsafe extern "C" fn lzma_str_list_filters( & OPTMAP_USE_NAME_VALUE_MAP != 0 { - let mut m: *const name_value_map = (*optmap.offset(j as isize)).u.map; - let mut k: size_t = 0 as size_t; + let m: *const name_value_map = (*optmap.offset(j as isize)).u.map; + let mut k: size_t = 0; while (*m.offset(k as isize)).name[0] as c_int != '\0' as i32 { - if k > 0 as size_t { + if k > 0 { str_append_str( &raw mut dest, b"|\0" as *const u8 as *const c_char, @@ -1392,11 +1386,11 @@ unsafe extern "C" fn run_static_initializers() { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dict\0\0\0\0\0\0\0\0"), type_0: 0, flags: OPTMAP_USE_BYTE_SUFFIX as u8, - offset: 0 as c_ulong as u16, + offset: 0, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: LZMA_DICT_SIZE_MIN as u32, - max: ((1 as u32) << 30).wrapping_add((1 as u32) << 29), + max: (1u32 << 30).wrapping_add((1) << 29), }, }, }, @@ -1404,7 +1398,7 @@ unsafe extern "C" fn run_static_initializers() { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lc\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 20 as c_ulong as u16, + offset: 20, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: LZMA_LCLP_MIN as u32, @@ -1416,7 +1410,7 @@ unsafe extern "C" fn run_static_initializers() { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lp\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 24 as c_ulong as u16, + offset: 24, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: LZMA_LCLP_MIN as u32, @@ -1428,7 +1422,7 @@ unsafe extern "C" fn run_static_initializers() { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"pb\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 28 as c_ulong as u16, + offset: 28, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: LZMA_PB_MIN as u32, @@ -1440,7 +1434,7 @@ unsafe extern "C" fn run_static_initializers() { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mode\0\0\0\0\0\0\0\0"), type_0: OPTMAP_TYPE_LZMA_MODE as u8, flags: OPTMAP_USE_NAME_VALUE_MAP as u8, - offset: 32 as c_ulong as u16, + offset: 32, u: C2RustUnnamed_0 { map: &raw const lzma12_mode_map as *const name_value_map, }, @@ -1449,19 +1443,16 @@ unsafe extern "C" fn run_static_initializers() { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"nice\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 36 as c_ulong as u16, + offset: 36, u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { - min: 2 as u32, - max: 273 as u32, - }, + range: C2RustUnnamed_1 { min: 2, max: 273 }, }, }, option_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mf\0\0\0\0\0\0\0\0\0\0"), type_0: OPTMAP_TYPE_LZMA_MATCH_FINDER as u8, flags: OPTMAP_USE_NAME_VALUE_MAP as u8, - offset: 40 as c_ulong as u16, + offset: 40, u: C2RustUnnamed_0 { map: &raw const lzma12_mf_map as *const name_value_map, }, @@ -1470,10 +1461,10 @@ unsafe extern "C" fn run_static_initializers() { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"depth\0\0\0\0\0\0\0"), type_0: 0, flags: 0, - offset: 44 as c_ulong as u16, + offset: 44, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: 0 as u32, + min: 0, max: UINT32_MAX as u32, }, }, diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index 6dbddd8e..ae3cfa31 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::c_int; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -21,18 +21,16 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; -pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; +pub const LZMA_VLI_BYTES_MAX: c_int = 9; #[no_mangle] pub unsafe extern "C" fn lzma_vli_decode( - mut vli: *mut lzma_vli, + vli: *mut lzma_vli, mut vli_pos: *mut size_t, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { - let mut vli_pos_internal: size_t = 0 as size_t; + let mut vli_pos_internal: size_t = 0; if vli_pos.is_null() { vli_pos = &raw mut vli_pos_internal; *vli = 0 as lzma_vli; @@ -40,11 +38,11 @@ pub unsafe extern "C" fn lzma_vli_decode( return LZMA_DATA_ERROR; } } else { - if *vli_pos == 0 as size_t { + if *vli_pos == 0 { *vli = 0 as lzma_vli; } if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t - || *vli >> (*vli_pos).wrapping_mul(7 as size_t) != 0 as lzma_vli + || *vli >> (*vli_pos).wrapping_mul(7) != 0 as lzma_vli { return LZMA_PROG_ERROR; } @@ -56,11 +54,11 @@ pub unsafe extern "C" fn lzma_vli_decode( let byte: u8 = *in_0.offset(*in_pos as isize); *in_pos = (*in_pos).wrapping_add(1); *vli = (*vli).wrapping_add( - ((byte as c_int & 0x7f as c_int) as lzma_vli) << (*vli_pos).wrapping_mul(7 as size_t), + ((byte as c_int & 0x7f as c_int) as lzma_vli) << (*vli_pos).wrapping_mul(7), ); *vli_pos = (*vli_pos).wrapping_add(1); if byte as c_int & 0x80 as c_int == 0 as c_int { - if byte as c_int == 0 as c_int && *vli_pos > 1 as size_t { + if byte as c_int == 0 as c_int && *vli_pos > 1 { return LZMA_DATA_ERROR; } return (if vli_pos == &raw mut vli_pos_internal { diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index 7a665b91..8b8e933d 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong}; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -21,20 +21,18 @@ pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; pub const LZMA_NO_CHECK: lzma_ret = 2; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_OK: lzma_ret = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_BYTES_MAX: c_int = 9 as c_int; +pub const LZMA_VLI_BYTES_MAX: c_int = 9; #[no_mangle] pub unsafe extern "C" fn lzma_vli_encode( mut vli: lzma_vli, mut vli_pos: *mut size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { - let mut vli_pos_internal: size_t = 0 as size_t; + let mut vli_pos_internal: size_t = 0; if vli_pos.is_null() { vli_pos = &raw mut vli_pos_internal; if *out_pos >= out_size { @@ -46,7 +44,7 @@ pub unsafe extern "C" fn lzma_vli_encode( if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || vli > LZMA_VLI_MAX as lzma_vli { return LZMA_PROG_ERROR; } - vli >>= (*vli_pos).wrapping_mul(7 as size_t); + vli >>= (*vli_pos).wrapping_mul(7); while vli >= 0x80 as lzma_vli { *vli_pos = (*vli_pos).wrapping_add(1); *out.offset(*out_pos as isize) = (vli as u8 as c_int | 0x80 as c_int) as u8; diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index 3ef9b7b2..c1df75d5 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -3,11 +3,11 @@ use core::ffi::{c_int, c_ulonglong}; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); #[no_mangle] -pub unsafe extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { +pub extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { if vli > LZMA_VLI_MAX as lzma_vli { - return 0 as u32; + return 0; } - let mut i: u32 = 0 as u32; + let mut i: u32 = 0; loop { vli >>= 7 as c_int; i = i.wrapping_add(1); diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index e9f732da..5d8df537 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; @@ -126,30 +126,25 @@ pub struct lzma_delta_coder { pub pos: u8, pub history: [u8; LZMA_DELTA_DIST_MAX as usize], } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; -pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; -unsafe extern "C" fn delta_coder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; +pub const LZMA_DELTA_DIST_MIN: c_int = 1; +pub const LZMA_DELTA_DIST_MAX: c_int = 256; +unsafe extern "C" fn delta_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free(coder as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_delta_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { let mut coder: *mut lzma_delta_coder = (*next).coder as *mut lzma_delta_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_delta_coder; if coder.is_null() { @@ -160,9 +155,9 @@ pub unsafe extern "C" fn lzma_delta_coder_init( Some(delta_coder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) as lzma_end_function; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -175,20 +170,19 @@ pub unsafe extern "C" fn lzma_delta_coder_init( if lzma_delta_coder_memusage((*filters.offset(0)).options) == UINT64_MAX as u64 { return LZMA_OPTIONS_ERROR; } - let mut opt: *const lzma_options_delta = - (*filters.offset(0)).options as *const lzma_options_delta; + let opt: *const lzma_options_delta = (*filters.offset(0)).options as *const lzma_options_delta; (*coder).distance = (*opt).dist as size_t; - (*coder).pos = 0 as u8; + (*coder).pos = 0; memset( &raw mut (*coder).history as *mut u8 as *mut c_void, 0 as c_int, - 256 as size_t, + 256, ); return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } #[no_mangle] -pub unsafe extern "C" fn lzma_delta_coder_memusage(mut options: *const c_void) -> u64 { - let mut opt: *const lzma_options_delta = options as *const lzma_options_delta; +pub unsafe extern "C" fn lzma_delta_coder_memusage(options: *const c_void) -> u64 { + let opt: *const lzma_options_delta = options as *const lzma_options_delta; if opt.is_null() || (*opt).type_0 != LZMA_DELTA_TYPE_BYTE || (*opt).dist < LZMA_DELTA_DIST_MIN as u32 @@ -196,5 +190,5 @@ pub unsafe extern "C" fn lzma_delta_coder_memusage(mut options: *const c_void) - { return UINT64_MAX as u64; } - return ::core::mem::size_of::() as u64; + return core::mem::size_of::() as u64; } diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 0c9818f9..5ab5e72b 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; fn lzma_delta_coder_init( @@ -123,16 +123,10 @@ pub struct lzma_delta_coder { pub pos: u8, pub history: [u8; LZMA_DELTA_DIST_MAX as usize], } -pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; -unsafe extern "C" fn decode_buffer( - mut coder: *mut lzma_delta_coder, - mut buffer: *mut u8, - mut size: size_t, -) { +pub const LZMA_DELTA_DIST_MAX: c_int = 256; +unsafe extern "C" fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { let distance: size_t = (*coder).distance; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < size { let ref mut fresh0 = *buffer.offset(i as isize); *fresh0 = (*fresh0 as c_int @@ -146,17 +140,17 @@ unsafe extern "C" fn decode_buffer( } } unsafe extern "C" fn delta_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; + let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; let out_start: size_t = *out_pos; let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, @@ -170,16 +164,16 @@ unsafe extern "C" fn delta_decode( action, ) as lzma_ret; let size: size_t = (*out_pos).wrapping_sub(out_start); - if size > 0 as size_t { + if size > 0 { decode_buffer(coder, out.offset(out_start as isize), size); } return ret; } #[no_mangle] pub unsafe extern "C" fn lzma_delta_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { (*next).code = Some( delta_decode @@ -199,16 +193,16 @@ pub unsafe extern "C" fn lzma_delta_decoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_delta_props_decode( - mut options: *mut *mut c_void, - mut allocator: *const lzma_allocator, - mut props: *const u8, - mut props_size: size_t, + options: *mut *mut c_void, + allocator: *const lzma_allocator, + props: *const u8, + props_size: size_t, ) -> lzma_ret { - if props_size != 1 as size_t { + if props_size != 1 { return LZMA_OPTIONS_ERROR; } - let mut opt: *mut lzma_options_delta = lzma_alloc( - ::core::mem::size_of::() as size_t, + let opt: *mut lzma_options_delta = lzma_alloc( + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_options_delta; if opt.is_null() { diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index 13ba4d25..5ba5efec 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn lzma_next_filter_update( next: *mut lzma_next_coder, @@ -128,19 +128,17 @@ pub struct lzma_delta_coder { pub pos: u8, pub history: [u8; LZMA_DELTA_DIST_MAX as usize], } -pub const LZMA_DELTA_DIST_MAX: c_int = 256 as c_int; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; +pub const LZMA_DELTA_DIST_MAX: c_int = 256; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_DELTA_DIST_MIN: c_int = 1 as c_int; +pub const LZMA_DELTA_DIST_MIN: c_int = 1; unsafe extern "C" fn copy_and_encode( - mut coder: *mut lzma_delta_coder, - mut in_0: *const u8, - mut out: *mut u8, - mut size: size_t, + coder: *mut lzma_delta_coder, + in_0: *const u8, + out: *mut u8, + size: size_t, ) { let distance: size_t = (*coder).distance; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < size { let tmp: u8 = (*coder).history [(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) as usize]; @@ -151,13 +149,9 @@ unsafe extern "C" fn copy_and_encode( i = i.wrapping_add(1); } } -unsafe extern "C" fn encode_in_place( - mut coder: *mut lzma_delta_coder, - mut buffer: *mut u8, - mut size: size_t, -) { +unsafe extern "C" fn encode_in_place(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { let distance: size_t = (*coder).distance; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < size { let tmp: u8 = (*coder).history [(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) as usize]; @@ -170,17 +164,17 @@ unsafe extern "C" fn encode_in_place( } } unsafe extern "C" fn delta_encode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; + let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; let mut ret: lzma_ret = LZMA_OK; if (*coder).next.code.is_none() { let in_avail: size_t = in_size.wrapping_sub(*in_pos); @@ -190,7 +184,7 @@ unsafe extern "C" fn delta_encode( } else { out_avail }; - if size > 0 as size_t { + if size > 0 { copy_and_encode( coder, in_0.offset(*in_pos as isize), @@ -219,19 +213,19 @@ unsafe extern "C" fn delta_encode( action, ); let size_0: size_t = (*out_pos).wrapping_sub(out_start); - if size_0 > 0 as size_t { + if size_0 > 0 { encode_in_place(coder, out.offset(out_start as isize), size_0); } } return ret; } unsafe extern "C" fn delta_encoder_update( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut filters_null: *const lzma_filter, - mut reversed_filters: *const lzma_filter, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + _filters_null: *const lzma_filter, + reversed_filters: *const lzma_filter, ) -> lzma_ret { - let mut coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; + let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; return lzma_next_filter_update( &raw mut (*coder).next, allocator, @@ -240,9 +234,9 @@ unsafe extern "C" fn delta_encoder_update( } #[no_mangle] pub unsafe extern "C" fn lzma_delta_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { (*next).code = Some( delta_encode @@ -278,14 +272,11 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( return lzma_delta_coder_init(next, allocator, filters); } #[no_mangle] -pub unsafe extern "C" fn lzma_delta_props_encode( - mut options: *const c_void, - mut out: *mut u8, -) -> lzma_ret { +pub unsafe extern "C" fn lzma_delta_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { if lzma_delta_coder_memusage(options) == UINT64_MAX as u64 { return LZMA_PROG_ERROR; } - let mut opt: *const lzma_options_delta = options as *const lzma_options_delta; + let opt: *const lzma_options_delta = options as *const lzma_options_delta; *out.offset(0) = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN as u32) as u8; return LZMA_OK; } diff --git a/liblzma-rs/src/lib.rs b/liblzma-rs/src/lib.rs index 555a5000..f591703b 100644 --- a/liblzma-rs/src/lib.rs +++ b/liblzma-rs/src/lib.rs @@ -5,10 +5,6 @@ non_snake_case, non_upper_case_globals, unused_assignments, - unused_mut, - unused_parens, - unused_variables, - unused_imports, clippy::all )] diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index cf927b80..549631b9 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulong, c_ulonglong, c_void}; extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; @@ -157,48 +157,44 @@ pub struct C2RustUnnamed { pub size: size_t, pub buffer: [u8; LZMA_BUFFER_SIZE as usize], } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_BUFFER_SIZE: c_int = 4096 as c_int; -pub const LZ_DICT_EXTRA: c_int = 0 as c_int; -pub const LZ_DICT_REPEAT_MAX: c_int = 288 as c_int; -pub const LZ_DICT_INIT_POS: c_int = 2 as c_int * LZ_DICT_REPEAT_MAX; +pub const LZMA_BUFFER_SIZE: c_int = 4096; +pub const LZ_DICT_EXTRA: c_int = 0; +pub const LZ_DICT_REPEAT_MAX: c_int = 288; +pub const LZ_DICT_INIT_POS: c_int = 2 * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { - coder: NULL, + coder: core::ptr::null_mut(), code: None, reset: None, set_uncompressed: None, end: None, }; -unsafe extern "C" fn lz_decoder_reset(mut coder: *mut lzma_coder) { +unsafe extern "C" fn lz_decoder_reset(coder: *mut lzma_coder) { (*coder).dict.pos = LZ_DICT_INIT_POS as size_t; - (*coder).dict.full = 0 as size_t; + (*coder).dict.full = 0; *(*coder) .dict .buf .offset((LZ_DICT_INIT_POS - 1 as c_int) as isize) = '\0' as i32 as u8; - (*coder).dict.has_wrapped = false_0 != 0; - (*coder).dict.need_reset = false_0 != 0; + (*coder).dict.has_wrapped = false; + (*coder).dict.need_reset = false; } unsafe extern "C" fn decode_buffer( - mut coder: *mut lzma_coder, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + coder: *mut lzma_coder, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { loop { if (*coder).dict.pos == (*coder).dict.size { (*coder).dict.pos = LZ_DICT_REPEAT_MAX as size_t; - (*coder).dict.has_wrapped = true_0 != 0; + (*coder).dict.has_wrapped = true; memcpy( (*coder).dict.buf as *mut c_void, (*coder) @@ -211,12 +207,12 @@ unsafe extern "C" fn decode_buffer( } let dict_start: size_t = (*coder).dict.pos; (*coder).dict.limit = (*coder).dict.pos.wrapping_add( - (if out_size.wrapping_sub(*out_pos) < (*coder).dict.size.wrapping_sub((*coder).dict.pos) + if out_size.wrapping_sub(*out_pos) < (*coder).dict.size.wrapping_sub((*coder).dict.pos) { out_size.wrapping_sub(*out_pos) } else { (*coder).dict.size.wrapping_sub((*coder).dict.pos) - }), + }, ); let ret: lzma_ret = (*coder).lz.code.expect("non-null function pointer")( (*coder).lz.coder, @@ -226,7 +222,7 @@ unsafe extern "C" fn decode_buffer( in_size, ) as lzma_ret; let copy_size: size_t = (*coder).dict.pos.wrapping_sub(dict_start); - if copy_size > 0 as size_t { + if copy_size > 0 { memcpy( out.offset(*out_pos as isize) as *mut c_void, (*coder).dict.buf.offset(dict_start as isize) as *const c_void, @@ -245,24 +241,24 @@ unsafe extern "C" fn decode_buffer( } } unsafe extern "C" fn lz_decode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; if (*coder).next.code.is_none() { return decode_buffer(coder, in_0, in_pos, in_size, out, out_pos, out_size); } while *out_pos < out_size { if !(*coder).next_finished && (*coder).temp.pos == (*coder).temp.size { - (*coder).temp.pos = 0 as size_t; - (*coder).temp.size = 0 as size_t; + (*coder).temp.pos = 0; + (*coder).temp.size = 0; let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, allocator, @@ -275,13 +271,13 @@ unsafe extern "C" fn lz_decode( action, ) as lzma_ret; if ret == LZMA_STREAM_END { - (*coder).next_finished = true_0 != 0; - } else if ret != LZMA_OK || (*coder).temp.size == 0 as size_t { + (*coder).next_finished = true; + } else if ret != LZMA_OK || (*coder).temp.size == 0 { return ret; } } if (*coder).this_finished { - if (*coder).temp.size != 0 as size_t { + if (*coder).temp.size != 0 { return LZMA_DATA_ERROR; } if (*coder).next_finished { @@ -299,7 +295,7 @@ unsafe extern "C" fn lz_decode( out_size, ) as lzma_ret; if ret_0 == LZMA_STREAM_END { - (*coder).this_finished = true_0 != 0; + (*coder).this_finished = true; } else if ret_0 != LZMA_OK { return ret_0; } else if (*coder).next_finished as c_int != 0 && *out_pos < out_size { @@ -308,11 +304,8 @@ unsafe extern "C" fn lz_decode( } return LZMA_OK; } -unsafe extern "C" fn lz_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; +unsafe extern "C" fn lz_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free((*coder).dict.buf as *mut c_void, allocator); if (*coder).lz.end.is_some() { @@ -324,10 +317,10 @@ unsafe extern "C" fn lz_decoder_end( } #[no_mangle] pub unsafe extern "C" fn lzma_lz_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut lz_init: Option< + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + lz_init: Option< unsafe extern "C" fn( *mut lzma_lz_decoder, *const lzma_allocator, @@ -339,8 +332,8 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( ) -> lzma_ret { let mut coder: *mut lzma_coder = (*next).coder as *mut lzma_coder; if coder.is_null() { - coder = lzma_alloc(::core::mem::size_of::() as size_t, allocator) - as *mut lzma_coder; + coder = + lzma_alloc(core::mem::size_of::() as size_t, allocator) as *mut lzma_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -362,13 +355,13 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( (*next).end = Some(lz_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) as lzma_end_function; - (*coder).dict.buf = ::core::ptr::null_mut::(); - (*coder).dict.size = 0 as size_t; + (*coder).dict.buf = core::ptr::null_mut(); + (*coder).dict.size = 0; (*coder).lz = LZMA_LZ_DECODER_INIT; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -393,18 +386,18 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( if ret_ != LZMA_OK { return ret_; } - if lz_options.dict_size < 4096 as size_t { - lz_options.dict_size = 4096 as size_t; + if lz_options.dict_size < 4096 { + lz_options.dict_size = 4096; } if lz_options.dict_size > (SIZE_MAX as size_t) - .wrapping_sub(15 as size_t) + .wrapping_sub(15) .wrapping_sub((2 as c_int * LZ_DICT_REPEAT_MAX) as size_t) .wrapping_sub(LZ_DICT_EXTRA as size_t) { return LZMA_MEM_ERROR; } - lz_options.dict_size = lz_options.dict_size.wrapping_add(15 as size_t) & !(15 as size_t); + lz_options.dict_size = lz_options.dict_size.wrapping_add(15) & !(15); let alloc_size: size_t = lz_options .dict_size .wrapping_add((2 as c_int * LZ_DICT_REPEAT_MAX) as size_t); @@ -418,7 +411,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( (*coder).dict.size = alloc_size; } lz_decoder_reset((*next).coder as *mut lzma_coder); - if !lz_options.preset_dict.is_null() && lz_options.preset_dict_size > 0 as size_t { + if !lz_options.preset_dict.is_null() && lz_options.preset_dict_size > 0 { let copy_size: size_t = if lz_options.preset_dict_size < lz_options.dict_size { lz_options.preset_dict_size } else { @@ -433,15 +426,15 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( (*coder).dict.pos = (*coder).dict.pos.wrapping_add(copy_size); (*coder).dict.full = copy_size; } - (*coder).next_finished = false_0 != 0; - (*coder).this_finished = false_0 != 0; - (*coder).temp.pos = 0 as size_t; - (*coder).temp.size = 0 as size_t; + (*coder).next_finished = false; + (*coder).this_finished = false; + (*coder).temp.pos = 0; + (*coder).temp.size = 0; return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } #[no_mangle] -pub unsafe extern "C" fn lzma_lz_decoder_memusage(mut dictionary_size: size_t) -> u64 { - return (::core::mem::size_of::() as u64) +pub extern "C" fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64 { + return (core::mem::size_of::() as u64) .wrapping_add(dictionary_size as u64) .wrapping_add((2 as c_int * LZ_DICT_REPEAT_MAX) as u64) .wrapping_add(LZ_DICT_EXTRA as u64); diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 9ab6a7dc..ddfedb50 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn memmove(__dst: *mut c_void, __src: *const c_void, __len: size_t) -> *mut c_void; @@ -201,22 +201,18 @@ pub struct lzma_coder { pub mf: lzma_mf, pub next: lzma_next_coder, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; #[inline] -unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> u32 { +extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { return match_finder as u32 & 0xf as u32; } pub const HASH_2_SIZE: c_uint = 1u32 << 10; pub const HASH_3_SIZE: c_uint = 1u32 << 16; -pub const LZMA_MEMCMPLEN_EXTRA: c_int = 0 as c_int; -unsafe extern "C" fn move_window(mut mf: *mut lzma_mf) { - let move_offset: u32 = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) & !(15 as u32); +pub const LZMA_MEMCMPLEN_EXTRA: c_int = 0; +unsafe extern "C" fn move_window(mf: *mut lzma_mf) { + let move_offset: u32 = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) & !(15); let move_size: size_t = (*mf).write_pos.wrapping_sub(move_offset) as size_t; memmove( (*mf).buffer as *mut c_void, @@ -229,12 +225,12 @@ unsafe extern "C" fn move_window(mut mf: *mut lzma_mf) { (*mf).write_pos = (*mf).write_pos.wrapping_sub(move_offset); } unsafe extern "C" fn fill_window( - mut coder: *mut lzma_coder, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut action: lzma_action, + coder: *mut lzma_coder, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + action: lzma_action, ) -> lzma_ret { if (*coder).mf.read_pos >= (*coder).mf.size.wrapping_sub((*coder).mf.keep_size_after) { move_window(&raw mut (*coder).mf); @@ -272,7 +268,7 @@ unsafe extern "C" fn fill_window( memset( (*coder).mf.buffer.offset(write_pos as isize) as *mut c_void, 0 as c_int, - 0 as size_t, + 0, ); if ret == LZMA_STREAM_END { ret = LZMA_OK; @@ -284,26 +280,26 @@ unsafe extern "C" fn fill_window( .write_pos .wrapping_sub((*coder).mf.keep_size_after); } - if (*coder).mf.pending > 0 as u32 && (*coder).mf.read_pos < (*coder).mf.read_limit { + if (*coder).mf.pending > 0 && (*coder).mf.read_pos < (*coder).mf.read_limit { let pending: u32 = (*coder).mf.pending; - (*coder).mf.pending = 0 as u32; + (*coder).mf.pending = 0; (*coder).mf.read_pos = (*coder).mf.read_pos.wrapping_sub(pending); (*coder).mf.skip.expect("non-null function pointer")(&raw mut (*coder).mf, pending); } return ret; } unsafe extern "C" fn lz_encode( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; while *out_pos < out_size && (*in_pos < in_size || action != LZMA_RUN) { if (*coder).mf.action == LZMA_RUN && (*coder).mf.read_pos >= (*coder).mf.read_limit { let ret_: lzma_ret = @@ -327,15 +323,15 @@ unsafe extern "C" fn lz_encode( return LZMA_OK; } unsafe extern "C" fn lz_encoder_prepare( - mut mf: *mut lzma_mf, - mut allocator: *const lzma_allocator, - mut lz_options: *const lzma_lz_options, + mf: *mut lzma_mf, + allocator: *const lzma_allocator, + lz_options: *const lzma_lz_options, ) -> bool { if !((*lz_options).dict_size >= LZMA_DICT_SIZE_MIN as size_t && (*lz_options).dict_size <= (1u32 << 30).wrapping_add(1u32 << 29) as size_t) || (*lz_options).nice_len > (*lz_options).match_len_max { - return true_0 != 0; + return true; } (*mf).keep_size_before = (*lz_options) .before_size @@ -343,16 +339,16 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).keep_size_after = (*lz_options) .after_size .wrapping_add((*lz_options).match_len_max) as u32; - let mut reserve: u32 = (*lz_options).dict_size.wrapping_div(2 as size_t) as u32; - if reserve > (1 as u32) << 30 { - reserve = reserve.wrapping_div(2 as u32); + let mut reserve: u32 = (*lz_options).dict_size.wrapping_div(2) as u32; + if reserve > (1) << 30 { + reserve = reserve.wrapping_div(2); } reserve = (reserve as size_t).wrapping_add( (*lz_options) .before_size .wrapping_add((*lz_options).match_len_max) .wrapping_add((*lz_options).after_size) - .wrapping_div(2 as size_t) + .wrapping_div(2) .wrapping_add((1u32 << 19) as size_t), ) as u32; let old_size: u32 = (*mf).size; @@ -362,11 +358,11 @@ unsafe extern "C" fn lz_encoder_prepare( .wrapping_add((*mf).keep_size_after); if !(*mf).buffer.is_null() && old_size != (*mf).size { lzma_free((*mf).buffer as *mut c_void, allocator); - (*mf).buffer = ::core::ptr::null_mut::(); + (*mf).buffer = core::ptr::null_mut(); } (*mf).match_len_max = (*lz_options).match_len_max as u32; (*mf).nice_len = (*lz_options).nice_len as u32; - (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1 as size_t) as u32; + (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1) as u32; match (*lz_options).match_finder { 3 => { (*mf).find = Some( @@ -408,23 +404,23 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).skip = Some(lzma_mf_bt4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) as Option ()>; } - _ => return true_0 != 0, + _ => return true, } let hash_bytes: u32 = mf_get_hash_bytes((*lz_options).match_finder) as u32; let is_bt: bool = (*lz_options).match_finder & 0x10 != 0; let mut hs: u32 = 0; - if hash_bytes == 2 as u32 { + if hash_bytes == 2 { hs = 0xffff as u32; } else { - hs = (*lz_options).dict_size.wrapping_sub(1 as size_t) as u32; + hs = (*lz_options).dict_size.wrapping_sub(1) as u32; hs |= hs >> 1; hs |= hs >> 2; hs |= hs >> 4; hs |= hs >> 8; hs >>= 1 as c_int; hs |= 0xffff as u32; - if hs > (1 as u32) << 24 { - if hash_bytes == 3 as u32 { + if hs > (1) << 24 { + if hash_bytes == 3 { hs = (1u32 << 24).wrapping_sub(1) as u32; } else { hs >>= 1 as c_int; @@ -433,10 +429,10 @@ unsafe extern "C" fn lz_encoder_prepare( } (*mf).hash_mask = hs; hs = hs.wrapping_add(1); - if hash_bytes > 2 as u32 { + if hash_bytes > 2 { hs = hs.wrapping_add(HASH_2_SIZE); } - if hash_bytes > 3 as u32 { + if hash_bytes > 3 { hs = hs.wrapping_add(HASH_3_SIZE); } let old_hash_count: u32 = (*mf).hash_count; @@ -444,28 +440,28 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).hash_count = hs; (*mf).sons_count = (*mf).cyclic_size; if is_bt { - (*mf).sons_count = (*mf).sons_count.wrapping_mul(2 as u32); + (*mf).sons_count = (*mf).sons_count.wrapping_mul(2); } if old_hash_count != (*mf).hash_count || old_sons_count != (*mf).sons_count { lzma_free((*mf).hash as *mut c_void, allocator); - (*mf).hash = ::core::ptr::null_mut::(); + (*mf).hash = core::ptr::null_mut(); lzma_free((*mf).son as *mut c_void, allocator); - (*mf).son = ::core::ptr::null_mut::(); + (*mf).son = core::ptr::null_mut(); } (*mf).depth = (*lz_options).depth; - if (*mf).depth == 0 as u32 { + if (*mf).depth == 0 { if is_bt { - (*mf).depth = (16 as u32).wrapping_add((*mf).nice_len.wrapping_div(2 as u32)); + (*mf).depth = (16u32).wrapping_add((*mf).nice_len.wrapping_div(2)); } else { - (*mf).depth = (4 as u32).wrapping_add((*mf).nice_len.wrapping_div(4 as u32)); + (*mf).depth = (4u32).wrapping_add((*mf).nice_len.wrapping_div(4)); } } - return false_0 != 0; + return false; } unsafe extern "C" fn lz_encoder_init( - mut mf: *mut lzma_mf, - mut allocator: *const lzma_allocator, - mut lz_options: *const lzma_lz_options, + mf: *mut lzma_mf, + allocator: *const lzma_allocator, + lz_options: *const lzma_lz_options, ) -> bool { if (*mf).buffer.is_null() { (*mf).buffer = lzma_alloc( @@ -473,45 +469,45 @@ unsafe extern "C" fn lz_encoder_init( allocator, ) as *mut u8; if (*mf).buffer.is_null() { - return true_0 != 0; + return true; } memset( (*mf).buffer.offset((*mf).size as isize) as *mut c_void, 0 as c_int, - 0 as size_t, + 0, ); } (*mf).offset = (*mf).cyclic_size; - (*mf).read_pos = 0 as u32; - (*mf).read_ahead = 0 as u32; - (*mf).read_limit = 0 as u32; - (*mf).write_pos = 0 as u32; - (*mf).pending = 0 as u32; + (*mf).read_pos = 0; + (*mf).read_ahead = 0; + (*mf).read_limit = 0; + (*mf).write_pos = 0; + (*mf).pending = 0; if (*mf).hash.is_null() { (*mf).hash = lzma_alloc_zero( - ((*mf).hash_count as size_t).wrapping_mul(::core::mem::size_of::() as size_t), + ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::() as size_t), allocator, ) as *mut u32; (*mf).son = lzma_alloc( - ((*mf).sons_count as size_t).wrapping_mul(::core::mem::size_of::() as size_t), + ((*mf).sons_count as size_t).wrapping_mul(core::mem::size_of::() as size_t), allocator, ) as *mut u32; if (*mf).hash.is_null() || (*mf).son.is_null() { lzma_free((*mf).hash as *mut c_void, allocator); - (*mf).hash = ::core::ptr::null_mut::(); + (*mf).hash = core::ptr::null_mut(); lzma_free((*mf).son as *mut c_void, allocator); - (*mf).son = ::core::ptr::null_mut::(); - return true_0 != 0; + (*mf).son = core::ptr::null_mut(); + return true; } } else { memset( (*mf).hash as *mut c_void, 0 as c_int, - ((*mf).hash_count as size_t).wrapping_mul(::core::mem::size_of::() as size_t), + ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::() as size_t), ); } - (*mf).cyclic_pos = 0 as u32; - if !(*lz_options).preset_dict.is_null() && (*lz_options).preset_dict_size > 0 as u32 { + (*mf).cyclic_pos = 0; + if !(*lz_options).preset_dict.is_null() && (*lz_options).preset_dict_size > 0 { (*mf).write_pos = if (*lz_options).preset_dict_size < (*mf).size { (*lz_options).preset_dict_size } else { @@ -529,12 +525,12 @@ unsafe extern "C" fn lz_encoder_init( (*mf).skip.expect("non-null function pointer")(mf, (*mf).write_pos); } (*mf).action = LZMA_RUN; - return false_0 != 0; + return false; } #[no_mangle] -pub unsafe extern "C" fn lzma_lz_encoder_memusage(mut lz_options: *const lzma_lz_options) -> u64 { +pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> u64 { let mut mf: lzma_mf = lzma_mf_s { - buffer: ::core::ptr::null_mut::(), + buffer: core::ptr::null_mut(), size: 0, keep_size_before: 0, keep_size_after: 0, @@ -546,8 +542,8 @@ pub unsafe extern "C" fn lzma_lz_encoder_memusage(mut lz_options: *const lzma_lz pending: 0, find: None, skip: None, - hash: ::core::ptr::null_mut::(), - son: ::core::ptr::null_mut::(), + hash: core::ptr::null_mut(), + son: core::ptr::null_mut(), cyclic_pos: 0, cyclic_size: 0, hash_mask: 0, @@ -555,27 +551,26 @@ pub unsafe extern "C" fn lzma_lz_encoder_memusage(mut lz_options: *const lzma_lz nice_len: 0, match_len_max: 0, action: LZMA_RUN, - hash_count: 0 as u32, - sons_count: 0 as u32, + hash_count: 0, + sons_count: 0, }; - if lz_encoder_prepare( - &raw mut mf, - ::core::ptr::null::(), - lz_options, - ) { + if unsafe { + lz_encoder_prepare( + &raw mut mf, + ::core::ptr::null::(), + lz_options, + ) + } { return UINT64_MAX as u64; } return (mf.hash_count as u64) .wrapping_add(mf.sons_count as u64) - .wrapping_mul(::core::mem::size_of::() as u64) + .wrapping_mul(core::mem::size_of::() as u64) .wrapping_add(mf.size as u64) - .wrapping_add(::core::mem::size_of::() as u64); + .wrapping_add(core::mem::size_of::() as u64); } -unsafe extern "C" fn lz_encoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; +unsafe extern "C" fn lz_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free((*coder).mf.son as *mut c_void, allocator); lzma_free((*coder).mf.hash as *mut c_void, allocator); @@ -588,12 +583,12 @@ unsafe extern "C" fn lz_encoder_end( lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lz_encoder_update( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut filters_null: *const lzma_filter, - mut reversed_filters: *const lzma_filter, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + _filters_null: *const lzma_filter, + reversed_filters: *const lzma_filter, ) -> lzma_ret { - let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; if (*coder).lz.options_update.is_none() { return LZMA_PROG_ERROR; } @@ -613,11 +608,11 @@ unsafe extern "C" fn lz_encoder_update( ); } unsafe extern "C" fn lz_encoder_set_out_limit( - mut coder_ptr: *mut c_void, - mut uncomp_size: *mut u64, - mut out_limit: u64, + coder_ptr: *mut c_void, + uncomp_size: *mut u64, + out_limit: u64, ) -> lzma_ret { - let mut coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; + let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; if (*coder).next.code.is_none() && (*coder).lz.set_out_limit.is_some() { return (*coder) .lz @@ -630,10 +625,10 @@ unsafe extern "C" fn lz_encoder_set_out_limit( } #[no_mangle] pub unsafe extern "C" fn lzma_lz_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut lz_init: Option< + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + lz_init: Option< unsafe extern "C" fn( *mut lzma_lz_encoder, *const lzma_allocator, @@ -645,8 +640,8 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( ) -> lzma_ret { let mut coder: *mut lzma_coder = (*next).coder as *mut lzma_coder; if coder.is_null() { - coder = lzma_alloc(::core::mem::size_of::() as size_t, allocator) - as *mut lzma_coder; + coder = + lzma_alloc(core::mem::size_of::() as size_t, allocator) as *mut lzma_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -690,21 +685,21 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret, ) as Option lzma_ret>; - (*coder).lz.coder = NULL; + (*coder).lz.coder = core::ptr::null_mut(); (*coder).lz.code = None; (*coder).lz.end = None; (*coder).lz.options_update = None; (*coder).lz.set_out_limit = None; - (*coder).mf.buffer = ::core::ptr::null_mut::(); - (*coder).mf.size = 0 as u32; - (*coder).mf.hash = ::core::ptr::null_mut::(); - (*coder).mf.son = ::core::ptr::null_mut::(); - (*coder).mf.hash_count = 0 as u32; - (*coder).mf.sons_count = 0 as u32; + (*coder).mf.buffer = core::ptr::null_mut(); + (*coder).mf.size = 0; + (*coder).mf.hash = core::ptr::null_mut(); + (*coder).mf.son = core::ptr::null_mut(); + (*coder).mf.hash_count = 0; + (*coder).mf.sons_count = 0; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -744,13 +739,13 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_is_supported(mut mf: lzma_match_finder) -> lzma_bool { +pub extern "C" fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { match mf { - 3 => return true_0 as lzma_bool, - 4 => return true_0 as lzma_bool, - 18 => return true_0 as lzma_bool, - 19 => return true_0 as lzma_bool, - 20 => return true_0 as lzma_bool, - _ => return false_0 as lzma_bool, + 3 => return true as lzma_bool, + 4 => return true as lzma_bool, + 18 => return true as lzma_bool, + 19 => return true as lzma_bool, + 20 => return true as lzma_bool, + _ => return false as lzma_bool, }; } diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index f7ac0fda..2f6960f2 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -43,14 +43,12 @@ pub struct lzma_mf_s { } pub type lzma_mf = lzma_mf_s; pub const UINT32_MAX: c_uint = 4294967295; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const u8 { +unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); } #[inline] -unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> u32 { +unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { return (*mf).write_pos.wrapping_sub((*mf).read_pos); } pub const HASH_2_SIZE: c_uint = 1u32 << 10; @@ -61,10 +59,10 @@ pub const FIX_3_HASH_SIZE: c_uint = 1u32 << 10; pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); #[inline(always)] unsafe extern "C" fn lzma_memcmplen( - mut buf1: *const u8, - mut buf2: *const u8, + buf1: *const u8, + buf2: *const u8, mut len: u32, - mut limit: u32, + limit: u32, ) -> u32 { while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int { @@ -74,22 +72,22 @@ unsafe extern "C" fn lzma_memcmplen( } #[no_mangle] pub unsafe extern "C" fn lzma_mf_find( - mut mf: *mut lzma_mf, - mut count_ptr: *mut u32, - mut matches: *mut lzma_match, + mf: *mut lzma_mf, + count_ptr: *mut u32, + matches: *mut lzma_match, ) -> u32 { let count: u32 = (*mf).find.expect("non-null function pointer")(mf, matches) as u32; - let mut len_best: u32 = 0 as u32; - if count > 0 as u32 { - len_best = (*matches.offset(count.wrapping_sub(1 as u32) as isize)).len; + let mut len_best: u32 = 0; + if count > 0 { + len_best = (*matches.offset(count.wrapping_sub(1) as isize)).len; if len_best == (*mf).nice_len { - let mut limit: u32 = mf_avail(mf).wrapping_add(1 as u32); + let mut limit: u32 = mf_avail(mf).wrapping_add(1); if limit > (*mf).match_len_max { limit = (*mf).match_len_max; } - let mut p1: *const u8 = mf_ptr(mf).offset(-1); - let mut p2: *const u8 = p1 - .offset(-((*matches.offset(count.wrapping_sub(1 as u32) as isize)).dist as isize)) + let p1: *const u8 = mf_ptr(mf).offset(-1); + let p2: *const u8 = p1 + .offset(-((*matches.offset(count.wrapping_sub(1) as isize)).dist as isize)) .offset(-1); len_best = lzma_memcmplen(p1, p2, len_best, limit); } @@ -98,11 +96,11 @@ pub unsafe extern "C" fn lzma_mf_find( (*mf).read_ahead = (*mf).read_ahead.wrapping_add(1); return len_best; } -pub const EMPTY_HASH_VALUE: c_int = 0 as c_int; +pub const EMPTY_HASH_VALUE: c_int = 0; pub const MUST_NORMALIZE_POS: c_uint = UINT32_MAX; -unsafe extern "C" fn normalize(mut mf: *mut lzma_mf) { +unsafe extern "C" fn normalize(mf: *mut lzma_mf) { let subvalue: u32 = (MUST_NORMALIZE_POS as u32).wrapping_sub((*mf).cyclic_size); - let mut i: u32 = 0 as u32; + let mut i: u32 = 0; while i < (*mf).hash_count { if *(*mf).hash.offset(i as isize) <= subvalue { *(*mf).hash.offset(i as isize) = EMPTY_HASH_VALUE as u32; @@ -112,7 +110,7 @@ unsafe extern "C" fn normalize(mut mf: *mut lzma_mf) { } i = i.wrapping_add(1); } - let mut i_0: u32 = 0 as u32; + let mut i_0: u32 = 0; while i_0 < (*mf).sons_count { if *(*mf).son.offset(i_0 as isize) <= subvalue { *(*mf).son.offset(i_0 as isize) = EMPTY_HASH_VALUE as u32; @@ -124,17 +122,17 @@ unsafe extern "C" fn normalize(mut mf: *mut lzma_mf) { } (*mf).offset = (*mf).offset.wrapping_sub(subvalue); } -unsafe extern "C" fn move_pos(mut mf: *mut lzma_mf) { +unsafe extern "C" fn move_pos(mf: *mut lzma_mf) { (*mf).cyclic_pos = (*mf).cyclic_pos.wrapping_add(1); if (*mf).cyclic_pos == (*mf).cyclic_size { - (*mf).cyclic_pos = 0 as u32; + (*mf).cyclic_pos = 0; } (*mf).read_pos = (*mf).read_pos.wrapping_add(1); - if ((*mf).read_pos.wrapping_add((*mf).offset) == 4294967295 as u32) as c_int as c_long != 0 { + if ((*mf).read_pos.wrapping_add((*mf).offset) == 4294967295) as c_int as c_long != 0 { normalize(mf); } } -unsafe extern "C" fn move_pending(mut mf: *mut lzma_mf) { +unsafe extern "C" fn move_pending(mf: *mut lzma_mf) { (*mf).read_pos = (*mf).read_pos.wrapping_add(1); (*mf).pending = (*mf).pending.wrapping_add(1); } @@ -155,25 +153,24 @@ unsafe extern "C" fn hc_find_func( let delta: u32 = pos.wrapping_sub(cur_match); let fresh2 = depth; depth = depth.wrapping_sub(1); - if fresh2 == 0 as u32 || delta >= cyclic_size { + if fresh2 == 0 || delta >= cyclic_size { return matches; } let pb: *const u8 = cur.offset(-(delta as isize)); - cur_match = *son.offset(cyclic_pos.wrapping_sub(delta).wrapping_add( - (if delta > cyclic_pos { - cyclic_size - } else { - 0 as u32 - }), - ) as isize); + cur_match = *son.offset( + cyclic_pos + .wrapping_sub(delta) + .wrapping_add(if delta > cyclic_pos { cyclic_size } else { 0 }) + as isize, + ); if *pb.offset(len_best as isize) as c_int == *cur.offset(len_best as isize) as c_int && *pb.offset(0) as c_int == *cur.offset(0) as c_int { - let mut len: u32 = lzma_memcmplen(pb, cur, 1 as u32, len_limit); + let len: u32 = lzma_memcmplen(pb, cur, 1, len_limit); if len_best < len { len_best = len; (*matches).len = len; - (*matches).dist = delta.wrapping_sub(1 as u32); + (*matches).dist = delta.wrapping_sub(1); matches = matches.offset(1); if len == len_limit { return matches; @@ -183,20 +180,17 @@ unsafe extern "C" fn hc_find_func( } } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_hc3_find( - mut mf: *mut lzma_mf, - mut matches: *mut lzma_match, -) -> u32 { +pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 3 as u32 || 0 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 3 || 0 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); - return 0 as u32; + return 0; } - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: u32 = 0 as u32; + let mut matches_count: u32 = 0; let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; @@ -208,16 +202,16 @@ pub unsafe extern "C" fn lzma_mf_hc3_find( *(*mf) .hash .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; - let mut len_best: u32 = 2 as u32; + let mut len_best: u32 = 2; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); (*matches.offset(0)).len = len_best; - (*matches.offset(0)).dist = delta2.wrapping_sub(1 as u32); - matches_count = 1 as u32; + (*matches.offset(0)).dist = delta2.wrapping_sub(1); + matches_count = 1; if len_best == len_limit { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); - return 1 as u32; + return 1; } } matches_count = hc_find_func( @@ -237,12 +231,12 @@ pub unsafe extern "C" fn lzma_mf_hc3_find( return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_hc3_skip(mut mf: *mut lzma_mf, mut amount: u32) { +pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { loop { - if mf_avail(mf) < 3 as u32 { + if mf_avail(mf) < 3 { move_pending(mf); } else { - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; @@ -258,26 +252,23 @@ pub unsafe extern "C" fn lzma_mf_hc3_skip(mut mf: *mut lzma_mf, mut amount: u32) move_pos(mf); } amount = amount.wrapping_sub(1); - if !(amount != 0 as u32) { + if !(amount != 0) { break; } } } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_hc4_find( - mut mf: *mut lzma_mf, - mut matches: *mut lzma_match, -) -> u32 { +pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 4 as u32 || 0 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 4 || 0 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); - return 0 as u32; + return 0; } - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: u32 = 0 as u32; + let mut matches_count: u32 = 0; let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; @@ -300,34 +291,34 @@ pub unsafe extern "C" fn lzma_mf_hc4_find( *(*mf) .hash .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; - let mut len_best: u32 = 1 as u32; + let mut len_best: u32 = 1; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { - len_best = 2 as u32; - (*matches.offset(0)).len = 2 as u32; - (*matches.offset(0)).dist = delta2.wrapping_sub(1 as u32); - matches_count = 1 as u32; + len_best = 2; + (*matches.offset(0)).len = 2; + (*matches.offset(0)).dist = delta2.wrapping_sub(1); + matches_count = 1; } if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) as c_int == *cur as c_int { - len_best = 3 as u32; + len_best = 3; let fresh3 = matches_count; matches_count = matches_count.wrapping_add(1); - (*matches.offset(fresh3 as isize)).dist = delta3.wrapping_sub(1 as u32); + (*matches.offset(fresh3 as isize)).dist = delta3.wrapping_sub(1); delta2 = delta3; } - if matches_count != 0 as u32 { + if matches_count != 0 { len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); - (*matches.offset(matches_count.wrapping_sub(1 as u32) as isize)).len = len_best; + (*matches.offset(matches_count.wrapping_sub(1) as isize)).len = len_best; if len_best == len_limit { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); return matches_count; } } - if len_best < 3 as u32 { - len_best = 3 as u32; + if len_best < 3 { + len_best = 3; } matches_count = hc_find_func( len_limit, @@ -346,12 +337,12 @@ pub unsafe extern "C" fn lzma_mf_hc4_find( return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_hc4_skip(mut mf: *mut lzma_mf, mut amount: u32) { +pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { loop { - if mf_avail(mf) < 4 as u32 { + if mf_avail(mf) < 4 { move_pending(mf); } else { - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; @@ -374,7 +365,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mut mf: *mut lzma_mf, mut amount: u32) move_pos(mf); } amount = amount.wrapping_sub(1); - if !(amount != 0 as u32) { + if !(amount != 0) { break; } } @@ -393,34 +384,31 @@ unsafe extern "C" fn bt_find_func( ) -> *mut lzma_match { let mut ptr0: *mut u32 = son.offset((cyclic_pos << 1) as isize).offset(1); let mut ptr1: *mut u32 = son.offset((cyclic_pos << 1) as isize); - let mut len0: u32 = 0 as u32; - let mut len1: u32 = 0 as u32; + let mut len0: u32 = 0; + let mut len1: u32 = 0; loop { let delta: u32 = pos.wrapping_sub(cur_match); let fresh4 = depth; depth = depth.wrapping_sub(1); - if fresh4 == 0 as u32 || delta >= cyclic_size { + if fresh4 == 0 || delta >= cyclic_size { *ptr0 = EMPTY_HASH_VALUE as u32; *ptr1 = EMPTY_HASH_VALUE as u32; return matches; } let pair: *mut u32 = son.offset( - (cyclic_pos.wrapping_sub(delta).wrapping_add( - (if delta > cyclic_pos { - cyclic_size - } else { - 0 as u32 - }), - ) << 1) as isize, + (cyclic_pos + .wrapping_sub(delta) + .wrapping_add(if delta > cyclic_pos { cyclic_size } else { 0 }) + << 1) as isize, ); let pb: *const u8 = cur.offset(-(delta as isize)); let mut len: u32 = if len0 < len1 { len0 } else { len1 }; if *pb.offset(len as isize) as c_int == *cur.offset(len as isize) as c_int { - len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as u32), len_limit); + len = lzma_memcmplen(pb, cur, len.wrapping_add(1), len_limit); if len_best < len { len_best = len; (*matches).len = len; - (*matches).dist = delta.wrapping_sub(1 as u32); + (*matches).dist = delta.wrapping_sub(1); matches = matches.offset(1); if len == len_limit { *ptr1 = *pair.offset(0); @@ -454,30 +442,27 @@ unsafe extern "C" fn bt_skip_func( ) { let mut ptr0: *mut u32 = son.offset((cyclic_pos << 1) as isize).offset(1); let mut ptr1: *mut u32 = son.offset((cyclic_pos << 1) as isize); - let mut len0: u32 = 0 as u32; - let mut len1: u32 = 0 as u32; + let mut len0: u32 = 0; + let mut len1: u32 = 0; loop { let delta: u32 = pos.wrapping_sub(cur_match); let fresh5 = depth; depth = depth.wrapping_sub(1); - if fresh5 == 0 as u32 || delta >= cyclic_size { + if fresh5 == 0 || delta >= cyclic_size { *ptr0 = EMPTY_HASH_VALUE as u32; *ptr1 = EMPTY_HASH_VALUE as u32; return; } - let mut pair: *mut u32 = son.offset( - (cyclic_pos.wrapping_sub(delta).wrapping_add( - (if delta > cyclic_pos { - cyclic_size - } else { - 0 as u32 - }), - ) << 1) as isize, + let pair: *mut u32 = son.offset( + (cyclic_pos + .wrapping_sub(delta) + .wrapping_add(if delta > cyclic_pos { cyclic_size } else { 0 }) + << 1) as isize, ); - let mut pb: *const u8 = cur.offset(-(delta as isize)); + let pb: *const u8 = cur.offset(-(delta as isize)); let mut len: u32 = if len0 < len1 { len0 } else { len1 }; if *pb.offset(len as isize) as c_int == *cur.offset(len as isize) as c_int { - len = lzma_memcmplen(pb, cur, len.wrapping_add(1 as u32), len_limit); + len = lzma_memcmplen(pb, cur, len.wrapping_add(1), len_limit); if len == len_limit { *ptr1 = *pair.offset(0); *ptr0 = *pair.offset(1); @@ -498,20 +483,17 @@ unsafe extern "C" fn bt_skip_func( } } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt2_find( - mut mf: *mut lzma_mf, - mut matches: *mut lzma_match, -) -> u32 { +pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 2 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 2 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); - return 0 as u32; + return 0; } - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: u32 = 0 as u32; + let mut matches_count: u32 = 0; let hash_value: u32 = *cur.offset(0) as u32 | (*cur.offset(1) as u32) << 8; let cur_match: u32 = *(*mf).hash.offset(hash_value as isize); *(*mf).hash.offset(hash_value as isize) = pos; @@ -525,21 +507,21 @@ pub unsafe extern "C" fn lzma_mf_bt2_find( (*mf).cyclic_pos, (*mf).cyclic_size, matches.offset(matches_count as isize), - 1 as u32, + 1, ) .offset_from(matches) as c_long as u32; move_pos(mf); return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: u32) { +pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_8: u64; loop { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_8 = 11875828834189669668; - } else if len_limit < 2 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 2 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_8 = 18088007599891946824; } else { @@ -547,7 +529,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: u32) } match current_block_8 { 11875828834189669668 => { - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let hash_value: u32 = *cur.offset(0) as u32 | (*cur.offset(1) as u32) << 8; let cur_match: u32 = *(*mf).hash.offset(hash_value as isize); @@ -567,26 +549,23 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mut mf: *mut lzma_mf, mut amount: u32) _ => {} } amount = amount.wrapping_sub(1); - if !(amount != 0 as u32) { + if !(amount != 0) { break; } } } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt3_find( - mut mf: *mut lzma_mf, - mut matches: *mut lzma_match, -) -> u32 { +pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 3 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 3 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); - return 0 as u32; + return 0; } - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: u32 = 0 as u32; + let mut matches_count: u32 = 0; let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; @@ -598,12 +577,12 @@ pub unsafe extern "C" fn lzma_mf_bt3_find( *(*mf) .hash .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; - let mut len_best: u32 = 2 as u32; + let mut len_best: u32 = 2; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); (*matches.offset(0)).len = len_best; - (*matches.offset(0)).dist = delta2.wrapping_sub(1 as u32); - matches_count = 1 as u32; + (*matches.offset(0)).dist = delta2.wrapping_sub(1); + matches_count = 1; if len_best == len_limit { bt_skip_func( len_limit, @@ -616,7 +595,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_find( (*mf).cyclic_size, ); move_pos(mf); - return 1 as u32; + return 1; } } matches_count = bt_find_func( @@ -636,14 +615,14 @@ pub unsafe extern "C" fn lzma_mf_bt3_find( return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: u32) { +pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_9: u64; loop { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_9 = 11875828834189669668; - } else if len_limit < 3 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 3 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_9 = 18088007599891946824; } else { @@ -651,7 +630,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: u32) } match current_block_9 { 11875828834189669668 => { - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; @@ -679,26 +658,23 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mut mf: *mut lzma_mf, mut amount: u32) _ => {} } amount = amount.wrapping_sub(1); - if !(amount != 0 as u32) { + if !(amount != 0) { break; } } } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt4_find( - mut mf: *mut lzma_mf, - mut matches: *mut lzma_match, -) -> u32 { +pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 4 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 4 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); - return 0 as u32; + return 0; } - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let mut matches_count: u32 = 0 as u32; + let mut matches_count: u32 = 0; let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; @@ -721,26 +697,26 @@ pub unsafe extern "C" fn lzma_mf_bt4_find( *(*mf) .hash .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; - let mut len_best: u32 = 1 as u32; + let mut len_best: u32 = 1; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { - len_best = 2 as u32; - (*matches.offset(0)).len = 2 as u32; - (*matches.offset(0)).dist = delta2.wrapping_sub(1 as u32); - matches_count = 1 as u32; + len_best = 2; + (*matches.offset(0)).len = 2; + (*matches.offset(0)).dist = delta2.wrapping_sub(1); + matches_count = 1; } if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) as c_int == *cur as c_int { - len_best = 3 as u32; + len_best = 3; let fresh6 = matches_count; matches_count = matches_count.wrapping_add(1); - (*matches.offset(fresh6 as isize)).dist = delta3.wrapping_sub(1 as u32); + (*matches.offset(fresh6 as isize)).dist = delta3.wrapping_sub(1); delta2 = delta3; } - if matches_count != 0 as u32 { + if matches_count != 0 { len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); - (*matches.offset(matches_count.wrapping_sub(1 as u32) as isize)).len = len_best; + (*matches.offset(matches_count.wrapping_sub(1) as isize)).len = len_best; if len_best == len_limit { bt_skip_func( len_limit, @@ -756,8 +732,8 @@ pub unsafe extern "C" fn lzma_mf_bt4_find( return matches_count; } } - if len_best < 3 as u32 { - len_best = 3 as u32; + if len_best < 3 { + len_best = 3; } matches_count = bt_find_func( len_limit, @@ -776,14 +752,14 @@ pub unsafe extern "C" fn lzma_mf_bt4_find( return matches_count; } #[no_mangle] -pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: u32) { +pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_10: u64; loop { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_10 = 11875828834189669668; - } else if len_limit < 4 as u32 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 4 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_10 = 18088007599891946824; } else { @@ -791,7 +767,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: u32) } match current_block_10 { 11875828834189669668 => { - let mut cur: *const u8 = mf_ptr(mf); + let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; @@ -826,7 +802,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mut mf: *mut lzma_mf, mut amount: u32) _ => {} } amount = amount.wrapping_sub(1); - if !(amount != 0 as u32) { + if !(amount != 0) { break; } } diff --git a/liblzma-rs/src/lzma/fastpos_table.rs b/liblzma-rs/src/lzma/fastpos_table.rs index e4d2f0a9..943e00e5 100644 --- a/liblzma-rs/src/lzma/fastpos_table.rs +++ b/liblzma-rs/src/lzma/fastpos_table.rs @@ -1,5 +1,3 @@ -use crate::types::*; -use core::ffi::c_int; #[no_mangle] pub static mut lzma_fastpos: [u8; 8192] = [ 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index e9c37c30..2b6e645b 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -220,15 +220,11 @@ pub const SEQ_COMPRESSED_0: sequence = 3; pub const SEQ_UNCOMPRESSED_2: sequence = 2; pub const SEQ_UNCOMPRESSED_1: sequence = 1; pub const SEQ_CONTROL: sequence = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; -pub const LZ_DICT_REPEAT_MAX: c_int = 288 as c_int; -pub const LZ_DICT_INIT_POS: c_int = 2 as c_int * LZ_DICT_REPEAT_MAX; +pub const LZ_DICT_REPEAT_MAX: c_int = 288; +pub const LZ_DICT_INIT_POS: c_int = 2 * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { - coder: NULL, + coder: core::ptr::null_mut(), code: None, reset: None, set_uncompressed: None, @@ -236,11 +232,11 @@ pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { }; #[inline] unsafe extern "C" fn dict_write( - mut dict: *mut lzma_dict, - mut in_0: *const u8, - mut in_pos: *mut size_t, + dict: *mut lzma_dict, + in_0: *const u8, + in_pos: *mut size_t, mut in_size: size_t, - mut left: *mut size_t, + left: *mut size_t, ) { if in_size.wrapping_sub(*in_pos) > *left { in_size = (*in_pos).wrapping_add(*left); @@ -258,28 +254,28 @@ unsafe extern "C" fn dict_write( } } #[inline] -unsafe extern "C" fn dict_reset(mut dict: *mut lzma_dict) { - (*dict).need_reset = true_0 != 0; +unsafe extern "C" fn dict_reset(dict: *mut lzma_dict) { + (*dict).need_reset = true; } unsafe extern "C" fn lzma2_decode( - mut coder_ptr: *mut c_void, - mut dict: *mut lzma_dict, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + coder_ptr: *mut c_void, + dict: *mut lzma_dict, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { - let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; + let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; while *in_pos < in_size || (*coder).sequence == SEQ_LZMA { match (*coder).sequence { 0 => { let control: u32 = *in_0.offset(*in_pos as isize) as u32; *in_pos = (*in_pos).wrapping_add(1); - if control == 0 as u32 { + if control == 0 { return LZMA_STREAM_END; } - if control >= 0xe0 as u32 || control == 1 as u32 { - (*coder).need_properties = true_0 != 0; - (*coder).need_dictionary_reset = true_0 != 0; + if control >= 0xe0 as u32 || control == 1 { + (*coder).need_properties = true; + (*coder).need_dictionary_reset = true; } else if (*coder).need_dictionary_reset { return LZMA_DATA_ERROR; } @@ -287,7 +283,7 @@ unsafe extern "C" fn lzma2_decode( (*coder).uncompressed_size = ((control & 0x1f as u32) << 16) as size_t; (*coder).sequence = SEQ_UNCOMPRESSED_1; if control >= 0xc0 as u32 { - (*coder).need_properties = false_0 != 0; + (*coder).need_properties = false; (*coder).next_sequence = SEQ_PROPERTIES; } else if (*coder).need_properties { return LZMA_DATA_ERROR; @@ -301,14 +297,14 @@ unsafe extern "C" fn lzma2_decode( } } } else { - if control > 2 as u32 { + if control > 2 { return LZMA_DATA_ERROR; } (*coder).sequence = SEQ_COMPRESSED_0; (*coder).next_sequence = SEQ_COPY; } if (*coder).need_dictionary_reset { - (*coder).need_dictionary_reset = false_0 != 0; + (*coder).need_dictionary_reset = false; dict_reset(dict); return LZMA_OK; } @@ -334,7 +330,7 @@ unsafe extern "C" fn lzma2_decode( .expect("non-null function pointer")( (*coder).lzma.coder, (*coder).uncompressed_size as lzma_vli, - false_0 != 0, + false, ); } 3 => { @@ -381,7 +377,7 @@ unsafe extern "C" fn lzma2_decode( if ret != LZMA_STREAM_END { return ret; } - if (*coder).compressed_size != 0 as size_t { + if (*coder).compressed_size != 0 { return LZMA_DATA_ERROR; } (*coder).sequence = SEQ_CONTROL; @@ -394,7 +390,7 @@ unsafe extern "C" fn lzma2_decode( in_size, &raw mut (*coder).compressed_size, ); - if (*coder).compressed_size != 0 as size_t { + if (*coder).compressed_size != 0 { return LZMA_OK; } (*coder).sequence = SEQ_CONTROL; @@ -404,25 +400,22 @@ unsafe extern "C" fn lzma2_decode( } return LZMA_OK; } -unsafe extern "C" fn lzma2_decoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; +unsafe extern "C" fn lzma2_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; lzma_free((*coder).lzma.coder, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma2_decoder_init( - mut lz: *mut lzma_lz_decoder, - mut allocator: *const lzma_allocator, - mut id: lzma_vli, - mut opt: *const c_void, - mut lz_options: *mut lzma_lz_options, + lz: *mut lzma_lz_decoder, + allocator: *const lzma_allocator, + _id: lzma_vli, + opt: *const c_void, + lz_options: *mut lzma_lz_options, ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_lzma2_coder; if coder.is_null() { @@ -454,18 +447,18 @@ unsafe extern "C" fn lzma2_decoder_init( as Option ()>; (*coder).lzma = LZMA_LZ_DECODER_INIT; } - let mut options: *const lzma_options_lzma = opt as *const lzma_options_lzma; + let options: *const lzma_options_lzma = opt as *const lzma_options_lzma; (*coder).sequence = SEQ_CONTROL; - (*coder).need_properties = true_0 != 0; + (*coder).need_properties = true; (*coder).need_dictionary_reset = - (*options).preset_dict.is_null() || (*options).preset_dict_size == 0 as u32; + (*options).preset_dict.is_null() || (*options).preset_dict_size == 0; return lzma_lzma_decoder_create(&raw mut (*coder).lzma, allocator, options, lz_options); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { return lzma_lz_decoder_init( next, @@ -484,18 +477,18 @@ pub unsafe extern "C" fn lzma_lzma2_decoder_init( ); } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma2_decoder_memusage(mut options: *const c_void) -> u64 { - return (::core::mem::size_of::() as u64) - .wrapping_add(lzma_lzma_decoder_memusage_nocheck(options)); +pub extern "C" fn lzma_lzma2_decoder_memusage(options: *const c_void) -> u64 { + return (core::mem::size_of::() as u64) + .wrapping_add(unsafe { lzma_lzma_decoder_memusage_nocheck(options) }); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_props_decode( - mut options: *mut *mut c_void, - mut allocator: *const lzma_allocator, - mut props: *const u8, - mut props_size: size_t, + options: *mut *mut c_void, + allocator: *const lzma_allocator, + props: *const u8, + props_size: size_t, ) -> lzma_ret { - if props_size != 1 as size_t { + if props_size != 1 { return LZMA_OPTIONS_ERROR; } if *props.offset(0) as c_int & 0xc0 as c_int != 0 { @@ -504,8 +497,8 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if *props.offset(0) as c_int > 40 as c_int { return LZMA_OPTIONS_ERROR; } - let mut opt: *mut lzma_options_lzma = lzma_alloc( - ::core::mem::size_of::() as size_t, + let opt: *mut lzma_options_lzma = lzma_alloc( + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_options_lzma; if opt.is_null() { @@ -518,7 +511,7 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( (*opt).dict_size <<= u32::from(*props.offset(0)).wrapping_div(2).wrapping_add(11); } (*opt).preset_dict = ::core::ptr::null::(); - (*opt).preset_dict_size = 0 as u32; + (*opt).preset_dict_size = 0; *options = opt as *mut c_void; return LZMA_OK; } diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 26bbca7b..d9fe0485 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -262,17 +262,13 @@ pub const SEQ_UNCOMPRESSED_HEADER: C2RustUnnamed = 3; pub const SEQ_LZMA_COPY: C2RustUnnamed = 2; pub const SEQ_LZMA_ENCODE: C2RustUnnamed = 1; pub const SEQ_INIT: C2RustUnnamed = 0; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; -pub const LZMA_LCLP_MAX: c_int = 4 as c_int; -pub const LZMA_PB_MAX: c_int = 4 as c_int; +pub const LZMA_LCLP_MAX: c_int = 4; +pub const LZMA_PB_MAX: c_int = 4; #[inline] -unsafe extern "C" fn mf_unencoded(mut mf: *const lzma_mf) -> u32 { +unsafe extern "C" fn mf_unencoded(mf: *const lzma_mf) -> u32 { return (*mf) .write_pos .wrapping_sub((*mf).read_pos) @@ -280,11 +276,11 @@ unsafe extern "C" fn mf_unencoded(mut mf: *const lzma_mf) -> u32 { } #[inline] unsafe extern "C" fn mf_read( - mut mf: *mut lzma_mf, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut left: *mut size_t, + mf: *mut lzma_mf, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + left: *mut size_t, ) { let out_avail: size_t = out_size.wrapping_sub(*out_pos); let copy_size: size_t = if out_avail < *left { out_avail } else { *left }; @@ -299,13 +295,13 @@ unsafe extern "C" fn mf_read( *out_pos = (*out_pos).wrapping_add(copy_size); *left = (*left).wrapping_sub(copy_size); } -pub const FASTPOS_BITS: c_int = 13 as c_int; +pub const FASTPOS_BITS: c_int = 13; #[inline] -unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { - if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { +unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { + if dist < (1) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { + if dist < (1) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( @@ -319,19 +315,19 @@ unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { } pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; pub const LZMA2_UNCOMPRESSED_MAX: c_uint = 1u32 << 21; -pub const LZMA2_HEADER_MAX: c_int = 6 as c_int; -pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3 as c_int; -unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { +pub const LZMA2_HEADER_MAX: c_int = 6; +pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3; +unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { let mut pos: size_t = 0; if (*coder).need_properties { - pos = 0 as size_t; + pos = 0; if (*coder).need_dictionary_reset { (*coder).buf[pos as usize] = (0x80 as c_int + ((3 as c_int) << 5)) as u8; } else { (*coder).buf[pos as usize] = (0x80 as c_int + ((2 as c_int) << 5)) as u8; } } else { - pos = 1 as size_t; + pos = 1; if (*coder).need_state_reset { (*coder).buf[pos as usize] = (0x80 as c_int + ((1 as c_int) << 5)) as u8; } else { @@ -339,7 +335,7 @@ unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { } } (*coder).buf_pos = pos; - let mut size: size_t = (*coder).uncompressed_size.wrapping_sub(1 as size_t); + let mut size: size_t = (*coder).uncompressed_size.wrapping_sub(1); let fresh1 = pos; pos = pos.wrapping_add(1); (*coder).buf[fresh1 as usize] = @@ -350,7 +346,7 @@ unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { let fresh3 = pos; pos = pos.wrapping_add(1); (*coder).buf[fresh3 as usize] = (size & 0xff as size_t) as u8; - size = (*coder).compressed_size.wrapping_sub(1 as size_t); + size = (*coder).compressed_size.wrapping_sub(1); let fresh4 = pos; pos = pos.wrapping_add(1); (*coder).buf[fresh4 as usize] = (size >> 8) as u8; @@ -363,41 +359,41 @@ unsafe extern "C" fn lzma2_header_lzma(mut coder: *mut lzma_lzma2_coder) { (&raw mut (*coder).buf as *mut u8).offset(pos as isize), ); } - (*coder).need_properties = false_0 != 0; - (*coder).need_state_reset = false_0 != 0; - (*coder).need_dictionary_reset = false_0 != 0; + (*coder).need_properties = false; + (*coder).need_state_reset = false; + (*coder).need_dictionary_reset = false; (*coder).compressed_size = (*coder) .compressed_size .wrapping_add(LZMA2_HEADER_MAX as size_t); } -unsafe extern "C" fn lzma2_header_uncompressed(mut coder: *mut lzma_lzma2_coder) { +unsafe extern "C" fn lzma2_header_uncompressed(coder: *mut lzma_lzma2_coder) { if (*coder).need_dictionary_reset { - (*coder).buf[0] = 1 as u8; + (*coder).buf[0] = 1; } else { - (*coder).buf[0] = 2 as u8; + (*coder).buf[0] = 2; } - (*coder).need_dictionary_reset = false_0 != 0; - (*coder).buf[1] = ((*coder).uncompressed_size.wrapping_sub(1 as size_t) >> 8) as u8; - (*coder).buf[2] = ((*coder).uncompressed_size.wrapping_sub(1 as size_t) & 0xff as size_t) as u8; - (*coder).buf_pos = 0 as size_t; + (*coder).need_dictionary_reset = false; + (*coder).buf[1] = ((*coder).uncompressed_size.wrapping_sub(1) >> 8) as u8; + (*coder).buf[2] = ((*coder).uncompressed_size.wrapping_sub(1) & 0xff as size_t) as u8; + (*coder).buf_pos = 0; } unsafe extern "C" fn lzma2_encode( - mut coder_ptr: *mut c_void, - mut mf: *mut lzma_mf, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + coder_ptr: *mut c_void, + mf: *mut lzma_mf, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { - let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; + let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; while *out_pos < out_size { let mut current_block_45: u64; match (*coder).sequence { 0 => { - if mf_unencoded(mf) == 0 as u32 { + if mf_unencoded(mf) == 0 { if (*mf).action == LZMA_FINISH { let fresh0 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0 as u8; + *out.offset(fresh0 as isize) = 0; } return (if (*mf).action == LZMA_RUN { LZMA_OK as c_int @@ -414,8 +410,8 @@ unsafe extern "C" fn lzma2_encode( return ret_; } } - (*coder).uncompressed_size = 0 as size_t; - (*coder).compressed_size = 0 as size_t; + (*coder).uncompressed_size = 0; + (*coder).compressed_size = 0; (*coder).sequence = SEQ_LZMA_ENCODE; current_block_45 = 2979737022853876585; } @@ -456,7 +452,7 @@ unsafe extern "C" fn lzma2_encode( out_size, &raw mut (*coder).uncompressed_size, ); - if (*coder).uncompressed_size != 0 as size_t { + if (*coder).uncompressed_size != 0 { return LZMA_OK; } (*coder).sequence = SEQ_INIT; @@ -468,7 +464,7 @@ unsafe extern "C" fn lzma2_encode( as u32; let mut limit: u32 = 0; if left < (*mf).match_len_max { - limit = 0 as u32; + limit = 0; } else { limit = (*mf) .read_pos @@ -498,9 +494,9 @@ unsafe extern "C" fn lzma2_encode( (*coder).uncompressed_size = (*coder) .uncompressed_size .wrapping_add((*mf).read_ahead as size_t); - (*mf).read_ahead = 0 as u32; + (*mf).read_ahead = 0; lzma2_header_uncompressed(coder); - (*coder).need_state_reset = true_0 != 0; + (*coder).need_state_reset = true; (*coder).sequence = SEQ_UNCOMPRESSED_HEADER; current_block_45 = 11743904203796629665; } else { @@ -531,23 +527,20 @@ unsafe extern "C" fn lzma2_encode( } return LZMA_OK; } -unsafe extern "C" fn lzma2_encoder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; +unsafe extern "C" fn lzma2_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; lzma_free((*coder).lzma, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma2_encoder_options_update( - mut coder_ptr: *mut c_void, - mut filter: *const lzma_filter, + coder_ptr: *mut c_void, + filter: *const lzma_filter, ) -> lzma_ret { - let mut coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; + let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; if (*filter).options.is_null() || (*coder).sequence != SEQ_INIT { return LZMA_PROG_ERROR; } - let mut opt: *const lzma_options_lzma = (*filter).options as *const lzma_options_lzma; + let opt: *const lzma_options_lzma = (*filter).options as *const lzma_options_lzma; if (*coder).opt_cur.lc != (*opt).lc || (*coder).opt_cur.lp != (*opt).lp || (*coder).opt_cur.pb != (*opt).pb @@ -562,17 +555,17 @@ unsafe extern "C" fn lzma2_encoder_options_update( (*coder).opt_cur.lc = (*opt).lc; (*coder).opt_cur.lp = (*opt).lp; (*coder).opt_cur.pb = (*opt).pb; - (*coder).need_properties = true_0 != 0; - (*coder).need_state_reset = true_0 != 0; + (*coder).need_properties = true; + (*coder).need_state_reset = true; } return LZMA_OK; } unsafe extern "C" fn lzma2_encoder_init( - mut lz: *mut lzma_lz_encoder, - mut allocator: *const lzma_allocator, - mut id: lzma_vli, - mut options: *const c_void, - mut lz_options: *mut lzma_lz_options, + lz: *mut lzma_lz_encoder, + allocator: *const lzma_allocator, + _id: lzma_vli, + options: *const c_void, + lz_options: *mut lzma_lz_options, ) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; @@ -580,7 +573,7 @@ unsafe extern "C" fn lzma2_encoder_init( let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; if coder.is_null() { coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_lzma2_coder; if coder.is_null() { @@ -615,14 +608,14 @@ unsafe extern "C" fn lzma2_encoder_init( as unsafe extern "C" fn(*mut c_void, *const lzma_filter) -> lzma_ret, ) as Option lzma_ret>; - (*coder).lzma = NULL; + (*coder).lzma = core::ptr::null_mut(); } (*coder).opt_cur = *(options as *const lzma_options_lzma); (*coder).sequence = SEQ_INIT; - (*coder).need_properties = true_0 != 0; - (*coder).need_state_reset = false_0 != 0; + (*coder).need_properties = true; + (*coder).need_state_reset = false; (*coder).need_dictionary_reset = - (*coder).opt_cur.preset_dict.is_null() || (*coder).opt_cur.preset_dict_size == 0 as u32; + (*coder).opt_cur.preset_dict.is_null() || (*coder).opt_cur.preset_dict_size == 0; let ret_: lzma_ret = lzma_lzma_encoder_create( &raw mut (*coder).lzma, allocator, @@ -645,9 +638,9 @@ unsafe extern "C" fn lzma2_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { return lzma_lz_encoder_init( next, @@ -666,26 +659,23 @@ pub unsafe extern "C" fn lzma_lzma2_encoder_init( ); } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma2_encoder_memusage(mut options: *const c_void) -> u64 { - let lzma_mem: u64 = lzma_lzma_encoder_memusage(options) as u64; +pub extern "C" fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64 { + let lzma_mem: u64 = unsafe { lzma_lzma_encoder_memusage(options) } as u64; if lzma_mem == UINT64_MAX as u64 { return UINT64_MAX as u64; } - return (::core::mem::size_of::() as u64).wrapping_add(lzma_mem); + return (core::mem::size_of::() as u64).wrapping_add(lzma_mem); } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma2_props_encode( - mut options: *const c_void, - mut out: *mut u8, -) -> lzma_ret { +pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; } let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; - let mut d: u32 = if (*opt).dict_size > 4096 as u32 { + let mut d: u32 = if (*opt).dict_size > 4096 { (*opt).dict_size } else { - 4096 as u32 + 4096 }; d = d.wrapping_sub(1); d |= d >> 2; @@ -694,23 +684,23 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode( d |= d >> 8; d |= d >> 16; if d == UINT32_MAX as u32 { - *out.offset(0) = 40 as u8; + *out.offset(0) = 40; } else { - *out.offset(0) = get_dist_slot(d.wrapping_add(1 as u32)).wrapping_sub(24 as u32) as u8; + *out.offset(0) = get_dist_slot(d.wrapping_add(1)).wrapping_sub(24) as u8; } return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma2_block_size(mut options: *const c_void) -> u64 { +pub unsafe extern "C" fn lzma_lzma2_block_size(options: *const c_void) -> u64 { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; if !((*opt).dict_size >= LZMA_DICT_SIZE_MIN as u32 - && (*opt).dict_size <= ((1 as u32) << 30).wrapping_add((1 as u32) << 29)) + && (*opt).dict_size <= (1u32 << 30).wrapping_add((1) << 29)) { return UINT64_MAX as u64; } - return if ((*opt).dict_size as u64).wrapping_mul(3 as u64) > (1 as u64) << 20 { - ((*opt).dict_size as u64).wrapping_mul(3 as u64) + return if ((*opt).dict_size as u64).wrapping_mul(3) > (1) << 20 { + ((*opt).dict_size as u64).wrapping_mul(3) } else { - (1 as u64) << 20 + (1) << 20 }; } diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 146318ff..10271286 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -270,59 +270,49 @@ pub struct lzma_length_decoder { pub mid: [[probability; 8]; 16], pub high: [probability; 256], } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0) as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - return num; +extern "C" fn read32le(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; + num + }; } pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; -pub const LZMA_LCLP_MAX: c_int = 4 as c_int; -pub const LZMA_PB_MAX: c_int = 4 as c_int; +pub const LZMA_LCLP_MAX: c_int = 4; +pub const LZMA_PB_MAX: c_int = 4; pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; -pub const LZ_DICT_REPEAT_MAX: c_int = 288 as c_int; -pub const LZ_DICT_INIT_POS: c_int = 2 as c_int * LZ_DICT_REPEAT_MAX; +pub const LZ_DICT_REPEAT_MAX: c_int = 288; +pub const LZ_DICT_INIT_POS: c_int = 2 * LZ_DICT_REPEAT_MAX; #[inline] unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { return *(*dict).buf.offset( (*dict) .pos .wrapping_sub(distance as size_t) - .wrapping_sub(1 as size_t) - .wrapping_add( - (if (distance as size_t) < (*dict).pos { - 0 as size_t - } else { - (*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t) - }), - ) as isize, + .wrapping_sub(1) + .wrapping_add(if (distance as size_t) < (*dict).pos { + 0 + } else { + (*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t) + }) as isize, ); } #[inline] unsafe extern "C" fn dict_get0(dict: *const lzma_dict) -> u8 { - return *(*dict) - .buf - .offset((*dict).pos.wrapping_sub(1 as size_t) as isize); + return *(*dict).buf.offset((*dict).pos.wrapping_sub(1) as isize); } #[inline] unsafe extern "C" fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bool { return (*dict).full > distance; } #[inline] -unsafe extern "C" fn dict_repeat( - mut dict: *mut lzma_dict, - mut distance: u32, - mut len: *mut u32, -) -> bool { +unsafe extern "C" fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut u32) -> bool { let dict_avail: size_t = (*dict).limit.wrapping_sub((*dict).pos); let mut left: u32 = (if dict_avail < *len as size_t { dict_avail @@ -330,10 +320,7 @@ unsafe extern "C" fn dict_repeat( *len as size_t }) as u32; *len = (*len).wrapping_sub(left); - let mut back: size_t = (*dict) - .pos - .wrapping_sub(distance as size_t) - .wrapping_sub(1 as size_t); + let mut back: size_t = (*dict).pos.wrapping_sub(distance as size_t).wrapping_sub(1); if distance as size_t >= (*dict).pos { back = back.wrapping_add((*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t)); } @@ -345,7 +332,7 @@ unsafe extern "C" fn dict_repeat( (*dict).pos = (*dict).pos.wrapping_add(1); *(*dict).buf.offset(fresh1 as isize) = *(*dict).buf.offset(fresh0 as isize); left = left.wrapping_sub(1); - if !(left > 0 as u32) { + if !(left > 0) { break; } } @@ -360,10 +347,10 @@ unsafe extern "C" fn dict_repeat( if !(*dict).has_wrapped { (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); } - return *len != 0 as u32; + return *len != 0; } #[inline] -unsafe extern "C" fn dict_put(mut dict: *mut lzma_dict, mut byte: u8) { +unsafe extern "C" fn dict_put(dict: *mut lzma_dict, byte: u8) { let fresh2 = (*dict).pos; (*dict).pos = (*dict).pos.wrapping_add(1); *(*dict).buf.offset(fresh2 as isize) = byte; @@ -372,68 +359,66 @@ unsafe extern "C" fn dict_put(mut dict: *mut lzma_dict, mut byte: u8) { } } #[inline] -unsafe extern "C" fn dict_put_safe(mut dict: *mut lzma_dict, mut byte: u8) -> bool { +unsafe extern "C" fn dict_put_safe(dict: *mut lzma_dict, byte: u8) -> bool { if ((*dict).pos == (*dict).limit) as c_long != 0 { - return true_0 != 0; + return true; } dict_put(dict, byte); - return false_0 != 0; + return false; } -pub const RC_SHIFT_BITS: c_int = 8 as c_int; -pub const RC_TOP_BITS: c_int = 24 as c_int; +pub const RC_SHIFT_BITS: c_int = 8; +pub const RC_TOP_BITS: c_int = 24; pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; -pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; +pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11; pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_BITS: c_int = 5 as c_int; +pub const RC_MOVE_BITS: c_int = 5; #[inline] -unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> bool { +unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { return (*options).lc <= LZMA_LCLP_MAX as u32 && (*options).lp <= LZMA_LCLP_MAX as u32 && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as u32 && (*options).pb <= LZMA_PB_MAX as u32; } -pub const STATES: c_int = 12 as c_int; -pub const LIT_STATES: c_int = 7 as c_int; +pub const STATES: c_int = 12; +pub const LIT_STATES: c_int = 7; pub const LITERAL_CODER_SIZE: c_uint = 0x300; #[inline] -unsafe extern "C" fn literal_init(mut probs: *mut probability, mut lc: u32, mut lp: u32) { +unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < coders { *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; i = i.wrapping_add(1); } } -pub const MATCH_LEN_MIN: c_int = 2 as c_int; -pub const LEN_LOW_BITS: c_int = 3 as c_int; -pub const LEN_LOW_SYMBOLS: c_int = (1 as c_int) << LEN_LOW_BITS; -pub const LEN_MID_BITS: c_int = 3 as c_int; -pub const LEN_MID_SYMBOLS: c_int = (1 as c_int) << LEN_MID_BITS; -pub const LEN_HIGH_BITS: c_int = 8 as c_int; -pub const LEN_HIGH_SYMBOLS: c_int = (1 as c_int) << LEN_HIGH_BITS; -pub const DIST_STATES: c_int = 4 as c_int; -pub const DIST_SLOT_BITS: c_int = 6 as c_int; -pub const DIST_SLOTS: c_int = (1 as c_int) << DIST_SLOT_BITS; -pub const DIST_MODEL_START: c_int = 4 as c_int; -pub const DIST_MODEL_END: c_int = 14 as c_int; -pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2 as c_int; -pub const FULL_DISTANCES: c_int = (1 as c_int) << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: c_int = 4 as c_int; -pub const ALIGN_SIZE: c_int = (1 as c_int) << ALIGN_BITS; +pub const MATCH_LEN_MIN: c_int = 2; +pub const LEN_LOW_BITS: c_int = 3; +pub const LEN_LOW_SYMBOLS: c_int = (1) << LEN_LOW_BITS; +pub const LEN_MID_BITS: c_int = 3; +pub const LEN_MID_SYMBOLS: c_int = (1) << LEN_MID_BITS; +pub const LEN_HIGH_BITS: c_int = 8; +pub const LEN_HIGH_SYMBOLS: c_int = (1) << LEN_HIGH_BITS; +pub const DIST_STATES: c_int = 4; +pub const DIST_SLOT_BITS: c_int = 6; +pub const DIST_SLOTS: c_int = (1) << DIST_SLOT_BITS; +pub const DIST_MODEL_START: c_int = 4; +pub const DIST_MODEL_END: c_int = 14; +pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2; +pub const FULL_DISTANCES: c_int = (1) << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: c_int = 4; +pub const ALIGN_SIZE: c_int = (1) << ALIGN_BITS; #[inline] unsafe extern "C" fn rc_read_init( - mut rc: *mut lzma_range_decoder, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + rc: *mut lzma_range_decoder, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { - while (*rc).init_bytes_left > 0 as u32 { + while (*rc).init_bytes_left > 0 { if *in_pos == in_size { return LZMA_OK; } - if (*rc).init_bytes_left == 5 as u32 - && *in_0.offset(*in_pos as isize) as c_int != 0 as c_int - { + if (*rc).init_bytes_left == 5 && *in_0.offset(*in_pos as isize) as c_int != 0 as c_int { return LZMA_DATA_ERROR; } (*rc).code = (*rc).code << 8 | *in_0.offset(*in_pos as isize) as u32; @@ -443,14 +428,14 @@ unsafe extern "C" fn rc_read_init( return LZMA_STREAM_END; } unsafe extern "C" fn lzma_decode( - mut coder_ptr: *mut c_void, - mut dictptr: *mut lzma_dict, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, + coder_ptr: *mut c_void, + dictptr: *mut lzma_dict, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, ) -> lzma_ret { let mut current_block: u64; - let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; + let coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; let ret: lzma_ret = rc_read_init(&raw mut (*coder).rc, in_0, in_pos, in_size) as lzma_ret; if ret != LZMA_STREAM_END { return ret; @@ -459,13 +444,12 @@ unsafe extern "C" fn lzma_decode( let dict_start: size_t = dict.pos; let mut rc: lzma_range_decoder = (*coder).rc; let mut rc_in_ptr: *const u8 = in_0.offset(*in_pos as isize); - let mut rc_in_end: *const u8 = in_0.offset(in_size as isize); - let mut rc_in_fast_end: *const u8 = - if rc_in_end.offset_from(rc_in_ptr) as c_long <= 20 as c_long { - rc_in_ptr - } else { - rc_in_end.offset(-20) - }; + let rc_in_end: *const u8 = in_0.offset(in_size as isize); + let rc_in_fast_end: *const u8 = if rc_in_end.offset_from(rc_in_ptr) as c_long <= 20 as c_long { + rc_in_ptr + } else { + rc_in_end.offset(-20) + }; let mut rc_bound: u32 = 0; let mut state: u32 = (*coder).state as u32; let mut rep0: u32 = (*coder).rep0; @@ -483,12 +467,12 @@ unsafe extern "C" fn lzma_decode( let mut pos_state: u32 = (dict.pos & pos_mask as size_t) as u32; let mut ret_0: lzma_ret = LZMA_OK; let mut eopm_is_valid: bool = (*coder).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli; - let mut might_finish_without_eopm: bool = false_0 != 0; + let mut might_finish_without_eopm: bool = false; if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli && (*coder).uncompressed_size <= dict.limit.wrapping_sub(dict.pos) as lzma_vli { dict.limit = dict.pos.wrapping_add((*coder).uncompressed_size as size_t); - might_finish_without_eopm = true_0 != 0; + might_finish_without_eopm = true; } match (*coder).sequence { 0 | 1 => { @@ -807,9 +791,7 @@ unsafe extern "C" fn lzma_decode( (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as c_int - ((*coder).is_rep[state as usize] as c_int >> RC_MOVE_BITS)) as probability; - if !(!dict_is_distance_valid(&raw mut dict, 0 as size_t) as c_int as c_long - != 0) - { + if !(!dict_is_distance_valid(&raw mut dict, 0) as c_int as c_long != 0) { current_block = 4420799852307653083; continue; } @@ -831,7 +813,7 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *fresh137 as u32; } } - ret_0 = (if rc.code == 0 as u32 { + ret_0 = (if rc.code == 0 { LZMA_STREAM_END as c_int } else { LZMA_DATA_ERROR as c_int @@ -899,17 +881,17 @@ unsafe extern "C" fn lzma_decode( } rc.range >>= 1 as c_int; rc.code = rc.code.wrapping_sub(rc.range); - rc_bound = (0 as u32).wrapping_sub(rc.code >> 31); + rc_bound = 0u32.wrapping_sub(rc.code >> 31); rc.code = rc.code.wrapping_add(rc.range & rc_bound); - rep0 = (rep0 << 1).wrapping_add(rc_bound.wrapping_add(1 as u32)); + rep0 = (rep0 << 1).wrapping_add(rc_bound.wrapping_add(1)); limit = limit.wrapping_sub(1); - if limit > 0 as u32 { + if limit > 0 { current_block = 15418612220330286504; continue; } rep0 <<= ALIGN_BITS; - symbol = 0 as u32; - offset = 1 as u32; + symbol = 0; + offset = 1; current_block = 10510472849010538284; continue; } @@ -943,7 +925,7 @@ unsafe extern "C" fn lzma_decode( *fresh134 = (*fresh134 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); rep0 = (rep0 as u32).wrapping_add(1u32 << offset) as u32; } offset = offset.wrapping_add(1); @@ -983,7 +965,7 @@ unsafe extern "C" fn lzma_decode( *fresh131 = (*fresh131 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if symbol < DIST_SLOTS as u32 { current_block = 4174862988780014241; @@ -993,16 +975,16 @@ unsafe extern "C" fn lzma_decode( if symbol < DIST_MODEL_START as u32 { rep0 = symbol; } else { - limit = (symbol >> 1).wrapping_sub(1 as u32); - rep0 = (2 as u32).wrapping_add(symbol & 1 as u32); + limit = (symbol >> 1).wrapping_sub(1); + rep0 = (2u32).wrapping_add(symbol & 1); if symbol < DIST_MODEL_END as u32 { rep0 <<= limit; probs = (&raw mut (*coder).pos_special as *mut probability) .offset(rep0 as isize) .offset(-(symbol as isize)) .offset(-1); - symbol = 1 as u32; - offset = 0 as u32; + symbol = 1; + offset = 0; current_block = 617447976488552541; continue; } else { @@ -1043,7 +1025,7 @@ unsafe extern "C" fn lzma_decode( *fresh128 = (*fresh128 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if symbol < limit { current_block = 592696588731961849; @@ -1057,7 +1039,7 @@ unsafe extern "C" fn lzma_decode( (DIST_STATES - 1 as c_int) as u32 }) as isize, ) as *mut probability; - symbol = 1 as u32; + symbol = 1; current_block = 4174862988780014241; continue; } @@ -1184,7 +1166,7 @@ unsafe extern "C" fn lzma_decode( *fresh122 = (*fresh122 as c_int - (*probs.offset(subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); offset &= match_bit; } len <<= 1 as c_int; @@ -1212,7 +1194,7 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *fresh115 as u32; } } - if rc.code == 0 as u32 { + if rc.code == 0 { ret_0 = LZMA_STREAM_END; current_block = 4609795085482299213; continue; @@ -1221,7 +1203,7 @@ unsafe extern "C" fn lzma_decode( current_block = 4609795085482299213; continue; } else { - eopm_is_valid = true_0 != 0; + eopm_is_valid = true; } } if rc.range < RC_TOP_VALUE as u32 { @@ -1257,20 +1239,20 @@ unsafe extern "C" fn lzma_decode( << literal_context_bits, ) as isize, ); - symbol = 1 as u32; + symbol = 1; if state < LIT_STATES as u32 { state = if state <= STATE_SHORTREP_LIT_LIT as u32 { STATE_LIT_LIT as u32 } else { - state.wrapping_sub(3 as u32) + state.wrapping_sub(3) }; current_block = 13844743919235296534; continue; } else { state = if state <= STATE_LIT_SHORTREP as u32 { - state.wrapping_sub(3 as u32) + state.wrapping_sub(3) } else { - state.wrapping_sub(6 as u32) + state.wrapping_sub(6) }; len = (dict_get(&raw mut dict, rep0) as u32) << 1; offset = 0x100 as u32; @@ -1318,7 +1300,7 @@ unsafe extern "C" fn lzma_decode( *fresh119 = (*fresh119 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if symbol < ((1 as c_int) << 8) as u32 { current_block = 13844743919235296534; @@ -1358,7 +1340,7 @@ unsafe extern "C" fn lzma_decode( *fresh146 = (*fresh146 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if symbol < limit { current_block = 2467942631393454738; @@ -1467,9 +1449,9 @@ unsafe extern "C" fn lzma_decode( state = if state <= STATE_SHORTREP_LIT_LIT as u32 { STATE_LIT_LIT as u32 } else { - state.wrapping_sub(3 as u32) + state.wrapping_sub(3) }; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh4 = rc_in_ptr; @@ -1494,7 +1476,7 @@ unsafe extern "C" fn lzma_decode( *fresh6 = (*fresh6 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1520,7 +1502,7 @@ unsafe extern "C" fn lzma_decode( *fresh9 = (*fresh9 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1546,7 +1528,7 @@ unsafe extern "C" fn lzma_decode( *fresh12 = (*fresh12 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1572,7 +1554,7 @@ unsafe extern "C" fn lzma_decode( *fresh15 = (*fresh15 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1598,7 +1580,7 @@ unsafe extern "C" fn lzma_decode( *fresh18 = (*fresh18 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1624,7 +1606,7 @@ unsafe extern "C" fn lzma_decode( *fresh21 = (*fresh21 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1650,7 +1632,7 @@ unsafe extern "C" fn lzma_decode( *fresh24 = (*fresh24 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1676,20 +1658,20 @@ unsafe extern "C" fn lzma_decode( *fresh27 = (*fresh27 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add(0 as u32); + symbol = symbol.wrapping_add(0); } else { state = if state <= STATE_LIT_SHORTREP as u32 { - state.wrapping_sub(3 as u32) + state.wrapping_sub(3) } else { - state.wrapping_sub(6 as u32) + state.wrapping_sub(6) }; let mut t_match_byte: u32 = dict_get(&raw mut dict, rep0) as u32; let mut t_match_bit: u32 = 0; let mut t_subcoder_index: u32 = 0; let mut t_offset: u32 = 0x100 as u32; - symbol = 1 as u32; + symbol = 1; t_match_byte <<= 1 as c_int; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); @@ -1719,7 +1701,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1751,7 +1733,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1783,7 +1765,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1815,7 +1797,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1847,7 +1829,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1879,7 +1861,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1911,7 +1893,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1 as c_int; @@ -1943,7 +1925,7 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(t_subcoder_index as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } } @@ -1979,7 +1961,7 @@ unsafe extern "C" fn lzma_decode( rep3 = rep2; rep2 = rep1; rep1 = rep0; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh53 = rc_in_ptr; @@ -1996,7 +1978,7 @@ unsafe extern "C" fn lzma_decode( .wrapping_sub((*coder).match_len_decoder.choice as u32) >> RC_MOVE_BITS, ) as probability as probability; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh54 = rc_in_ptr; @@ -2035,7 +2017,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2075,7 +2057,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2115,7 +2097,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add((-((1 as c_int) << 3) + 2 as c_int) as u32); @@ -2144,7 +2126,7 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh58 = rc_in_ptr; @@ -2186,7 +2168,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2229,7 +2211,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2272,7 +2254,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add( (-((1 as c_int) << 3) + 2 as c_int + ((1 as c_int) << 3)) @@ -2287,7 +2269,7 @@ unsafe extern "C" fn lzma_decode( - ((*coder).match_len_decoder.choice2 as c_int >> RC_MOVE_BITS)) as probability; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh61 = rc_in_ptr; @@ -2318,7 +2300,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2350,7 +2332,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2382,7 +2364,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2414,7 +2396,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2446,7 +2428,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2478,7 +2460,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2510,7 +2492,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2542,7 +2524,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add( (-((1 as c_int) << 8) @@ -2562,7 +2544,7 @@ unsafe extern "C" fn lzma_decode( (DIST_STATES - 1 as c_int) as u32 }) as isize, ) as *mut probability; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh69 = rc_in_ptr; @@ -2587,7 +2569,7 @@ unsafe extern "C" fn lzma_decode( *fresh71 = (*fresh71 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2613,7 +2595,7 @@ unsafe extern "C" fn lzma_decode( *fresh74 = (*fresh74 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2639,7 +2621,7 @@ unsafe extern "C" fn lzma_decode( *fresh77 = (*fresh77 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2665,7 +2647,7 @@ unsafe extern "C" fn lzma_decode( *fresh80 = (*fresh80 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2691,7 +2673,7 @@ unsafe extern "C" fn lzma_decode( *fresh83 = (*fresh83 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2717,22 +2699,22 @@ unsafe extern "C" fn lzma_decode( *fresh86 = (*fresh86 as c_int - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add(-((1 as c_int) << 6) as u32); if symbol < DIST_MODEL_START as u32 { rep0 = symbol; } else { - limit = (symbol >> 1).wrapping_sub(1 as u32); - rep0 = (2 as u32).wrapping_add(symbol & 1 as u32); + limit = (symbol >> 1).wrapping_sub(1); + rep0 = (2u32).wrapping_add(symbol & 1); if symbol < DIST_MODEL_END as u32 { rep0 <<= limit; probs = (&raw mut (*coder).pos_special as *mut probability) .offset(rep0 as isize) .offset(-(symbol as isize)) .offset(-1); - symbol = 1 as u32; - offset = 1 as u32; + symbol = 1; + offset = 1; loop { if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2761,19 +2743,19 @@ unsafe extern "C" fn lzma_decode( - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); rep0 = rep0.wrapping_add(offset); } offset <<= 1 as c_int; limit = limit.wrapping_sub(1); - if !(limit > 0 as u32) { + if !(limit > 0) { break; } } } else { limit = limit.wrapping_sub(ALIGN_BITS as u32); loop { - rep0 = (rep0 << 1).wrapping_add(1 as u32); + rep0 = (rep0 << 1).wrapping_add(1); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh90 = rc_in_ptr; @@ -2782,16 +2764,16 @@ unsafe extern "C" fn lzma_decode( } rc.range >>= 1 as c_int; rc.code = rc.code.wrapping_sub(rc.range); - rc_bound = (0 as u32).wrapping_sub(rc.code >> 31); + rc_bound = 0u32.wrapping_sub(rc.code >> 31); rep0 = rep0.wrapping_add(rc_bound); rc.code = rc.code.wrapping_add(rc.range & rc_bound); limit = limit.wrapping_sub(1); - if !(limit > 0 as u32) { + if !(limit > 0) { break; } } rep0 <<= ALIGN_BITS; - symbol = 0 as u32; + symbol = 0; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh91 = rc_in_ptr; @@ -2799,34 +2781,33 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *fresh91 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] - as u32, + (*coder).pos_align[symbol.wrapping_add(1) as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] = - ((*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align - [symbol.wrapping_add(1 as u32) as usize] - as u32, - ) >> RC_MOVE_BITS, - ) as probability - as probability; + (*coder).pos_align[symbol.wrapping_add(1) as usize] = ((*coder) + .pos_align + [symbol.wrapping_add(1) as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[symbol.wrapping_add(1) as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] = - ((*coder).pos_align[symbol.wrapping_add(1 as u32) as usize] + (*coder).pos_align[symbol.wrapping_add(1) as usize] = + ((*coder).pos_align[symbol.wrapping_add(1) as usize] as c_int - - ((*coder).pos_align - [symbol.wrapping_add(1 as u32) as usize] + - ((*coder).pos_align[symbol.wrapping_add(1) as usize] as c_int >> RC_MOVE_BITS)) as probability; - symbol = symbol.wrapping_add(1 as u32); + symbol = symbol.wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2835,34 +2816,33 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *fresh92 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] - as u32, + (*coder).pos_align[symbol.wrapping_add(2) as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] = - ((*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align - [symbol.wrapping_add(2 as u32) as usize] - as u32, - ) >> RC_MOVE_BITS, - ) as probability - as probability; + (*coder).pos_align[symbol.wrapping_add(2) as usize] = ((*coder) + .pos_align + [symbol.wrapping_add(2) as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[symbol.wrapping_add(2) as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] = - ((*coder).pos_align[symbol.wrapping_add(2 as u32) as usize] + (*coder).pos_align[symbol.wrapping_add(2) as usize] = + ((*coder).pos_align[symbol.wrapping_add(2) as usize] as c_int - - ((*coder).pos_align - [symbol.wrapping_add(2 as u32) as usize] + - ((*coder).pos_align[symbol.wrapping_add(2) as usize] as c_int >> RC_MOVE_BITS)) as probability; - symbol = symbol.wrapping_add(2 as u32); + symbol = symbol.wrapping_add(2); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2871,34 +2851,33 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *fresh93 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] - as u32, + (*coder).pos_align[symbol.wrapping_add(4) as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] = - ((*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align - [symbol.wrapping_add(4 as u32) as usize] - as u32, - ) >> RC_MOVE_BITS, - ) as probability - as probability; + (*coder).pos_align[symbol.wrapping_add(4) as usize] = ((*coder) + .pos_align + [symbol.wrapping_add(4) as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[symbol.wrapping_add(4) as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] = - ((*coder).pos_align[symbol.wrapping_add(4 as u32) as usize] + (*coder).pos_align[symbol.wrapping_add(4) as usize] = + ((*coder).pos_align[symbol.wrapping_add(4) as usize] as c_int - - ((*coder).pos_align - [symbol.wrapping_add(4 as u32) as usize] + - ((*coder).pos_align[symbol.wrapping_add(4) as usize] as c_int >> RC_MOVE_BITS)) as probability; - symbol = symbol.wrapping_add(4 as u32); + symbol = symbol.wrapping_add(4); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2907,34 +2886,33 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *fresh94 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] - as u32, + (*coder).pos_align[symbol.wrapping_add(8) as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] = - ((*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align - [symbol.wrapping_add(8 as u32) as usize] - as u32, - ) >> RC_MOVE_BITS, - ) as probability - as probability; + (*coder).pos_align[symbol.wrapping_add(8) as usize] = ((*coder) + .pos_align + [symbol.wrapping_add(8) as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[symbol.wrapping_add(8) as usize] + as u32, + ) >> RC_MOVE_BITS, + ) + as probability + as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] = - ((*coder).pos_align[symbol.wrapping_add(8 as u32) as usize] + (*coder).pos_align[symbol.wrapping_add(8) as usize] = + ((*coder).pos_align[symbol.wrapping_add(8) as usize] as c_int - - ((*coder).pos_align - [symbol.wrapping_add(8 as u32) as usize] + - ((*coder).pos_align[symbol.wrapping_add(8) as usize] as c_int >> RC_MOVE_BITS)) as probability; - symbol = symbol.wrapping_add(8 as u32); + symbol = symbol.wrapping_add(8); } rep0 = rep0.wrapping_add(symbol); if rep0 == UINT32_MAX as u32 { @@ -2953,9 +2931,7 @@ unsafe extern "C" fn lzma_decode( (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as c_int - ((*coder).is_rep[state as usize] as c_int >> RC_MOVE_BITS)) as probability; - if !dict_is_distance_valid(&raw mut dict, 0 as size_t) as c_int as c_long - != 0 - { + if !dict_is_distance_valid(&raw mut dict, 0) as c_int as c_long != 0 { ret_0 = LZMA_DATA_ERROR; current_block = 4609795085482299213; continue 'c_9380; @@ -3097,7 +3073,7 @@ unsafe extern "C" fn lzma_decode( } else { STATE_NONLIT_REP as c_int }) as u32; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh99 = rc_in_ptr; @@ -3115,7 +3091,7 @@ unsafe extern "C" fn lzma_decode( >> RC_MOVE_BITS, ) as probability as probability; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh100 = rc_in_ptr; @@ -3156,7 +3132,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3198,7 +3174,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3240,7 +3216,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add((-((1 as c_int) << 3) + 2 as c_int) as u32); @@ -3269,7 +3245,7 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh104 = rc_in_ptr; @@ -3311,7 +3287,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3354,7 +3330,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3397,7 +3373,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add( (-((1 as c_int) << 3) + 2 as c_int + ((1 as c_int) << 3)) @@ -3412,7 +3388,7 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.choice2 as c_int >> RC_MOVE_BITS)) as probability; - symbol = 1 as u32; + symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh107 = rc_in_ptr; @@ -3446,7 +3422,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3481,7 +3457,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3516,7 +3492,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3551,7 +3527,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3586,7 +3562,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3621,7 +3597,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3656,7 +3632,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3691,7 +3667,7 @@ unsafe extern "C" fn lzma_decode( as c_int >> RC_MOVE_BITS)) as probability; - symbol = (symbol << 1).wrapping_add(1 as u32); + symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add( (-((1 as c_int) << 8) @@ -3714,7 +3690,7 @@ unsafe extern "C" fn lzma_decode( } }, 16690975975023747857 => { - symbol = 1 as u32; + symbol = 1; current_block = 2467942631393454738; continue; } @@ -3728,7 +3704,7 @@ unsafe extern "C" fn lzma_decode( continue; } 8485842003490715114 => { - symbol = 1 as u32; + symbol = 1; current_block = 592696588731961849; continue; } @@ -3769,24 +3745,24 @@ unsafe extern "C" fn lzma_decode( } if ret_0 == LZMA_STREAM_END { (*coder).rc.range = UINT32_MAX as u32; - (*coder).rc.code = 0 as u32; - (*coder).rc.init_bytes_left = 5 as u32; + (*coder).rc.code = 0; + (*coder).rc.init_bytes_left = 5; (*coder).sequence = SEQ_IS_MATCH; } return ret_0; } unsafe extern "C" fn lzma_decoder_uncompressed( - mut coder_ptr: *mut c_void, - mut uncompressed_size: lzma_vli, - mut allow_eopm: bool, + coder_ptr: *mut c_void, + uncompressed_size: lzma_vli, + allow_eopm: bool, ) { - let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; + let coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; (*coder).uncompressed_size = uncompressed_size; (*coder).allow_eopm = allow_eopm; } -unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *const c_void) { - let mut coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; - let mut options: *const lzma_options_lzma = opt as *const lzma_options_lzma; +unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_void) { + let coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; + let options: *const lzma_options_lzma = opt as *const lzma_options_lzma; (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; literal_init( &raw mut (*coder).literal as *mut probability, @@ -3797,17 +3773,17 @@ unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *co (*coder).literal_mask = ((0x100 as u32) << (*options).lp).wrapping_sub(0x100 >> (*options).lc) as u32; (*coder).state = STATE_LIT_LIT; - (*coder).rep0 = 0 as u32; - (*coder).rep1 = 0 as u32; - (*coder).rep2 = 0 as u32; - (*coder).rep3 = 0 as u32; + (*coder).rep0 = 0; + (*coder).rep1 = 0; + (*coder).rep2 = 0; + (*coder).rep3 = 0; (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; (*coder).rc.range = UINT32_MAX as u32; - (*coder).rc.code = 0 as u32; - (*coder).rc.init_bytes_left = 5 as u32; - let mut i: u32 = 0 as u32; + (*coder).rc.code = 0; + (*coder).rc.init_bytes_left = 5; + let mut i: u32 = 0; while i < STATES as u32 { - let mut j: u32 = 0 as u32; + let mut j: u32 = 0; while j <= (*coder).pos_mask { (*coder).is_match[i as usize][j as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep0_long[i as usize][j as usize] = @@ -3820,9 +3796,9 @@ unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *co (*coder).is_rep2[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; i = i.wrapping_add(1); } - let mut i_0: u32 = 0 as u32; + let mut i_0: u32 = 0; while i_0 < DIST_STATES as u32 { - let mut bt_i: u32 = 0 as u32; + let mut bt_i: u32 = 0; while bt_i < ((1 as c_int) << 6) as u32 { (*coder).dist_slot[i_0 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; @@ -3830,42 +3806,42 @@ unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *co } i_0 = i_0.wrapping_add(1); } - let mut i_1: u32 = 0 as u32; + let mut i_1: u32 = 0; while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as u32 { (*coder).pos_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; i_1 = i_1.wrapping_add(1); } - let mut bt_i_0: u32 = 0 as u32; + let mut bt_i_0: u32 = 0; while bt_i_0 < ((1 as c_int) << 4) as u32 { (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } - let num_pos_states: u32 = (1 as u32) << (*options).pb; + let num_pos_states: u32 = (1) << (*options).pb; (*coder).match_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).match_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).rep_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).rep_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1) as probability; - let mut pos_state: u32 = 0 as u32; + let mut pos_state: u32 = 0; while pos_state < num_pos_states { - let mut bt_i_1: u32 = 0 as u32; + let mut bt_i_1: u32 = 0; while bt_i_1 < ((1 as c_int) << 3) as u32 { (*coder).match_len_decoder.low[pos_state as usize][bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_1 = bt_i_1.wrapping_add(1); } - let mut bt_i_2: u32 = 0 as u32; + let mut bt_i_2: u32 = 0; while bt_i_2 < ((1 as c_int) << 3) as u32 { (*coder).match_len_decoder.mid[pos_state as usize][bt_i_2 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_2 = bt_i_2.wrapping_add(1); } - let mut bt_i_3: u32 = 0 as u32; + let mut bt_i_3: u32 = 0; while bt_i_3 < ((1 as c_int) << 3) as u32 { (*coder).rep_len_decoder.low[pos_state as usize][bt_i_3 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_3 = bt_i_3.wrapping_add(1); } - let mut bt_i_4: u32 = 0 as u32; + let mut bt_i_4: u32 = 0; while bt_i_4 < ((1 as c_int) << 3) as u32 { (*coder).rep_len_decoder.mid[pos_state as usize][bt_i_4 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; @@ -3873,33 +3849,33 @@ unsafe extern "C" fn lzma_decoder_reset(mut coder_ptr: *mut c_void, mut opt: *co } pos_state = pos_state.wrapping_add(1); } - let mut bt_i_5: u32 = 0 as u32; + let mut bt_i_5: u32 = 0; while bt_i_5 < ((1 as c_int) << 8) as u32 { (*coder).match_len_decoder.high[bt_i_5 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_5 = bt_i_5.wrapping_add(1); } - let mut bt_i_6: u32 = 0 as u32; + let mut bt_i_6: u32 = 0; while bt_i_6 < ((1 as c_int) << 8) as u32 { (*coder).rep_len_decoder.high[bt_i_6 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_6 = bt_i_6.wrapping_add(1); } (*coder).sequence = SEQ_IS_MATCH; - (*coder).probs = ::core::ptr::null_mut::(); - (*coder).symbol = 0 as u32; - (*coder).limit = 0 as u32; - (*coder).offset = 0 as u32; - (*coder).len = 0 as u32; + (*coder).probs = core::ptr::null_mut(); + (*coder).symbol = 0; + (*coder).limit = 0; + (*coder).offset = 0; + (*coder).len = 0; } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_decoder_create( - mut lz: *mut lzma_lz_decoder, - mut allocator: *const lzma_allocator, - mut options: *const lzma_options_lzma, - mut lz_options: *mut lzma_lz_options, + lz: *mut lzma_lz_decoder, + allocator: *const lzma_allocator, + options: *const lzma_options_lzma, + lz_options: *mut lzma_lz_options, ) -> lzma_ret { if (*lz).coder.is_null() { (*lz).coder = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ); if (*lz).coder.is_null() { @@ -3938,25 +3914,25 @@ pub unsafe extern "C" fn lzma_lzma_decoder_create( return LZMA_OK; } unsafe extern "C" fn lzma_decoder_init( - mut lz: *mut lzma_lz_decoder, - mut allocator: *const lzma_allocator, - mut id: lzma_vli, - mut options: *const c_void, - mut lz_options: *mut lzma_lz_options, + lz: *mut lzma_lz_decoder, + allocator: *const lzma_allocator, + id: lzma_vli, + options: *const c_void, + lz_options: *mut lzma_lz_options, ) -> lzma_ret { if !is_lclppb_valid(options as *const lzma_options_lzma) { return LZMA_PROG_ERROR; } let mut uncomp_size: lzma_vli = LZMA_VLI_UNKNOWN as lzma_vli; - let mut allow_eopm: bool = true_0 != 0; + let mut allow_eopm: bool = true; if id == LZMA_FILTER_LZMA1EXT as lzma_vli { - let mut opt: *const lzma_options_lzma = options as *const lzma_options_lzma; + let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; if (*opt).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; } uncomp_size = ((*opt).ext_size_low as u64).wrapping_add(((*opt).ext_size_high as u64) << 32) as lzma_vli; - allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 as u32 + allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 || uncomp_size == LZMA_VLI_UNKNOWN as lzma_vli; } let ret_: lzma_ret = lzma_lzma_decoder_create( @@ -3974,9 +3950,9 @@ unsafe extern "C" fn lzma_decoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { return lzma_lz_decoder_init( next, @@ -3996,44 +3972,45 @@ pub unsafe extern "C" fn lzma_lzma_decoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_lclppb_decode( - mut options: *mut lzma_options_lzma, + options: *mut lzma_options_lzma, mut byte: u8, ) -> bool { if byte as c_int > (4 as c_int * 5 as c_int + 4 as c_int) * 9 as c_int + 8 as c_int { - return true_0 != 0; + return true; } (*options).pb = (byte as c_int / (9 as c_int * 5 as c_int)) as u32; - byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9 as u32).wrapping_mul(5 as u32)) - as u8 as u8; + byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9u32).wrapping_mul(5)) as u8 as u8; (*options).lp = (byte as c_int / 9 as c_int) as u32; - (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9 as u32)); + (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9)); return (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX as u32; } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma_decoder_memusage_nocheck(mut options: *const c_void) -> u64 { - let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; - return (::core::mem::size_of::() as u64) - .wrapping_add(lzma_lz_decoder_memusage((*opt).dict_size as size_t)); +pub extern "C" fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64 { + return unsafe { + let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; + (core::mem::size_of::() as u64) + .wrapping_add(lzma_lz_decoder_memusage((*opt).dict_size as size_t)) + }; } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma_decoder_memusage(mut options: *const c_void) -> u64 { - if !is_lclppb_valid(options as *const lzma_options_lzma) { +pub extern "C" fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64 { + if !unsafe { is_lclppb_valid(options as *const lzma_options_lzma) } { return UINT64_MAX as u64; } return lzma_lzma_decoder_memusage_nocheck(options); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_props_decode( - mut options: *mut *mut c_void, - mut allocator: *const lzma_allocator, - mut props: *const u8, - mut props_size: size_t, + options: *mut *mut c_void, + allocator: *const lzma_allocator, + props: *const u8, + props_size: size_t, ) -> lzma_ret { - if props_size != 5 as size_t { + if props_size != 5 { return LZMA_OPTIONS_ERROR; } - let mut opt: *mut lzma_options_lzma = lzma_alloc( - ::core::mem::size_of::() as size_t, + let opt: *mut lzma_options_lzma = lzma_alloc( + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_options_lzma; if opt.is_null() { @@ -4045,7 +4022,7 @@ pub unsafe extern "C" fn lzma_lzma_props_decode( } else { (*opt).dict_size = read32le(props.offset(1)); (*opt).preset_dict = ::core::ptr::null::(); - (*opt).preset_dict_size = 0 as u32; + (*opt).preset_dict_size = 0; *options = opt as *mut c_void; return LZMA_OK; }; diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 2e1e9e52..3fb6eea7 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_long, c_uchar, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_long, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; fn lzma_lz_encoder_init( @@ -319,58 +319,60 @@ pub struct lzma_length_encoder { pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT32_MAX: c_uint = 4294967295; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0) = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; +extern "C" fn write32le(buf: *mut u8, num: u32) { + unsafe { + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; + } } pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; -pub const LZMA_LCLP_MAX: c_int = 4 as c_int; -pub const LZMA_PB_MAX: c_int = 4 as c_int; +pub const LZMA_LCLP_MAX: c_int = 4; +pub const LZMA_PB_MAX: c_int = 4; pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; #[inline] -unsafe extern "C" fn mf_get_hash_bytes(mut match_finder: lzma_match_finder) -> u32 { +extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { return match_finder as u32 & 0xf as u32; } #[inline] -unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: u32) { - if amount != 0 as u32 { +unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { + if amount != 0 { (*mf).skip.expect("non-null function pointer")(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const RC_SHIFT_BITS: c_int = 8 as c_int; -pub const RC_TOP_BITS: c_int = 24 as c_int; +pub const RC_SHIFT_BITS: c_int = 8; +pub const RC_TOP_BITS: c_int = 24; pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; -pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; +pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11; pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_BITS: c_int = 5 as c_int; -pub const RC_MOVE_REDUCING_BITS: c_int = 4 as c_int; +pub const RC_MOVE_BITS: c_int = 5; +pub const RC_MOVE_REDUCING_BITS: c_int = 4; #[inline] -unsafe extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { - return lzma_rc_prices[((prob as u32 - ^ (0 as u32).wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1 as u32)) - >> RC_MOVE_REDUCING_BITS) as usize] as u32; +extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { + return unsafe { + lzma_rc_prices[((prob as u32 + ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) + >> RC_MOVE_REDUCING_BITS) as usize] as u32 + }; } #[inline] -unsafe extern "C" fn rc_bit_0_price(prob: probability) -> u32 { - return lzma_rc_prices[(prob as c_int >> RC_MOVE_REDUCING_BITS) as usize] as u32; +extern "C" fn rc_bit_0_price(prob: probability) -> u32 { + return unsafe { lzma_rc_prices[(prob as c_int >> RC_MOVE_REDUCING_BITS) as usize] as u32 }; } #[inline] -unsafe extern "C" fn rc_bit_1_price(prob: probability) -> u32 { - return lzma_rc_prices - [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] - as u32; +extern "C" fn rc_bit_1_price(prob: probability) -> u32 { + return unsafe { + lzma_rc_prices + [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] + as u32 + }; } #[inline] unsafe extern "C" fn rc_bittree_price( @@ -378,74 +380,70 @@ unsafe extern "C" fn rc_bittree_price( bit_levels: u32, mut symbol: u32, ) -> u32 { - let mut price: u32 = 0 as u32; + let mut price: u32 = 0; symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; loop { - let bit: u32 = symbol & 1 as u32; + let bit: u32 = symbol & 1; symbol >>= 1 as c_int; price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); - if !(symbol != 1 as u32) { + if !(symbol != 1) { break; } } return price; } #[inline] -unsafe extern "C" fn rc_reset(mut rc: *mut lzma_range_encoder) { - (*rc).low = 0 as u64; - (*rc).cache_size = 1 as u64; +unsafe extern "C" fn rc_reset(rc: *mut lzma_range_encoder) { + (*rc).low = 0; + (*rc).cache_size = 1; (*rc).range = UINT32_MAX as u32; - (*rc).cache = 0 as u8; - (*rc).out_total = 0 as u64; - (*rc).count = 0 as size_t; - (*rc).pos = 0 as size_t; + (*rc).cache = 0; + (*rc).out_total = 0; + (*rc).count = 0; + (*rc).pos = 0; } #[inline] -unsafe extern "C" fn rc_forget(mut rc: *mut lzma_range_encoder) { - (*rc).count = 0 as size_t; +unsafe extern "C" fn rc_forget(rc: *mut lzma_range_encoder) { + (*rc).count = 0; } #[inline] -unsafe extern "C" fn rc_bit( - mut rc: *mut lzma_range_encoder, - mut prob: *mut probability, - mut bit: u32, -) { +unsafe extern "C" fn rc_bit(rc: *mut lzma_range_encoder, prob: *mut probability, bit: u32) { (*rc).symbols[(*rc).count as usize] = bit as C2RustUnnamed; (*rc).probs[(*rc).count as usize] = prob; (*rc).count = (*rc).count.wrapping_add(1); } #[inline] unsafe extern "C" fn rc_bittree( - mut rc: *mut lzma_range_encoder, - mut probs: *mut probability, + rc: *mut lzma_range_encoder, + probs: *mut probability, mut bit_count: u32, - mut symbol: u32, + symbol: u32, ) { - let mut model_index: u32 = 1 as u32; + let mut model_index: u32 = 1; loop { bit_count = bit_count.wrapping_sub(1); - let bit: u32 = symbol >> bit_count & 1 as u32; + let bit: u32 = symbol >> bit_count & 1; rc_bit( rc, probs.offset(model_index as isize) as *mut probability, bit, ); model_index = (model_index << 1).wrapping_add(bit); - if !(bit_count != 0 as u32) { + if !(bit_count != 0) { break; } } } #[inline] unsafe extern "C" fn rc_bittree_reverse( - mut rc: *mut lzma_range_encoder, - mut probs: *mut probability, + rc: *mut lzma_range_encoder, + probs: *mut probability, mut bit_count: u32, mut symbol: u32, ) { - let mut model_index: u32 = 1 as u32; + let mut model_index: u32 = 1; loop { - let bit: u32 = symbol & 1 as u32; + let bit: u32 = symbol & 1; symbol >>= 1 as c_int; rc_bit( rc, @@ -454,32 +452,28 @@ unsafe extern "C" fn rc_bittree_reverse( ); model_index = (model_index << 1).wrapping_add(bit); bit_count = bit_count.wrapping_sub(1); - if !(bit_count != 0 as u32) { + if !(bit_count != 0) { break; } } } #[inline] -unsafe extern "C" fn rc_direct( - mut rc: *mut lzma_range_encoder, - mut value: u32, - mut bit_count: u32, -) { +unsafe extern "C" fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) { loop { bit_count = bit_count.wrapping_sub(1); let fresh0 = (*rc).count; (*rc).count = (*rc).count.wrapping_add(1); (*rc).symbols[fresh0 as usize] = - (RC_DIRECT_0 as u32).wrapping_add(value >> bit_count & 1 as u32) as C2RustUnnamed; - if !(bit_count != 0 as u32) { + (RC_DIRECT_0 as u32).wrapping_add(value >> bit_count & 1) as C2RustUnnamed; + if !(bit_count != 0) { break; } } } #[inline] -unsafe extern "C" fn rc_flush(mut rc: *mut lzma_range_encoder) { - let mut i: size_t = 0 as size_t; - while i < 5 as size_t { +unsafe extern "C" fn rc_flush(rc: *mut lzma_range_encoder) { + let mut i: size_t = 0; + while i < 5 { let fresh1 = (*rc).count; (*rc).count = (*rc).count.wrapping_add(1); (*rc).symbols[fresh1 as usize] = RC_FLUSH; @@ -488,15 +482,15 @@ unsafe extern "C" fn rc_flush(mut rc: *mut lzma_range_encoder) { } #[inline] unsafe extern "C" fn rc_shift_low( - mut rc: *mut lzma_range_encoder, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + rc: *mut lzma_range_encoder, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> bool { - if ((*rc).low as u32) < 0xff000000 as u32 || ((*rc).low >> 32) as u32 != 0 as u32 { + if ((*rc).low as u32) < 0xff000000 as u32 || ((*rc).low >> 32) as u32 != 0 { loop { if *out_pos == out_size { - return true_0 != 0; + return true; } *out.offset(*out_pos as isize) = ((*rc).cache as c_int + ((*rc).low >> 32) as u8 as c_int) as u8; @@ -504,7 +498,7 @@ unsafe extern "C" fn rc_shift_low( (*rc).out_total = (*rc).out_total.wrapping_add(1); (*rc).cache = 0xff as u8; (*rc).cache_size = (*rc).cache_size.wrapping_sub(1); - if !((*rc).cache_size != 0 as u64) { + if !((*rc).cache_size != 0) { break; } } @@ -512,25 +506,25 @@ unsafe extern "C" fn rc_shift_low( } (*rc).cache_size = (*rc).cache_size.wrapping_add(1); (*rc).low = ((*rc).low & 0xffffff as u64) << RC_SHIFT_BITS; - return false_0 != 0; + return false; } #[inline] unsafe extern "C" fn rc_shift_low_dummy( - mut low: *mut u64, - mut cache_size: *mut u64, - mut cache: *mut u8, - mut out_pos: *mut u64, - mut out_size: u64, + low: *mut u64, + cache_size: *mut u64, + cache: *mut u8, + out_pos: *mut u64, + out_size: u64, ) -> bool { - if (*low as u32) < 0xff000000 as u32 || (*low >> 32) as u32 != 0 as u32 { + if (*low as u32) < 0xff000000 as u32 || (*low >> 32) as u32 != 0 { loop { if *out_pos == out_size { - return true_0 != 0; + return true; } *out_pos = (*out_pos).wrapping_add(1); *cache = 0xff as u8; *cache_size = (*cache_size).wrapping_sub(1); - if !(*cache_size != 0 as u64) { + if !(*cache_size != 0) { break; } } @@ -538,19 +532,19 @@ unsafe extern "C" fn rc_shift_low_dummy( } *cache_size = (*cache_size).wrapping_add(1); *low = (*low & 0xffffff as u64) << RC_SHIFT_BITS; - return false_0 != 0; + return false; } #[inline] unsafe extern "C" fn rc_encode( - mut rc: *mut lzma_range_encoder, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + rc: *mut lzma_range_encoder, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> bool { while (*rc).pos < (*rc).count { if (*rc).range < RC_TOP_VALUE as u32 { if rc_shift_low(rc, out, out_pos, out_size) { - return true_0 != 0; + return true; } (*rc).range <<= RC_SHIFT_BITS; } @@ -583,7 +577,7 @@ unsafe extern "C" fn rc_encode( (*rc).range = UINT32_MAX as u32; loop { if rc_shift_low(rc, out, out_pos, out_size) { - return true_0 != 0; + return true; } (*rc).pos = (*rc).pos.wrapping_add(1); if !((*rc).pos < (*rc).count) { @@ -591,21 +585,18 @@ unsafe extern "C" fn rc_encode( } } rc_reset(rc); - return false_0 != 0; + return false; } _ => {} } (*rc).pos = (*rc).pos.wrapping_add(1); } - (*rc).count = 0 as size_t; - (*rc).pos = 0 as size_t; - return false_0 != 0; + (*rc).count = 0; + (*rc).pos = 0; + return false; } #[inline] -unsafe extern "C" fn rc_encode_dummy( - mut rc: *const lzma_range_encoder, - mut out_limit: u64, -) -> bool { +unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u64) -> bool { let mut low: u64 = (*rc).low; let mut cache_size: u64 = (*rc).cache_size; let mut range: u32 = (*rc).range; @@ -621,7 +612,7 @@ unsafe extern "C" fn rc_encode_dummy( &raw mut out_pos, out_limit, ) { - return true_0 != 0; + return true; } range <<= RC_SHIFT_BITS; } @@ -630,11 +621,11 @@ unsafe extern "C" fn rc_encode_dummy( } match (*rc).symbols[pos as usize] { 0 => { - let mut prob: probability = *(*rc).probs[pos as usize]; + let prob: probability = *(*rc).probs[pos as usize]; range = (range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul(prob as u32); } 1 => { - let mut prob_0: probability = *(*rc).probs[pos as usize]; + let prob_0: probability = *(*rc).probs[pos as usize]; let bound: u32 = (prob_0 as u32).wrapping_mul(range >> RC_BIT_MODEL_TOTAL_BITS); low = low.wrapping_add(bound as u64); range = range.wrapping_sub(bound); @@ -650,8 +641,8 @@ unsafe extern "C" fn rc_encode_dummy( } pos = pos.wrapping_add(1); } - pos = 0 as size_t; - while pos < 5 as size_t { + pos = 0; + while pos < 5 { if rc_shift_low_dummy( &raw mut low, &raw mut cache_size, @@ -659,65 +650,62 @@ unsafe extern "C" fn rc_encode_dummy( &raw mut out_pos, out_limit, ) { - return true_0 != 0; + return true; } pos = pos.wrapping_add(1); } - return false_0 != 0; + return false; } #[inline] -unsafe extern "C" fn rc_pending(mut rc: *const lzma_range_encoder) -> u64 { - return (*rc) - .cache_size - .wrapping_add(5 as u64) - .wrapping_sub(1 as u64); +unsafe extern "C" fn rc_pending(rc: *const lzma_range_encoder) -> u64 { + return (*rc).cache_size.wrapping_add(5).wrapping_sub(1); } #[inline] -unsafe extern "C" fn is_lclppb_valid(mut options: *const lzma_options_lzma) -> bool { +unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { return (*options).lc <= LZMA_LCLP_MAX as u32 && (*options).lp <= LZMA_LCLP_MAX as u32 && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as u32 && (*options).pb <= LZMA_PB_MAX as u32; } -pub const STATES: c_int = 12 as c_int; -pub const LIT_STATES: c_int = 7 as c_int; +pub const STATES: c_int = 12; +pub const LIT_STATES: c_int = 7; pub const LITERAL_CODER_SIZE: c_uint = 0x300; #[inline] -unsafe extern "C" fn literal_init(mut probs: *mut probability, mut lc: u32, mut lp: u32) { +unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < coders { *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; i = i.wrapping_add(1); } } -pub const MATCH_LEN_MIN: c_int = 2 as c_int; -pub const LEN_LOW_BITS: c_int = 3 as c_int; -pub const LEN_LOW_SYMBOLS: c_int = (1 as c_int) << LEN_LOW_BITS; -pub const LEN_MID_BITS: c_int = 3 as c_int; -pub const LEN_MID_SYMBOLS: c_int = (1 as c_int) << LEN_MID_BITS; -pub const LEN_HIGH_BITS: c_int = 8 as c_int; -pub const LEN_HIGH_SYMBOLS: c_int = (1 as c_int) << LEN_HIGH_BITS; +pub const MATCH_LEN_MIN: c_int = 2; +pub const LEN_LOW_BITS: c_int = 3; +pub const LEN_LOW_SYMBOLS: c_int = (1) << LEN_LOW_BITS; +pub const LEN_MID_BITS: c_int = 3; +pub const LEN_MID_SYMBOLS: c_int = (1) << LEN_MID_BITS; +pub const LEN_HIGH_BITS: c_int = 8; +pub const LEN_HIGH_SYMBOLS: c_int = (1) << LEN_HIGH_BITS; pub const LEN_SYMBOLS: c_int = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS; -pub const MATCH_LEN_MAX: c_int = MATCH_LEN_MIN + LEN_SYMBOLS - 1 as c_int; -pub const DIST_STATES: c_int = 4 as c_int; -pub const DIST_SLOT_BITS: c_int = 6 as c_int; -pub const DIST_MODEL_START: c_int = 4 as c_int; -pub const DIST_MODEL_END: c_int = 14 as c_int; -pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2 as c_int; -pub const FULL_DISTANCES: c_int = (1 as c_int) << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: c_int = 4 as c_int; -pub const ALIGN_SIZE: c_int = (1 as c_int) << ALIGN_BITS; -pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1 as c_int; -pub const REPS: c_int = 4 as c_int; -pub const OPTS: c_int = (1 as c_int) << 12; -pub const FASTPOS_BITS: c_int = 13 as c_int; +pub const MATCH_LEN_MAX: c_int = MATCH_LEN_MIN + LEN_SYMBOLS - 1; +pub const DIST_STATES: c_int = 4; +pub const DIST_SLOT_BITS: c_int = 6; +pub const DIST_MODEL_START: c_int = 4; +pub const DIST_MODEL_END: c_int = 14; +pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2; +pub const FULL_DISTANCES: c_int = (1) << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: c_int = 4; +pub const ALIGN_SIZE: c_int = (1) << ALIGN_BITS; +pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1; +pub const REPS: c_int = 4; +pub const OPTS: c_int = (1) << 12; +pub const FASTPOS_BITS: c_int = 13; #[inline] -unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { - if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { +unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { + if dist < (1) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { + if dist < (1) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( @@ -731,8 +719,8 @@ unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { } #[inline] unsafe extern "C" fn literal_matched( - mut rc: *mut lzma_range_encoder, - mut subcoder: *mut probability, + rc: *mut lzma_range_encoder, + subcoder: *mut probability, mut match_byte: u32, mut symbol: u32, ) { @@ -742,7 +730,7 @@ unsafe extern "C" fn literal_matched( match_byte <<= 1 as c_int; let match_bit: u32 = match_byte & offset; let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol >> 8); - let bit: u32 = symbol >> 7 & 1 as u32; + let bit: u32 = symbol >> 7 & 1; rc_bit( rc, subcoder.offset(subcoder_index as isize) as *mut probability, @@ -750,28 +738,24 @@ unsafe extern "C" fn literal_matched( ); symbol <<= 1 as c_int; offset &= !(match_byte ^ symbol); - if !(symbol < (1 as u32) << 16) { + if !(symbol < (1) << 16) { break; } } } #[inline] -unsafe extern "C" fn literal( - mut coder: *mut lzma_lzma1_encoder, - mut mf: *mut lzma_mf, - mut position: u32, -) { +unsafe extern "C" fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u32) { let cur_byte: u8 = *(*mf) .buffer .offset((*mf).read_pos.wrapping_sub((*mf).read_ahead) as isize); - let mut subcoder: *mut probability = (&raw mut (*coder).literal as *mut probability).offset( - (3 as u32).wrapping_mul( + let subcoder: *mut probability = (&raw mut (*coder).literal as *mut probability).offset( + (3u32).wrapping_mul( ((position << 8).wrapping_add( *(*mf).buffer.offset( (*mf) .read_pos .wrapping_sub((*mf).read_ahead) - .wrapping_sub(1 as u32) as isize, + .wrapping_sub(1) as isize, ) as u32, ) & (*coder).literal_mask) << (*coder).literal_context_bits, @@ -783,7 +767,7 @@ unsafe extern "C" fn literal( } else { ((*coder).state as u32).wrapping_sub(3) }) as lzma_lzma_state; - rc_bittree(&raw mut (*coder).rc, subcoder, 8 as u32, cur_byte as u32); + rc_bittree(&raw mut (*coder).rc, subcoder, 8, cur_byte as u32); } else { (*coder).state = (if (*coder).state <= STATE_LIT_SHORTREP { ((*coder).state as u32).wrapping_sub(3) @@ -794,7 +778,7 @@ unsafe extern "C" fn literal( (*mf) .read_pos .wrapping_sub((*coder).reps[0]) - .wrapping_sub(1 as u32) + .wrapping_sub(1) .wrapping_sub((*mf).read_ahead) as isize, ); literal_matched( @@ -805,7 +789,7 @@ unsafe extern "C" fn literal( ); }; } -unsafe extern "C" fn length_update_prices(mut lc: *mut lzma_length_encoder, pos_state: u32) { +unsafe extern "C" fn length_update_prices(lc: *mut lzma_length_encoder, pos_state: u32) { let table_size: u32 = (*lc).table_size; (*lc).counters[pos_state as usize] = table_size; let a0: u32 = rc_bit_0_price((*lc).choice) as u32; @@ -815,7 +799,7 @@ unsafe extern "C" fn length_update_prices(mut lc: *mut lzma_length_encoder, pos_ let prices: *mut u32 = &raw mut *(&raw mut (*lc).prices as *mut [u32; 272]).offset(pos_state as isize) as *mut u32; let mut i: u32 = 0; - i = 0 as u32; + i = 0; while i < table_size && i < LEN_LOW_SYMBOLS as u32 { *prices.offset(i as isize) = a0.wrapping_add(rc_bittree_price( &raw mut *(&raw mut (*lc).low as *mut [probability; 8]).offset(pos_state as isize) @@ -846,15 +830,15 @@ unsafe extern "C" fn length_update_prices(mut lc: *mut lzma_length_encoder, pos_ } #[inline] unsafe extern "C" fn length( - mut rc: *mut lzma_range_encoder, - mut lc: *mut lzma_length_encoder, + rc: *mut lzma_range_encoder, + lc: *mut lzma_length_encoder, pos_state: u32, mut len: u32, fast_mode: bool, ) { len = len.wrapping_sub(MATCH_LEN_MIN as u32); if len < LEN_LOW_SYMBOLS as u32 { - rc_bit(rc, &raw mut (*lc).choice, 0 as u32); + rc_bit(rc, &raw mut (*lc).choice, 0); rc_bittree( rc, &raw mut *(&raw mut (*lc).low as *mut [probability; 8]).offset(pos_state as isize) @@ -863,10 +847,10 @@ unsafe extern "C" fn length( len, ); } else { - rc_bit(rc, &raw mut (*lc).choice, 1 as u32); + rc_bit(rc, &raw mut (*lc).choice, 1); len = len.wrapping_sub(LEN_LOW_SYMBOLS as u32); if len < LEN_MID_SYMBOLS as u32 { - rc_bit(rc, &raw mut (*lc).choice2, 0 as u32); + rc_bit(rc, &raw mut (*lc).choice2, 0); rc_bittree( rc, &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]).offset(pos_state as isize) @@ -875,7 +859,7 @@ unsafe extern "C" fn length( len, ); } else { - rc_bit(rc, &raw mut (*lc).choice2, 1 as u32); + rc_bit(rc, &raw mut (*lc).choice2, 1); len = len.wrapping_sub(LEN_MID_SYMBOLS as u32); rc_bittree( rc, @@ -887,14 +871,14 @@ unsafe extern "C" fn length( } if !fast_mode { (*lc).counters[pos_state as usize] = (*lc).counters[pos_state as usize].wrapping_sub(1); - if (*lc).counters[pos_state as usize] == 0 as u32 { + if (*lc).counters[pos_state as usize] == 0 { length_update_prices(lc, pos_state); } } } #[inline] unsafe extern "C" fn match_0( - mut coder: *mut lzma_lzma1_encoder, + coder: *mut lzma_lzma1_encoder, pos_state: u32, distance: u32, len: u32, @@ -925,8 +909,8 @@ unsafe extern "C" fn match_0( dist_slot, ); if dist_slot >= DIST_MODEL_START as u32 { - let footer_bits: u32 = (dist_slot >> 1).wrapping_sub(1 as u32); - let base: u32 = (2 as u32 | dist_slot & 1 as u32) << footer_bits; + let footer_bits: u32 = (dist_slot >> 1).wrapping_sub(1); + let base: u32 = (2 | dist_slot & 1) << footer_bits; let dist_reduced: u32 = distance.wrapping_sub(base); if dist_slot < DIST_MODEL_END as u32 { rc_bittree_reverse( @@ -960,25 +944,20 @@ unsafe extern "C" fn match_0( (*coder).match_price_count = (*coder).match_price_count.wrapping_add(1); } #[inline] -unsafe extern "C" fn rep_match( - mut coder: *mut lzma_lzma1_encoder, - pos_state: u32, - rep: u32, - len: u32, -) { - if rep == 0 as u32 { +unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, rep: u32, len: u32) { + if rep == 0 { rc_bit( &raw mut (*coder).rc, (&raw mut (*coder).is_rep0 as *mut probability).offset((*coder).state as isize) as *mut probability, - 0 as u32, + 0, ); rc_bit( &raw mut (*coder).rc, (&raw mut *(&raw mut (*coder).is_rep0_long as *mut [probability; 16]) .offset((*coder).state as isize) as *mut probability) .offset(pos_state as isize) as *mut probability, - (len != 1 as u32) as u32, + (len != 1) as u32, ); } else { let distance: u32 = (*coder).reps[rep as usize]; @@ -986,29 +965,29 @@ unsafe extern "C" fn rep_match( &raw mut (*coder).rc, (&raw mut (*coder).is_rep0 as *mut probability).offset((*coder).state as isize) as *mut probability, - 1 as u32, + 1, ); - if rep == 1 as u32 { + if rep == 1 { rc_bit( &raw mut (*coder).rc, (&raw mut (*coder).is_rep1 as *mut probability).offset((*coder).state as isize) as *mut probability, - 0 as u32, + 0, ); } else { rc_bit( &raw mut (*coder).rc, (&raw mut (*coder).is_rep1 as *mut probability).offset((*coder).state as isize) as *mut probability, - 1 as u32, + 1, ); rc_bit( &raw mut (*coder).rc, (&raw mut (*coder).is_rep2 as *mut probability).offset((*coder).state as isize) as *mut probability, - rep.wrapping_sub(2 as u32), + rep.wrapping_sub(2), ); - if rep == 3 as u32 { + if rep == 3 { (*coder).reps[3] = (*coder).reps[2]; } (*coder).reps[2] = (*coder).reps[1]; @@ -1016,7 +995,7 @@ unsafe extern "C" fn rep_match( (*coder).reps[1] = (*coder).reps[0]; (*coder).reps[0] = distance; } - if len == 1 as u32 { + if len == 1 { (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { STATE_LIT_SHORTREP as c_int } else { @@ -1038,11 +1017,11 @@ unsafe extern "C" fn rep_match( }; } unsafe extern "C" fn encode_symbol( - mut coder: *mut lzma_lzma1_encoder, - mut mf: *mut lzma_mf, - mut back: u32, - mut len: u32, - mut position: u32, + coder: *mut lzma_lzma1_encoder, + mf: *mut lzma_mf, + back: u32, + len: u32, + position: u32, ) { let pos_state: u32 = position & (*coder).pos_mask; if back == UINT32_MAX as u32 { @@ -1051,7 +1030,7 @@ unsafe extern "C" fn encode_symbol( (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) .offset((*coder).state as isize) as *mut probability) .offset(pos_state as isize) as *mut probability, - 0 as u32, + 0, ); literal(coder, mf, position); } else { @@ -1060,14 +1039,14 @@ unsafe extern "C" fn encode_symbol( (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) .offset((*coder).state as isize) as *mut probability) .offset(pos_state as isize) as *mut probability, - 1 as u32, + 1, ); if back < REPS as u32 { rc_bit( &raw mut (*coder).rc, (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) as *mut probability, - 1 as u32, + 1, ); rep_match(coder, pos_state, back, len); } else { @@ -1075,65 +1054,65 @@ unsafe extern "C" fn encode_symbol( &raw mut (*coder).rc, (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) as *mut probability, - 0 as u32, + 0, ); match_0(coder, pos_state, back.wrapping_sub(REPS as u32), len); } } (*mf).read_ahead = (*mf).read_ahead.wrapping_sub(len); } -unsafe extern "C" fn encode_init(mut coder: *mut lzma_lzma1_encoder, mut mf: *mut lzma_mf) -> bool { +unsafe extern "C" fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool { if (*mf).read_pos == (*mf).read_limit { if (*mf).action == LZMA_RUN { - return false_0 != 0; + return false; } } else { - mf_skip(mf, 1 as u32); - (*mf).read_ahead = 0 as u32; + mf_skip(mf, 1); + (*mf).read_ahead = 0; rc_bit( &raw mut (*coder).rc, (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]).offset(0) as *mut probability) .offset(0) as *mut probability, - 0 as u32, + 0, ); rc_bittree( &raw mut (*coder).rc, (&raw mut (*coder).literal as *mut probability).offset(0), - 8 as u32, + 8, *(*mf).buffer.offset(0) as u32, ); (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(1); } - (*coder).is_initialized = true_0 != 0; - return true_0 != 0; + (*coder).is_initialized = true; + return true; } -unsafe extern "C" fn encode_eopm(mut coder: *mut lzma_lzma1_encoder, mut position: u32) { +unsafe extern "C" fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) { let pos_state: u32 = position & (*coder).pos_mask; rc_bit( &raw mut (*coder).rc, (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) .offset((*coder).state as isize) as *mut probability) .offset(pos_state as isize) as *mut probability, - 1 as u32, + 1, ); rc_bit( &raw mut (*coder).rc, (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) as *mut probability, - 0 as u32, + 0, ); match_0(coder, pos_state, UINT32_MAX as u32, MATCH_LEN_MIN as u32); } -pub const LOOP_INPUT_MAX: c_int = OPTS + 1 as c_int; +pub const LOOP_INPUT_MAX: c_int = OPTS + 1; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encode( - mut coder: *mut lzma_lzma1_encoder, - mut mf: *mut lzma_mf, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut limit: u32, + coder: *mut lzma_lzma1_encoder, + mf: *mut lzma_mf, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + limit: u32, ) -> lzma_ret { if !(*coder).is_initialized && !encode_init(coder, mf) { return LZMA_OK; @@ -1153,7 +1132,7 @@ pub unsafe extern "C" fn lzma_lzma_encode( if (*mf).action == LZMA_RUN { return LZMA_OK; } - if (*mf).read_ahead == 0 as u32 { + if (*mf).read_ahead == 0 { break; } } @@ -1171,7 +1150,7 @@ pub unsafe extern "C" fn lzma_lzma_encode( ); } encode_symbol(coder, mf, back, len, (*coder).uncomp_size as u32); - if (*coder).out_limit != 0 as u64 + if (*coder).out_limit != 0 && rc_encode_dummy(&raw mut (*coder).rc, (*coder).out_limit) as c_int != 0 { rc_forget(&raw mut (*coder).rc); @@ -1191,17 +1170,17 @@ pub unsafe extern "C" fn lzma_lzma_encode( } rc_flush(&raw mut (*coder).rc); if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { - (*coder).is_flushed = true_0 != 0; + (*coder).is_flushed = true; return LZMA_OK; } return LZMA_STREAM_END; } unsafe extern "C" fn lzma_encode( - mut coder: *mut c_void, - mut mf: *mut lzma_mf, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, + coder: *mut c_void, + mf: *mut lzma_mf, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, ) -> lzma_ret { if ((*mf).action == LZMA_SYNC_FLUSH) as c_long != 0 { return LZMA_OPTIONS_ERROR; @@ -1216,59 +1195,63 @@ unsafe extern "C" fn lzma_encode( ); } unsafe extern "C" fn lzma_lzma_set_out_limit( - mut coder_ptr: *mut c_void, - mut uncomp_size: *mut u64, - mut out_limit: u64, + coder_ptr: *mut c_void, + uncomp_size: *mut u64, + out_limit: u64, ) -> lzma_ret { - if out_limit < 6 as u64 { + if out_limit < 6 { return LZMA_BUF_ERROR; } - let mut coder: *mut lzma_lzma1_encoder = coder_ptr as *mut lzma_lzma1_encoder; + let coder: *mut lzma_lzma1_encoder = coder_ptr as *mut lzma_lzma1_encoder; (*coder).out_limit = out_limit; (*coder).uncomp_size_ptr = uncomp_size; - (*coder).use_eopm = false_0 != 0; + (*coder).use_eopm = false; return LZMA_OK; } -unsafe extern "C" fn is_options_valid(mut options: *const lzma_options_lzma) -> bool { - return is_lclppb_valid(options) as c_int != 0 - && (*options).nice_len >= MATCH_LEN_MIN as u32 - && (*options).nice_len <= MATCH_LEN_MAX as u32 - && ((*options).mode == LZMA_MODE_FAST || (*options).mode == LZMA_MODE_NORMAL); +extern "C" fn is_options_valid(options: *const lzma_options_lzma) -> bool { + return unsafe { + is_lclppb_valid(options) as c_int != 0 + && (*options).nice_len >= MATCH_LEN_MIN as u32 + && (*options).nice_len <= MATCH_LEN_MAX as u32 + && ((*options).mode == LZMA_MODE_FAST || (*options).mode == LZMA_MODE_NORMAL) + }; } -unsafe extern "C" fn set_lz_options( - mut lz_options: *mut lzma_lz_options, - mut options: *const lzma_options_lzma, +extern "C" fn set_lz_options( + lz_options: *mut lzma_lz_options, + options: *const lzma_options_lzma, ) { - (*lz_options).before_size = OPTS as size_t; - (*lz_options).dict_size = (*options).dict_size as size_t; - (*lz_options).after_size = LOOP_INPUT_MAX as size_t; - (*lz_options).match_len_max = MATCH_LEN_MAX as size_t; - (*lz_options).nice_len = (if mf_get_hash_bytes((*options).mf) > (*options).nice_len { - mf_get_hash_bytes((*options).mf) - } else { - (*options).nice_len - }) as size_t; - (*lz_options).match_finder = (*options).mf; - (*lz_options).depth = (*options).depth; - (*lz_options).preset_dict = (*options).preset_dict; - (*lz_options).preset_dict_size = (*options).preset_dict_size; + unsafe { + (*lz_options).before_size = OPTS as size_t; + (*lz_options).dict_size = (*options).dict_size as size_t; + (*lz_options).after_size = LOOP_INPUT_MAX as size_t; + (*lz_options).match_len_max = MATCH_LEN_MAX as size_t; + (*lz_options).nice_len = (if mf_get_hash_bytes((*options).mf) > (*options).nice_len { + mf_get_hash_bytes((*options).mf) + } else { + (*options).nice_len + }) as size_t; + (*lz_options).match_finder = (*options).mf; + (*lz_options).depth = (*options).depth; + (*lz_options).preset_dict = (*options).preset_dict; + (*lz_options).preset_dict_size = (*options).preset_dict_size; + } } unsafe extern "C" fn length_encoder_reset( - mut lencoder: *mut lzma_length_encoder, + lencoder: *mut lzma_length_encoder, num_pos_states: u32, fast_mode: bool, ) { (*lencoder).choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*lencoder).choice2 = (RC_BIT_MODEL_TOTAL >> 1) as probability; - let mut pos_state: size_t = 0 as size_t; + let mut pos_state: size_t = 0; while pos_state < num_pos_states as size_t { - let mut bt_i: u32 = 0 as u32; + let mut bt_i: u32 = 0; while bt_i < ((1 as c_int) << 3) as u32 { (*lencoder).low[pos_state as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i = bt_i.wrapping_add(1); } - let mut bt_i_0: u32 = 0 as u32; + let mut bt_i_0: u32 = 0; while bt_i_0 < ((1 as c_int) << 3) as u32 { (*lencoder).mid[pos_state as usize][bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; @@ -1276,13 +1259,13 @@ unsafe extern "C" fn length_encoder_reset( } pos_state = pos_state.wrapping_add(1); } - let mut bt_i_1: u32 = 0 as u32; + let mut bt_i_1: u32 = 0; while bt_i_1 < ((1 as c_int) << 8) as u32 { (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_1 = bt_i_1.wrapping_add(1); } if !fast_mode { - let mut pos_state_0: u32 = 0 as u32; + let mut pos_state_0: u32 = 0; while pos_state_0 < num_pos_states { length_update_prices(lencoder, pos_state_0); pos_state_0 = pos_state_0.wrapping_add(1); @@ -1291,8 +1274,8 @@ unsafe extern "C" fn length_encoder_reset( } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_reset( - mut coder: *mut lzma_lzma1_encoder, - mut options: *const lzma_options_lzma, + coder: *mut lzma_lzma1_encoder, + options: *const lzma_options_lzma, ) -> lzma_ret { if !is_options_valid(options) { return LZMA_OPTIONS_ERROR; @@ -1303,9 +1286,9 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( ((0x100 as u32) << (*options).lp).wrapping_sub(0x100 >> (*options).lc) as u32; rc_reset(&raw mut (*coder).rc); (*coder).state = STATE_LIT_LIT; - let mut i: size_t = 0 as size_t; + let mut i: size_t = 0; while i < REPS as size_t { - (*coder).reps[i as usize] = 0 as u32; + (*coder).reps[i as usize] = 0; i = i.wrapping_add(1); } literal_init( @@ -1313,9 +1296,9 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( (*options).lc, (*options).lp, ); - let mut i_0: size_t = 0 as size_t; + let mut i_0: size_t = 0; while i_0 < STATES as size_t { - let mut j: size_t = 0 as size_t; + let mut j: size_t = 0; while j <= (*coder).pos_mask as size_t { (*coder).is_match[i_0 as usize][j as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep0_long[i_0 as usize][j as usize] = @@ -1328,14 +1311,14 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( (*coder).is_rep2[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; i_0 = i_0.wrapping_add(1); } - let mut i_1: size_t = 0 as size_t; + let mut i_1: size_t = 0; while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as size_t { (*coder).dist_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; i_1 = i_1.wrapping_add(1); } - let mut i_2: size_t = 0 as size_t; + let mut i_2: size_t = 0; while i_2 < DIST_STATES as size_t { - let mut bt_i: u32 = 0 as u32; + let mut bt_i: u32 = 0; while bt_i < ((1 as c_int) << 6) as u32 { (*coder).dist_slot[i_2 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; @@ -1343,95 +1326,94 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( } i_2 = i_2.wrapping_add(1); } - let mut bt_i_0: u32 = 0 as u32; + let mut bt_i_0: u32 = 0; while bt_i_0 < ((1 as c_int) << 4) as u32 { (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } length_encoder_reset( &raw mut (*coder).match_len_encoder, - (1 as u32) << (*options).pb, + (1) << (*options).pb, (*coder).fast_mode, ); length_encoder_reset( &raw mut (*coder).rep_len_encoder, - (1 as u32) << (*options).pb, + (1) << (*options).pb, (*coder).fast_mode, ); (*coder).match_price_count = UINT32_MAX.wrapping_div(2) as u32; (*coder).align_price_count = UINT32_MAX.wrapping_div(2) as u32; - (*coder).opts_end_index = 0 as u32; - (*coder).opts_current_index = 0 as u32; + (*coder).opts_end_index = 0; + (*coder).opts_current_index = 0; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_create( - mut coder_ptr: *mut *mut c_void, - mut allocator: *const lzma_allocator, - mut id: lzma_vli, - mut options: *const lzma_options_lzma, - mut lz_options: *mut lzma_lz_options, + coder_ptr: *mut *mut c_void, + allocator: *const lzma_allocator, + id: lzma_vli, + options: *const lzma_options_lzma, + lz_options: *mut lzma_lz_options, ) -> lzma_ret { if (*coder_ptr).is_null() { *coder_ptr = lzma_alloc( - ::core::mem::size_of::() as size_t, + core::mem::size_of::() as size_t, allocator, ); if (*coder_ptr).is_null() { return LZMA_MEM_ERROR; } } - let mut coder: *mut lzma_lzma1_encoder = *coder_ptr as *mut lzma_lzma1_encoder; + let coder: *mut lzma_lzma1_encoder = *coder_ptr as *mut lzma_lzma1_encoder; match (*options).mode { 1 => { - (*coder).fast_mode = true_0 != 0; + (*coder).fast_mode = true; } 2 => { - (*coder).fast_mode = false_0 != 0; - if (*options).dict_size > ((1 as u32) << 30).wrapping_add((1 as u32) << 29) { + (*coder).fast_mode = false; + if (*options).dict_size > (1u32 << 30).wrapping_add((1) << 29) { return LZMA_OPTIONS_ERROR; } - let mut log_size: u32 = 0 as u32; - while (1 as u32) << log_size < (*options).dict_size { + let mut log_size: u32 = 0; + while (1) << log_size < (*options).dict_size { log_size = log_size.wrapping_add(1); } - (*coder).dist_table_size = log_size.wrapping_mul(2 as u32); + (*coder).dist_table_size = log_size.wrapping_mul(2); let nice_len: u32 = if mf_get_hash_bytes((*options).mf) > (*options).nice_len { mf_get_hash_bytes((*options).mf) as u32 } else { (*options).nice_len }; (*coder).match_len_encoder.table_size = nice_len - .wrapping_add(1 as u32) + .wrapping_add(1u32) .wrapping_sub(MATCH_LEN_MIN as u32); (*coder).rep_len_encoder.table_size = nice_len - .wrapping_add(1 as u32) + .wrapping_add(1u32) .wrapping_sub(MATCH_LEN_MIN as u32); } _ => return LZMA_OPTIONS_ERROR, } - (*coder).is_initialized = - !(*options).preset_dict.is_null() && (*options).preset_dict_size > 0 as u32; - (*coder).is_flushed = false_0 != 0; - (*coder).uncomp_size = 0 as u64; - (*coder).uncomp_size_ptr = ::core::ptr::null_mut::(); - (*coder).out_limit = 0 as u64; + (*coder).is_initialized = !(*options).preset_dict.is_null() && (*options).preset_dict_size > 0; + (*coder).is_flushed = false; + (*coder).uncomp_size = 0; + (*coder).uncomp_size_ptr = core::ptr::null_mut(); + (*coder).out_limit = 0; (*coder).use_eopm = id == LZMA_FILTER_LZMA1 as lzma_vli; if id == LZMA_FILTER_LZMA1EXT as lzma_vli { if (*options).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; } - (*coder).use_eopm = (*options).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 as u32; + (*coder).use_eopm = (*options).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0; } set_lz_options(lz_options, options); return lzma_lzma_encoder_reset(coder, options); } unsafe extern "C" fn lzma_encoder_init( - mut lz: *mut lzma_lz_encoder, - mut allocator: *const lzma_allocator, - mut id: lzma_vli, - mut options: *const c_void, - mut lz_options: *mut lzma_lz_options, + lz: *mut lzma_lz_encoder, + allocator: *const lzma_allocator, + id: lzma_vli, + options: *const c_void, + lz_options: *mut lzma_lz_options, ) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; @@ -1469,9 +1451,9 @@ unsafe extern "C" fn lzma_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { return lzma_lz_encoder_init( next, @@ -1490,7 +1472,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_init( ); } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma_encoder_memusage(mut options: *const c_void) -> u64 { +pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { if !is_options_valid(options as *const lzma_options_lzma) { return UINT64_MAX as u64; } @@ -1506,33 +1488,30 @@ pub unsafe extern "C" fn lzma_lzma_encoder_memusage(mut options: *const c_void) preset_dict_size: 0, }; set_lz_options(&raw mut lz_options, options as *const lzma_options_lzma); - let lz_memusage: u64 = lzma_lz_encoder_memusage(&raw mut lz_options) as u64; + let lz_memusage: u64 = unsafe { lzma_lz_encoder_memusage(&raw mut lz_options) } as u64; if lz_memusage == UINT64_MAX as u64 { return UINT64_MAX as u64; } - return (::core::mem::size_of::() as u64).wrapping_add(lz_memusage); + return (core::mem::size_of::() as u64).wrapping_add(lz_memusage); } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_lclppb_encode( - mut options: *const lzma_options_lzma, - mut byte: *mut u8, + options: *const lzma_options_lzma, + byte: *mut u8, ) -> bool { if !is_lclppb_valid(options) { - return true_0 != 0; + return true; } *byte = (*options) .pb - .wrapping_mul(5 as u32) + .wrapping_mul(5) .wrapping_add((*options).lp) - .wrapping_mul(9 as u32) + .wrapping_mul(9) .wrapping_add((*options).lc) as u8; - return false_0 != 0; + return false; } #[no_mangle] -pub unsafe extern "C" fn lzma_lzma_props_encode( - mut options: *const c_void, - mut out: *mut u8, -) -> lzma_ret { +pub unsafe extern "C" fn lzma_lzma_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; } @@ -1544,6 +1523,6 @@ pub unsafe extern "C" fn lzma_lzma_props_encode( return LZMA_OK; } #[no_mangle] -pub unsafe extern "C" fn lzma_mode_is_supported(mut mode: lzma_mode) -> lzma_bool { +pub extern "C" fn lzma_mode_is_supported(mode: lzma_mode) -> lzma_bool { return (mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL) as lzma_bool; } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 4cbc4e5d..d540d358 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -115,7 +115,7 @@ pub struct lzma_lzma1_encoder_s { pub opts_current_index: u32, pub opts: [lzma_optimal; OPTS as usize], } -pub const OPTS: c_int = (1 as c_int) << 12; +pub const OPTS: c_int = (1) << 12; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { @@ -144,27 +144,27 @@ pub struct lzma_length_encoder { pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; pub const UINT32_MAX: c_uint = 4294967295; #[inline] -unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const u8 { +unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); } #[inline] -unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> u32 { +unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { return (*mf).write_pos.wrapping_sub((*mf).read_pos); } #[inline] -unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: u32) { - if amount != 0 as u32 { +unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { + if amount != 0 { (*mf).skip.expect("non-null function pointer")(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const REPS: c_int = 4 as c_int; +pub const REPS: c_int = 4; #[inline(always)] unsafe extern "C" fn lzma_memcmplen( - mut buf1: *const u8, - mut buf2: *const u8, + buf1: *const u8, + buf2: *const u8, mut len: u32, - mut limit: u32, + limit: u32, ) -> u32 { while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int { @@ -174,15 +174,15 @@ unsafe extern "C" fn lzma_memcmplen( } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_optimum_fast( - mut coder: *mut lzma_lzma1_encoder, - mut mf: *mut lzma_mf, - mut back_res: *mut u32, - mut len_res: *mut u32, + coder: *mut lzma_lzma1_encoder, + mf: *mut lzma_mf, + back_res: *mut u32, + len_res: *mut u32, ) { let nice_len: u32 = (*mf).nice_len; let mut len_main: u32 = 0; let mut matches_count: u32 = 0; - if (*mf).read_ahead == 0 as u32 { + if (*mf).read_ahead == 0 { len_main = lzma_mf_find( mf, &raw mut matches_count, @@ -193,33 +193,33 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( matches_count = (*coder).matches_count; } let mut buf: *const u8 = mf_ptr(mf).offset(-1); - let buf_avail: u32 = if mf_avail(mf).wrapping_add(1 as u32) + let buf_avail: u32 = if mf_avail(mf).wrapping_add(1) < (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - 1 as c_int) as u32 { - (mf_avail(mf) as u32).wrapping_add(1 as u32) + (mf_avail(mf) as u32).wrapping_add(1) } else { (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - 1 as c_int) as u32 }; - if buf_avail < 2 as u32 { + if buf_avail < 2 { *back_res = UINT32_MAX as u32; - *len_res = 1 as u32; + *len_res = 1; return; } - let mut rep_len: u32 = 0 as u32; - let mut rep_index: u32 = 0 as u32; - let mut i: u32 = 0 as u32; + let mut rep_len: u32 = 0; + let mut rep_index: u32 = 0; + let mut i: u32 = 0; while i < REPS as u32 { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); if !(*buf.offset(0) as c_int != *buf_back.offset(0) as c_int || *buf.offset(1) as c_int != *buf_back.offset(1) as c_int) { - let len: u32 = lzma_memcmplen(buf, buf_back, 2 as u32, buf_avail) as u32; + let len: u32 = lzma_memcmplen(buf, buf_back, 2, buf_avail) as u32; if len >= nice_len { *back_res = i; *len_res = len; - mf_skip(mf, len.wrapping_sub(1 as u32)); + mf_skip(mf, len.wrapping_sub(1)); return; } if len > rep_len { @@ -230,49 +230,47 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( i = i.wrapping_add(1); } if len_main >= nice_len { - *back_res = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize] + *back_res = (*coder).matches[matches_count.wrapping_sub(1) as usize] .dist .wrapping_add(REPS as u32); *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(1 as u32)); + mf_skip(mf, len_main.wrapping_sub(1)); return; } - let mut back_main: u32 = 0 as u32; - if len_main >= 2 as u32 { - back_main = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize].dist; - while matches_count > 1 as u32 + let mut back_main: u32 = 0; + if len_main >= 2 { + back_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].dist; + while matches_count > 1 && len_main - == (*coder).matches[matches_count.wrapping_sub(2 as u32) as usize] + == (*coder).matches[matches_count.wrapping_sub(2) as usize] .len - .wrapping_add(1 as u32) + .wrapping_add(1) { - if !(back_main >> 7 - > (*coder).matches[matches_count.wrapping_sub(2 as u32) as usize].dist) - { + if !(back_main >> 7 > (*coder).matches[matches_count.wrapping_sub(2) as usize].dist) { break; } matches_count = matches_count.wrapping_sub(1); - len_main = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize].len; - back_main = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize].dist; + len_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].len; + back_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].dist; } - if len_main == 2 as u32 && back_main >= 0x80 as u32 { - len_main = 1 as u32; + if len_main == 2 && back_main >= 0x80 as u32 { + len_main = 1; } } - if rep_len >= 2 as u32 { - if rep_len.wrapping_add(1 as u32) >= len_main - || rep_len.wrapping_add(2 as u32) >= len_main && back_main > (1 as u32) << 9 - || rep_len.wrapping_add(3 as u32) >= len_main && back_main > (1 as u32) << 15 + if rep_len >= 2 { + if rep_len.wrapping_add(1) >= len_main + || rep_len.wrapping_add(2) >= len_main && back_main > (1) << 9 + || rep_len.wrapping_add(3) >= len_main && back_main > (1) << 15 { *back_res = rep_index; *len_res = rep_len; - mf_skip(mf, rep_len.wrapping_sub(1 as u32)); + mf_skip(mf, rep_len.wrapping_sub(1)); return; } } - if len_main < 2 as u32 || buf_avail <= 2 as u32 { + if len_main < 2 || buf_avail <= 2 { *back_res = UINT32_MAX as u32; - *len_res = 1 as u32; + *len_res = 1; return; } (*coder).longest_match_length = lzma_mf_find( @@ -280,29 +278,28 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( &raw mut (*coder).matches_count, &raw mut (*coder).matches as *mut lzma_match, ); - if (*coder).longest_match_length >= 2 as u32 { - let new_dist: u32 = - (*coder).matches[(*coder).matches_count.wrapping_sub(1 as u32) as usize].dist; + if (*coder).longest_match_length >= 2 { + let new_dist: u32 = (*coder).matches[(*coder).matches_count.wrapping_sub(1) as usize].dist; if (*coder).longest_match_length >= len_main && new_dist < back_main - || (*coder).longest_match_length == len_main.wrapping_add(1 as u32) + || (*coder).longest_match_length == len_main.wrapping_add(1) && !(new_dist >> 7 > back_main) - || (*coder).longest_match_length > len_main.wrapping_add(1 as u32) - || (*coder).longest_match_length.wrapping_add(1 as u32) >= len_main - && len_main >= 3 as u32 + || (*coder).longest_match_length > len_main.wrapping_add(1) + || (*coder).longest_match_length.wrapping_add(1) >= len_main + && len_main >= 3 && back_main >> 7 > new_dist { *back_res = UINT32_MAX as u32; - *len_res = 1 as u32; + *len_res = 1; return; } } buf = buf.offset(1); - let limit: u32 = if 2 as u32 > len_main.wrapping_sub(1 as u32) { - 2 as u32 + let limit: u32 = if 2 > len_main.wrapping_sub(1) { + 2 } else { - len_main.wrapping_sub(1 as u32) + len_main.wrapping_sub(1) }; - let mut i_0: u32 = 0 as u32; + let mut i_0: u32 = 0; while i_0 < REPS as u32 { if memcmp( buf as *const c_void, @@ -312,12 +309,12 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( ) == 0 as c_int { *back_res = UINT32_MAX as u32; - *len_res = 1 as u32; + *len_res = 1; return; } i_0 = i_0.wrapping_add(1); } *back_res = back_main.wrapping_add(REPS as u32); *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(2 as u32)); + mf_skip(mf, len_main.wrapping_sub(2)); } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 9f67fd0a..4a783ce1 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -117,7 +117,7 @@ pub struct lzma_lzma1_encoder_s { pub opts_current_index: u32, pub opts: [lzma_optimal; OPTS as usize], } -pub const OPTS: c_int = (1 as c_int) << 12; +pub const OPTS: c_int = (1) << 12; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { @@ -145,43 +145,45 @@ pub struct lzma_length_encoder { } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; pub const UINT32_MAX: c_uint = 4294967295; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn mf_ptr(mut mf: *const lzma_mf) -> *const u8 { +unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); } #[inline] -unsafe extern "C" fn mf_avail(mut mf: *const lzma_mf) -> u32 { +unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { return (*mf).write_pos.wrapping_sub((*mf).read_pos); } #[inline] -unsafe extern "C" fn mf_skip(mut mf: *mut lzma_mf, mut amount: u32) { - if amount != 0 as u32 { +unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { + if amount != 0 { (*mf).skip.expect("non-null function pointer")(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11 as c_int; +pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11; pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_REDUCING_BITS: c_int = 4 as c_int; -pub const RC_BIT_PRICE_SHIFT_BITS: c_int = 4 as c_int; +pub const RC_MOVE_REDUCING_BITS: c_int = 4; +pub const RC_BIT_PRICE_SHIFT_BITS: c_int = 4; pub const RC_INFINITY_PRICE: c_uint = 1u32 << 30; #[inline] -unsafe extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { - return lzma_rc_prices[((prob as u32 - ^ (0 as u32).wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1 as u32)) - >> RC_MOVE_REDUCING_BITS) as usize] as u32; +extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { + return unsafe { + lzma_rc_prices[((prob as u32 + ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) + >> RC_MOVE_REDUCING_BITS) as usize] as u32 + }; } #[inline] -unsafe extern "C" fn rc_bit_0_price(prob: probability) -> u32 { - return lzma_rc_prices[(prob as c_int >> RC_MOVE_REDUCING_BITS) as usize] as u32; +extern "C" fn rc_bit_0_price(prob: probability) -> u32 { + return unsafe { lzma_rc_prices[(prob as c_int >> RC_MOVE_REDUCING_BITS) as usize] as u32 }; } #[inline] -unsafe extern "C" fn rc_bit_1_price(prob: probability) -> u32 { - return lzma_rc_prices - [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] - as u32; +extern "C" fn rc_bit_1_price(prob: probability) -> u32 { + return unsafe { + lzma_rc_prices + [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] + as u32 + }; } #[inline] unsafe extern "C" fn rc_bittree_price( @@ -189,13 +191,13 @@ unsafe extern "C" fn rc_bittree_price( bit_levels: u32, mut symbol: u32, ) -> u32 { - let mut price: u32 = 0 as u32; + let mut price: u32 = 0; symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; loop { - let bit: u32 = symbol & 1 as u32; + let bit: u32 = symbol & 1; symbol >>= 1 as c_int; price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); - if !(symbol != 1 as u32) { + if !(symbol != 1) { break; } } @@ -207,43 +209,43 @@ unsafe extern "C" fn rc_bittree_reverse_price( mut bit_levels: u32, mut symbol: u32, ) -> u32 { - let mut price: u32 = 0 as u32; - let mut model_index: u32 = 1 as u32; + let mut price: u32 = 0; + let mut model_index: u32 = 1; loop { - let bit: u32 = symbol & 1 as u32; + let bit: u32 = symbol & 1; symbol >>= 1 as c_int; price = price.wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); model_index = (model_index << 1).wrapping_add(bit); bit_levels = bit_levels.wrapping_sub(1); - if !(bit_levels != 0 as u32) { + if !(bit_levels != 0) { break; } } return price; } #[inline] -unsafe extern "C" fn rc_direct_price(bits: u32) -> u32 { +extern "C" fn rc_direct_price(bits: u32) -> u32 { return bits << RC_BIT_PRICE_SHIFT_BITS; } -pub const LIT_STATES: c_int = 7 as c_int; -pub const MATCH_LEN_MIN: c_int = 2 as c_int; -pub const DIST_STATES: c_int = 4 as c_int; -pub const DIST_SLOT_BITS: c_int = 6 as c_int; -pub const DIST_MODEL_START: c_int = 4 as c_int; -pub const DIST_MODEL_END: c_int = 14 as c_int; -pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2 as c_int; -pub const FULL_DISTANCES: c_int = (1 as c_int) << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: c_int = 4 as c_int; -pub const ALIGN_SIZE: c_int = (1 as c_int) << ALIGN_BITS; -pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1 as c_int; -pub const REPS: c_int = 4 as c_int; -pub const FASTPOS_BITS: c_int = 13 as c_int; +pub const LIT_STATES: c_int = 7; +pub const MATCH_LEN_MIN: c_int = 2; +pub const DIST_STATES: c_int = 4; +pub const DIST_SLOT_BITS: c_int = 6; +pub const DIST_MODEL_START: c_int = 4; +pub const DIST_MODEL_END: c_int = 14; +pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2; +pub const FULL_DISTANCES: c_int = (1) << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: c_int = 4; +pub const ALIGN_SIZE: c_int = (1) << ALIGN_BITS; +pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1; +pub const REPS: c_int = 4; +pub const FASTPOS_BITS: c_int = 13; #[inline] -unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { - if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { +unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { + if dist < (1) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1 as u32) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { + if dist < (1) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) .wrapping_add( @@ -256,9 +258,9 @@ unsafe extern "C" fn get_dist_slot(mut dist: u32) -> u32 { ); } #[inline] -unsafe extern "C" fn get_dist_slot_2(mut dist: u32) -> u32 { +unsafe extern "C" fn get_dist_slot_2(dist: u32) -> u32 { if dist - < (1 as u32) + < (1) << FASTPOS_BITS + (14 as c_int / 2 as c_int - 1 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { @@ -272,7 +274,7 @@ unsafe extern "C" fn get_dist_slot_2(mut dist: u32) -> u32 { ); } if dist - < (1 as u32) + < (1) << FASTPOS_BITS + (14 as c_int / 2 as c_int - 1 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { @@ -296,10 +298,10 @@ unsafe extern "C" fn get_dist_slot_2(mut dist: u32) -> u32 { } #[inline(always)] unsafe extern "C" fn lzma_memcmplen( - mut buf1: *const u8, - mut buf2: *const u8, + buf1: *const u8, + buf2: *const u8, mut len: u32, - mut limit: u32, + limit: u32, ) -> u32 { while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int { @@ -316,13 +318,13 @@ unsafe extern "C" fn get_literal_price( mut symbol: u32, ) -> u32 { let subcoder: *const probability = - (&raw const (*coder).literal as *const probability).offset((3 as u32).wrapping_mul( + (&raw const (*coder).literal as *const probability).offset((3u32).wrapping_mul( ((pos << 8).wrapping_add(prev_byte) & (*coder).literal_mask) << (*coder).literal_context_bits, ) as isize); - let mut price: u32 = 0 as u32; + let mut price: u32 = 0; if !match_mode { - price = rc_bittree_price(subcoder, 8 as u32, symbol); + price = rc_bittree_price(subcoder, 8, symbol); } else { let mut offset: u32 = 0x100 as u32; symbol = (symbol as u32).wrapping_add(1u32 << 8) as u32; @@ -330,12 +332,12 @@ unsafe extern "C" fn get_literal_price( match_byte <<= 1 as c_int; let match_bit: u32 = match_byte & offset; let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol >> 8); - let bit: u32 = symbol >> 7 & 1 as u32; + let bit: u32 = symbol >> 7 & 1; price = price.wrapping_add(rc_bit_price(*subcoder.offset(subcoder_index as isize), bit)); symbol <<= 1 as c_int; offset &= !(match_byte ^ symbol); - if !(symbol < (1 as u32) << 16) { + if !(symbol < (1) << 16) { break; } } @@ -343,95 +345,105 @@ unsafe extern "C" fn get_literal_price( return price; } #[inline] -unsafe extern "C" fn get_len_price( +extern "C" fn get_len_price( lencoder: *const lzma_length_encoder, len: u32, pos_state: u32, ) -> u32 { - return (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN as u32) as usize]; + return unsafe { + (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN as u32) as usize] + }; } #[inline] -unsafe extern "C" fn get_short_rep_price( +extern "C" fn get_short_rep_price( coder: *const lzma_lzma1_encoder, state: lzma_lzma_state, pos_state: u32, ) -> u32 { - return rc_bit_0_price((*coder).is_rep0[state as usize]).wrapping_add(rc_bit_0_price( - (*coder).is_rep0_long[state as usize][pos_state as usize], - )); + return unsafe { + rc_bit_0_price((*coder).is_rep0[state as usize]).wrapping_add(rc_bit_0_price( + (*coder).is_rep0_long[state as usize][pos_state as usize], + )) + }; } #[inline] -unsafe extern "C" fn get_pure_rep_price( +extern "C" fn get_pure_rep_price( coder: *const lzma_lzma1_encoder, rep_index: u32, state: lzma_lzma_state, - mut pos_state: u32, + pos_state: u32, ) -> u32 { - let mut price: u32 = 0; - if rep_index == 0 as u32 { - price = rc_bit_0_price((*coder).is_rep0[state as usize]); - price = price.wrapping_add(rc_bit_1_price( - (*coder).is_rep0_long[state as usize][pos_state as usize], - )); - } else { - price = rc_bit_1_price((*coder).is_rep0[state as usize]); - if rep_index == 1 as u32 { - price = price.wrapping_add(rc_bit_0_price((*coder).is_rep1[state as usize])); - } else { - price = price.wrapping_add(rc_bit_1_price((*coder).is_rep1[state as usize])); - price = price.wrapping_add(rc_bit_price( - (*coder).is_rep2[state as usize], - rep_index.wrapping_sub(2 as u32), + return unsafe { + let mut price: u32 = 0; + if rep_index == 0 { + price = rc_bit_0_price((*coder).is_rep0[state as usize]); + price = price.wrapping_add(rc_bit_1_price( + (*coder).is_rep0_long[state as usize][pos_state as usize], )); + } else { + price = rc_bit_1_price((*coder).is_rep0[state as usize]); + if rep_index == 1 { + price = price.wrapping_add(rc_bit_0_price((*coder).is_rep1[state as usize])); + } else { + price = price.wrapping_add(rc_bit_1_price((*coder).is_rep1[state as usize])); + price = price.wrapping_add(rc_bit_price( + (*coder).is_rep2[state as usize], + rep_index.wrapping_sub(2), + )); + } } - } - return price; + price + }; } #[inline] -unsafe extern "C" fn get_rep_price( +extern "C" fn get_rep_price( coder: *const lzma_lzma1_encoder, rep_index: u32, len: u32, state: lzma_lzma_state, pos_state: u32, ) -> u32 { - return get_len_price(&raw const (*coder).rep_len_encoder, len, pos_state) - .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state)); + return unsafe { + get_len_price(&raw const (*coder).rep_len_encoder, len, pos_state) + .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state)) + }; } #[inline] -unsafe extern "C" fn get_dist_len_price( +extern "C" fn get_dist_len_price( coder: *const lzma_lzma1_encoder, dist: u32, len: u32, pos_state: u32, ) -> u32 { - let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN as u32) - } else { - (DIST_STATES - 1 as c_int) as u32 + return unsafe { + let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { + len.wrapping_sub(MATCH_LEN_MIN as u32) + } else { + (DIST_STATES - 1 as c_int) as u32 + }; + let mut price: u32 = 0; + if dist < FULL_DISTANCES as u32 { + price = (*coder).dist_prices[dist_state as usize][dist as usize]; + } else { + let dist_slot: u32 = get_dist_slot_2(dist) as u32; + price = (*coder).dist_slot_prices[dist_state as usize][dist_slot as usize] + .wrapping_add((*coder).align_prices[(dist & ALIGN_MASK as u32) as usize]); + } + price = price.wrapping_add(get_len_price( + &raw const (*coder).match_len_encoder, + len, + pos_state, + )); + price }; - let mut price: u32 = 0; - if dist < FULL_DISTANCES as u32 { - price = (*coder).dist_prices[dist_state as usize][dist as usize]; - } else { - let dist_slot: u32 = get_dist_slot_2(dist) as u32; - price = (*coder).dist_slot_prices[dist_state as usize][dist_slot as usize] - .wrapping_add((*coder).align_prices[(dist & ALIGN_MASK as u32) as usize]); - } - price = price.wrapping_add(get_len_price( - &raw const (*coder).match_len_encoder, - len, - pos_state, - )); - return price; } -unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { - let mut dist_state: u32 = 0 as u32; +unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { + let mut dist_state: u32 = 0; while dist_state < DIST_STATES as u32 { let dist_slot_prices: *mut u32 = &raw mut *(&raw mut (*coder).dist_slot_prices as *mut [u32; 64]) .offset(dist_state as isize) as *mut u32; - let mut dist_slot: u32 = 0 as u32; + let mut dist_slot: u32 = 0; while dist_slot < (*coder).dist_table_size { *dist_slot_prices.offset(dist_slot as isize) = rc_bittree_price( &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) @@ -446,12 +458,12 @@ unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { let ref mut fresh1 = *dist_slot_prices.offset(dist_slot_0 as isize); *fresh1 = (*fresh1).wrapping_add(rc_direct_price( (dist_slot_0 >> 1) - .wrapping_sub(1 as u32) + .wrapping_sub(1) .wrapping_sub(ALIGN_BITS as u32), )); dist_slot_0 = dist_slot_0.wrapping_add(1); } - let mut i: u32 = 0 as u32; + let mut i: u32 = 0; while i < DIST_MODEL_START as u32 { (*coder).dist_prices[dist_state as usize][i as usize] = *dist_slot_prices.offset(i as isize); @@ -462,8 +474,8 @@ unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { let mut i_0: u32 = DIST_MODEL_START as u32; while i_0 < FULL_DISTANCES as u32 { let dist_slot_1: u32 = get_dist_slot(i_0) as u32; - let footer_bits: u32 = (dist_slot_1 >> 1).wrapping_sub(1 as u32); - let base: u32 = (2 as u32 | dist_slot_1 & 1 as u32) << footer_bits; + let footer_bits: u32 = (dist_slot_1 >> 1).wrapping_sub(1); + let base: u32 = (2 | dist_slot_1 & 1) << footer_bits; let price: u32 = rc_bittree_reverse_price( (&raw mut (*coder).dist_special as *mut probability) .offset(base as isize) @@ -472,7 +484,7 @@ unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { footer_bits, i_0.wrapping_sub(base), ) as u32; - let mut dist_state_0: u32 = 0 as u32; + let mut dist_state_0: u32 = 0; while dist_state_0 < DIST_STATES as u32 { (*coder).dist_prices[dist_state_0 as usize][i_0 as usize] = price.wrapping_add( (*coder).dist_slot_prices[dist_state_0 as usize][dist_slot_1 as usize], @@ -481,10 +493,10 @@ unsafe extern "C" fn fill_dist_prices(mut coder: *mut lzma_lzma1_encoder) { } i_0 = i_0.wrapping_add(1); } - (*coder).match_price_count = 0 as u32; + (*coder).match_price_count = 0; } -unsafe extern "C" fn fill_align_prices(mut coder: *mut lzma_lzma1_encoder) { - let mut i: u32 = 0 as u32; +unsafe extern "C" fn fill_align_prices(coder: *mut lzma_lzma1_encoder) { + let mut i: u32 = 0; while i < ALIGN_SIZE as u32 { (*coder).align_prices[i as usize] = rc_bittree_reverse_price( &raw mut (*coder).dist_align as *mut probability, @@ -493,22 +505,22 @@ unsafe extern "C" fn fill_align_prices(mut coder: *mut lzma_lzma1_encoder) { ); i = i.wrapping_add(1); } - (*coder).align_price_count = 0 as u32; + (*coder).align_price_count = 0; } #[inline] -unsafe extern "C" fn make_literal(mut optimal: *mut lzma_optimal) { +unsafe extern "C" fn make_literal(optimal: *mut lzma_optimal) { (*optimal).back_prev = UINT32_MAX as u32; - (*optimal).prev_1_is_literal = false_0 != 0; + (*optimal).prev_1_is_literal = false; } #[inline] -unsafe extern "C" fn make_short_rep(mut optimal: *mut lzma_optimal) { - (*optimal).back_prev = 0 as u32; - (*optimal).prev_1_is_literal = false_0 != 0; +unsafe extern "C" fn make_short_rep(optimal: *mut lzma_optimal) { + (*optimal).back_prev = 0; + (*optimal).prev_1_is_literal = false; } unsafe extern "C" fn backward( - mut coder: *mut lzma_lzma1_encoder, - mut len_res: *mut u32, - mut back_res: *mut u32, + coder: *mut lzma_lzma1_encoder, + len_res: *mut u32, + back_res: *mut u32, mut cur: u32, ) { (*coder).opts_end_index = cur; @@ -520,13 +532,12 @@ unsafe extern "C" fn backward( (&raw mut (*coder).opts as *mut lzma_optimal).offset(pos_mem as isize) as *mut lzma_optimal, ); - (*coder).opts[pos_mem as usize].pos_prev = pos_mem.wrapping_sub(1 as u32); + (*coder).opts[pos_mem as usize].pos_prev = pos_mem.wrapping_sub(1); if (*coder).opts[cur as usize].prev_2 { - (*coder).opts[pos_mem.wrapping_sub(1 as u32) as usize].prev_1_is_literal = - false_0 != 0; - (*coder).opts[pos_mem.wrapping_sub(1 as u32) as usize].pos_prev = + (*coder).opts[pos_mem.wrapping_sub(1) as usize].prev_1_is_literal = false; + (*coder).opts[pos_mem.wrapping_sub(1) as usize].pos_prev = (*coder).opts[cur as usize].pos_prev_2; - (*coder).opts[pos_mem.wrapping_sub(1 as u32) as usize].back_prev = + (*coder).opts[pos_mem.wrapping_sub(1) as usize].back_prev = (*coder).opts[cur as usize].back_prev_2; } } @@ -537,7 +548,7 @@ unsafe extern "C" fn backward( (*coder).opts[pos_prev as usize].back_prev = back_cur; (*coder).opts[pos_prev as usize].pos_prev = cur; cur = pos_prev; - if !(cur != 0 as u32) { + if !(cur != 0) { break; } } @@ -547,16 +558,16 @@ unsafe extern "C" fn backward( } #[inline] unsafe extern "C" fn helper1( - mut coder: *mut lzma_lzma1_encoder, - mut mf: *mut lzma_mf, - mut back_res: *mut u32, - mut len_res: *mut u32, - mut position: u32, + coder: *mut lzma_lzma1_encoder, + mf: *mut lzma_mf, + back_res: *mut u32, + len_res: *mut u32, + position: u32, ) -> u32 { let nice_len: u32 = (*mf).nice_len; let mut len_main: u32 = 0; let mut matches_count: u32 = 0; - if (*mf).read_ahead == 0 as u32 { + if (*mf).read_ahead == 0 { len_main = lzma_mf_find( mf, &raw mut matches_count, @@ -566,32 +577,32 @@ unsafe extern "C" fn helper1( len_main = (*coder).longest_match_length; matches_count = (*coder).matches_count; } - let buf_avail: u32 = if mf_avail(mf).wrapping_add(1 as u32) + let buf_avail: u32 = if mf_avail(mf).wrapping_add(1) < (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - 1 as c_int) as u32 { - (mf_avail(mf) as u32).wrapping_add(1 as u32) + (mf_avail(mf) as u32).wrapping_add(1) } else { (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - 1 as c_int) as u32 }; - if buf_avail < 2 as u32 { + if buf_avail < 2 { *back_res = UINT32_MAX as u32; - *len_res = 1 as u32; + *len_res = 1; return UINT32_MAX as u32; } let buf: *const u8 = mf_ptr(mf).offset(-1); let mut rep_lens: [u32; 4] = [0; 4]; - let mut rep_max_index: u32 = 0 as u32; - let mut i: u32 = 0 as u32; + let mut rep_max_index: u32 = 0; + let mut i: u32 = 0; while i < REPS as u32 { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); if *buf.offset(0) as c_int != *buf_back.offset(0) as c_int || *buf.offset(1) as c_int != *buf_back.offset(1) as c_int { - rep_lens[i as usize] = 0 as u32; + rep_lens[i as usize] = 0; } else { - rep_lens[i as usize] = lzma_memcmplen(buf, buf_back, 2 as u32, buf_avail); + rep_lens[i as usize] = lzma_memcmplen(buf, buf_back, 2, buf_avail); if rep_lens[i as usize] > rep_lens[rep_max_index as usize] { rep_max_index = i; } @@ -601,25 +612,25 @@ unsafe extern "C" fn helper1( if rep_lens[rep_max_index as usize] >= nice_len { *back_res = rep_max_index; *len_res = rep_lens[rep_max_index as usize]; - mf_skip(mf, (*len_res).wrapping_sub(1 as u32)); + mf_skip(mf, (*len_res).wrapping_sub(1)); return UINT32_MAX as u32; } if len_main >= nice_len { - *back_res = (*coder).matches[matches_count.wrapping_sub(1 as u32) as usize] + *back_res = (*coder).matches[matches_count.wrapping_sub(1) as usize] .dist .wrapping_add(REPS as u32); *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(1 as u32)); + mf_skip(mf, len_main.wrapping_sub(1)); return UINT32_MAX as u32; } let current_byte: u8 = *buf; let match_byte: u8 = *buf.offset(-((*coder).reps[0] as isize)).offset(-1); - if len_main < 2 as u32 + if len_main < 2 && current_byte as c_int != match_byte as c_int - && rep_lens[rep_max_index as usize] < 2 as u32 + && rep_lens[rep_max_index as usize] < 2 { *back_res = UINT32_MAX as u32; - *len_res = 1 as u32; + *len_res = 1; return UINT32_MAX as u32; } (*coder).opts[0].state = (*coder).state; @@ -655,13 +666,13 @@ unsafe extern "C" fn helper1( } else { rep_lens[rep_max_index as usize] }; - if len_end < 2 as u32 { + if len_end < 2 { *back_res = (*coder).opts[1].back_prev; - *len_res = 1 as u32; + *len_res = 1; return UINT32_MAX as u32; } - (*coder).opts[1].pos_prev = 0 as u32; - let mut i_0: u32 = 0 as u32; + (*coder).opts[1].pos_prev = 0; + let mut i_0: u32 = 0; while i_0 < REPS as u32 { (*coder).opts[0].backs[i_0 as usize] = (*coder).reps[i_0 as usize]; i_0 = i_0.wrapping_add(1); @@ -670,14 +681,14 @@ unsafe extern "C" fn helper1( loop { (*coder).opts[len as usize].price = RC_INFINITY_PRICE as u32; len = len.wrapping_sub(1); - if !(len >= 2 as u32) { + if !(len >= 2) { break; } } - let mut i_1: u32 = 0 as u32; + let mut i_1: u32 = 0; while i_1 < REPS as u32 { let mut rep_len: u32 = rep_lens[i_1 as usize]; - if !(rep_len < 2 as u32) { + if !(rep_len < 2) { let price: u32 = rep_match_price.wrapping_add(get_pure_rep_price( coder, i_1, @@ -692,12 +703,12 @@ unsafe extern "C" fn helper1( ) as u32); if cur_and_len_price < (*coder).opts[rep_len as usize].price { (*coder).opts[rep_len as usize].price = cur_and_len_price; - (*coder).opts[rep_len as usize].pos_prev = 0 as u32; + (*coder).opts[rep_len as usize].pos_prev = 0; (*coder).opts[rep_len as usize].back_prev = i_1; - (*coder).opts[rep_len as usize].prev_1_is_literal = false_0 != 0; + (*coder).opts[rep_len as usize].prev_1_is_literal = false; } rep_len = rep_len.wrapping_sub(1); - if !(rep_len >= 2 as u32) { + if !(rep_len >= 2) { break; } } @@ -706,13 +717,13 @@ unsafe extern "C" fn helper1( } let normal_match_price: u32 = match_price.wrapping_add(rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as u32); - len = if rep_lens[0] >= 2 as u32 { - rep_lens[0].wrapping_add(1 as u32) + len = if rep_lens[0] >= 2 { + rep_lens[0].wrapping_add(1) } else { - 2 as u32 + 2 }; if len <= len_main { - let mut i_2: u32 = 0 as u32; + let mut i_2: u32 = 0; while len > (*coder).matches[i_2 as usize].len { i_2 = i_2.wrapping_add(1); } @@ -722,9 +733,9 @@ unsafe extern "C" fn helper1( .wrapping_add(get_dist_len_price(coder, dist, len, pos_state) as u32); if cur_and_len_price_0 < (*coder).opts[len as usize].price { (*coder).opts[len as usize].price = cur_and_len_price_0; - (*coder).opts[len as usize].pos_prev = 0 as u32; + (*coder).opts[len as usize].pos_prev = 0; (*coder).opts[len as usize].back_prev = dist.wrapping_add(REPS as u32); - (*coder).opts[len as usize].prev_1_is_literal = false_0 != 0; + (*coder).opts[len as usize].prev_1_is_literal = false; } if len == (*coder).matches[i_2 as usize].len { i_2 = i_2.wrapping_add(1); @@ -739,11 +750,11 @@ unsafe extern "C" fn helper1( } #[inline] unsafe extern "C" fn helper2( - mut coder: *mut lzma_lzma1_encoder, - mut reps: *mut u32, - mut buf: *const u8, + coder: *mut lzma_lzma1_encoder, + reps: *mut u32, + buf: *const u8, mut len_end: u32, - mut position: u32, + position: u32, cur: u32, nice_len: u32, buf_avail_full: u32, @@ -782,8 +793,8 @@ unsafe extern "C" fn helper2( } else { state = (*coder).opts[pos_prev as usize].state; } - if pos_prev == cur.wrapping_sub(1 as u32) { - if (*coder).opts[cur as usize].back_prev == 0 as u32 { + if pos_prev == cur.wrapping_sub(1) { + if (*coder).opts[cur as usize].back_prev == 0 { state = (if (state as u32) < LIT_STATES as u32 { STATE_LIT_SHORTREP as c_int } else { @@ -829,10 +840,10 @@ unsafe extern "C" fn helper2( if pos < REPS as u32 { *reps.offset(0) = (*coder).opts[pos_prev as usize].backs[pos as usize]; let mut i: u32 = 0; - i = 1 as u32; + i = 1; while i <= pos { *reps.offset(i as isize) = - (*coder).opts[pos_prev as usize].backs[i.wrapping_sub(1 as u32) as usize]; + (*coder).opts[pos_prev as usize].backs[i.wrapping_sub(1) as usize]; i = i.wrapping_add(1); } while i < REPS as u32 { @@ -841,16 +852,16 @@ unsafe extern "C" fn helper2( } } else { *reps.offset(0) = pos.wrapping_sub(REPS as u32); - let mut i_0: u32 = 1 as u32; + let mut i_0: u32 = 1; while i_0 < REPS as u32 { *reps.offset(i_0 as isize) = - (*coder).opts[pos_prev as usize].backs[i_0.wrapping_sub(1 as u32) as usize]; + (*coder).opts[pos_prev as usize].backs[i_0.wrapping_sub(1) as usize]; i_0 = i_0.wrapping_add(1); } } } (*coder).opts[cur as usize].state = state; - let mut i_1: u32 = 0 as u32; + let mut i_1: u32 = 0; while i_1 < REPS as u32 { (*coder).opts[cur as usize].backs[i_1 as usize] = *reps.offset(i_1 as isize); i_1 = i_1.wrapping_add(1); @@ -869,38 +880,37 @@ unsafe extern "C" fn helper2( match_byte as u32, current_byte as u32, ) as u32); - let mut next_is_literal: bool = false_0 != 0; - if cur_and_1_price < (*coder).opts[cur.wrapping_add(1 as u32) as usize].price { - (*coder).opts[cur.wrapping_add(1 as u32) as usize].price = cur_and_1_price; - (*coder).opts[cur.wrapping_add(1 as u32) as usize].pos_prev = cur; + let mut next_is_literal: bool = false; + if cur_and_1_price < (*coder).opts[cur.wrapping_add(1) as usize].price { + (*coder).opts[cur.wrapping_add(1) as usize].price = cur_and_1_price; + (*coder).opts[cur.wrapping_add(1) as usize].pos_prev = cur; make_literal( - (&raw mut (*coder).opts as *mut lzma_optimal) - .offset(cur.wrapping_add(1 as u32) as isize) as *mut lzma_optimal, + (&raw mut (*coder).opts as *mut lzma_optimal).offset(cur.wrapping_add(1) as isize) + as *mut lzma_optimal, ); - next_is_literal = true_0 != 0; + next_is_literal = true; } let match_price: u32 = cur_price .wrapping_add(rc_bit_1_price((*coder).is_match[state as usize][pos_state as usize]) as u32); let rep_match_price: u32 = match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[state as usize]) as u32); if match_byte as c_int == current_byte as c_int - && !((*coder).opts[cur.wrapping_add(1 as u32) as usize].pos_prev < cur - && (*coder).opts[cur.wrapping_add(1 as u32) as usize].back_prev == 0 as u32) + && !((*coder).opts[cur.wrapping_add(1) as usize].pos_prev < cur + && (*coder).opts[cur.wrapping_add(1) as usize].back_prev == 0) { let short_rep_price: u32 = rep_match_price.wrapping_add(get_short_rep_price(coder, state, pos_state) as u32); - if short_rep_price <= (*coder).opts[cur.wrapping_add(1 as u32) as usize].price { - (*coder).opts[cur.wrapping_add(1 as u32) as usize].price = short_rep_price; - (*coder).opts[cur.wrapping_add(1 as u32) as usize].pos_prev = cur; + if short_rep_price <= (*coder).opts[cur.wrapping_add(1) as usize].price { + (*coder).opts[cur.wrapping_add(1) as usize].price = short_rep_price; + (*coder).opts[cur.wrapping_add(1) as usize].pos_prev = cur; make_short_rep( - (&raw mut (*coder).opts as *mut lzma_optimal) - .offset(cur.wrapping_add(1 as u32) as isize) + (&raw mut (*coder).opts as *mut lzma_optimal).offset(cur.wrapping_add(1) as isize) as *mut lzma_optimal, ); - next_is_literal = true_0 != 0; + next_is_literal = true; } } - if buf_avail_full < 2 as u32 { + if buf_avail_full < 2 { return len_end; } let buf_avail: u32 = if buf_avail_full < nice_len { @@ -910,14 +920,13 @@ unsafe extern "C" fn helper2( }; if !next_is_literal && match_byte as c_int != current_byte as c_int { let buf_back: *const u8 = buf.offset(-(*reps.offset(0) as isize)).offset(-1); - let limit: u32 = if buf_avail_full < nice_len.wrapping_add(1 as u32) { + let limit: u32 = if buf_avail_full < nice_len.wrapping_add(1) { buf_avail_full } else { - nice_len.wrapping_add(1 as u32) + nice_len.wrapping_add(1) }; - let len_test: u32 = - (lzma_memcmplen(buf, buf_back, 1 as u32, limit) as u32).wrapping_sub(1 as u32); - if len_test >= 2 as u32 { + let len_test: u32 = (lzma_memcmplen(buf, buf_back, 1, limit) as u32).wrapping_sub(1); + if len_test >= 2 { let mut state_2: lzma_lzma_state = state; state_2 = (if state_2 <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT @@ -926,35 +935,35 @@ unsafe extern "C" fn helper2( } else { (state_2 as u32).wrapping_sub(6) }) as lzma_lzma_state; - let pos_state_next: u32 = position.wrapping_add(1 as u32) & (*coder).pos_mask; + let pos_state_next: u32 = position.wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price: u32 = cur_and_1_price .wrapping_add(rc_bit_1_price( (*coder).is_match[state_2 as usize][pos_state_next as usize], ) as u32) .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2 as usize]) as u32); - let offset: u32 = cur.wrapping_add(1 as u32).wrapping_add(len_test); + let offset: u32 = cur.wrapping_add(1u32).wrapping_add(len_test); while len_end < offset { len_end = len_end.wrapping_add(1); (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } let cur_and_len_price: u32 = next_rep_match_price.wrapping_add(get_rep_price( coder, - 0 as u32, + 0, len_test, state_2, pos_state_next, ) as u32); if cur_and_len_price < (*coder).opts[offset as usize].price { (*coder).opts[offset as usize].price = cur_and_len_price; - (*coder).opts[offset as usize].pos_prev = cur.wrapping_add(1 as u32); - (*coder).opts[offset as usize].back_prev = 0 as u32; - (*coder).opts[offset as usize].prev_1_is_literal = true_0 != 0; - (*coder).opts[offset as usize].prev_2 = false_0 != 0; + (*coder).opts[offset as usize].pos_prev = cur.wrapping_add(1); + (*coder).opts[offset as usize].back_prev = 0; + (*coder).opts[offset as usize].prev_1_is_literal = true; + (*coder).opts[offset as usize].prev_2 = false; } } } - let mut start_len: u32 = 2 as u32; - let mut rep_index: u32 = 0 as u32; + let mut start_len: u32 = 2; + let mut rep_index: u32 = 0; while rep_index < REPS as u32 { let buf_back_0: *const u8 = buf .offset(-(*reps.offset(rep_index as isize) as isize)) @@ -962,7 +971,7 @@ unsafe extern "C" fn helper2( if !(*buf.offset(0) as c_int != *buf_back_0.offset(0) as c_int || *buf.offset(1) as c_int != *buf_back_0.offset(1) as c_int) { - let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2 as u32, buf_avail); + let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2, buf_avail); while len_end < cur.wrapping_add(len_test_0) { len_end = len_end.wrapping_add(1); (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; @@ -982,19 +991,18 @@ unsafe extern "C" fn helper2( cur_and_len_price_0; (*coder).opts[cur.wrapping_add(len_test_0) as usize].pos_prev = cur; (*coder).opts[cur.wrapping_add(len_test_0) as usize].back_prev = rep_index; - (*coder).opts[cur.wrapping_add(len_test_0) as usize].prev_1_is_literal = - false_0 != 0; + (*coder).opts[cur.wrapping_add(len_test_0) as usize].prev_1_is_literal = false; } len_test_0 = len_test_0.wrapping_sub(1); - if !(len_test_0 >= 2 as u32) { + if !(len_test_0 >= 2) { break; } } len_test_0 = len_test_temp; - if rep_index == 0 as u32 { - start_len = len_test_0.wrapping_add(1 as u32); + if rep_index == 0 { + start_len = len_test_0.wrapping_add(1); } - let mut len_test_2: u32 = len_test_0.wrapping_add(1 as u32); + let mut len_test_2: u32 = len_test_0.wrapping_add(1); let limit_0: u32 = if buf_avail_full < len_test_2.wrapping_add(nice_len) { buf_avail_full } else { @@ -1003,8 +1011,8 @@ unsafe extern "C" fn helper2( if len_test_2 < limit_0 { len_test_2 = lzma_memcmplen(buf, buf_back_0, len_test_2, limit_0); } - len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1 as u32)); - if len_test_2 >= 2 as u32 { + len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1)); + if len_test_2 >= 2 { let mut state_2_0: lzma_lzma_state = state; state_2_0 = (if (state_2_0 as u32) < LIT_STATES as u32 { STATE_LIT_LONGREP as c_int @@ -1025,8 +1033,8 @@ unsafe extern "C" fn helper2( .wrapping_add(get_literal_price( coder, position.wrapping_add(len_test_0), - *buf.offset(len_test_0.wrapping_sub(1 as u32) as isize) as u32, - true_0 != 0, + *buf.offset(len_test_0.wrapping_sub(1) as isize) as u32, + true, *buf_back_0.offset(len_test_0 as isize) as u32, *buf.offset(len_test_0 as isize) as u32, ) as u32); @@ -1038,7 +1046,7 @@ unsafe extern "C" fn helper2( (state_2_0 as u32).wrapping_sub(6) }) as lzma_lzma_state; pos_state_next_0 = - position.wrapping_add(len_test_0).wrapping_add(1 as u32) & (*coder).pos_mask; + position.wrapping_add(len_test_0).wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price_0: u32 = cur_and_len_literal_price .wrapping_add(rc_bit_1_price( (*coder).is_match[state_2_0 as usize][pos_state_next_0 as usize], @@ -1046,7 +1054,7 @@ unsafe extern "C" fn helper2( .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2_0 as usize]) as u32); let offset_0: u32 = cur .wrapping_add(len_test_0) - .wrapping_add(1 as u32) + .wrapping_add(1) .wrapping_add(len_test_2); while len_end < offset_0 { len_end = len_end.wrapping_add(1); @@ -1054,7 +1062,7 @@ unsafe extern "C" fn helper2( } let cur_and_len_price_1: u32 = next_rep_match_price_0.wrapping_add(get_rep_price( coder, - 0 as u32, + 0, len_test_2, state_2_0, pos_state_next_0, @@ -1063,10 +1071,10 @@ unsafe extern "C" fn helper2( if cur_and_len_price_1 < (*coder).opts[offset_0 as usize].price { (*coder).opts[offset_0 as usize].price = cur_and_len_price_1; (*coder).opts[offset_0 as usize].pos_prev = - cur.wrapping_add(len_test_0).wrapping_add(1 as u32); - (*coder).opts[offset_0 as usize].back_prev = 0 as u32; - (*coder).opts[offset_0 as usize].prev_1_is_literal = true_0 != 0; - (*coder).opts[offset_0 as usize].prev_2 = true_0 != 0; + cur.wrapping_add(len_test_0).wrapping_add(1); + (*coder).opts[offset_0 as usize].back_prev = 0; + (*coder).opts[offset_0 as usize].prev_1_is_literal = true; + (*coder).opts[offset_0 as usize].prev_2 = true; (*coder).opts[offset_0 as usize].pos_prev_2 = cur; (*coder).opts[offset_0 as usize].back_prev_2 = rep_index; } @@ -1076,7 +1084,7 @@ unsafe extern "C" fn helper2( } if new_len > buf_avail { new_len = buf_avail; - matches_count = 0 as u32; + matches_count = 0; while new_len > (*coder).matches[matches_count as usize].len { matches_count = matches_count.wrapping_add(1); } @@ -1091,7 +1099,7 @@ unsafe extern "C" fn helper2( len_end = len_end.wrapping_add(1); (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } - let mut i_2: u32 = 0 as u32; + let mut i_2: u32 = 0; while start_len > (*coder).matches[i_2 as usize].len { i_2 = i_2.wrapping_add(1); } @@ -1105,12 +1113,11 @@ unsafe extern "C" fn helper2( (*coder).opts[cur.wrapping_add(len_test_1) as usize].pos_prev = cur; (*coder).opts[cur.wrapping_add(len_test_1) as usize].back_prev = cur_back.wrapping_add(REPS as u32); - (*coder).opts[cur.wrapping_add(len_test_1) as usize].prev_1_is_literal = - false_0 != 0; + (*coder).opts[cur.wrapping_add(len_test_1) as usize].prev_1_is_literal = false; } if len_test_1 == (*coder).matches[i_2 as usize].len { let buf_back_1: *const u8 = buf.offset(-(cur_back as isize)).offset(-1); - let mut len_test_2_0: u32 = len_test_1.wrapping_add(1 as u32); + let mut len_test_2_0: u32 = len_test_1.wrapping_add(1); let limit_1: u32 = if buf_avail_full < len_test_2_0.wrapping_add(nice_len) { buf_avail_full } else { @@ -1119,8 +1126,8 @@ unsafe extern "C" fn helper2( if len_test_2_0 < limit_1 { len_test_2_0 = lzma_memcmplen(buf, buf_back_1, len_test_2_0, limit_1); } - len_test_2_0 = len_test_2_0.wrapping_sub(len_test_1.wrapping_add(1 as u32)); - if len_test_2_0 >= 2 as u32 { + len_test_2_0 = len_test_2_0.wrapping_sub(len_test_1.wrapping_add(1)); + if len_test_2_0 >= 2 { let mut state_2_1: lzma_lzma_state = state; state_2_1 = (if (state_2_1 as u32) < LIT_STATES as u32 { STATE_LIT_MATCH as c_int @@ -1136,8 +1143,8 @@ unsafe extern "C" fn helper2( .wrapping_add(get_literal_price( coder, position.wrapping_add(len_test_1), - *buf.offset(len_test_1.wrapping_sub(1 as u32) as isize) as u32, - true_0 != 0, + *buf.offset(len_test_1.wrapping_sub(1) as isize) as u32, + true, *buf_back_1.offset(len_test_1 as isize) as u32, *buf.offset(len_test_1 as isize) as u32, ) as u32); @@ -1148,7 +1155,7 @@ unsafe extern "C" fn helper2( } else { (state_2_1 as u32).wrapping_sub(6) }) as lzma_lzma_state; - pos_state_next_1 = pos_state_next_1.wrapping_add(1 as u32) & (*coder).pos_mask; + pos_state_next_1 = pos_state_next_1.wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price_1: u32 = cur_and_len_literal_price_0 .wrapping_add(rc_bit_1_price( (*coder).is_match[state_2_1 as usize][pos_state_next_1 as usize], @@ -1156,7 +1163,7 @@ unsafe extern "C" fn helper2( .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2_1 as usize]) as u32); let offset_1: u32 = cur .wrapping_add(len_test_1) - .wrapping_add(1 as u32) + .wrapping_add(1) .wrapping_add(len_test_2_0); while len_end < offset_1 { len_end = len_end.wrapping_add(1); @@ -1164,7 +1171,7 @@ unsafe extern "C" fn helper2( } cur_and_len_price_2 = next_rep_match_price_1.wrapping_add(get_rep_price( coder, - 0 as u32, + 0, len_test_2_0, state_2_1, pos_state_next_1, @@ -1172,10 +1179,10 @@ unsafe extern "C" fn helper2( if cur_and_len_price_2 < (*coder).opts[offset_1 as usize].price { (*coder).opts[offset_1 as usize].price = cur_and_len_price_2; (*coder).opts[offset_1 as usize].pos_prev = - cur.wrapping_add(len_test_1).wrapping_add(1 as u32); - (*coder).opts[offset_1 as usize].back_prev = 0 as u32; - (*coder).opts[offset_1 as usize].prev_1_is_literal = true_0 != 0; - (*coder).opts[offset_1 as usize].prev_2 = true_0 != 0; + cur.wrapping_add(len_test_1).wrapping_add(1); + (*coder).opts[offset_1 as usize].back_prev = 0; + (*coder).opts[offset_1 as usize].prev_1_is_literal = true; + (*coder).opts[offset_1 as usize].prev_2 = true; (*coder).opts[offset_1 as usize].pos_prev_2 = cur; (*coder).opts[offset_1 as usize].back_prev_2 = cur_back.wrapping_add(REPS as u32); @@ -1193,11 +1200,11 @@ unsafe extern "C" fn helper2( } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_optimum_normal( - mut coder: *mut lzma_lzma1_encoder, - mut mf: *mut lzma_mf, - mut back_res: *mut u32, - mut len_res: *mut u32, - mut position: u32, + coder: *mut lzma_lzma1_encoder, + mf: *mut lzma_mf, + back_res: *mut u32, + len_res: *mut u32, + position: u32, ) { if (*coder).opts_end_index != (*coder).opts_current_index { *len_res = (*coder).opts[(*coder).opts_current_index as usize] @@ -1207,7 +1214,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( (*coder).opts_current_index = (*coder).opts[(*coder).opts_current_index as usize].pos_prev; return; } - if (*mf).read_ahead == 0 as u32 { + if (*mf).read_ahead == 0 { if (*coder).match_price_count >= ((1 as c_int) << 7) as u32 { fill_dist_prices(coder); } @@ -1223,10 +1230,10 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( memcpy( &raw mut reps as *mut u32 as *mut c_void, &raw mut (*coder).reps as *mut u32 as *const c_void, - ::core::mem::size_of::<[u32; 4]>() as size_t, + core::mem::size_of::<[u32; 4]>() as size_t, ); let mut cur: u32 = 0; - cur = 1 as u32; + cur = 1; while cur < len_end { (*coder).longest_match_length = lzma_mf_find( mf, @@ -1244,10 +1251,10 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( position.wrapping_add(cur), cur, (*mf).nice_len, - if mf_avail(mf).wrapping_add(1 as u32) + if mf_avail(mf).wrapping_add(1) < ((((1 as c_int) << 12) - 1 as c_int) as u32).wrapping_sub(cur) { - mf_avail(mf).wrapping_add(1 as u32) + mf_avail(mf).wrapping_add(1) } else { ((((1 as c_int) << 12) - 1 as c_int) as u32).wrapping_sub(cur) }, diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index ec7a2356..244457dc 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uchar, c_uint, c_void}; +use core::ffi::{c_int, c_uint, c_void}; pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; pub const LZMA_MF_BT4: lzma_match_finder = 20; pub const LZMA_MF_BT3: lzma_match_finder = 19; @@ -36,72 +36,65 @@ pub struct lzma_options_lzma { pub reserved_ptr1: *mut c_void, pub reserved_ptr2: *mut c_void, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; -pub const LZMA_LC_DEFAULT: c_int = 3 as c_int; -pub const LZMA_LP_DEFAULT: c_int = 0 as c_int; -pub const LZMA_PB_DEFAULT: c_int = 2 as c_int; +pub const LZMA_LC_DEFAULT: c_int = 3; +pub const LZMA_LP_DEFAULT: c_int = 0; +pub const LZMA_PB_DEFAULT: c_int = 2; pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f; pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_preset( - mut options: *mut lzma_options_lzma, - mut preset: u32, + options: *mut lzma_options_lzma, + preset: u32, ) -> lzma_bool { let level: u32 = preset & LZMA_PRESET_LEVEL_MASK as u32; let flags: u32 = preset & !(LZMA_PRESET_LEVEL_MASK as u32); let supported_flags: u32 = LZMA_PRESET_EXTREME as u32; - if level > 9 as u32 || flags & !supported_flags != 0 { - return true_0 as lzma_bool; + if level > 9 || flags & !supported_flags != 0 { + return true as lzma_bool; } (*options).preset_dict = ::core::ptr::null::(); - (*options).preset_dict_size = 0 as u32; + (*options).preset_dict_size = 0; (*options).lc = LZMA_LC_DEFAULT as u32; (*options).lp = LZMA_LP_DEFAULT as u32; (*options).pb = LZMA_PB_DEFAULT as u32; - static mut dict_pow2: [u8; 10] = [ - 18 as u8, 20 as u8, 21 as u8, 22 as u8, 22 as u8, 23 as u8, 23 as u8, 24 as u8, 25 as u8, - 26 as u8, - ]; + static mut dict_pow2: [u8; 10] = [18, 20, 21, 22, 22, 23, 23, 24, 25, 26]; (*options).dict_size = (1u32 << dict_pow2[level as usize] as c_int) as u32; - if level <= 3 as u32 { + if level <= 3 { (*options).mode = LZMA_MODE_FAST; - (*options).mf = (if level == 0 as u32 { + (*options).mf = (if level == 0 { LZMA_MF_HC3 as c_int } else { LZMA_MF_HC4 as c_int }) as lzma_match_finder; - (*options).nice_len = (if level <= 1 as u32 { + (*options).nice_len = (if level <= 1 { 128 as c_int } else { 273 as c_int }) as u32; - static mut depths: [u8; 4] = [4 as u8, 8 as u8, 24 as u8, 48 as u8]; + static mut depths: [u8; 4] = [4, 8, 24, 48]; (*options).depth = depths[level as usize] as u32; } else { (*options).mode = LZMA_MODE_NORMAL; (*options).mf = LZMA_MF_BT4; - (*options).nice_len = (if level == 4 as u32 { + (*options).nice_len = (if level == 4 { 16 as c_int - } else if level == 5 as u32 { + } else if level == 5 { 32 as c_int } else { 64 as c_int }) as u32; - (*options).depth = 0 as u32; + (*options).depth = 0; } if flags & LZMA_PRESET_EXTREME as u32 != 0 { (*options).mode = LZMA_MODE_NORMAL; (*options).mf = LZMA_MF_BT4; - if level == 3 as u32 || level == 5 as u32 { - (*options).nice_len = 192 as u32; - (*options).depth = 0 as u32; + if level == 3 || level == 5 { + (*options).nice_len = 192; + (*options).depth = 0; } else { - (*options).nice_len = 273 as u32; - (*options).depth = 512 as u32; + (*options).nice_len = 273; + (*options).depth = 512; } } - return false_0 as lzma_bool; + return false as lzma_bool; } diff --git a/liblzma-rs/src/rangecoder/price_table.rs b/liblzma-rs/src/rangecoder/price_table.rs index 43e798b8..1f74ec81 100644 --- a/liblzma-rs/src/rangecoder/price_table.rs +++ b/liblzma-rs/src/rangecoder/price_table.rs @@ -1,5 +1,3 @@ -use crate::types::*; -use core::ffi::c_int; #[no_mangle] pub static mut lzma_rc_prices: [u8; 128] = [ 128, 103, 91, 84, 78, 73, 69, 66, 63, 61, 58, 56, 54, 52, 51, 49, 48, 46, 45, 44, 43, 42, 41, diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index c35c6cce..bbf72fdb 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -106,72 +106,74 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn arm_code( - mut simple: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, + _simple: *mut c_void, + now_pos: u32, + is_encoder: bool, + buffer: *mut u8, mut size: size_t, ) -> size_t { - size &= !(3 as size_t); + size &= !(3); let mut i: size_t = 0; - i = 0 as size_t; + i = 0; while i < size { - if *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int == 0xeb as c_int { - let mut src: u32 = (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16 - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8 - | *buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32; + if *buffer.offset(i.wrapping_add(3) as isize) as c_int == 0xeb as c_int { + let mut src: u32 = (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16 + | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8 + | *buffer.offset(i.wrapping_add(0) as isize) as u32; src <<= 2 as c_int; let mut dest: u32 = 0; if is_encoder { dest = now_pos .wrapping_add(i as u32) - .wrapping_add(8 as u32) + .wrapping_add(8) .wrapping_add(src); } else { - dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(8 as u32)); + dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(8)); } dest >>= 2 as c_int; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 16) as u8; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 8) as u8; - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = dest as u8; + *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 16) as u8; + *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 8) as u8; + *buffer.offset(i.wrapping_add(0) as isize) = dest as u8; } - i = i.wrapping_add(4 as size_t); + i = i.wrapping_add(4); } return i; } -unsafe extern "C" fn arm_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut is_encoder: bool, +extern "C" fn arm_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + is_encoder: bool, ) -> lzma_ret { - return lzma_simple_coder_init( - next, - allocator, - filters, - Some(arm_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), - 0 as size_t, - 4 as size_t, - 4 as u32, - is_encoder, - ); + return unsafe { + lzma_simple_coder_init( + next, + allocator, + filters, + Some( + arm_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + ), + 0, + 4, + 4, + is_encoder, + ) + }; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_arm_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return arm_coder_init(next, allocator, filters, true_0 != 0); + return arm_coder_init(next, allocator, filters, true); } #[no_mangle] pub unsafe extern "C" fn lzma_simple_arm_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return arm_coder_init(next, allocator, filters, false_0 != 0); + return arm_coder_init(next, allocator, filters, false); } diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index 2238a697..0e9c34f9 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -106,35 +106,35 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0) as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - return num; +extern "C" fn read32le(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; + num + }; } #[inline] -unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0) = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; +extern "C" fn write32le(buf: *mut u8, num: u32) { + unsafe { + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; + } } unsafe extern "C" fn arm64_code( - mut simple: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, + _simple: *mut c_void, + now_pos: u32, + is_encoder: bool, + buffer: *mut u8, mut size: size_t, ) -> size_t { - size &= !(3 as size_t); + size &= !(3); let mut i: size_t = 0; - i = 0 as size_t; + i = 0; while i < size { let mut pc: u32 = (now_pos as size_t).wrapping_add(i) as u32; let mut instr: u32 = read32le(buffer.offset(i as isize)); @@ -143,78 +143,83 @@ unsafe extern "C" fn arm64_code( instr = 0x94000000 as u32; pc >>= 2 as c_int; if !is_encoder { - pc = (0 as u32).wrapping_sub(pc); + pc = 0u32.wrapping_sub(pc); } instr |= src.wrapping_add(pc) & 0x3ffffff as u32; write32le(buffer.offset(i as isize), instr); } else if instr & 0x9f000000 as u32 == 0x90000000 as u32 { - let src_0: u32 = instr >> 29 & 3 as u32 | instr >> 3 & 0x1ffffc as u32; + let src_0: u32 = instr >> 29 & 3 | instr >> 3 & 0x1ffffc as u32; if !(src_0.wrapping_add(0x20000 as u32) & 0x1c0000 as u32 != 0) { instr = (instr & 0x9000001f) as u32; pc >>= 12 as c_int; if !is_encoder { - pc = (0 as u32).wrapping_sub(pc); + pc = 0u32.wrapping_sub(pc); } let dest: u32 = src_0.wrapping_add(pc); - instr |= (dest & 3 as u32) << 29; + instr |= (dest & 3) << 29; instr |= (dest & 0x3fffc as u32) << 3; - instr = (instr | ((0 as u32).wrapping_sub(dest & 0x20000 as u32) & 0xe00000 as u32)) - as u32; + instr = + (instr | (0u32.wrapping_sub(dest & 0x20000 as u32) & 0xe00000 as u32)) as u32; write32le(buffer.offset(i as isize), instr); } } - i = i.wrapping_add(4 as size_t); + i = i.wrapping_add(4); } return i; } -unsafe extern "C" fn arm64_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut is_encoder: bool, +extern "C" fn arm64_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + is_encoder: bool, ) -> lzma_ret { - return lzma_simple_coder_init( - next, - allocator, - filters, - Some(arm64_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), - 0 as size_t, - 4 as size_t, - 4 as u32, - is_encoder, - ); + return unsafe { + lzma_simple_coder_init( + next, + allocator, + filters, + Some( + arm64_code + as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + ), + 0, + 4, + 4, + is_encoder, + ) + }; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return arm64_coder_init(next, allocator, filters, true_0 != 0); + return arm64_coder_init(next, allocator, filters, true); } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_arm64_encode( mut start_offset: u32, - mut buf: *mut u8, - mut size: size_t, + buf: *mut u8, + size: size_t, ) -> size_t { start_offset = (start_offset & !3u32) as u32; - return arm64_code(NULL, start_offset, true_0 != 0, buf, size); + return arm64_code(core::ptr::null_mut(), start_offset, true, buf, size); } #[no_mangle] pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return arm64_coder_init(next, allocator, filters, false_0 != 0); + return arm64_coder_init(next, allocator, filters, false); } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_arm64_decode( mut start_offset: u32, - mut buf: *mut u8, - mut size: size_t, + buf: *mut u8, + size: size_t, ) -> size_t { start_offset = (start_offset & !3u32) as u32; - return arm64_code(NULL, start_offset, false_0 != 0, buf, size); + return arm64_code(core::ptr::null_mut(), start_offset, false, buf, size); } diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index 02a8dd1a..0b76c3cd 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -106,88 +106,85 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn armthumb_code( - mut simple: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, + _simple: *mut c_void, + now_pos: u32, + is_encoder: bool, + buffer: *mut u8, mut size: size_t, ) -> size_t { - if size < 4 as size_t { - return 0 as size_t; + if size < 4 { + return 0; } - size = size.wrapping_sub(4 as size_t); + size = size.wrapping_sub(4); let mut i: size_t = 0; - i = 0 as size_t; + i = 0; while i <= size { - if *buffer.offset(i.wrapping_add(1 as size_t) as isize) as c_int & 0xf8 as c_int - == 0xf0 as c_int - && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int & 0xf8 as c_int - == 0xf8 as c_int + if *buffer.offset(i.wrapping_add(1) as isize) as c_int & 0xf8 as c_int == 0xf0 as c_int + && *buffer.offset(i.wrapping_add(3) as isize) as c_int & 0xf8 as c_int == 0xf8 as c_int { - let mut src: u32 = - (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32 & 7 as u32) << 19 - | (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32) << 11 - | (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32 & 7 as u32) << 8 - | *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; + let mut src: u32 = (*buffer.offset(i.wrapping_add(1) as isize) as u32 & 7) << 19 + | (*buffer.offset(i.wrapping_add(0) as isize) as u32) << 11 + | (*buffer.offset(i.wrapping_add(3) as isize) as u32 & 7) << 8 + | *buffer.offset(i.wrapping_add(2) as isize) as u32; src <<= 1 as c_int; let mut dest: u32 = 0; if is_encoder { dest = now_pos .wrapping_add(i as u32) - .wrapping_add(4 as u32) + .wrapping_add(4) .wrapping_add(src); } else { - dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(4 as u32)); + dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(4)); } dest >>= 1 as c_int; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = + *buffer.offset(i.wrapping_add(1) as isize) = (0xf0 as u32 | dest >> 19 & 0x7 as u32) as u8; - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest >> 11) as u8; - *buffer.offset(i.wrapping_add(3 as size_t) as isize) = + *buffer.offset(i.wrapping_add(0) as isize) = (dest >> 11) as u8; + *buffer.offset(i.wrapping_add(3) as isize) = (0xf8 as u32 | dest >> 8 & 0x7 as u32) as u8; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = dest as u8; - i = i.wrapping_add(2 as size_t); + *buffer.offset(i.wrapping_add(2) as isize) = dest as u8; + i = i.wrapping_add(2); } - i = i.wrapping_add(2 as size_t); + i = i.wrapping_add(2); } return i; } -unsafe extern "C" fn armthumb_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut is_encoder: bool, +extern "C" fn armthumb_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + is_encoder: bool, ) -> lzma_ret { - return lzma_simple_coder_init( - next, - allocator, - filters, - Some( - armthumb_code - as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, - ), - 0 as size_t, - 4 as size_t, - 2 as u32, - is_encoder, - ); + return unsafe { + lzma_simple_coder_init( + next, + allocator, + filters, + Some( + armthumb_code + as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, + ), + 0, + 4, + 2, + is_encoder, + ) + }; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_armthumb_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return armthumb_coder_init(next, allocator, filters, true_0 != 0); + return armthumb_coder_init(next, allocator, filters, true); } #[no_mangle] pub unsafe extern "C" fn lzma_simple_armthumb_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return armthumb_coder_init(next, allocator, filters, false_0 != 0); + return armthumb_coder_init(next, allocator, filters, false); } diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index cd011027..4fa20f9b 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -106,36 +106,32 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn ia64_code( - mut simple: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, + _simple: *mut c_void, + now_pos: u32, + is_encoder: bool, + buffer: *mut u8, mut size: size_t, ) -> size_t { static mut BRANCH_TABLE: [u32; 32] = [ - 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, - 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 0 as u32, 4 as u32, 4 as u32, - 6 as u32, 6 as u32, 0 as u32, 0 as u32, 7 as u32, 7 as u32, 4 as u32, 4 as u32, 0 as u32, - 0 as u32, 4 as u32, 4 as u32, 0 as u32, 0 as u32, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 6, 6, 0, 0, 7, 7, 4, 4, 0, 0, 4, 4, + 0, 0, ]; - size &= !(15 as size_t); + size &= !(15); let mut i: size_t = 0; - i = 0 as size_t; + i = 0; while i < size { let instr_template: u32 = (*buffer.offset(i as isize) as c_int & 0x1f as c_int) as u32; let mask: u32 = BRANCH_TABLE[instr_template as usize]; - let mut bit_pos: u32 = 5 as u32; - let mut slot: size_t = 0 as size_t; - while slot < 3 as size_t { - if !(mask >> slot & 1 as u32 == 0 as u32) { + let mut bit_pos: u32 = 5; + let mut slot: size_t = 0; + while slot < 3 { + if !(mask >> slot & 1 == 0) { let byte_pos: size_t = (bit_pos >> 3) as size_t; let bit_res: u32 = bit_pos & 0x7 as u32; - let mut instruction: u64 = 0 as u64; - let mut j: size_t = 0 as size_t; - while j < 6 as size_t { + let mut instruction: u64 = 0; + let mut j: size_t = 0; + while j < 6 { instruction = instruction.wrapping_add( (*buffer.offset(i.wrapping_add(j).wrapping_add(byte_pos) as isize) as u64) << (8 as size_t).wrapping_mul(j), @@ -143,11 +139,9 @@ unsafe extern "C" fn ia64_code( j = j.wrapping_add(1); } let mut inst_norm: u64 = instruction >> bit_res; - if inst_norm >> 37 & 0xf as u64 == 0x5 as u64 - && inst_norm >> 9 & 0x7 as u64 == 0 as u64 - { + if inst_norm >> 37 & 0xf as u64 == 0x5 as u64 && inst_norm >> 9 & 0x7 as u64 == 0 { let mut src: u32 = (inst_norm >> 13 & 0xfffff as u64) as u32; - src = (src as u64 | (inst_norm >> 36 & 1 as u64) << 20) as u32; + src = (src as u64 | (inst_norm >> 36 & 1) << 20) as u32; src <<= 4 as c_int; let mut dest: u32 = 0; if is_encoder { @@ -161,8 +155,8 @@ unsafe extern "C" fn ia64_code( inst_norm |= ((dest & 0x100000 as u32) as u64) << 36 - 20 as c_int; instruction &= (1u32 << bit_res).wrapping_sub(1) as u64; instruction |= inst_norm << bit_res; - let mut j_0: size_t = 0 as size_t; - while j_0 < 6 as size_t { + let mut j_0: size_t = 0; + while j_0 < 6 { *buffer.offset(i.wrapping_add(j_0).wrapping_add(byte_pos) as isize) = (instruction >> (8 as size_t).wrapping_mul(j_0)) as u8; j_0 = j_0.wrapping_add(1); @@ -170,42 +164,46 @@ unsafe extern "C" fn ia64_code( } } slot = slot.wrapping_add(1); - bit_pos = bit_pos.wrapping_add(41 as u32); + bit_pos = bit_pos.wrapping_add(41); } - i = i.wrapping_add(16 as size_t); + i = i.wrapping_add(16); } return i; } -unsafe extern "C" fn ia64_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut is_encoder: bool, +extern "C" fn ia64_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + is_encoder: bool, ) -> lzma_ret { - return lzma_simple_coder_init( - next, - allocator, - filters, - Some(ia64_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), - 0 as size_t, - 16 as size_t, - 16 as u32, - is_encoder, - ); + return unsafe { + lzma_simple_coder_init( + next, + allocator, + filters, + Some( + ia64_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + ), + 0, + 16, + 16, + is_encoder, + ) + }; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_ia64_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return ia64_coder_init(next, allocator, filters, true_0 != 0); + return ia64_coder_init(next, allocator, filters, true); } #[no_mangle] pub unsafe extern "C" fn lzma_simple_ia64_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return ia64_coder_init(next, allocator, filters, false_0 != 0); + return ia64_coder_init(next, allocator, filters, false); } diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index 7b12462f..095c093e 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -106,79 +106,78 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn powerpc_code( - mut simple: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, + _simple: *mut c_void, + now_pos: u32, + is_encoder: bool, + buffer: *mut u8, mut size: size_t, ) -> size_t { - size &= !(3 as size_t); + size &= !(3); let mut i: size_t = 0; - i = 0 as size_t; + i = 0; while i < size { if *buffer.offset(i as isize) as c_int >> 2 == 0x12 as c_int - && *buffer.offset(i.wrapping_add(3 as size_t) as isize) as c_int & 3 as c_int - == 1 as c_int + && *buffer.offset(i.wrapping_add(3) as isize) as c_int & 3 as c_int == 1 as c_int { - let src: u32 = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32 & 3 as u32) - << 24 - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 16 - | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 8 - | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32 & !(3 as u32); + let src: u32 = (*buffer.offset(i.wrapping_add(0) as isize) as u32 & 3) << 24 + | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 16 + | (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 8 + | *buffer.offset(i.wrapping_add(3) as isize) as u32 & !(3); let mut dest: u32 = 0; if is_encoder { dest = now_pos.wrapping_add(i as u32).wrapping_add(src); } else { dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = + *buffer.offset(i.wrapping_add(0) as isize) = (0x48 as u32 | dest >> 24 & 0x3 as u32) as u8; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 16) as u8; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 8) as u8; - let ref mut fresh0 = *buffer.offset(i.wrapping_add(3 as size_t) as isize); + *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 16) as u8; + *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 8) as u8; + let ref mut fresh0 = *buffer.offset(i.wrapping_add(3) as isize); *fresh0 = (*fresh0 as c_int & 0x3 as c_int) as u8; - let ref mut fresh1 = *buffer.offset(i.wrapping_add(3 as size_t) as isize); + let ref mut fresh1 = *buffer.offset(i.wrapping_add(3) as isize); *fresh1 = (*fresh1 as u32 | dest) as u8; } - i = i.wrapping_add(4 as size_t); + i = i.wrapping_add(4); } return i; } -unsafe extern "C" fn powerpc_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut is_encoder: bool, +extern "C" fn powerpc_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + is_encoder: bool, ) -> lzma_ret { - return lzma_simple_coder_init( - next, - allocator, - filters, - Some( - powerpc_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, - ), - 0 as size_t, - 4 as size_t, - 4 as u32, - is_encoder, - ); + return unsafe { + lzma_simple_coder_init( + next, + allocator, + filters, + Some( + powerpc_code + as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, + ), + 0, + 4, + 4, + is_encoder, + ) + }; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_powerpc_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return powerpc_coder_init(next, allocator, filters, true_0 != 0); + return powerpc_coder_init(next, allocator, filters, true); } #[no_mangle] pub unsafe extern "C" fn lzma_simple_powerpc_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return powerpc_coder_init(next, allocator, filters, false_0 != 0); + return powerpc_coder_init(next, allocator, filters, false); } diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 26ec105e..7c186db1 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -106,61 +106,65 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; #[inline] -unsafe extern "C" fn read32be(mut buf: *const u8) -> u32 { - let mut num: u32 = (*buf.offset(0) as u32) << 24; - num |= (*buf.offset(1) as u32) << 16; - num |= (*buf.offset(2) as u32) << 8; - num |= *buf.offset(3) as u32; - return num; +extern "C" fn read32be(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = (*buf.offset(0) as u32) << 24; + num |= (*buf.offset(1) as u32) << 16; + num |= (*buf.offset(2) as u32) << 8; + num |= *buf.offset(3) as u32; + num + }; } #[inline] -unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0) as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - return num; +extern "C" fn read32le(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; + num + }; } #[inline] -unsafe extern "C" fn write32be(mut buf: *mut u8, mut num: u32) { - *buf.offset(0) = (num >> 24) as u8; - *buf.offset(1) = (num >> 16) as u8; - *buf.offset(2) = (num >> 8) as u8; - *buf.offset(3) = num as u8; +extern "C" fn write32be(buf: *mut u8, num: u32) { + unsafe { + *buf.offset(0) = (num >> 24) as u8; + *buf.offset(1) = (num >> 16) as u8; + *buf.offset(2) = (num >> 8) as u8; + *buf.offset(3) = num as u8; + } } #[inline] -unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0) = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; +extern "C" fn write32le(buf: *mut u8, num: u32) { + unsafe { + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; + } } unsafe extern "C" fn riscv_encode( - mut simple: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, + _simple: *mut c_void, + now_pos: u32, + _is_encoder: bool, + buffer: *mut u8, mut size: size_t, ) -> size_t { - if size < 8 as size_t { - return 0 as size_t; + if size < 8 { + return 0; } - size = size.wrapping_sub(8 as size_t); + size = size.wrapping_sub(8); let mut i: size_t = 0; let mut current_block_22: u64; - i = 0 as size_t; + i = 0; while i <= size { let mut inst: u32 = *buffer.offset(i as isize) as u32; if inst == 0xef as u32 { - let b1: u32 = *buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32; - if !(b1 & 0xd as u32 != 0 as u32) { - let b2: u32 = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; - let b3: u32 = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; + let b1: u32 = *buffer.offset(i.wrapping_add(1) as isize) as u32; + if !(b1 & 0xd as u32 != 0) { + let b2: u32 = *buffer.offset(i.wrapping_add(2) as isize) as u32; + let b3: u32 = *buffer.offset(i.wrapping_add(3) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); let mut addr: u32 = (b1 & 0xf0 as u32) << 8 | (b2 & 0xf as u32) << 16 @@ -169,19 +173,19 @@ unsafe extern "C" fn riscv_encode( | (b3 & 0x7f as u32) << 4 | (b3 & 0x80 as u32) << 13; addr = addr.wrapping_add(pc); - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = + *buffer.offset(i.wrapping_add(1) as isize) = (b1 & 0xf as u32 | addr >> 13 & 0xf0 as u32) as u8; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (addr >> 9) as u8; - *buffer.offset(i.wrapping_add(3 as size_t) as isize) = (addr >> 1) as u8; + *buffer.offset(i.wrapping_add(2) as isize) = (addr >> 9) as u8; + *buffer.offset(i.wrapping_add(3) as isize) = (addr >> 1) as u8; i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); } } else if inst & 0x7f as u32 == 0x17 as u32 { - inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8; - inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16; - inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32) << 24; + inst |= (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8; + inst |= (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16; + inst |= (*buffer.offset(i.wrapping_add(3) as isize) as u32) << 24; if inst & 0xe80 as u32 != 0 { - let mut inst2: u32 = read32le(buffer.offset(i as isize).offset(4)); - if (inst << 8 ^ inst2.wrapping_sub(3 as u32)) & 0xf8003 as u32 != 0 { + let inst2: u32 = read32le(buffer.offset(i as isize).offset(4)); + if (inst << 8 ^ inst2.wrapping_sub(3)) & 0xf8003 as u32 != 0 { i = i.wrapping_add((6 as c_int - 2 as c_int) as size_t); current_block_22 = 12517898123489920830; } else { @@ -215,15 +219,15 @@ unsafe extern "C" fn riscv_encode( } } } - i = i.wrapping_add(2 as size_t); + i = i.wrapping_add(2); } return i; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { return lzma_simple_coder_init( next, @@ -232,62 +236,62 @@ pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( Some( riscv_encode as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), - 0 as size_t, - 8 as size_t, - 2 as u32, - true_0 != 0, + 0, + 8, + 2, + true, ); } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_riscv_encode( mut start_offset: u32, - mut buf: *mut u8, - mut size: size_t, + buf: *mut u8, + size: size_t, ) -> size_t { start_offset = (start_offset & !1u32) as u32; - return riscv_encode(NULL, start_offset, true_0 != 0, buf, size); + return riscv_encode(core::ptr::null_mut(), start_offset, true, buf, size); } unsafe extern "C" fn riscv_decode( - mut simple: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, + _simple: *mut c_void, + now_pos: u32, + _is_encoder: bool, + buffer: *mut u8, mut size: size_t, ) -> size_t { - if size < 8 as size_t { - return 0 as size_t; + if size < 8 { + return 0; } - size = size.wrapping_sub(8 as size_t); + size = size.wrapping_sub(8); let mut i: size_t = 0; let mut current_block_23: u64; - i = 0 as size_t; + i = 0; while i <= size { let mut inst: u32 = *buffer.offset(i as isize) as u32; if inst == 0xef as u32 { - let b1: u32 = *buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32; - if !(b1 & 0xd as u32 != 0 as u32) { - let b2: u32 = *buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32; - let b3: u32 = *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; + let b1: u32 = *buffer.offset(i.wrapping_add(1) as isize) as u32; + if !(b1 & 0xd as u32 != 0) { + let b2: u32 = *buffer.offset(i.wrapping_add(2) as isize) as u32; + let b3: u32 = *buffer.offset(i.wrapping_add(3) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); let mut addr: u32 = (b1 & 0xf0 as u32) << 13 | b2 << 9 | b3 << 1; addr = addr.wrapping_sub(pc); - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = + *buffer.offset(i.wrapping_add(1) as isize) = (b1 & 0xf as u32 | addr >> 8 & 0xf0 as u32) as u8; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = + *buffer.offset(i.wrapping_add(2) as isize) = (addr >> 16 & 0xf as u32 | addr >> 7 & 0x10 as u32 | addr << 4 & 0xe0 as u32) as u8; - *buffer.offset(i.wrapping_add(3 as size_t) as isize) = + *buffer.offset(i.wrapping_add(3) as isize) = (addr >> 4 & 0x7f as u32 | addr >> 13 & 0x80 as u32) as u8; i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); } } else if inst & 0x7f as u32 == 0x17 as u32 { let mut inst2: u32 = 0; - inst |= (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 8; - inst |= (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 16; - inst |= (*buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32) << 24; + inst |= (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8; + inst |= (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16; + inst |= (*buffer.offset(i.wrapping_add(3) as isize) as u32) << 24; if inst & 0xe80 as u32 != 0 { inst2 = read32le(buffer.offset(i as isize).offset(4)); - if (inst << 8 ^ inst2.wrapping_sub(3 as u32)) & 0xf8003 as u32 != 0 { + if (inst << 8 ^ inst2.wrapping_sub(3)) & 0xf8003 as u32 != 0 { i = i.wrapping_add((6 as c_int - 2 as c_int) as size_t); current_block_23 = 12517898123489920830; } else { @@ -321,15 +325,15 @@ unsafe extern "C" fn riscv_decode( } } } - i = i.wrapping_add(2 as size_t); + i = i.wrapping_add(2); } return i; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { return lzma_simple_coder_init( next, @@ -338,18 +342,18 @@ pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( Some( riscv_decode as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), - 0 as size_t, - 8 as size_t, - 2 as u32, - false_0 != 0, + 0, + 8, + 2, + false, ); } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_riscv_decode( mut start_offset: u32, - mut buf: *mut u8, - mut size: size_t, + buf: *mut u8, + size: size_t, ) -> size_t { start_offset = (start_offset & !1u32) as u32; - return riscv_decode(NULL, start_offset, false_0 != 0, buf, size); + return riscv_decode(core::ptr::null_mut(), start_offset, false, buf, size); } diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 23582b38..b518dd05 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong, c_void}; extern "C" { fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn memmove(__dst: *mut c_void, __src: *const c_void, __len: size_t) -> *mut c_void; @@ -139,27 +139,23 @@ pub struct lzma_simple_coder { pub size: size_t, pub buffer: [u8; 0], } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; unsafe extern "C" fn copy_or_code( - mut coder: *mut lzma_simple_coder, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder: *mut lzma_simple_coder, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { if (*coder).next.code.is_none() { lzma_bufcpy(in_0, in_pos, in_size, out, out_pos, out_size); if (*coder).is_encoder as c_int != 0 && action == LZMA_FINISH && *in_pos == in_size { - (*coder).end_was_reached = true_0 != 0; + (*coder).end_was_reached = true; } } else { let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( @@ -174,7 +170,7 @@ unsafe extern "C" fn copy_or_code( action, ) as lzma_ret; if ret == LZMA_STREAM_END { - (*coder).end_was_reached = true_0 != 0; + (*coder).end_was_reached = true; } else if ret != LZMA_OK { return ret; } @@ -182,9 +178,9 @@ unsafe extern "C" fn copy_or_code( return LZMA_OK; } unsafe extern "C" fn call_filter( - mut coder: *mut lzma_simple_coder, - mut buffer: *mut u8, - mut size: size_t, + coder: *mut lzma_simple_coder, + buffer: *mut u8, + size: size_t, ) -> size_t { let filtered: size_t = (*coder).filter.expect("non-null function pointer")( (*coder).simple, @@ -197,17 +193,17 @@ unsafe extern "C" fn call_filter( return filtered; } unsafe extern "C" fn simple_code( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut in_0: *const u8, - mut in_pos: *mut size_t, - mut in_size: size_t, - mut out: *mut u8, - mut out_pos: *mut size_t, - mut out_size: size_t, - mut action: lzma_action, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, ) -> lzma_ret { - let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; + let coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; if action == LZMA_SYNC_FLUSH { return LZMA_OPTIONS_ERROR; } @@ -227,12 +223,12 @@ unsafe extern "C" fn simple_code( return LZMA_STREAM_END; } } - (*coder).filtered = 0 as size_t; + (*coder).filtered = 0; let out_avail: size_t = out_size.wrapping_sub(*out_pos); let buf_avail: size_t = (*coder).size.wrapping_sub((*coder).pos); - if out_avail > buf_avail || buf_avail == 0 as size_t { + if out_avail > buf_avail || buf_avail == 0 { let out_start: size_t = *out_pos; - if buf_avail > 0 as size_t { + if buf_avail > 0 { memcpy( out.offset(*out_pos as isize) as *mut c_void, (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) @@ -248,17 +244,17 @@ unsafe extern "C" fn simple_code( return ret; } let size: size_t = (*out_pos).wrapping_sub(out_start); - let filtered: size_t = if size == 0 as size_t { - 0 as size_t + let filtered: size_t = if size == 0 { + 0 } else { call_filter(coder, out.offset(out_start as isize), size) as size_t }; let unfiltered: size_t = size.wrapping_sub(filtered); - (*coder).pos = 0 as size_t; + (*coder).pos = 0; (*coder).size = unfiltered; if (*coder).end_was_reached { - (*coder).size = 0 as size_t; - } else if unfiltered > 0 as size_t { + (*coder).size = 0; + } else if unfiltered > 0 { *out_pos = (*out_pos).wrapping_sub(unfiltered); memcpy( &raw mut (*coder).buffer as *mut u8 as *mut c_void, @@ -266,16 +262,16 @@ unsafe extern "C" fn simple_code( unfiltered, ); } - } else if (*coder).pos > 0 as size_t { + } else if (*coder).pos > 0 { memmove( &raw mut (*coder).buffer as *mut u8 as *mut c_void, (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const c_void, buf_avail, ); (*coder).size = (*coder).size.wrapping_sub((*coder).pos); - (*coder).pos = 0 as size_t; + (*coder).pos = 0; } - if (*coder).size > 0 as size_t { + if (*coder).size > 0 { let ret_0: lzma_ret = copy_or_code( coder, allocator, @@ -308,22 +304,19 @@ unsafe extern "C" fn simple_code( } return LZMA_OK; } -unsafe extern "C" fn simple_coder_end( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, -) { - let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; +unsafe extern "C" fn simple_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { + let coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free((*coder).simple, allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn simple_coder_update( - mut coder_ptr: *mut c_void, - mut allocator: *const lzma_allocator, - mut filters_null: *const lzma_filter, - mut reversed_filters: *const lzma_filter, + coder_ptr: *mut c_void, + allocator: *const lzma_allocator, + _filters_null: *const lzma_filter, + reversed_filters: *const lzma_filter, ) -> lzma_ret { - let mut coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; + let coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; return lzma_next_filter_update( &raw mut (*coder).next, allocator, @@ -332,19 +325,19 @@ unsafe extern "C" fn simple_coder_update( } #[no_mangle] pub unsafe extern "C" fn lzma_simple_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut filter: Option size_t>, - mut simple_size: size_t, - mut unfiltered_max: size_t, - mut alignment: u32, - mut is_encoder: bool, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option size_t>, + simple_size: size_t, + unfiltered_max: size_t, + alignment: u32, + is_encoder: bool, ) -> lzma_ret { let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; if coder.is_null() { coder = lzma_alloc( - (::core::mem::size_of::() as size_t) + (core::mem::size_of::() as size_t) .wrapping_add((2 as size_t).wrapping_mul(unfiltered_max)), allocator, ) as *mut lzma_simple_coder; @@ -387,9 +380,9 @@ pub unsafe extern "C" fn lzma_simple_coder_init( ) -> lzma_ret, >; (*coder).next = lzma_next_coder_s { - coder: NULL, + coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN as lzma_vli, - init: ::core::ptr::null_mut::() as uintptr_t, + init: 0, code: None, end: None, get_progress: None, @@ -400,29 +393,29 @@ pub unsafe extern "C" fn lzma_simple_coder_init( }; (*coder).filter = filter; (*coder).allocated = (2 as size_t).wrapping_mul(unfiltered_max); - if simple_size > 0 as size_t { + if simple_size > 0 { (*coder).simple = lzma_alloc(simple_size, allocator); if (*coder).simple.is_null() { return LZMA_MEM_ERROR; } } else { - (*coder).simple = NULL; + (*coder).simple = core::ptr::null_mut(); } } if !(*filters.offset(0)).options.is_null() { - let mut simple: *const lzma_options_bcj = + let simple: *const lzma_options_bcj = (*filters.offset(0)).options as *const lzma_options_bcj; (*coder).now_pos = (*simple).start_offset; - if (*coder).now_pos & alignment.wrapping_sub(1 as u32) != 0 { + if (*coder).now_pos & alignment.wrapping_sub(1) != 0 { return LZMA_OPTIONS_ERROR; } } else { - (*coder).now_pos = 0 as u32; + (*coder).now_pos = 0; } (*coder).is_encoder = is_encoder; - (*coder).end_was_reached = false_0 != 0; - (*coder).pos = 0 as size_t; - (*coder).filtered = 0 as size_t; - (*coder).size = 0 as size_t; + (*coder).end_was_reached = false; + (*coder).pos = 0; + (*coder).filtered = 0; + (*coder).size = 0; return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs index 41d23276..3230f2f6 100644 --- a/liblzma-rs/src/simple/simple_decoder.rs +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); @@ -37,38 +37,38 @@ pub struct lzma_allocator { pub struct lzma_options_bcj { pub start_offset: u32, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; #[inline] -unsafe extern "C" fn read32le(mut buf: *const u8) -> u32 { - let mut num: u32 = *buf.offset(0) as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - return num; +extern "C" fn read32le(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = *buf.offset(0) as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; + num + }; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_decode( - mut options: *mut *mut c_void, - mut allocator: *const lzma_allocator, - mut props: *const u8, - mut props_size: size_t, + options: *mut *mut c_void, + allocator: *const lzma_allocator, + props: *const u8, + props_size: size_t, ) -> lzma_ret { - if props_size == 0 as size_t { + if props_size == 0 { return LZMA_OK; } - if props_size != 4 as size_t { + if props_size != 4 { return LZMA_OPTIONS_ERROR; } - let mut opt: *mut lzma_options_bcj = lzma_alloc( - ::core::mem::size_of::() as size_t, + let opt: *mut lzma_options_bcj = lzma_alloc( + core::mem::size_of::() as size_t, allocator, ) as *mut lzma_options_bcj; if opt.is_null() { return LZMA_MEM_ERROR; } (*opt).start_offset = read32le(props); - if (*opt).start_offset == 0 as u32 { + if (*opt).start_offset == 0 { lzma_free(opt as *mut c_void, allocator); } else { *options = opt as *mut c_void; diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index d4c3e7a0..523d7397 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; @@ -26,22 +26,22 @@ pub const LZMA_OK: lzma_ret = 0; pub struct lzma_options_bcj { pub start_offset: u32, } -pub const __DARWIN_NULL: *mut c_void = ::core::ptr::null_mut::(); -pub const NULL: *mut c_void = __DARWIN_NULL; #[inline] -unsafe extern "C" fn write32le(mut buf: *mut u8, mut num: u32) { - *buf.offset(0) = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; +extern "C" fn write32le(buf: *mut u8, num: u32) { + unsafe { + *buf.offset(0) = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; + } } #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_size( - mut size: *mut u32, - mut options: *const c_void, + size: *mut u32, + options: *const c_void, ) -> lzma_ret { let opt: *const lzma_options_bcj = options as *const lzma_options_bcj; - *size = (if opt.is_null() || (*opt).start_offset == 0 as u32 { + *size = (if opt.is_null() || (*opt).start_offset == 0 { 0 as c_int } else { 4 as c_int @@ -50,11 +50,11 @@ pub unsafe extern "C" fn lzma_simple_props_size( } #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_encode( - mut options: *const c_void, - mut out: *mut u8, + options: *const c_void, + out: *mut u8, ) -> lzma_ret { let opt: *const lzma_options_bcj = options as *const lzma_options_bcj; - if opt.is_null() || (*opt).start_offset == 0 as u32 { + if opt.is_null() || (*opt).start_offset == 0 { return LZMA_OK; } write32le(out, (*opt).start_offset); diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index 5eca34dc..b703dc75 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -106,30 +106,27 @@ pub type lzma_init_function = Option< ) -> lzma_ret, >; pub type lzma_filter_info = lzma_filter_info_s; -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn sparc_code( - mut simple: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, + _simple: *mut c_void, + now_pos: u32, + is_encoder: bool, + buffer: *mut u8, mut size: size_t, ) -> size_t { - size &= !(3 as size_t); + size &= !(3); let mut i: size_t = 0; - i = 0 as size_t; + i = 0; while i < size { if *buffer.offset(i as isize) as c_int == 0x40 as c_int - && *buffer.offset(i.wrapping_add(1 as size_t) as isize) as c_int & 0xc0 as c_int - == 0 as c_int + && *buffer.offset(i.wrapping_add(1) as isize) as c_int & 0xc0 as c_int == 0 as c_int || *buffer.offset(i as isize) as c_int == 0x7f as c_int - && *buffer.offset(i.wrapping_add(1 as size_t) as isize) as c_int & 0xc0 as c_int + && *buffer.offset(i.wrapping_add(1) as isize) as c_int & 0xc0 as c_int == 0xc0 as c_int { - let mut src: u32 = (*buffer.offset(i.wrapping_add(0 as size_t) as isize) as u32) << 24 - | (*buffer.offset(i.wrapping_add(1 as size_t) as isize) as u32) << 16 - | (*buffer.offset(i.wrapping_add(2 as size_t) as isize) as u32) << 8 - | *buffer.offset(i.wrapping_add(3 as size_t) as isize) as u32; + let mut src: u32 = (*buffer.offset(i.wrapping_add(0) as isize) as u32) << 24 + | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 16 + | (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 8 + | *buffer.offset(i.wrapping_add(3) as isize) as u32; src <<= 2 as c_int; let mut dest: u32 = 0; if is_encoder { @@ -138,48 +135,52 @@ unsafe extern "C" fn sparc_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } dest >>= 2 as c_int; - dest = (0 as u32).wrapping_sub(dest >> 22 & 1 as u32) << 22 & 0x3fffffff as u32 + dest = 0u32.wrapping_sub(dest >> 22 & 1) << 22 & 0x3fffffff as u32 | dest & 0x3fffff as u32 | 0x40000000 as u32; - *buffer.offset(i.wrapping_add(0 as size_t) as isize) = (dest >> 24) as u8; - *buffer.offset(i.wrapping_add(1 as size_t) as isize) = (dest >> 16) as u8; - *buffer.offset(i.wrapping_add(2 as size_t) as isize) = (dest >> 8) as u8; - *buffer.offset(i.wrapping_add(3 as size_t) as isize) = dest as u8; + *buffer.offset(i.wrapping_add(0) as isize) = (dest >> 24) as u8; + *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 16) as u8; + *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 8) as u8; + *buffer.offset(i.wrapping_add(3) as isize) = dest as u8; } - i = i.wrapping_add(4 as size_t); + i = i.wrapping_add(4); } return i; } -unsafe extern "C" fn sparc_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut is_encoder: bool, +extern "C" fn sparc_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + is_encoder: bool, ) -> lzma_ret { - return lzma_simple_coder_init( - next, - allocator, - filters, - Some(sparc_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), - 0 as size_t, - 4 as size_t, - 4 as u32, - is_encoder, - ); + return unsafe { + lzma_simple_coder_init( + next, + allocator, + filters, + Some( + sparc_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + ), + 0, + 4, + 4, + is_encoder, + ) + }; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_sparc_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return sparc_coder_init(next, allocator, filters, true_0 != 0); + return sparc_coder_init(next, allocator, filters, true); } #[no_mangle] pub unsafe extern "C" fn lzma_simple_sparc_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return sparc_coder_init(next, allocator, filters, false_0 != 0); + return sparc_coder_init(next, allocator, filters, false); } diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index 5b724284..3fcddf81 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -127,27 +127,25 @@ pub struct lzma_simple_coder { pub size: size_t, pub buffer: [u8; 0], } -pub const true_0: c_int = 1 as c_int; -pub const false_0: c_int = 0 as c_int; unsafe extern "C" fn x86_code( - mut simple_ptr: *mut c_void, - mut now_pos: u32, - mut is_encoder: bool, - mut buffer: *mut u8, - mut size: size_t, + simple_ptr: *mut c_void, + now_pos: u32, + is_encoder: bool, + buffer: *mut u8, + size: size_t, ) -> size_t { - static mut MASK_TO_BIT_NUMBER: [u32; 5] = [0 as u32, 1 as u32, 2 as u32, 2 as u32, 3 as u32]; - let mut simple: *mut lzma_simple_x86 = simple_ptr as *mut lzma_simple_x86; + static mut MASK_TO_BIT_NUMBER: [u32; 5] = [0, 1, 2, 2, 3]; + let simple: *mut lzma_simple_x86 = simple_ptr as *mut lzma_simple_x86; let mut prev_mask: u32 = (*simple).prev_mask; let mut prev_pos: u32 = (*simple).prev_pos; - if size < 5 as size_t { - return 0 as size_t; + if size < 5 { + return 0; } - if now_pos.wrapping_sub(prev_pos) > 5 as u32 { - prev_pos = now_pos.wrapping_sub(5 as u32); + if now_pos.wrapping_sub(prev_pos) > 5 { + prev_pos = now_pos.wrapping_sub(5); } - let limit: size_t = size.wrapping_sub(5 as size_t); - let mut buffer_pos: size_t = 0 as size_t; + let limit: size_t = size.wrapping_sub(5); + let mut buffer_pos: size_t = 0; while buffer_pos <= limit { let mut b: u8 = *buffer.offset(buffer_pos as isize); if b as c_int != 0xe8 as c_int && b as c_int != 0xe9 as c_int { @@ -157,62 +155,55 @@ unsafe extern "C" fn x86_code( .wrapping_add(buffer_pos as u32) .wrapping_sub(prev_pos); prev_pos = now_pos.wrapping_add(buffer_pos as u32); - if offset > 5 as u32 { - prev_mask = 0 as u32; + if offset > 5 { + prev_mask = 0; } else { - let mut i: u32 = 0 as u32; + let mut i: u32 = 0; while i < offset { prev_mask &= 0x77 as u32; prev_mask <<= 1 as c_int; i = i.wrapping_add(1); } } - b = *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize); + b = *buffer.offset(buffer_pos.wrapping_add(4) as isize); if (b as c_int == 0 as c_int || b as c_int == 0xff as c_int) - && prev_mask >> 1 <= 4 as u32 - && prev_mask >> 1 != 3 as u32 + && prev_mask >> 1 <= 4 + && prev_mask >> 1 != 3 { let mut src: u32 = (b as u32) << 24 - | (*buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) as u32) << 16 - | (*buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) as u32) << 8 - | *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) as u32; + | (*buffer.offset(buffer_pos.wrapping_add(3) as isize) as u32) << 16 + | (*buffer.offset(buffer_pos.wrapping_add(2) as isize) as u32) << 8 + | *buffer.offset(buffer_pos.wrapping_add(1) as isize) as u32; let mut dest: u32 = 0; loop { if is_encoder { - dest = src.wrapping_add( - now_pos - .wrapping_add(buffer_pos as u32) - .wrapping_add(5 as u32), - ); + dest = src + .wrapping_add(now_pos.wrapping_add(buffer_pos as u32).wrapping_add(5)); } else { - dest = src.wrapping_sub( - now_pos - .wrapping_add(buffer_pos as u32) - .wrapping_add(5 as u32), - ); + dest = src + .wrapping_sub(now_pos.wrapping_add(buffer_pos as u32).wrapping_add(5)); } - if prev_mask == 0 as u32 { + if prev_mask == 0 { break; } let i_0: u32 = MASK_TO_BIT_NUMBER[(prev_mask >> 1) as usize]; - b = (dest >> (24 as u32).wrapping_sub(i_0.wrapping_mul(8 as u32))) as u8; + b = (dest >> (24u32).wrapping_sub(i_0.wrapping_mul(8))) as u8; if !(b as c_int == 0 as c_int || b as c_int == 0xff as c_int) { break; } - src = dest - ^ ((1 as u32) << (32 as u32).wrapping_sub(i_0.wrapping_mul(8 as u32))) - .wrapping_sub(1 as u32); + src = + dest ^ (1u32 << (32u32).wrapping_sub(i_0.wrapping_mul(8))).wrapping_sub(1); } - *buffer.offset(buffer_pos.wrapping_add(4 as size_t) as isize) = - !(dest >> 24 & 1 as u32).wrapping_sub(1 as u32) as u8; - *buffer.offset(buffer_pos.wrapping_add(3 as size_t) as isize) = (dest >> 16) as u8; - *buffer.offset(buffer_pos.wrapping_add(2 as size_t) as isize) = (dest >> 8) as u8; - *buffer.offset(buffer_pos.wrapping_add(1 as size_t) as isize) = dest as u8; - buffer_pos = buffer_pos.wrapping_add(5 as size_t); - prev_mask = 0 as u32; + *buffer.offset(buffer_pos.wrapping_add(4) as isize) = + !(dest >> 24 & 1).wrapping_sub(1) as u8; + *buffer.offset(buffer_pos.wrapping_add(3) as isize) = (dest >> 16) as u8; + *buffer.offset(buffer_pos.wrapping_add(2) as isize) = (dest >> 8) as u8; + *buffer.offset(buffer_pos.wrapping_add(1) as isize) = dest as u8; + buffer_pos = buffer_pos.wrapping_add(5); + prev_mask = 0; } else { buffer_pos = buffer_pos.wrapping_add(1); - prev_mask |= 1 as u32; + prev_mask |= 1; if b as c_int == 0 as c_int || b as c_int == 0xff as c_int { prev_mask |= 0x10 as u32; } @@ -223,78 +214,82 @@ unsafe extern "C" fn x86_code( (*simple).prev_pos = prev_pos; return buffer_pos; } -unsafe extern "C" fn x86_coder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, - mut is_encoder: bool, +extern "C" fn x86_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + is_encoder: bool, ) -> lzma_ret { - let ret: lzma_ret = lzma_simple_coder_init( - next, - allocator, - filters, - Some(x86_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t), - ::core::mem::size_of::() as size_t, - 5 as size_t, - 1 as u32, - is_encoder, - ) as lzma_ret; - if ret == LZMA_OK { - let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; - let mut simple: *mut lzma_simple_x86 = (*coder).simple as *mut lzma_simple_x86; - (*simple).prev_mask = 0 as u32; - (*simple).prev_pos = -(5 as c_int) as u32; - } - return ret; + return unsafe { + let ret: lzma_ret = lzma_simple_coder_init( + next, + allocator, + filters, + Some( + x86_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + ), + core::mem::size_of::() as size_t, + 5, + 1, + is_encoder, + ) as lzma_ret; + if ret == LZMA_OK { + let coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; + let simple: *mut lzma_simple_x86 = (*coder).simple as *mut lzma_simple_x86; + (*simple).prev_mask = 0; + (*simple).prev_pos = -(5 as c_int) as u32; + } + ret + }; } #[no_mangle] pub unsafe extern "C" fn lzma_simple_x86_encoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return x86_coder_init(next, allocator, filters, true_0 != 0); + return x86_coder_init(next, allocator, filters, true); } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_x86_encode( - mut start_offset: u32, - mut buf: *mut u8, - mut size: size_t, + start_offset: u32, + buf: *mut u8, + size: size_t, ) -> size_t { let mut simple: lzma_simple_x86 = lzma_simple_x86 { - prev_mask: 0 as u32, + prev_mask: 0, prev_pos: -(5 as c_int) as u32, }; return x86_code( &raw mut simple as *mut c_void, start_offset, - true_0 != 0, + true, buf, size, ); } #[no_mangle] pub unsafe extern "C" fn lzma_simple_x86_decoder_init( - mut next: *mut lzma_next_coder, - mut allocator: *const lzma_allocator, - mut filters: *const lzma_filter_info, + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, ) -> lzma_ret { - return x86_coder_init(next, allocator, filters, false_0 != 0); + return x86_coder_init(next, allocator, filters, false); } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_x86_decode( - mut start_offset: u32, - mut buf: *mut u8, - mut size: size_t, + start_offset: u32, + buf: *mut u8, + size: size_t, ) -> size_t { let mut simple: lzma_simple_x86 = lzma_simple_x86 { - prev_mask: 0 as u32, + prev_mask: 0, prev_pos: -(5 as c_int) as u32, }; return x86_code( &raw mut simple as *mut c_void, start_offset, - false_0 != 0, + false, buf, size, ); diff --git a/liblzma-rs/src/tuklib/tuklib_cpucores.rs b/liblzma-rs/src/tuklib/tuklib_cpucores.rs index 7092289d..cfb46237 100644 --- a/liblzma-rs/src/tuklib/tuklib_cpucores.rs +++ b/liblzma-rs/src/tuklib/tuklib_cpucores.rs @@ -1,7 +1,5 @@ -use crate::types::*; - #[no_mangle] -pub unsafe extern "C" fn tuklib_cpucores() -> u32 { +pub extern "C" fn tuklib_cpucores() -> u32 { match std::thread::available_parallelism() { Ok(n) => n.get() as u32, Err(_) => 0, diff --git a/liblzma-rs/src/tuklib/tuklib_physmem.rs b/liblzma-rs/src/tuklib/tuklib_physmem.rs index 0b2392d6..4106e98a 100644 --- a/liblzma-rs/src/tuklib/tuklib_physmem.rs +++ b/liblzma-rs/src/tuklib/tuklib_physmem.rs @@ -1,21 +1,20 @@ -use crate::types::*; -use core::ffi::{c_int, c_void}; - #[no_mangle] -pub unsafe extern "C" fn tuklib_physmem() -> u64 { +pub extern "C" fn tuklib_physmem() -> u64 { #[cfg(target_os = "macos")] { let mut memsize: u64 = 0; let mut len = core::mem::size_of::() as libc::size_t; let mut mib: [libc::c_int; 2] = [libc::CTL_HW, libc::HW_MEMSIZE]; - if libc::sysctl( - mib.as_mut_ptr(), - 2, - &mut memsize as *mut u64 as *mut libc::c_void, - &mut len, - core::ptr::null_mut(), - 0, - ) == 0 + if unsafe { + libc::sysctl( + mib.as_mut_ptr(), + 2, + &mut memsize as *mut u64 as *mut libc::c_void, + &mut len, + core::ptr::null_mut(), + 0, + ) + } == 0 { return memsize; } @@ -24,8 +23,8 @@ pub unsafe extern "C" fn tuklib_physmem() -> u64 { #[cfg(target_os = "linux")] { - let pages = libc::sysconf(libc::_SC_PHYS_PAGES); - let page_size = libc::sysconf(libc::_SC_PAGESIZE); + let pages = unsafe { libc::sysconf(libc::_SC_PHYS_PAGES) }; + let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) }; if pages > 0 && page_size > 0 { return (pages as u64).wrapping_mul(page_size as u64); } From 79a6c1802f4346b08de696ba5101bf8cc9c34762 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 1 Mar 2026 15:18:30 +0900 Subject: [PATCH 06/51] centralize structs and remove c2rust boilerplate --- liblzma-rs-sys/src/lib.rs | 133 ++-- liblzma-rs/src/check/check.rs | 33 - liblzma-rs/src/check/sha256.rs | 33 +- liblzma-rs/src/common/alone_decoder.rs | 209 +------ liblzma-rs/src/common/alone_encoder.rs | 194 +----- liblzma-rs/src/common/auto_decoder.rs | 167 +---- liblzma-rs/src/common/block_buffer_decoder.rs | 119 +--- liblzma-rs/src/common/block_buffer_encoder.rs | 202 +----- liblzma-rs/src/common/block_decoder.rs | 231 +------ liblzma-rs/src/common/block_encoder.rs | 205 +----- liblzma-rs/src/common/block_header_decoder.rs | 99 +-- liblzma-rs/src/common/block_header_encoder.rs | 105 +--- liblzma-rs/src/common/block_util.rs | 87 +-- liblzma-rs/src/common/common.rs | 257 ++------ liblzma-rs/src/common/easy_buffer_encoder.rs | 81 --- .../src/common/easy_decoder_memusage.rs | 50 -- liblzma-rs/src/common/easy_encoder.rs | 162 ----- .../src/common/easy_encoder_memusage.rs | 50 -- liblzma-rs/src/common/easy_preset.rs | 57 +- liblzma-rs/src/common/file_info.rs | 184 +----- .../src/common/filter_buffer_decoder.rs | 86 +-- .../src/common/filter_buffer_encoder.rs | 86 +-- liblzma-rs/src/common/filter_common.rs | 264 ++------ liblzma-rs/src/common/filter_decoder.rs | 193 +----- liblzma-rs/src/common/filter_encoder.rs | 212 +------ liblzma-rs/src/common/filter_flags_decoder.rs | 44 +- liblzma-rs/src/common/filter_flags_encoder.rs | 44 +- liblzma-rs/src/common/index.rs | 153 ++--- liblzma-rs/src/common/index_decoder.rs | 140 +---- liblzma-rs/src/common/index_encoder.rs | 153 +---- liblzma-rs/src/common/index_hash.rs | 95 +-- liblzma-rs/src/common/lzip_decoder.rs | 226 +------ liblzma-rs/src/common/microlzma_decoder.rs | 195 +----- liblzma-rs/src/common/microlzma_encoder.rs | 193 +----- liblzma-rs/src/common/outqueue.rs | 67 +- .../src/common/stream_buffer_decoder.rs | 85 +-- .../src/common/stream_buffer_encoder.rs | 102 +-- liblzma-rs/src/common/stream_decoder.rs | 252 +------- liblzma-rs/src/common/stream_decoder_mt.rs | 372 ++--------- liblzma-rs/src/common/stream_encoder.rs | 232 +------ liblzma-rs/src/common/stream_encoder_mt.rs | 377 ++--------- liblzma-rs/src/common/stream_flags_common.rs | 57 +- liblzma-rs/src/common/stream_flags_decoder.rs | 67 +- liblzma-rs/src/common/stream_flags_encoder.rs | 57 +- liblzma-rs/src/common/stream_mt.rs | 2 +- liblzma-rs/src/common/string_conversion.rs | 204 ++---- liblzma-rs/src/common/vli_decoder.rs | 38 +- liblzma-rs/src/common/vli_encoder.rs | 44 +- liblzma-rs/src/common/vli_size.rs | 6 +- liblzma-rs/src/delta/delta_common.rs | 135 +--- liblzma-rs/src/delta/delta_decoder.rs | 126 +--- liblzma-rs/src/delta/delta_encoder.rs | 129 +--- liblzma-rs/src/lz/lz_decoder.rs | 144 +---- liblzma-rs/src/lz/lz_encoder.rs | 194 +----- liblzma-rs/src/lz/lz_encoder_mf.rs | 70 +-- liblzma-rs/src/lzma/lzma2_decoder.rs | 177 +----- liblzma-rs/src/lzma/lzma2_encoder.rs | 211 +------ liblzma-rs/src/lzma/lzma_decoder.rs | 236 +------ liblzma-rs/src/lzma/lzma_encoder.rs | 222 +------ .../src/lzma/lzma_encoder_optimum_fast.rs | 53 -- .../src/lzma/lzma_encoder_optimum_normal.rs | 65 +- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 38 +- liblzma-rs/src/simple/arm.rs | 96 +-- liblzma-rs/src/simple/arm64.rs | 96 +-- liblzma-rs/src/simple/armthumb.rs | 94 --- liblzma-rs/src/simple/ia64.rs | 97 +-- liblzma-rs/src/simple/powerpc.rs | 94 --- liblzma-rs/src/simple/riscv.rs | 94 --- liblzma-rs/src/simple/simple_coder.rs | 136 +--- liblzma-rs/src/simple/simple_decoder.rs | 43 +- liblzma-rs/src/simple/simple_encoder.rs | 26 - liblzma-rs/src/simple/sparc.rs | 97 +-- liblzma-rs/src/simple/x86.rs | 115 +--- liblzma-rs/src/types.rs | 589 +++++++++++++++++- src/stream.rs | 2 +- 75 files changed, 1416 insertions(+), 8667 deletions(-) diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs index 02001e11..1388f86e 100644 --- a/liblzma-rs-sys/src/lib.rs +++ b/liblzma-rs-sys/src/lib.rs @@ -36,12 +36,12 @@ pub type lzma_bool = c_uchar; pub type lzma_vli = u64; // === Canonical struct re-exports === -pub use liblzma_rs::common::common::lzma_allocator; -pub use liblzma_rs::common::common::lzma_stream; -pub use liblzma_rs::common::filter_common::lzma_options_lzma; pub use liblzma_rs::common::index_decoder::lzma_index; -pub use liblzma_rs::common::stream_flags_decoder::lzma_stream_flags; -pub use liblzma_rs::delta::delta_common::lzma_filter; +pub use liblzma_rs::types::lzma_allocator; +pub use liblzma_rs::types::lzma_filter; +pub use liblzma_rs::types::lzma_options_lzma; +pub use liblzma_rs::types::lzma_stream; +pub use liblzma_rs::types::lzma_stream_flags; #[repr(C)] pub struct lzma_options_bcj { @@ -54,82 +54,41 @@ pub enum lzma_internal {} // Constants // ========================================================================= -// --- Return codes / actions --- -pub const LZMA_OK: lzma_ret = liblzma_rs::common::common::LZMA_OK as lzma_ret; -pub const LZMA_STREAM_END: lzma_ret = liblzma_rs::common::common::LZMA_STREAM_END as lzma_ret; -pub const LZMA_NO_CHECK: lzma_ret = liblzma_rs::common::common::LZMA_NO_CHECK as lzma_ret; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = - liblzma_rs::common::common::LZMA_UNSUPPORTED_CHECK as lzma_ret; -pub const LZMA_GET_CHECK: lzma_ret = liblzma_rs::common::common::LZMA_GET_CHECK as lzma_ret; -pub const LZMA_MEM_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_MEM_ERROR as lzma_ret; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = - liblzma_rs::common::common::LZMA_MEMLIMIT_ERROR as lzma_ret; -pub const LZMA_FORMAT_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_FORMAT_ERROR as lzma_ret; -pub const LZMA_OPTIONS_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_OPTIONS_ERROR as lzma_ret; -pub const LZMA_DATA_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_DATA_ERROR as lzma_ret; -pub const LZMA_BUF_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_BUF_ERROR as lzma_ret; -pub const LZMA_PROG_ERROR: lzma_ret = liblzma_rs::common::common::LZMA_PROG_ERROR as lzma_ret; -pub const LZMA_SEEK_NEEDED: lzma_ret = liblzma_rs::common::common::LZMA_SEEK_NEEDED as lzma_ret; - -pub const LZMA_RUN: lzma_action = liblzma_rs::common::common::LZMA_RUN as lzma_action; -pub const LZMA_SYNC_FLUSH: lzma_action = liblzma_rs::common::common::LZMA_SYNC_FLUSH as lzma_action; -pub const LZMA_FULL_FLUSH: lzma_action = liblzma_rs::common::common::LZMA_FULL_FLUSH as lzma_action; -pub const LZMA_FULL_BARRIER: lzma_action = - liblzma_rs::common::common::LZMA_FULL_BARRIER as lzma_action; -pub const LZMA_FINISH: lzma_action = liblzma_rs::common::common::LZMA_FINISH as lzma_action; +// --- Return codes --- +pub use liblzma_rs::types::{ + LZMA_BUF_ERROR, LZMA_DATA_ERROR, LZMA_FORMAT_ERROR, LZMA_GET_CHECK, LZMA_MEMLIMIT_ERROR, + LZMA_MEM_ERROR, LZMA_NO_CHECK, LZMA_OK, LZMA_OPTIONS_ERROR, LZMA_PROG_ERROR, LZMA_SEEK_NEEDED, + LZMA_STREAM_END, LZMA_UNSUPPORTED_CHECK, +}; + +// --- Actions --- +pub use liblzma_rs::types::{ + LZMA_FINISH, LZMA_FULL_BARRIER, LZMA_FULL_FLUSH, LZMA_RUN, LZMA_SYNC_FLUSH, +}; // --- Check types --- -pub const LZMA_CHECK_NONE: lzma_check = liblzma_rs::check::check::LZMA_CHECK_NONE as lzma_check; -pub const LZMA_CHECK_CRC32: lzma_check = liblzma_rs::check::check::LZMA_CHECK_CRC32 as lzma_check; -pub const LZMA_CHECK_CRC64: lzma_check = liblzma_rs::check::check::LZMA_CHECK_CRC64 as lzma_check; -pub const LZMA_CHECK_SHA256: lzma_check = liblzma_rs::check::check::LZMA_CHECK_SHA256 as lzma_check; - -// --- Modes / match finders / filter IDs --- -pub const LZMA_MODE_FAST: lzma_mode = - liblzma_rs::common::filter_common::LZMA_MODE_FAST as lzma_mode; -pub const LZMA_MODE_NORMAL: lzma_mode = - liblzma_rs::common::filter_common::LZMA_MODE_NORMAL as lzma_mode; -pub const LZMA_MF_HC3: lzma_match_finder = - liblzma_rs::common::filter_common::LZMA_MF_HC3 as lzma_match_finder; -pub const LZMA_MF_HC4: lzma_match_finder = - liblzma_rs::common::filter_common::LZMA_MF_HC4 as lzma_match_finder; -pub const LZMA_MF_BT2: lzma_match_finder = - liblzma_rs::common::filter_common::LZMA_MF_BT2 as lzma_match_finder; -pub const LZMA_MF_BT3: lzma_match_finder = - liblzma_rs::common::filter_common::LZMA_MF_BT3 as lzma_match_finder; -pub const LZMA_MF_BT4: lzma_match_finder = - liblzma_rs::common::filter_common::LZMA_MF_BT4 as lzma_match_finder; - -pub const LZMA_FILTER_X86: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_X86 as lzma_vli; -pub const LZMA_FILTER_POWERPC: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_POWERPC as lzma_vli; -pub const LZMA_FILTER_IA64: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_IA64 as lzma_vli; -pub const LZMA_FILTER_ARM: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_ARM as lzma_vli; -pub const LZMA_FILTER_ARMTHUMB: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_ARMTHUMB as lzma_vli; -pub const LZMA_FILTER_SPARC: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_SPARC as lzma_vli; -pub const LZMA_FILTER_ARM64: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_ARM64 as lzma_vli; -pub const LZMA_FILTER_DELTA: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_DELTA as lzma_vli; -pub const LZMA_FILTER_RISCV: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_RISCV as lzma_vli; -pub const LZMA_FILTER_LZMA1: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_LZMA1 as lzma_vli; -pub const LZMA_FILTER_LZMA2: lzma_vli = - liblzma_rs::common::filter_common::LZMA_FILTER_LZMA2 as lzma_vli; +pub use liblzma_rs::types::{ + LZMA_CHECK_CRC32, LZMA_CHECK_CRC64, LZMA_CHECK_NONE, LZMA_CHECK_SHA256, +}; + +// --- Modes / match finders --- +pub use liblzma_rs::types::{ + LZMA_MF_BT2, LZMA_MF_BT3, LZMA_MF_BT4, LZMA_MF_HC3, LZMA_MF_HC4, LZMA_MODE_FAST, + LZMA_MODE_NORMAL, +}; + +// --- Filter IDs --- +pub use liblzma_rs::types::{ + LZMA_FILTER_ARM, LZMA_FILTER_ARM64, LZMA_FILTER_ARMTHUMB, LZMA_FILTER_DELTA, LZMA_FILTER_IA64, + LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA2, LZMA_FILTER_POWERPC, LZMA_FILTER_RISCV, + LZMA_FILTER_SPARC, LZMA_FILTER_X86, +}; // --- Decoder flags --- -pub const LZMA_TELL_NO_CHECK: u32 = liblzma_rs::common::auto_decoder::LZMA_TELL_NO_CHECK as u32; -pub const LZMA_TELL_UNSUPPORTED_CHECK: u32 = - liblzma_rs::common::auto_decoder::LZMA_TELL_UNSUPPORTED_CHECK as u32; -pub const LZMA_TELL_ANY_CHECK: u32 = liblzma_rs::common::auto_decoder::LZMA_TELL_ANY_CHECK as u32; -pub const LZMA_IGNORE_CHECK: u32 = liblzma_rs::common::auto_decoder::LZMA_IGNORE_CHECK as u32; -pub const LZMA_CONCATENATED: u32 = liblzma_rs::common::auto_decoder::LZMA_CONCATENATED as u32; +pub use liblzma_rs::types::{ + LZMA_CONCATENATED, LZMA_IGNORE_CHECK, LZMA_TELL_ANY_CHECK, LZMA_TELL_NO_CHECK, + LZMA_TELL_UNSUPPORTED_CHECK, +}; // --- Presets / option limits --- pub const LZMA_PRESET_DEFAULT: u32 = @@ -138,29 +97,25 @@ pub const LZMA_PRESET_LEVEL_MASK: u32 = liblzma_rs::lzma::lzma_encoder_presets::LZMA_PRESET_LEVEL_MASK as u32; pub const LZMA_PRESET_EXTREME: u32 = liblzma_rs::common::string_conversion::LZMA_PRESET_EXTREME as u32; -pub const LZMA_DICT_SIZE_MIN: u32 = - liblzma_rs::common::string_conversion::LZMA_DICT_SIZE_MIN as u32; +pub const LZMA_DICT_SIZE_MIN: u32 = liblzma_rs::types::LZMA_DICT_SIZE_MIN as u32; pub const LZMA_DICT_SIZE_DEFAULT: u32 = liblzma_rs::common::string_conversion::LZMA_DICT_SIZE_DEFAULT as u32; pub const LZMA_LCLP_MIN: u32 = liblzma_rs::common::string_conversion::LZMA_LCLP_MIN as u32; -pub const LZMA_LCLP_MAX: u32 = liblzma_rs::common::string_conversion::LZMA_LCLP_MAX as u32; +pub const LZMA_LCLP_MAX: u32 = liblzma_rs::types::LZMA_LCLP_MAX as u32; pub const LZMA_LC_DEFAULT: u32 = liblzma_rs::lzma::lzma_encoder_presets::LZMA_LC_DEFAULT as u32; pub const LZMA_LP_DEFAULT: u32 = liblzma_rs::lzma::lzma_encoder_presets::LZMA_LP_DEFAULT as u32; pub const LZMA_PB_MIN: u32 = liblzma_rs::common::string_conversion::LZMA_PB_MIN as u32; -pub const LZMA_PB_MAX: u32 = liblzma_rs::common::string_conversion::LZMA_PB_MAX as u32; +pub const LZMA_PB_MAX: u32 = liblzma_rs::types::LZMA_PB_MAX as u32; pub const LZMA_PB_DEFAULT: u32 = liblzma_rs::lzma::lzma_encoder_presets::LZMA_PB_DEFAULT as u32; // --- Backward size / VLI --- -pub const LZMA_BACKWARD_SIZE_MIN: lzma_vli = - liblzma_rs::common::stream_flags_common::LZMA_BACKWARD_SIZE_MIN as lzma_vli; -pub const LZMA_BACKWARD_SIZE_MAX: lzma_vli = - liblzma_rs::common::stream_flags_common::LZMA_BACKWARD_SIZE_MAX as lzma_vli; -pub const LZMA_VLI_MAX: lzma_vli = liblzma_rs::common::vli_encoder::LZMA_VLI_MAX as lzma_vli; -pub const LZMA_VLI_UNKNOWN: lzma_vli = liblzma_rs::common::common::LZMA_VLI_UNKNOWN as lzma_vli; -pub const LZMA_VLI_BYTES_MAX: usize = liblzma_rs::common::vli_encoder::LZMA_VLI_BYTES_MAX as usize; +pub const LZMA_BACKWARD_SIZE_MIN: lzma_vli = liblzma_rs::types::LZMA_BACKWARD_SIZE_MIN as lzma_vli; +pub const LZMA_BACKWARD_SIZE_MAX: lzma_vli = liblzma_rs::types::LZMA_BACKWARD_SIZE_MAX as lzma_vli; +pub use liblzma_rs::types::{LZMA_VLI_MAX, LZMA_VLI_UNKNOWN}; +pub const LZMA_VLI_BYTES_MAX: usize = liblzma_rs::types::LZMA_VLI_BYTES_MAX as usize; // --- Stream header size --- -pub const LZMA_STREAM_HEADER_SIZE: u32 = liblzma_rs::common::index::LZMA_STREAM_HEADER_SIZE as u32; +pub const LZMA_STREAM_HEADER_SIZE: u32 = liblzma_rs::types::LZMA_STREAM_HEADER_SIZE as u32; // ========================================================================= // Functions diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index ffc2408e..e037cd47 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_uint; extern "C" { fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64; @@ -7,38 +6,6 @@ extern "C" { fn lzma_sha256_update(buf: *const u8, size: size_t, check: *mut lzma_check_state); fn lzma_sha256_finish(check: *mut lzma_check_state); } -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_sha256_state { - pub state: [u32; 8], - pub size: u64, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_check_state { - pub buffer: C2RustUnnamed_0, - pub state: C2RustUnnamed, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed { - pub crc32: u32, - pub crc64: u64, - pub sha256: lzma_sha256_state, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_0 { - pub u8_0: [u8; 64], - pub u32_0: [u32; 16], - pub u64_0: [u64; 8], -} -pub const UINT32_MAX: c_uint = 4294967295; -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; #[no_mangle] pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { if type_0 > LZMA_CHECK_ID_MAX { diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index 3b364b94..c90f50a3 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -1,34 +1,5 @@ use crate::types::*; use core::ffi::{c_int, c_uint, c_void}; -extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_sha256_state { - pub state: [u32; 8], - pub size: u64, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_check_state { - pub buffer: C2RustUnnamed_0, - pub state: C2RustUnnamed, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed { - pub crc32: u32, - pub crc64: u64, - pub sha256: lzma_sha256_state, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_0 { - pub u8_0: [u8; 64], - pub u32_0: [u32; 16], - pub u64_0: [u64; 8], -} #[inline] extern "C" fn rotr_32(num: u32, amount: c_uint) -> u32 { return num >> amount | num << 32u32.wrapping_sub(amount); @@ -49,7 +20,7 @@ unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { memcpy( &raw mut T as *mut u32 as *mut c_void, state as *const c_void, - core::mem::size_of::<[u32; 8]>() as size_t, + core::mem::size_of::<[u32; 8]>(), ); W[0] = (*data.offset(0) & 0xff) << 24 | (*data.offset(0) & 0xff00) << 8 @@ -583,7 +554,7 @@ pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { memcpy( &raw mut (*check).state.sha256.state as *mut u32 as *mut c_void, &raw const s as *const u32 as *const c_void, - core::mem::size_of::<[u32; 8]>() as size_t, + core::mem::size_of::<[u32; 8]>(), ); (*check).state.sha256.size = 0; } diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 461b0612..a636fb16 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -1,9 +1,7 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -19,161 +17,6 @@ extern "C" { fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_alone_coder { @@ -192,27 +35,7 @@ pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; pub const SEQ_UNCOMPRESSED_SIZE: C2RustUnnamed_0 = 2; pub const SEQ_DICTIONARY_SIZE: C2RustUnnamed_0 = 1; pub const SEQ_PROPERTIES: C2RustUnnamed_0 = 0; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; unsafe extern "C" fn alone_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -245,9 +68,7 @@ unsafe extern "C" fn alone_decode( as u32; (*coder).pos = (*coder).pos.wrapping_add(1); if (*coder).pos == 4 { - if (*coder).picky as c_int != 0 - && (*coder).options.dict_size != UINT32_MAX as u32 - { + if (*coder).picky && (*coder).options.dict_size != UINT32_MAX as u32 { let mut d: u32 = (*coder).options.dict_size.wrapping_sub(1); d |= d >> 2; d |= d >> 3; @@ -273,8 +94,8 @@ unsafe extern "C" fn alone_decode( if (*coder).pos < 8 { current_block_42 = 11048769245176032998; } else { - if (*coder).picky as c_int != 0 - && (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli + if (*coder).picky + && (*coder).uncompressed_size != LZMA_VLI_UNKNOWN && (*coder).uncompressed_size >= (1 as lzma_vli) << 38 { return LZMA_FORMAT_ERROR; @@ -285,7 +106,7 @@ unsafe extern "C" fn alone_decode( (*coder).memusage = lzma_lzma_decoder_memusage_nocheck( &raw mut (*coder).options as *const c_void, ) - .wrapping_add(LZMA_MEMUSAGE_BASE as u64); + .wrapping_add(LZMA_MEMUSAGE_BASE); (*coder).pos = 0; (*coder).sequence = SEQ_CODER_INIT; current_block_42 = 14763689060501151050; @@ -316,7 +137,7 @@ unsafe extern "C" fn alone_decode( } let mut filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { - id: LZMA_FILTER_LZMA1EXT as lzma_vli, + id: LZMA_FILTER_LZMA1EXT, init: Some( lzma_lzma_decoder_init as unsafe extern "C" fn( @@ -338,7 +159,7 @@ unsafe extern "C" fn alone_decode( &raw mut (*coder).next, allocator, &raw mut filters as *mut lzma_filter_info, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -421,10 +242,8 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( )); let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_alone_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_alone_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -453,7 +272,7 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( as Option lzma_ret>; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -472,12 +291,12 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( (*coder).options.preset_dict_size = 0; (*coder).uncompressed_size = 0 as lzma_vli; (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; - (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; + (*coder).memusage = LZMA_MEMUSAGE_BASE; return LZMA_OK; } #[no_mangle] pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -485,8 +304,8 @@ pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u6 &raw mut (*(*strm).internal).next, (*strm).allocator, memlimit, - 0 as c_int != 0, - ) as lzma_ret; + false, + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index d69da6db..5afe9d3e 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -1,10 +1,7 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -27,176 +24,6 @@ extern "C" { ) -> lzma_ret; fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_alone_coder { @@ -208,8 +35,6 @@ pub struct lzma_alone_coder { pub type C2RustUnnamed_0 = c_uint; pub const SEQ_CODE: C2RustUnnamed_0 = 1; pub const SEQ_HEADER: C2RustUnnamed_0 = 0; -pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { @@ -219,9 +44,6 @@ extern "C" fn write32le(buf: *mut u8, num: u32) { *buf.offset(3) = (num >> 24) as u8; } } -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; pub const ALONE_HEADER_SIZE: c_int = 1 + 4 as c_int + 8 as c_int; unsafe extern "C" fn alone_encode( coder_ptr: *mut c_void, @@ -318,10 +140,8 @@ unsafe extern "C" fn alone_encoder_init( )); let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_alone_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_alone_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -345,7 +165,7 @@ unsafe extern "C" fn alone_encoder_init( ) as lzma_end_function; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -381,7 +201,7 @@ unsafe extern "C" fn alone_encoder_init( ); let filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { - id: LZMA_FILTER_LZMA1 as lzma_vli, + id: LZMA_FILTER_LZMA1, init: Some( lzma_lzma_encoder_init as unsafe extern "C" fn( @@ -409,7 +229,7 @@ pub unsafe extern "C" fn lzma_alone_encoder( strm: *mut lzma_stream, options: *const lzma_options_lzma, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -417,7 +237,7 @@ pub unsafe extern "C" fn lzma_alone_encoder( &raw mut (*(*strm).internal).next, (*strm).allocator, options, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 0d283c8a..65fd4fcb 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -1,9 +1,7 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_stream_decoder_init( @@ -19,126 +17,6 @@ extern "C" { picky: bool, ) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} pub type C2RustUnnamed_0 = c_uint; pub const SEQ_FINISH: C2RustUnnamed_0 = 2; pub const SEQ_CODE: C2RustUnnamed_0 = 1; @@ -151,21 +29,6 @@ pub struct lzma_auto_coder { pub flags: u32, pub sequence: C2RustUnnamed_0, } -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; -pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; -pub const LZMA_IGNORE_CHECK: c_uint = 0x10; -pub const LZMA_CONCATENATED: c_uint = 0x8; -pub const LZMA_FAIL_FAST: c_uint = 0x20; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; -pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK - | LZMA_TELL_UNSUPPORTED_CHECK - | LZMA_TELL_ANY_CHECK - | LZMA_IGNORE_CHECK - | LZMA_CONCATENATED - | LZMA_FAIL_FAST; unsafe extern "C" fn auto_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -191,7 +54,7 @@ unsafe extern "C" fn auto_decode( allocator, (*coder).memlimit, (*coder).flags, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -200,8 +63,8 @@ unsafe extern "C" fn auto_decode( &raw mut (*coder).next, allocator, (*coder).memlimit, - 1 as c_int != 0, - ) as lzma_ret; + true, + ); if ret__0 != LZMA_OK { return ret__0; } @@ -234,7 +97,7 @@ unsafe extern "C" fn auto_decode( out_pos, out_size, action, - ) as lzma_ret; + ); if ret != LZMA_STREAM_END || (*coder).flags & LZMA_CONCATENATED as u32 == 0 { return ret; } @@ -245,11 +108,11 @@ unsafe extern "C" fn auto_decode( if *in_pos < in_size { return LZMA_DATA_ERROR; } - return (if action == LZMA_FINISH { - LZMA_STREAM_END as c_int + return if action == LZMA_FINISH { + LZMA_STREAM_END } else { - LZMA_OK as c_int - }) as lzma_ret; + LZMA_OK + }; } unsafe extern "C" fn auto_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; @@ -282,7 +145,7 @@ unsafe extern "C" fn auto_decoder_memconfig( new_memlimit, ); } else { - *memusage = LZMA_MEMUSAGE_BASE as u64; + *memusage = LZMA_MEMUSAGE_BASE; *old_memlimit = (*coder).memlimit; ret = LZMA_OK; if new_memlimit != 0 && new_memlimit < *memusage { @@ -336,8 +199,8 @@ unsafe extern "C" fn auto_decoder_init( } let mut coder: *mut lzma_auto_coder = (*next).coder as *mut lzma_auto_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::() as size_t, allocator) - as *mut lzma_auto_coder; + coder = + lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_auto_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -369,7 +232,7 @@ unsafe extern "C" fn auto_decoder_init( as Option lzma_ret>; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -391,7 +254,7 @@ pub unsafe extern "C" fn lzma_auto_decoder( memlimit: u64, flags: u32, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -400,7 +263,7 @@ pub unsafe extern "C" fn lzma_auto_decoder( (*strm).allocator, memlimit, flags, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index 8e13e2ae..75c481f1 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_block_decoder_init( @@ -8,122 +7,6 @@ extern "C" { block: *mut lzma_block, ) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_decode( block: *mut lzma_block, @@ -146,7 +29,7 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( } let mut block_decoder: lzma_next_coder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 8583b8a0..8c012ba2 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -1,7 +1,6 @@ use crate::types::*; use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; fn lzma_check_size(check: lzma_check) -> u32; fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; @@ -21,190 +20,7 @@ extern "C" { ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed { - pub u8_0: [u8; 64], - pub u32_0: [u32; 16], - pub u64_0: [u64; 8], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_check_state { - pub buffer: C2RustUnnamed, - pub state: C2RustUnnamed_0, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_0 { - pub crc32: u32, - pub crc64: u64, - pub sha256: lzma_sha256_state, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_sha256_state { - pub state: [u32; 8], - pub size: u64, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_VLI_BYTES_MAX: c_int = 9; -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_CHECK_SIZE_MAX: c_int = 64; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) @@ -286,9 +102,9 @@ unsafe extern "C" fn block_encode_uncompressed( id: 0, options: core::ptr::null_mut(), }; 2]; - filters[0].id = LZMA_FILTER_LZMA2 as lzma_vli; + filters[0].id = LZMA_FILTER_LZMA2; filters[0].options = &raw mut lzma2 as *mut c_void; - filters[1].id = LZMA_VLI_UNKNOWN as lzma_vli; + filters[1].id = LZMA_VLI_UNKNOWN; let filters_orig: *mut lzma_filter = (*block).filters; (*block).filters = &raw mut filters as *mut lzma_filter; if lzma_block_header_size(block) != LZMA_OK { @@ -347,7 +163,7 @@ unsafe extern "C" fn block_encode_normal( out_pos: *mut size_t, mut out_size: size_t, ) -> lzma_ret { - let ret_: lzma_ret = lzma_block_header_size(block) as lzma_ret; + let ret_: lzma_ret = lzma_block_header_size(block); if ret_ != LZMA_OK { return ret_; } @@ -361,7 +177,7 @@ unsafe extern "C" fn block_encode_normal( } let mut raw_encoder: lzma_next_coder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -425,9 +241,7 @@ unsafe extern "C" fn block_buffer_encode( if (*block).version > 1 { return LZMA_OPTIONS_ERROR; } - if (*block).check > LZMA_CHECK_ID_MAX - || try_to_compress as c_int != 0 && (*block).filters.is_null() - { + if (*block).check > LZMA_CHECK_ID_MAX || try_to_compress && (*block).filters.is_null() { return LZMA_PROG_ERROR; } if lzma_check_is_supported((*block).check) == 0 { @@ -453,7 +267,7 @@ unsafe extern "C" fn block_buffer_encode( return ret; } let ret_: lzma_ret = - block_encode_uncompressed(block, in_0, in_size, out, out_pos, out_size) as lzma_ret; + block_encode_uncompressed(block, in_0, in_size, out, out_pos, out_size); if ret_ != LZMA_OK { return ret_; } @@ -467,8 +281,8 @@ unsafe extern "C" fn block_buffer_encode( } if check_size > 0 { let mut check: lzma_check_state = lzma_check_state { - buffer: C2RustUnnamed { u8_0: [0; 64] }, - state: C2RustUnnamed_0 { crc32: 0 }, + buffer: lzma_check_state_buffer { u8_0: [0; 64] }, + state: lzma_check_state_inner { crc32: 0 }, }; lzma_check_init(&raw mut check, (*block).check); lzma_check_update(&raw mut check, (*block).check, in_0, in_size); diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 25d76902..1e176971 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -1,13 +1,10 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { - fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; fn lzma_end(strm: *mut lzma_stream); fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; fn lzma_check_size(check: lzma_check) -> u32; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( @@ -32,160 +29,6 @@ extern "C" { ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block_coder { @@ -200,42 +43,13 @@ pub struct lzma_block_coder { pub check: lzma_check_state, pub ignore_check: bool, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_check_state { - pub buffer: C2RustUnnamed_1, - pub state: C2RustUnnamed_0, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_0 { - pub crc32: u32, - pub crc64: u64, - pub sha256: lzma_sha256_state, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_sha256_state { - pub state: [u32; 8], - pub size: u64, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_1 { - pub u8_0: [u8; 64], - pub u32_0: [u32; 16], - pub u64_0: [u64; 8], -} pub type C2RustUnnamed_2 = c_uint; pub const SEQ_CHECK: C2RustUnnamed_2 = 2; pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[inline] extern "C" fn is_size_valid(size: lzma_vli, reference: lzma_vli) -> bool { - return reference == LZMA_VLI_UNKNOWN as lzma_vli || reference == size; + return reference == LZMA_VLI_UNKNOWN || reference == size; } unsafe extern "C" fn block_decode( coder_ptr: *mut c_void, @@ -291,7 +105,7 @@ unsafe extern "C" fn block_decode( out_pos, out_stop, action, - ) as lzma_ret; + ); let in_used: size_t = (*in_pos).wrapping_sub(in_start); let out_used: size_t = (*out_pos).wrapping_sub(out_start); (*coder).compressed_size = @@ -304,13 +118,13 @@ unsafe extern "C" fn block_decode( (*coder).compressed_size == (*(*coder).block).compressed_size; let uncomp_done: bool = (*coder).uncompressed_size == (*(*coder).block).uncompressed_size; - if comp_done as c_int != 0 && uncomp_done as c_int != 0 { + if comp_done && uncomp_done { return LZMA_DATA_ERROR; } - if comp_done as c_int != 0 && *out_pos < out_size { + if comp_done && *out_pos < out_size { return LZMA_DATA_ERROR; } - if uncomp_done as c_int != 0 && *in_pos < in_size { + if uncomp_done && *in_pos < in_size { return LZMA_DATA_ERROR; } } @@ -357,7 +171,7 @@ unsafe extern "C" fn block_decode( (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) as c_int != 0 as c_int { + if *in_0.offset(fresh0 as isize) != 0 { return LZMA_DATA_ERROR; } } @@ -384,12 +198,12 @@ unsafe extern "C" fn block_decode( return LZMA_OK; } if !(*coder).ignore_check - && lzma_check_is_supported((*(*coder).block).check) as c_int != 0 + && lzma_check_is_supported((*(*coder).block).check) != 0 && memcmp( &raw mut (*(*coder).block).raw_check as *mut u8 as *const c_void, &raw mut (*coder).check.buffer.u8_0 as *mut u8 as *const c_void, check_size, - ) != 0 as c_int + ) != 0 { return LZMA_DATA_ERROR; } @@ -446,17 +260,15 @@ pub unsafe extern "C" fn lzma_block_decoder_init( ) -> lzma_ret, )); if lzma_block_unpadded_size(block) == 0 as lzma_vli - || !((*block).uncompressed_size <= LZMA_VLI_MAX as lzma_vli - || (*block).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli) + || !((*block).uncompressed_size <= LZMA_VLI_MAX + || (*block).uncompressed_size == LZMA_VLI_UNKNOWN) { return LZMA_PROG_ERROR; } let mut coder: *mut lzma_block_coder = (*next).coder as *mut lzma_block_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_block_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_block_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -480,7 +292,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( ) as lzma_end_function; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -495,22 +307,22 @@ pub unsafe extern "C" fn lzma_block_decoder_init( (*coder).block = block; (*coder).compressed_size = 0 as lzma_vli; (*coder).uncompressed_size = 0 as lzma_vli; - (*coder).compressed_limit = if (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli { - (LZMA_VLI_MAX as lzma_vli & !(3 as lzma_vli)) + (*coder).compressed_limit = if (*block).compressed_size == LZMA_VLI_UNKNOWN { + (LZMA_VLI_MAX & !(3 as lzma_vli)) .wrapping_sub((*block).header_size as lzma_vli) .wrapping_sub(lzma_check_size((*block).check) as lzma_vli) } else { (*block).compressed_size }; - (*coder).uncompressed_limit = if (*block).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli { - LZMA_VLI_MAX as lzma_vli + (*coder).uncompressed_limit = if (*block).uncompressed_size == LZMA_VLI_UNKNOWN { + LZMA_VLI_MAX } else { (*block).uncompressed_size }; (*coder).check_pos = 0; lzma_check_init(&raw mut (*coder).check, (*block).check); (*coder).ignore_check = if (*block).version >= 1 { - (*block).ignore_check as c_int != 0 + (*block).ignore_check != 0 } else { false }; @@ -521,13 +333,12 @@ pub unsafe extern "C" fn lzma_block_decoder( strm: *mut lzma_stream, block: *mut lzma_block, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = - lzma_block_decoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block) - as lzma_ret; + lzma_block_decoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 643984d7..306513dd 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -1,12 +1,9 @@ use crate::types::*; use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_end(strm: *mut lzma_stream); fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; fn lzma_check_size(check: lzma_check) -> u32; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_update( next: *mut lzma_next_coder, @@ -36,160 +33,6 @@ extern "C" { ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block_coder { @@ -201,42 +44,11 @@ pub struct lzma_block_coder { pub pos: size_t, pub check: lzma_check_state, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_check_state { - pub buffer: C2RustUnnamed_1, - pub state: C2RustUnnamed_0, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_0 { - pub crc32: u32, - pub crc64: u64, - pub sha256: lzma_sha256_state, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_sha256_state { - pub state: [u32; 8], - pub size: u64, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_1 { - pub u8_0: [u8; 64], - pub u32_0: [u32; 16], - pub u64_0: [u64; 8], -} pub type C2RustUnnamed_2 = c_uint; pub const SEQ_CHECK: C2RustUnnamed_2 = 2; pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_CHECK_SIZE_MAX: c_int = 64; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) @@ -253,7 +65,7 @@ unsafe extern "C" fn block_encode( action: lzma_action, ) -> lzma_ret { let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; - if (LZMA_VLI_MAX as lzma_vli).wrapping_sub((*coder).uncompressed_size) + if (LZMA_VLI_MAX).wrapping_sub((*coder).uncompressed_size) < in_size.wrapping_sub(*in_pos) as lzma_vli { return LZMA_DATA_ERROR; @@ -274,7 +86,7 @@ unsafe extern "C" fn block_encode( out_pos, out_size, action, - ) as lzma_ret; + ); let in_used: size_t = (*in_pos).wrapping_sub(in_start); let out_used: size_t = (*out_pos).wrapping_sub(out_start); if (COMPRESSED_SIZE_MAX as lzma_vli).wrapping_sub((*coder).compressed_size) @@ -425,10 +237,8 @@ pub unsafe extern "C" fn lzma_block_encoder_init( } let mut coder: *mut lzma_block_coder = (*next).coder as *mut lzma_block_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_block_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_block_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -469,7 +279,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( >; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -493,13 +303,12 @@ pub unsafe extern "C" fn lzma_block_encoder( strm: *mut lzma_stream, block: *mut lzma_block, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = - lzma_block_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block) - as lzma_ret; + lzma_block_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 873beba3..bf86229f 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::c_int; extern "C" { fn lzma_vli_decode( vli: *mut lzma_vli, @@ -19,80 +19,6 @@ extern "C" { ) -> lzma_ret; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { @@ -103,9 +29,6 @@ extern "C" fn read32le(buf: *const u8) -> u32 { num }; } -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_FILTERS_MAX: c_int = 4; #[no_mangle] pub unsafe extern "C" fn lzma_block_header_decode( block: *mut lzma_block, @@ -117,7 +40,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( } let mut i: size_t = 0; while i <= LZMA_FILTERS_MAX as size_t { - (*(*block).filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN as lzma_vli; + (*(*block).filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN; let ref mut fresh0 = (*(*block).filters.offset(i as isize)).options; *fresh0 = core::ptr::null_mut(); i = i.wrapping_add(1); @@ -135,18 +58,18 @@ pub unsafe extern "C" fn lzma_block_header_decode( if lzma_crc32(in_0, in_size, 0) != read32le(in_0.offset(in_size as isize)) { return LZMA_DATA_ERROR; } - if *in_0.offset(1) as c_int & 0x3c as c_int != 0 { + if *in_0.offset(1) as c_int & 0x3c != 0 { return LZMA_OPTIONS_ERROR; } let mut in_pos: size_t = 2; - if *in_0.offset(1) as c_int & 0x40 as c_int != 0 { + if *in_0.offset(1) as c_int & 0x40 != 0 { let ret_: lzma_ret = lzma_vli_decode( &raw mut (*block).compressed_size, core::ptr::null_mut(), in_0, &raw mut in_pos, in_size, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -154,21 +77,21 @@ pub unsafe extern "C" fn lzma_block_header_decode( return LZMA_DATA_ERROR; } } else { - (*block).compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; + (*block).compressed_size = LZMA_VLI_UNKNOWN; } - if *in_0.offset(1) as c_int & 0x80 as c_int != 0 { + if *in_0.offset(1) as c_int & 0x80 != 0 { let ret__0: lzma_ret = lzma_vli_decode( &raw mut (*block).uncompressed_size, core::ptr::null_mut(), in_0, &raw mut in_pos, in_size, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { return ret__0; } } else { - (*block).uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; + (*block).uncompressed_size = LZMA_VLI_UNKNOWN; } let filter_count: size_t = (u32::from(*in_0.offset(1)) & 3).wrapping_add(1) as size_t; let mut i_0: size_t = 0; @@ -179,7 +102,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( in_0, &raw mut in_pos, in_size, - ) as lzma_ret; + ); if ret != LZMA_OK { lzma_filters_free((*block).filters, allocator); return ret; @@ -189,7 +112,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( while in_pos < in_size { let fresh1 = in_pos; in_pos = in_pos.wrapping_add(1); - if *in_0.offset(fresh1 as isize) as c_int != 0 as c_int { + if *in_0.offset(fresh1 as isize) != 0 { lzma_filters_free((*block).filters, allocator); return LZMA_OPTIONS_ERROR; } diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index a0531244..46e544d5 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,7 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { - fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; fn lzma_vli_encode( vli: lzma_vli, vli_pos: *mut size_t, @@ -20,73 +19,6 @@ extern "C" { ) -> lzma_ret; fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { @@ -96,42 +28,37 @@ extern "C" fn write32le(buf: *mut u8, num: u32) { *buf.offset(3) = (num >> 24) as u8; } } -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: c_int = 4; #[no_mangle] pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { if (*block).version > 1 { return LZMA_OPTIONS_ERROR; } let mut size: u32 = (1 as c_int + 1 as c_int + 4 as c_int) as u32; - if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + if (*block).compressed_size != LZMA_VLI_UNKNOWN { let add: u32 = lzma_vli_size((*block).compressed_size) as u32; if add == 0 || (*block).compressed_size == 0 as lzma_vli { return LZMA_PROG_ERROR; } size = size.wrapping_add(add); } - if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + if (*block).uncompressed_size != LZMA_VLI_UNKNOWN { let add_0: u32 = lzma_vli_size((*block).uncompressed_size) as u32; if add_0 == 0 { return LZMA_PROG_ERROR; } size = size.wrapping_add(add_0); } - if (*block).filters.is_null() - || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli - { + if (*block).filters.is_null() || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; } let mut i: size_t = 0; - while (*(*block).filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + while (*(*block).filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN { if i == LZMA_FILTERS_MAX as size_t { return LZMA_PROG_ERROR; } let mut add_1: u32 = 0; let ret_: lzma_ret = - lzma_filter_flags_size(&raw mut add_1, (*block).filters.offset(i as isize)) as lzma_ret; + lzma_filter_flags_size(&raw mut add_1, (*block).filters.offset(i as isize)); if ret_ != LZMA_OK { return ret_; } @@ -147,8 +74,8 @@ pub unsafe extern "C" fn lzma_block_header_encode( out: *mut u8, ) -> lzma_ret { if lzma_block_unpadded_size(block) == 0 as lzma_vli - || !((*block).uncompressed_size <= LZMA_VLI_MAX as lzma_vli - || (*block).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli) + || !((*block).uncompressed_size <= LZMA_VLI_MAX + || (*block).uncompressed_size == LZMA_VLI_UNKNOWN) { return LZMA_PROG_ERROR; } @@ -156,37 +83,35 @@ pub unsafe extern "C" fn lzma_block_header_encode( *out.offset(0) = out_size.wrapping_div(4) as u8; *out.offset(1) = 0; let mut out_pos: size_t = 2; - if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + if (*block).compressed_size != LZMA_VLI_UNKNOWN { let ret_: lzma_ret = lzma_vli_encode( (*block).compressed_size, core::ptr::null_mut(), out, &raw mut out_pos, out_size, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } let ref mut fresh0 = *out.offset(1); *fresh0 = (*fresh0 as c_int | 0x40 as c_int) as u8; } - if (*block).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + if (*block).uncompressed_size != LZMA_VLI_UNKNOWN { let ret__0: lzma_ret = lzma_vli_encode( (*block).uncompressed_size, core::ptr::null_mut(), out, &raw mut out_pos, out_size, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { return ret__0; } let ref mut fresh1 = *out.offset(1); *fresh1 = (*fresh1 as c_int | 0x80 as c_int) as u8; } - if (*block).filters.is_null() - || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli - { + if (*block).filters.is_null() || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; } let mut filter_count: size_t = 0; @@ -199,12 +124,12 @@ pub unsafe extern "C" fn lzma_block_header_encode( out, &raw mut out_pos, out_size, - ) as lzma_ret; + ); if ret__1 != LZMA_OK { return ret__1; } filter_count = filter_count.wrapping_add(1); - if !((*(*block).filters.offset(filter_count as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { + if !((*(*block).filters.offset(filter_count as isize)).id != LZMA_VLI_UNKNOWN) { break; } } diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index bb0990c2..93d844f8 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -1,80 +1,9 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulonglong}; extern "C" { fn lzma_check_size(check: lzma_check) -> u32; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; pub const LZMA_BLOCK_HEADER_SIZE_MIN: c_int = 8; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { @@ -95,9 +24,7 @@ pub unsafe extern "C" fn lzma_block_compressed_size( return LZMA_DATA_ERROR; } let compressed_size: lzma_vli = unpadded_size.wrapping_sub(container_size as lzma_vli); - if (*block).compressed_size != LZMA_VLI_UNKNOWN as lzma_vli - && (*block).compressed_size != compressed_size - { + if (*block).compressed_size != LZMA_VLI_UNKNOWN && (*block).compressed_size != compressed_size { return LZMA_DATA_ERROR; } (*block).compressed_size = compressed_size; @@ -110,15 +37,15 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> l || (*block).header_size < LZMA_BLOCK_HEADER_SIZE_MIN as u32 || (*block).header_size > LZMA_BLOCK_HEADER_SIZE_MAX as u32 || (*block).header_size & 3 != 0 - || !((*block).compressed_size <= LZMA_VLI_MAX as lzma_vli - || (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli) + || !((*block).compressed_size <= LZMA_VLI_MAX + || (*block).compressed_size == LZMA_VLI_UNKNOWN) || (*block).compressed_size == 0 as lzma_vli || (*block).check > LZMA_CHECK_ID_MAX { return 0 as lzma_vli; } - if (*block).compressed_size == LZMA_VLI_UNKNOWN as lzma_vli { - return LZMA_VLI_UNKNOWN as lzma_vli; + if (*block).compressed_size == LZMA_VLI_UNKNOWN { + return LZMA_VLI_UNKNOWN; } let unpadded_size: lzma_vli = (*block) .compressed_size @@ -132,7 +59,7 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> l #[no_mangle] pub unsafe extern "C" fn lzma_block_total_size(block: *const lzma_block) -> lzma_vli { let mut unpadded_size: lzma_vli = lzma_block_unpadded_size(block); - if unpadded_size != LZMA_VLI_UNKNOWN as lzma_vli { + if unpadded_size != LZMA_VLI_UNKNOWN { unpadded_size = vli_ceil4(unpadded_size); } return unpadded_size; diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index 08a3586f..07ae98eb 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -1,148 +1,10 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_char, c_int, c_uint, c_void}; extern "C" { fn malloc(__size: size_t) -> *mut c_void; fn calloc(__count: size_t, __size: size_t) -> *mut c_void; fn free(_: *mut c_void); - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_VERSION_MAJOR: c_int = 5; pub const LZMA_VERSION_MINOR: c_int = 8; pub const LZMA_VERSION_PATCH: c_int = 2; @@ -153,7 +15,6 @@ pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR as u32) .wrapping_add((LZMA_VERSION_MINOR as u32).wrapping_mul(10000)) .wrapping_add((LZMA_VERSION_PATCH as u32).wrapping_mul(10)) .wrapping_add(LZMA_VERSION_STABILITY as u32); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_TIMED_OUT: c_uint = 101; #[no_mangle] pub extern "C" fn lzma_version_number() -> u32 { @@ -247,13 +108,13 @@ pub unsafe extern "C" fn lzma_next_filter_init( (*next).init = ::core::mem::transmute::((*filters.offset(0)).init); (*next).id = (*filters.offset(0)).id; - return (if (*filters.offset(0)).init.is_none() { + return if (*filters.offset(0)).init.is_none() { LZMA_OK } else { (*filters.offset(0)) .init .expect("non-null function pointer")(next, allocator, filters) - }) as lzma_ret; + }; } #[no_mangle] pub unsafe extern "C" fn lzma_next_filter_update( @@ -264,7 +125,7 @@ pub unsafe extern "C" fn lzma_next_filter_update( if (*reversed_filters.offset(0)).id != (*next).id { return LZMA_PROG_ERROR; } - if (*reversed_filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { + if (*reversed_filters.offset(0)).id == LZMA_VLI_UNKNOWN { return LZMA_OK; } return (*next).update.expect("non-null function pointer")( @@ -287,7 +148,7 @@ pub unsafe extern "C" fn lzma_next_end( } *next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -305,16 +166,14 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { return LZMA_PROG_ERROR; } if (*strm).internal.is_null() { - (*strm).internal = lzma_alloc( - core::mem::size_of::() as size_t, - (*strm).allocator, - ) as *mut lzma_internal; + (*strm).internal = lzma_alloc(core::mem::size_of::(), (*strm).allocator) + as *mut lzma_internal; if (*strm).internal.is_null() { return LZMA_MEM_ERROR; } (*(*strm).internal).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -328,7 +187,7 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { memset( &raw mut (*(*strm).internal).supported_actions as *mut bool as *mut c_void, 0 as c_int, - core::mem::size_of::<[bool; 5]>() as size_t, + core::mem::size_of::<[bool; 5]>(), ); (*(*strm).internal).sequence = ISEQ_RUN; (*(*strm).internal).allow_buf_error = false; @@ -507,56 +366,62 @@ pub unsafe extern "C" fn lzma_get_progress( }; } #[no_mangle] -pub unsafe extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { - if (*(*strm).internal).next.get_check.is_none() { - return LZMA_CHECK_NONE; - } - return (*(*strm).internal) - .next - .get_check - .expect("non-null function pointer")((*(*strm).internal).next.coder); +pub extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { + return unsafe { + if (*(*strm).internal).next.get_check.is_none() { + return LZMA_CHECK_NONE; + } + (*(*strm).internal) + .next + .get_check + .expect("non-null function pointer")((*(*strm).internal).next.coder) + }; } #[no_mangle] -pub unsafe extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { - let mut memusage: u64 = 0; - let mut old_memlimit: u64 = 0; - if strm.is_null() - || (*strm).internal.is_null() - || (*(*strm).internal).next.memconfig.is_none() - || (*(*strm).internal) - .next - .memconfig - .expect("non-null function pointer")( - (*(*strm).internal).next.coder, - &raw mut memusage, - &raw mut old_memlimit, - 0, - ) != LZMA_OK - { - return 0; - } - return memusage; +pub extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { + return unsafe { + let mut memusage: u64 = 0; + let mut old_memlimit: u64 = 0; + if strm.is_null() + || (*strm).internal.is_null() + || (*(*strm).internal).next.memconfig.is_none() + || (*(*strm).internal) + .next + .memconfig + .expect("non-null function pointer")( + (*(*strm).internal).next.coder, + &raw mut memusage, + &raw mut old_memlimit, + 0, + ) != LZMA_OK + { + return 0; + } + memusage + }; } #[no_mangle] -pub unsafe extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { - let mut old_memlimit: u64 = 0; - let mut memusage: u64 = 0; - if strm.is_null() - || (*strm).internal.is_null() - || (*(*strm).internal).next.memconfig.is_none() - || (*(*strm).internal) - .next - .memconfig - .expect("non-null function pointer")( - (*(*strm).internal).next.coder, - &raw mut memusage, - &raw mut old_memlimit, - 0, - ) != LZMA_OK - { - return 0; - } - return old_memlimit; +pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { + return unsafe { + let mut old_memlimit: u64 = 0; + let mut memusage: u64 = 0; + if strm.is_null() + || (*strm).internal.is_null() + || (*(*strm).internal).next.memconfig.is_none() + || (*(*strm).internal) + .next + .memconfig + .expect("non-null function pointer")( + (*(*strm).internal).next.coder, + &raw mut memusage, + &raw mut old_memlimit, + 0, + ) != LZMA_OK + { + return 0; + } + old_memlimit + }; } #[no_mangle] pub unsafe extern "C" fn lzma_memlimit_set( diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 59c155e0..cb8c98c5 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { fn lzma_stream_buffer_encode( filters: *mut lzma_filter, @@ -13,86 +12,6 @@ extern "C" { ) -> lzma_ret; fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_easy { - pub filters: [lzma_filter; 5], - pub opt_lzma: lzma_options_lzma, -} #[no_mangle] pub unsafe extern "C" fn lzma_easy_buffer_encode( preset: u32, diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index 9b60a387..aed419fe 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -1,58 +1,8 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_easy { - pub filters: [lzma_filter; 5], - pub opt_lzma: lzma_options_lzma, -} -pub const UINT32_MAX: c_uint = 4294967295; #[no_mangle] pub extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index 019a2e27..f75d6746 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_stream_encoder( strm: *mut lzma_stream, @@ -8,167 +7,6 @@ extern "C" { ) -> lzma_ret; fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_easy { - pub filters: [lzma_filter; 5], - pub opt_lzma: lzma_options_lzma, -} #[no_mangle] pub unsafe extern "C" fn lzma_easy_encoder( strm: *mut lzma_stream, diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index 377e2261..1c4705e0 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -1,58 +1,8 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64; fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_easy { - pub filters: [lzma_filter; 5], - pub opt_lzma: lzma_options_lzma, -} -pub const UINT32_MAX: c_uint = 4294967295; #[no_mangle] pub extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index 4b94c994..be14be3c 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -1,66 +1,15 @@ use crate::types::*; -use core::ffi::{c_ulonglong, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_easy { - pub filters: [lzma_filter; 5], - pub opt_lzma: lzma_options_lzma, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; #[no_mangle] pub unsafe extern "C" fn lzma_easy_preset(opt_easy: *mut lzma_options_easy, preset: u32) -> bool { if lzma_lzma_preset(&raw mut (*opt_easy).opt_lzma, preset) != 0 { return true; } - (*opt_easy).filters[0].id = LZMA_FILTER_LZMA2 as lzma_vli; + (*opt_easy).filters[0].id = LZMA_FILTER_LZMA2; (*opt_easy).filters[0].options = &raw mut (*opt_easy).opt_lzma as *mut c_void; - (*opt_easy).filters[1].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*opt_easy).filters[1].id = LZMA_VLI_UNKNOWN; return false; } diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 8ba0c0f6..383ca4f6 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -26,8 +26,6 @@ extern "C" { src: *mut lzma_index, allocator: *const lzma_allocator, ) -> lzma_ret; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( @@ -45,147 +43,6 @@ extern "C" { memlimit: u64, ) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] @@ -218,10 +75,6 @@ pub const SEQ_FOOTER: C2RustUnnamed_0 = 3; pub const SEQ_PADDING_DECODE: C2RustUnnamed_0 = 2; pub const SEQ_PADDING_SEEK: C2RustUnnamed_0 = 1; pub const SEQ_MAGIC_BYTES: C2RustUnnamed_0 = 0; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; unsafe extern "C" fn fill_temp( coder: *mut lzma_file_info_coder, in_0: *const u8, @@ -335,7 +188,7 @@ unsafe extern "C" fn decode_index( core::ptr::null_mut(), 0, LZMA_RUN, - ) as lzma_ret; + ); (*coder).index_remaining = (*coder) .index_remaining .wrapping_sub((*in_pos).wrapping_sub(in_start) as lzma_vli); @@ -378,7 +231,7 @@ unsafe extern "C" fn file_info_decode( let ret_: lzma_ret = lzma_stream_header_decode( &raw mut (*coder).first_header_flags, &raw mut (*coder).temp as *mut u8, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -414,7 +267,7 @@ unsafe extern "C" fn file_info_decode( match current_block_142 { 10445208204442080639 => { (*coder).sequence = SEQ_PADDING_DECODE; - let ret__0: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; + let ret__0: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); if ret__0 != LZMA_OK { return ret__0; } @@ -446,8 +299,7 @@ unsafe extern "C" fn file_info_decode( (*coder).temp_size = (*coder).temp_size.wrapping_sub(new_padding); (*coder).temp_pos = (*coder).temp_size; if (*coder).temp_size < LZMA_STREAM_HEADER_SIZE as size_t { - let ret__1: lzma_ret = - reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; + let ret__1: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); if ret__1 != LZMA_OK { return ret__1; } @@ -471,7 +323,7 @@ unsafe extern "C" fn file_info_decode( let ret__2: lzma_ret = hide_format_error(lzma_stream_footer_decode( &raw mut (*coder).footer_flags, (&raw mut (*coder).temp as *mut u8).offset((*coder).temp_size as isize), - )) as lzma_ret; + )); if ret__2 != LZMA_OK { return ret__2; } @@ -516,7 +368,7 @@ unsafe extern "C" fn file_info_decode( allocator, &raw mut (*coder).this_index, (*coder).memlimit.wrapping_sub(memused), - ) as lzma_ret; + ); if ret__3 != LZMA_OK { return ret__3; } @@ -586,8 +438,7 @@ unsafe extern "C" fn file_info_decode( as size_t; (*coder).temp_size = (*coder).temp_pos; } else { - let ret__4: lzma_ret = - reverse_seek(coder, in_start, in_pos, in_size) as lzma_ret; + let ret__4: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); if ret__4 != LZMA_OK { return ret__4; } @@ -612,7 +463,7 @@ unsafe extern "C" fn file_info_decode( let ret__5: lzma_ret = hide_format_error(lzma_stream_header_decode( &raw mut (*coder).header_flags, (&raw mut (*coder).temp as *mut u8).offset((*coder).temp_size as isize), - )) as lzma_ret; + )); if ret__5 != LZMA_OK { return ret__5; } @@ -626,7 +477,7 @@ unsafe extern "C" fn file_info_decode( let ret__6: lzma_ret = lzma_stream_flags_compare( &raw mut (*coder).header_flags, &raw mut (*coder).footer_flags, - ) as lzma_ret; + ); if ret__6 != LZMA_OK { return ret__6; } @@ -643,8 +494,7 @@ unsafe extern "C" fn file_info_decode( (*coder).stream_padding = 0 as lzma_vli; if !(*coder).combined_index.is_null() { let ret__7: lzma_ret = - lzma_index_cat((*coder).this_index, (*coder).combined_index, allocator) - as lzma_ret; + lzma_index_cat((*coder).this_index, (*coder).combined_index, allocator); if ret__7 != LZMA_OK { return ret__7; } @@ -798,10 +648,8 @@ unsafe extern "C" fn lzma_file_info_decoder_init( } let mut coder: *mut lzma_file_info_coder = (*next).coder as *mut lzma_file_info_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_file_info_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_file_info_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -830,7 +678,7 @@ unsafe extern "C" fn lzma_file_info_decoder_init( as Option lzma_ret>; (*coder).index_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -866,7 +714,7 @@ pub unsafe extern "C" fn lzma_file_info_decoder( memlimit: u64, file_size: u64, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -877,7 +725,7 @@ pub unsafe extern "C" fn lzma_file_info_decoder( dest_index, memlimit, file_size, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index b9739b49..72c6fffc 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_raw_decoder_init( @@ -8,87 +7,6 @@ extern "C" { options: *const lzma_filter, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_decode( filters: *const lzma_filter, @@ -111,7 +29,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( } let mut next: lzma_next_coder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -121,7 +39,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( update: None, set_out_limit: None, }; - let ret_: lzma_ret = lzma_raw_decoder_init(&raw mut next, allocator, filters) as lzma_ret; + let ret_: lzma_ret = lzma_raw_decoder_init(&raw mut next, allocator, filters); if ret_ != LZMA_OK { return ret_; } diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index b94539b0..d0063176 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_raw_encoder_init( @@ -8,87 +7,6 @@ extern "C" { filters: *const lzma_filter, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_encode( filters: *const lzma_filter, @@ -104,7 +22,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( } let mut next: lzma_next_coder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -114,7 +32,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( update: None, set_out_limit: None, }; - let ret_: lzma_ret = lzma_raw_encoder_init(&raw mut next, allocator, filters) as lzma_ret; + let ret_: lzma_ret = lzma_raw_encoder_init(&raw mut next, allocator, filters); if ret_ != LZMA_OK { return ret_; } diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index ed797b02..817d9181 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -1,9 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::c_void; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -11,86 +8,6 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; #[derive(Copy, Clone)] #[repr(C)] pub struct C2RustUnnamed { @@ -100,185 +17,93 @@ pub struct C2RustUnnamed { pub last_ok: bool, pub changes_size: bool, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_delta { - pub type_0: lzma_delta_type, - pub dist: u32, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: u32, - pub reserved_int4: u32, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_bcj { - pub start_offset: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_coder { - pub id: lzma_vli, - pub init: lzma_init_function, - pub memusage: Option u64>, -} -pub type lzma_filter_find = Option *const lzma_filter_coder>; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: c_int = 4; -pub const LZMA_FILTER_X86: c_ulonglong = 0x4; -pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; -pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; -pub const LZMA_FILTER_ARM: c_ulonglong = 0x7; -pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8; -pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; -pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; -pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; -pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; static mut features: [C2RustUnnamed; 13] = [ C2RustUnnamed { - id: LZMA_FILTER_LZMA1 as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_LZMA1, + options_size: core::mem::size_of::(), non_last_ok: false, last_ok: true, changes_size: true, }, C2RustUnnamed { - id: LZMA_FILTER_LZMA1EXT as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_LZMA1EXT, + options_size: core::mem::size_of::(), non_last_ok: false, last_ok: true, changes_size: true, }, C2RustUnnamed { - id: LZMA_FILTER_LZMA2 as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_LZMA2, + options_size: core::mem::size_of::(), non_last_ok: false, last_ok: true, changes_size: true, }, C2RustUnnamed { - id: LZMA_FILTER_X86 as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_X86, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_FILTER_POWERPC as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_POWERPC, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_FILTER_IA64 as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_IA64, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_FILTER_ARM as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_ARM, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_FILTER_ARMTHUMB as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_ARMTHUMB, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_FILTER_ARM64 as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_ARM64, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_FILTER_SPARC as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_SPARC, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_FILTER_RISCV as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_RISCV, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_FILTER_DELTA as lzma_vli, - options_size: core::mem::size_of::() as size_t, + id: LZMA_FILTER_DELTA, + options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, C2RustUnnamed { - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, options_size: 0, non_last_ok: false, last_ok: false, @@ -303,7 +128,7 @@ pub unsafe extern "C" fn lzma_filters_copy( let mut i: size_t = 0; i = 0; 's_15: loop { - if !((*src.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { + if !((*src.offset(i as isize)).id != LZMA_VLI_UNKNOWN) { current_block = 7175849428784450219; break; } @@ -319,7 +144,7 @@ pub unsafe extern "C" fn lzma_filters_copy( let mut j: size_t = 0; j = 0; while (*src.offset(i as isize)).id != features[j as usize].id { - if features[j as usize].id == LZMA_VLI_UNKNOWN as lzma_vli { + if features[j as usize].id == LZMA_VLI_UNKNOWN { ret = LZMA_OPTIONS_ERROR; current_block = 6392083060350426025; break 's_15; @@ -352,13 +177,13 @@ pub unsafe extern "C" fn lzma_filters_copy( return ret; } _ => { - dest[i as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + dest[i as usize].id = LZMA_VLI_UNKNOWN; dest[i as usize].options = core::ptr::null_mut(); memcpy( real_dest as *mut c_void, &raw mut dest as *mut lzma_filter as *const c_void, i.wrapping_add(1) - .wrapping_mul(core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::()), ); return LZMA_OK; } @@ -373,14 +198,14 @@ pub unsafe extern "C" fn lzma_filters_free( return; } let mut i: size_t = 0; - while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN { if i == LZMA_FILTERS_MAX as size_t { break; } lzma_free((*filters.offset(i as isize)).options, allocator); let ref mut fresh0 = (*filters.offset(i as isize)).options; *fresh0 = core::ptr::null_mut(); - (*filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN as lzma_vli; + (*filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN; i = i.wrapping_add(1); } } @@ -389,7 +214,7 @@ pub unsafe extern "C" fn lzma_validate_chain( filters: *const lzma_filter, count: *mut size_t, ) -> lzma_ret { - if filters.is_null() || (*filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { + if filters.is_null() || (*filters.offset(0)).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; } let mut changes_size_count: size_t = 0; @@ -400,7 +225,7 @@ pub unsafe extern "C" fn lzma_validate_chain( let mut j: size_t = 0; j = 0; while (*filters.offset(i as isize)).id != features[j as usize].id { - if features[j as usize].id == LZMA_VLI_UNKNOWN as lzma_vli { + if features[j as usize].id == LZMA_VLI_UNKNOWN { return LZMA_OPTIONS_ERROR; } j = j.wrapping_add(1); @@ -413,7 +238,7 @@ pub unsafe extern "C" fn lzma_validate_chain( changes_size_count = changes_size_count.wrapping_add(features[j as usize].changes_size as size_t); i = i.wrapping_add(1); - if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { + if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN) { break; } } @@ -432,7 +257,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( is_encoder: bool, ) -> lzma_ret { let mut count: size_t = 0; - let ret_: lzma_ret = lzma_validate_chain(options, &raw mut count) as lzma_ret; + let ret_: lzma_ret = lzma_validate_chain(options, &raw mut count); if ret_ != LZMA_OK { return ret_; } @@ -471,11 +296,10 @@ pub unsafe extern "C" fn lzma_raw_coder_init( i_0 = i_0.wrapping_add(1); } } - filters[count as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + filters[count as usize].id = LZMA_VLI_UNKNOWN; filters[count as usize].init = None; let ret: lzma_ret = - lzma_next_filter_init(next, allocator, &raw mut filters as *mut lzma_filter_info) - as lzma_ret; + lzma_next_filter_init(next, allocator, &raw mut filters as *mut lzma_filter_info); if ret != LZMA_OK { lzma_next_end(next, allocator); } @@ -488,7 +312,7 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( ) -> u64 { let mut tmp: size_t = 0; if lzma_validate_chain(filters, &raw mut tmp) != LZMA_OK { - return UINT64_MAX as u64; + return UINT64_MAX; } let mut total: u64 = 0; let mut i: size_t = 0; @@ -497,7 +321,7 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( coder_find.expect("non-null function pointer")((*filters.offset(i as isize)).id) as *const lzma_filter_coder; if fc.is_null() { - return UINT64_MAX as u64; + return UINT64_MAX; } if (*fc).memusage.is_none() { total = total.wrapping_add(1024 as u64); @@ -505,15 +329,15 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( let usage: u64 = (*fc).memusage.expect("non-null function pointer")( (*filters.offset(i as isize)).options, ) as u64; - if usage == UINT64_MAX as u64 { - return UINT64_MAX as u64; + if usage == UINT64_MAX { + return UINT64_MAX; } total = total.wrapping_add(usage); } i = i.wrapping_add(1); - if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli) { + if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN) { break; } } - return total.wrapping_add(LZMA_MEMUSAGE_BASE as u64); + return total.wrapping_add(LZMA_MEMUSAGE_BASE); } diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 0a47e8c9..a824c428 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -94,126 +94,6 @@ extern "C" { props_size: size_t, ) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_decoder { @@ -229,44 +109,9 @@ pub struct lzma_filter_decoder { ) -> lzma_ret, >, } -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_coder { - pub id: lzma_vli, - pub init: lzma_init_function, - pub memusage: Option u64>, -} -pub type lzma_filter_find = Option *const lzma_filter_coder>; -pub const LZMA_FILTER_X86: c_ulonglong = 0x4; -pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; -pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; -pub const LZMA_FILTER_ARM: c_ulonglong = 0x7; -pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8; -pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; -pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; -pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; -pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; static decoders: [lzma_filter_decoder; 12] = [ lzma_filter_decoder { - id: LZMA_FILTER_LZMA1 as lzma_vli, + id: LZMA_FILTER_LZMA1, init: Some( lzma_lzma_decoder_init as unsafe extern "C" fn( @@ -287,7 +132,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_LZMA1EXT as lzma_vli, + id: LZMA_FILTER_LZMA1EXT, init: Some( lzma_lzma_decoder_init as unsafe extern "C" fn( @@ -308,7 +153,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_LZMA2 as lzma_vli, + id: LZMA_FILTER_LZMA2, init: Some( lzma_lzma2_decoder_init as unsafe extern "C" fn( @@ -329,7 +174,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_X86 as lzma_vli, + id: LZMA_FILTER_X86, init: Some( lzma_simple_x86_decoder_init as unsafe extern "C" fn( @@ -350,7 +195,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_POWERPC as lzma_vli, + id: LZMA_FILTER_POWERPC, init: Some( lzma_simple_powerpc_decoder_init as unsafe extern "C" fn( @@ -371,7 +216,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_IA64 as lzma_vli, + id: LZMA_FILTER_IA64, init: Some( lzma_simple_ia64_decoder_init as unsafe extern "C" fn( @@ -392,7 +237,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_ARM as lzma_vli, + id: LZMA_FILTER_ARM, init: Some( lzma_simple_arm_decoder_init as unsafe extern "C" fn( @@ -413,7 +258,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_ARMTHUMB as lzma_vli, + id: LZMA_FILTER_ARMTHUMB, init: Some( lzma_simple_armthumb_decoder_init as unsafe extern "C" fn( @@ -434,7 +279,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_ARM64 as lzma_vli, + id: LZMA_FILTER_ARM64, init: Some( lzma_simple_arm64_decoder_init as unsafe extern "C" fn( @@ -455,7 +300,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_SPARC as lzma_vli, + id: LZMA_FILTER_SPARC, init: Some( lzma_simple_sparc_decoder_init as unsafe extern "C" fn( @@ -476,7 +321,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_RISCV as lzma_vli, + id: LZMA_FILTER_RISCV, init: Some( lzma_simple_riscv_decoder_init as unsafe extern "C" fn( @@ -497,7 +342,7 @@ static decoders: [lzma_filter_decoder; 12] = [ ), }, lzma_filter_decoder { - id: LZMA_FILTER_DELTA as lzma_vli, + id: LZMA_FILTER_DELTA, init: Some( lzma_delta_decoder_init as unsafe extern "C" fn( @@ -557,7 +402,7 @@ pub unsafe extern "C" fn lzma_raw_decoder( strm: *mut lzma_stream, options: *const lzma_filter, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -565,7 +410,7 @@ pub unsafe extern "C" fn lzma_raw_decoder( &raw mut (*(*strm).internal).next, (*strm).allocator, options, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; @@ -594,11 +439,11 @@ pub unsafe extern "C" fn lzma_properties_decode( return LZMA_OPTIONS_ERROR; } if (*fd).props_decode.is_none() { - return (if props_size == 0 { - LZMA_OK as c_int + return if props_size == 0 { + LZMA_OK } else { - LZMA_OPTIONS_ERROR as c_int - }) as lzma_ret; + LZMA_OPTIONS_ERROR + }; } return (*fd).props_decode.expect("non-null function pointer")( &raw mut (*filter).options, diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index b81f3ac5..87b5e279 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -76,126 +76,6 @@ extern "C" { ) -> lzma_ret; fn lzma_delta_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_encoder { @@ -207,47 +87,9 @@ pub struct lzma_filter_encoder { pub props_size_fixed: u32, pub props_encode: Option lzma_ret>, } -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_coder { - pub id: lzma_vli, - pub init: lzma_init_function, - pub memusage: Option u64>, -} -pub type lzma_filter_find = Option *const lzma_filter_coder>; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_X86: c_ulonglong = 0x4; -pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; -pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; -pub const LZMA_FILTER_ARM: c_ulonglong = 0x7; -pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8; -pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; -pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; -pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; -pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; static encoders: [lzma_filter_encoder; 12] = [ lzma_filter_encoder { - id: LZMA_FILTER_LZMA1 as lzma_vli, + id: LZMA_FILTER_LZMA1, init: Some( lzma_lzma_encoder_init as unsafe extern "C" fn( @@ -265,7 +107,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_LZMA1EXT as lzma_vli, + id: LZMA_FILTER_LZMA1EXT, init: Some( lzma_lzma_encoder_init as unsafe extern "C" fn( @@ -283,7 +125,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_LZMA2 as lzma_vli, + id: LZMA_FILTER_LZMA2, init: Some( lzma_lzma2_encoder_init as unsafe extern "C" fn( @@ -301,7 +143,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_X86 as lzma_vli, + id: LZMA_FILTER_X86, init: Some( lzma_simple_x86_encoder_init as unsafe extern "C" fn( @@ -321,7 +163,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_POWERPC as lzma_vli, + id: LZMA_FILTER_POWERPC, init: Some( lzma_simple_powerpc_encoder_init as unsafe extern "C" fn( @@ -341,7 +183,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_IA64 as lzma_vli, + id: LZMA_FILTER_IA64, init: Some( lzma_simple_ia64_encoder_init as unsafe extern "C" fn( @@ -361,7 +203,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_ARM as lzma_vli, + id: LZMA_FILTER_ARM, init: Some( lzma_simple_arm_encoder_init as unsafe extern "C" fn( @@ -381,7 +223,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_ARMTHUMB as lzma_vli, + id: LZMA_FILTER_ARMTHUMB, init: Some( lzma_simple_armthumb_encoder_init as unsafe extern "C" fn( @@ -401,7 +243,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_ARM64 as lzma_vli, + id: LZMA_FILTER_ARM64, init: Some( lzma_simple_arm64_encoder_init as unsafe extern "C" fn( @@ -421,7 +263,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_SPARC as lzma_vli, + id: LZMA_FILTER_SPARC, init: Some( lzma_simple_sparc_encoder_init as unsafe extern "C" fn( @@ -441,7 +283,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_RISCV as lzma_vli, + id: LZMA_FILTER_RISCV, init: Some( lzma_simple_riscv_encoder_init as unsafe extern "C" fn( @@ -461,7 +303,7 @@ static encoders: [lzma_filter_encoder; 12] = [ ), }, lzma_filter_encoder { - id: LZMA_FILTER_DELTA as lzma_vli, + id: LZMA_FILTER_DELTA, init: Some( lzma_delta_encoder_init as unsafe extern "C" fn( @@ -507,11 +349,11 @@ pub unsafe extern "C" fn lzma_filters_update( if (*(*strm).internal).next.update.is_none() { return LZMA_PROG_ERROR; } - if lzma_raw_encoder_memusage(filters) == UINT64_MAX as u64 { + if lzma_raw_encoder_memusage(filters) == UINT64_MAX { return LZMA_OPTIONS_ERROR; } let mut count: size_t = 1; - while (*filters.offset(count as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + while (*filters.offset(count as isize)).id != LZMA_VLI_UNKNOWN { count = count.wrapping_add(1); } let mut reversed_filters: [lzma_filter; 5] = [lzma_filter { @@ -524,7 +366,7 @@ pub unsafe extern "C" fn lzma_filters_update( *filters.offset(i as isize); i = i.wrapping_add(1); } - reversed_filters[count as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + reversed_filters[count as usize].id = LZMA_VLI_UNKNOWN; return (*(*strm).internal) .next .update @@ -554,7 +396,7 @@ pub unsafe extern "C" fn lzma_raw_encoder( strm: *mut lzma_stream, filters: *const lzma_filter, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -563,8 +405,8 @@ pub unsafe extern "C" fn lzma_raw_encoder( (*strm).allocator, filters, Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), - 1 as c_int != 0, - ) as lzma_ret; + true, + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; @@ -584,15 +426,15 @@ pub unsafe extern "C" fn lzma_raw_encoder_memusage(filters: *const lzma_filter) #[no_mangle] pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { if filters.is_null() { - return UINT64_MAX as u64; + return UINT64_MAX; } let mut max: u64 = 0; let mut i: size_t = 0; - while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN { let fe: *const lzma_filter_encoder = encoder_find((*filters.offset(i as isize)).id) as *const lzma_filter_encoder; if fe.is_null() { - return UINT64_MAX as u64; + return UINT64_MAX; } if (*fe).block_size.is_some() { let size: u64 = (*fe).block_size.expect("non-null function pointer")( @@ -604,7 +446,7 @@ pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 } i = i.wrapping_add(1); } - return if max == 0 { UINT64_MAX as u64 } else { max }; + return if max == 0 { UINT64_MAX } else { max }; } #[no_mangle] pub unsafe extern "C" fn lzma_properties_size( @@ -613,11 +455,11 @@ pub unsafe extern "C" fn lzma_properties_size( ) -> lzma_ret { let fe: *const lzma_filter_encoder = encoder_find((*filter).id) as *const lzma_filter_encoder; if fe.is_null() { - return (if (*filter).id <= LZMA_VLI_MAX as lzma_vli { - LZMA_OPTIONS_ERROR as c_int + return if (*filter).id <= LZMA_VLI_MAX { + LZMA_OPTIONS_ERROR } else { - LZMA_PROG_ERROR as c_int - }) as lzma_ret; + LZMA_PROG_ERROR + }; } if (*fe).props_size_get.is_none() { *size = (*fe).props_size_fixed; diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 861b9192..47f1595f 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_vli_decode( vli: *mut lzma_vli, @@ -15,41 +14,6 @@ extern "C" { props_size: size_t, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_decode( filter: *mut lzma_filter, @@ -65,11 +29,11 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( in_0, in_pos, in_size, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } - if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { + if (*filter).id >= LZMA_FILTER_RESERVED_START { return LZMA_DATA_ERROR; } let mut props_size: lzma_vli = 0; @@ -79,7 +43,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( in_0, in_pos, in_size, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { return ret__0; } @@ -91,7 +55,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( allocator, in_0.offset(*in_pos as isize), props_size as size_t, - ) as lzma_ret; + ); *in_pos = (*in_pos as lzma_vli).wrapping_add(props_size) as size_t as size_t; return ret; } diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index 6c38a80b..ee47a8fc 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_ulonglong, c_void}; extern "C" { fn lzma_vli_encode( vli: lzma_vli, @@ -12,43 +11,15 @@ extern "C" { fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret; fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_size( size: *mut u32, filter: *const lzma_filter, ) -> lzma_ret { - if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { + if (*filter).id >= LZMA_FILTER_RESERVED_START { return LZMA_PROG_ERROR; } - let ret_: lzma_ret = lzma_properties_size(size, filter) as lzma_ret; + let ret_: lzma_ret = lzma_properties_size(size, filter); if ret_ != LZMA_OK { return ret_; } @@ -63,16 +34,16 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret { - if (*filter).id >= LZMA_FILTER_RESERVED_START as lzma_vli { + if (*filter).id >= LZMA_FILTER_RESERVED_START { return LZMA_PROG_ERROR; } let ret_: lzma_ret = - lzma_vli_encode((*filter).id, core::ptr::null_mut(), out, out_pos, out_size) as lzma_ret; + lzma_vli_encode((*filter).id, core::ptr::null_mut(), out, out_pos, out_size); if ret_ != LZMA_OK { return ret_; } let mut props_size: u32 = 0; - let ret__0: lzma_ret = lzma_properties_size(&raw mut props_size, filter) as lzma_ret; + let ret__0: lzma_ret = lzma_properties_size(&raw mut props_size, filter); if ret__0 != LZMA_OK { return ret__0; } @@ -82,15 +53,14 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( out, out_pos, out_size, - ) as lzma_ret; + ); if ret__1 != LZMA_OK { return ret__1; } if out_size.wrapping_sub(*out_pos) < props_size as size_t { return LZMA_PROG_ERROR; } - let ret__2: lzma_ret = - lzma_properties_encode(filter, out.offset(*out_pos as isize)) as lzma_ret; + let ret__2: lzma_ret = lzma_properties_encode(filter, out.offset(*out_pos as isize)); if ret__2 != LZMA_OK { return ret__2; } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index eb2033c7..b7c95f7c 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -1,68 +1,11 @@ use crate::types::*; use core::ffi::{c_int, c_uint, c_ulong, c_ulonglong, c_void}; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_vli_size(vli: lzma_vli) -> u32; fn lzma_stream_flags_compare( a: *const lzma_stream_flags, b: *const lzma_stream_flags, ) -> lzma_ret; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); -} -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, } #[derive(Copy, Clone)] #[repr(C)] @@ -199,8 +142,6 @@ pub struct index_cat_info { } pub type C2RustUnnamed_2 = c_uint; pub type C2RustUnnamed_3 = c_uint; -pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; #[inline] @@ -211,10 +152,6 @@ extern "C" fn bsr32(n: u32) -> u32 { extern "C" fn ctz32(n: u32) -> u32 { return n.trailing_zeros() as i32 as u32; } -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; -pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] @@ -335,7 +272,7 @@ unsafe extern "C" fn index_stream_init( allocator: *const lzma_allocator, ) -> *mut index_stream { let s: *mut index_stream = - lzma_alloc(core::mem::size_of::() as size_t, allocator) as *mut index_stream; + lzma_alloc(core::mem::size_of::(), allocator) as *mut index_stream; if s.is_null() { return core::ptr::null_mut(); } @@ -364,7 +301,7 @@ unsafe extern "C" fn index_stream_end(node: *mut c_void, allocator: *const lzma_ } unsafe extern "C" fn index_init_plain(allocator: *const lzma_allocator) -> *mut lzma_index { let i: *mut lzma_index = - lzma_alloc(core::mem::size_of::() as size_t, allocator) as *mut lzma_index; + lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_index; if !i.is_null() { index_tree_init(&raw mut (*i).streams); (*i).uncompressed_size = 0 as lzma_vli; @@ -413,15 +350,13 @@ pub unsafe extern "C" fn lzma_index_prealloc(i: *mut lzma_index, mut records: lz } #[no_mangle] pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64 { - let alloc_overhead: size_t = - (4 as size_t).wrapping_mul(core::mem::size_of::<*mut c_void>() as size_t); - let stream_base: size_t = (core::mem::size_of::() as size_t) - .wrapping_add(core::mem::size_of::() as size_t) + let alloc_overhead: size_t = (4 as size_t).wrapping_mul(core::mem::size_of::<*mut c_void>()); + let stream_base: size_t = (core::mem::size_of::()) + .wrapping_add(core::mem::size_of::()) .wrapping_add((2 as size_t).wrapping_mul(alloc_overhead)); - let group_base: size_t = (core::mem::size_of::() as size_t) + let group_base: size_t = (core::mem::size_of::()) .wrapping_add( - (INDEX_GROUP_SIZE as size_t) - .wrapping_mul(core::mem::size_of::() as size_t), + (INDEX_GROUP_SIZE as size_t).wrapping_mul(core::mem::size_of::()), ) .wrapping_add(alloc_overhead); let groups: lzma_vli = blocks @@ -432,46 +367,48 @@ pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u6 let groups_mem: u64 = (groups as u64).wrapping_mul(group_base as u64); let index_base: u64 = (core::mem::size_of::() as usize).wrapping_add(alloc_overhead as usize) as u64; - let limit: u64 = (UINT64_MAX as u64).wrapping_sub(index_base); + let limit: u64 = (UINT64_MAX).wrapping_sub(index_base); if streams == 0 as lzma_vli || streams > UINT32_MAX as lzma_vli - || blocks > LZMA_VLI_MAX as lzma_vli + || blocks > LZMA_VLI_MAX || streams > limit.wrapping_div(stream_base as u64) || groups > limit.wrapping_div(group_base as u64) || limit.wrapping_sub(streams_mem) < groups_mem { - return UINT64_MAX as u64; + return UINT64_MAX; } return index_base .wrapping_add(streams_mem) .wrapping_add(groups_mem); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_memused(i: *const lzma_index) -> u64 { - return lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count); +pub extern "C" fn lzma_index_memused(i: *const lzma_index) -> u64 { + return unsafe { lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count) }; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli { - return (*i).record_count; +pub extern "C" fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli { + return unsafe { (*i).record_count }; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_stream_count(i: *const lzma_index) -> lzma_vli { - return (*i).streams.count as lzma_vli; +pub extern "C" fn lzma_index_stream_count(i: *const lzma_index) -> lzma_vli { + return unsafe { (*i).streams.count as lzma_vli }; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_size(i: *const lzma_index) -> lzma_vli { - return index_size((*i).record_count, (*i).index_list_size); +pub extern "C" fn lzma_index_size(i: *const lzma_index) -> lzma_vli { + return unsafe { index_size((*i).record_count, (*i).index_list_size) }; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { - return (*i).total_size; +pub extern "C" fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { + return unsafe { (*i).total_size }; } #[no_mangle] -pub unsafe extern "C" fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { - return (LZMA_STREAM_HEADER_SIZE as lzma_vli) - .wrapping_add((*i).total_size) - .wrapping_add(index_size((*i).record_count, (*i).index_list_size)) - .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli); +pub extern "C" fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { + return unsafe { + (LZMA_STREAM_HEADER_SIZE as lzma_vli) + .wrapping_add((*i).total_size) + .wrapping_add(index_size((*i).record_count, (*i).index_list_size)) + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) + }; } unsafe extern "C" fn index_file_size( compressed_base: lzma_vli, @@ -484,12 +421,12 @@ unsafe extern "C" fn index_file_size( .wrapping_add((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) .wrapping_add(stream_padding) .wrapping_add(vli_ceil4(unpadded_sum)); - if file_size > LZMA_VLI_MAX as lzma_vli { - return LZMA_VLI_UNKNOWN as lzma_vli; + if file_size > LZMA_VLI_MAX { + return LZMA_VLI_UNKNOWN; } file_size = file_size.wrapping_add(index_size(record_count, index_list_size)); - if file_size > LZMA_VLI_MAX as lzma_vli { - return LZMA_VLI_UNKNOWN as lzma_vli; + if file_size > LZMA_VLI_MAX { + return LZMA_VLI_UNKNOWN; } return file_size; } @@ -537,7 +474,7 @@ pub unsafe extern "C" fn lzma_index_stream_flags( if i.is_null() || stream_flags.is_null() { return LZMA_PROG_ERROR; } - let ret_: lzma_ret = lzma_stream_flags_compare(stream_flags, stream_flags) as lzma_ret; + let ret_: lzma_ret = lzma_stream_flags_compare(stream_flags, stream_flags); if ret_ != LZMA_OK { return ret_; } @@ -551,7 +488,7 @@ pub unsafe extern "C" fn lzma_index_stream_padding( stream_padding: lzma_vli, ) -> lzma_ret { if i.is_null() - || stream_padding > LZMA_VLI_MAX as lzma_vli + || stream_padding > LZMA_VLI_MAX || stream_padding & 3 as lzma_vli != 0 as lzma_vli { return LZMA_PROG_ERROR; @@ -559,7 +496,7 @@ pub unsafe extern "C" fn lzma_index_stream_padding( let s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; let old_stream_padding: lzma_vli = (*s).stream_padding; (*s).stream_padding = 0 as lzma_vli; - if lzma_index_file_size(i).wrapping_add(stream_padding) > LZMA_VLI_MAX as lzma_vli { + if lzma_index_file_size(i).wrapping_add(stream_padding) > LZMA_VLI_MAX { (*s).stream_padding = old_stream_padding; return LZMA_DATA_ERROR; } @@ -576,7 +513,7 @@ pub unsafe extern "C" fn lzma_index_append( if i.is_null() || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli - || uncompressed_size > LZMA_VLI_MAX as lzma_vli + || uncompressed_size > LZMA_VLI_MAX { return LZMA_PROG_ERROR; } @@ -596,7 +533,7 @@ pub unsafe extern "C" fn lzma_index_append( }; let index_list_size_add: u32 = (lzma_vli_size(unpadded_size) as u32).wrapping_add(lzma_vli_size(uncompressed_size) as u32); - if uncompressed_base.wrapping_add(uncompressed_size) > LZMA_VLI_MAX as lzma_vli { + if uncompressed_base.wrapping_add(uncompressed_size) > LZMA_VLI_MAX { return LZMA_DATA_ERROR; } if compressed_base.wrapping_add(unpadded_size) > UNPADDED_SIZE_MAX as lzma_vli { @@ -609,7 +546,7 @@ pub unsafe extern "C" fn lzma_index_append( (*s).index_list_size .wrapping_add(index_list_size_add as lzma_vli), (*s).stream_padding, - ) == LZMA_VLI_UNKNOWN as lzma_vli + ) == LZMA_VLI_UNKNOWN { return LZMA_DATA_ERROR; } @@ -625,9 +562,9 @@ pub unsafe extern "C" fn lzma_index_append( (*g).last = (*g).last.wrapping_add(1); } else { g = lzma_alloc( - (core::mem::size_of::() as size_t).wrapping_add( + (core::mem::size_of::()).wrapping_add( (*i).prealloc - .wrapping_mul(core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::()), ), allocator, ) as *mut index_group; @@ -688,11 +625,11 @@ pub unsafe extern "C" fn lzma_index_cat( return LZMA_PROG_ERROR; } let dest_file_size: lzma_vli = lzma_index_file_size(dest) as lzma_vli; - if dest_file_size.wrapping_add(lzma_index_file_size(src)) > LZMA_VLI_MAX as lzma_vli + if dest_file_size.wrapping_add(lzma_index_file_size(src)) > LZMA_VLI_MAX || (*dest) .uncompressed_size .wrapping_add((*src).uncompressed_size) - > LZMA_VLI_MAX as lzma_vli + > LZMA_VLI_MAX { return LZMA_DATA_ERROR; } @@ -707,10 +644,10 @@ pub unsafe extern "C" fn lzma_index_cat( let g: *mut index_group = (*s).groups.rightmost as *mut index_group; if !g.is_null() && (*g).last.wrapping_add(1) < (*g).allocated { let newg: *mut index_group = lzma_alloc( - (core::mem::size_of::() as size_t).wrapping_add( + (core::mem::size_of::()).wrapping_add( (*g).last .wrapping_add(1) - .wrapping_mul(core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::()), ), allocator, ) as *mut index_group; @@ -726,7 +663,7 @@ pub unsafe extern "C" fn lzma_index_cat( &raw mut (*g).records as *mut index_record as *const c_void, (*newg) .allocated - .wrapping_mul(core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::()), ); if !(*g).node.parent.is_null() { (*(*g).node.parent).right = &raw mut (*newg).node; @@ -807,7 +744,7 @@ unsafe extern "C" fn index_dup_stream( (*srcg) .last .wrapping_add(1) - .wrapping_mul(core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::()), ); i = i.wrapping_add((*srcg).last.wrapping_add(1)); srcg = index_tree_next(&raw const (*srcg).node) as *const index_group; diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index ecd543a4..9932beda 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -23,133 +23,11 @@ extern "C" { unpadded_size: lzma_vli, uncompressed_size: lzma_vli, ) -> lzma_ret; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_index_padding_size(i: *const lzma_index) -> u32; fn lzma_index_prealloc(i: *mut lzma_index, records: lzma_vli); } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] @@ -173,8 +51,6 @@ pub const SEQ_UNPADDED: C2RustUnnamed_0 = 3; pub const SEQ_MEMUSAGE: C2RustUnnamed_0 = 2; pub const SEQ_COUNT: C2RustUnnamed_0 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; pub const INDEX_INDICATOR: c_int = 0; @@ -247,7 +123,7 @@ unsafe extern "C" fn index_decode( allocator, (*coder).unpadded_size, (*coder).uncompressed_size, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -279,7 +155,7 @@ unsafe extern "C" fn index_decode( (*coder).pos = (*coder).pos.wrapping_sub(1); let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh1 as isize) as c_int != 0 as c_int { + if *in_0.offset(fresh1 as isize) != 0 { return LZMA_DATA_ERROR; } continue; @@ -429,10 +305,8 @@ pub unsafe extern "C" fn lzma_index_decoder_init( } let mut coder: *mut lzma_index_coder = (*next).coder as *mut lzma_index_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_index_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_index_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -474,7 +348,7 @@ pub unsafe extern "C" fn lzma_index_decoder( if !i.is_null() { *i = core::ptr::null_mut(); } - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -483,7 +357,7 @@ pub unsafe extern "C" fn lzma_index_decoder( (*strm).allocator, i, memlimit, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; @@ -519,7 +393,7 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( pos: 0, crc32: 0, }; - let ret_: lzma_ret = index_decoder_reset(&raw mut coder, allocator, i, *memlimit) as lzma_ret; + let ret_: lzma_ret = index_decoder_reset(&raw mut coder, allocator, i, *memlimit); if ret_ != LZMA_OK { return ret_; } diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index b7c71933..85f1ecf2 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -18,153 +18,10 @@ extern "C" { fn lzma_index_size(i: *const lzma_index) -> lzma_vli; fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index); fn lzma_index_iter_next(iter: *mut lzma_index_iter, mode: lzma_index_iter_mode) -> lzma_bool; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_index_padding_size(i: *const lzma_index) -> u32; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] @@ -407,10 +264,7 @@ pub unsafe extern "C" fn lzma_index_encoder_init( return LZMA_PROG_ERROR; } if (*next).coder.is_null() { - (*next).coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ); + (*next).coder = lzma_alloc(core::mem::size_of::(), allocator); if (*next).coder.is_null() { return LZMA_MEM_ERROR; } @@ -440,13 +294,12 @@ pub unsafe extern "C" fn lzma_index_encoder( strm: *mut lzma_stream, i: *const lzma_index, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } let ret__0: lzma_ret = - lzma_index_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, i) - as lzma_ret; + lzma_index_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, i); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index f926c24e..3e98a1ae 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -1,7 +1,6 @@ use crate::types::*; use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; fn lzma_vli_decode( vli: *mut lzma_vli, vli_pos: *mut size_t, @@ -12,8 +11,6 @@ extern "C" { fn lzma_vli_size(vli: lzma_vli) -> u32; fn lzma_check_size(check: lzma_check) -> u32; fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); fn lzma_check_update( check: *mut lzma_check_state, @@ -23,38 +20,6 @@ extern "C" { ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_hash_s { @@ -76,32 +41,6 @@ pub struct lzma_index_hash_info { pub index_list_size: lzma_vli, pub check: lzma_check_state, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_check_state { - pub buffer: C2RustUnnamed_0, - pub state: C2RustUnnamed, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed { - pub crc32: u32, - pub crc64: u64, - pub sha256: lzma_sha256_state, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_sha256_state { - pub state: [u32; 8], - pub size: u64, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_0 { - pub u8_0: [u8; 64], - pub u32_0: [u32; 16], - pub u64_0: [u64; 8], -} pub type C2RustUnnamed_1 = c_uint; pub const SEQ_CRC32: C2RustUnnamed_1 = 6; pub const SEQ_PADDING: C2RustUnnamed_1 = 5; @@ -111,10 +50,6 @@ pub const SEQ_UNPADDED: C2RustUnnamed_1 = 2; pub const SEQ_COUNT: C2RustUnnamed_1 = 1; pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; pub type lzma_index_hash = lzma_index_hash_s; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; -pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; pub const INDEX_INDICATOR: c_int = 0; @@ -149,8 +84,8 @@ pub unsafe extern "C" fn lzma_index_hash_init( allocator: *const lzma_allocator, ) -> *mut lzma_index_hash { if index_hash.is_null() { - index_hash = lzma_alloc(core::mem::size_of::() as size_t, allocator) - as *mut lzma_index_hash; + index_hash = + lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_index_hash; if index_hash.is_null() { return core::ptr::null_mut(); } @@ -180,11 +115,13 @@ pub unsafe extern "C" fn lzma_index_hash_end( lzma_free(index_hash as *mut c_void, allocator); } #[no_mangle] -pub unsafe extern "C" fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { - return index_size( - (*index_hash).blocks.count, - (*index_hash).blocks.index_list_size, - ); +pub extern "C" fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { + return unsafe { + index_size( + (*index_hash).blocks.count, + (*index_hash).blocks.index_list_size, + ) + }; } unsafe extern "C" fn hash_append( info: *mut lzma_index_hash_info, @@ -202,7 +139,7 @@ unsafe extern "C" fn hash_append( &raw mut (*info).check, LZMA_CHECK_SHA256, &raw const sizes as *const lzma_vli as *const u8, - core::mem::size_of::<[lzma_vli; 2]>() as size_t, + core::mem::size_of::<[lzma_vli; 2]>(), ); } #[no_mangle] @@ -215,7 +152,7 @@ pub unsafe extern "C" fn lzma_index_hash_append( || (*index_hash).sequence != SEQ_BLOCK || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli - || uncompressed_size > LZMA_VLI_MAX as lzma_vli + || uncompressed_size > LZMA_VLI_MAX { return LZMA_PROG_ERROR; } @@ -224,8 +161,8 @@ pub unsafe extern "C" fn lzma_index_hash_append( unpadded_size, uncompressed_size, ); - if (*index_hash).blocks.blocks_size > LZMA_VLI_MAX as lzma_vli - || (*index_hash).blocks.uncompressed_size > LZMA_VLI_MAX as lzma_vli + if (*index_hash).blocks.blocks_size > LZMA_VLI_MAX + || (*index_hash).blocks.uncompressed_size > LZMA_VLI_MAX || index_size( (*index_hash).blocks.count, (*index_hash).blocks.index_list_size, @@ -234,7 +171,7 @@ pub unsafe extern "C" fn lzma_index_hash_append( (*index_hash).blocks.blocks_size, (*index_hash).blocks.count, (*index_hash).blocks.index_list_size, - ) > LZMA_VLI_MAX as lzma_vli + ) > LZMA_VLI_MAX { return LZMA_DATA_ERROR; } @@ -351,7 +288,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( (*index_hash).pos = (*index_hash).pos.wrapping_sub(1); let fresh1 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh1 as isize) as c_int != 0 as c_int { + if *in_0.offset(fresh1 as isize) != 0 { return LZMA_DATA_ERROR; } continue; @@ -371,7 +308,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( &raw mut (*index_hash).records.check.buffer.u8_0 as *mut u8 as *const c_void, lzma_check_size(LZMA_CHECK_SHA256) as size_t, - ) != 0 as c_int + ) != 0 { return LZMA_DATA_ERROR; } diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 1fb5c271..10cfef02 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -1,10 +1,8 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -27,161 +25,6 @@ extern "C" { ) -> lzma_ret; fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzip_coder { @@ -208,22 +51,6 @@ pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; pub const SEQ_DICT_SIZE: C2RustUnnamed_0 = 2; pub const SEQ_VERSION: C2RustUnnamed_0 = 1; pub const SEQ_ID_STRING: C2RustUnnamed_0 = 0; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { @@ -248,21 +75,6 @@ extern "C" fn read64le(buf: *const u8) -> u64 { num }; } -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; -pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; -pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; -pub const LZMA_IGNORE_CHECK: c_uint = 0x10; -pub const LZMA_CONCATENATED: c_uint = 0x8; -pub const LZMA_FAIL_FAST: c_uint = 0x20; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; -pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK - | LZMA_TELL_UNSUPPORTED_CHECK - | LZMA_TELL_ANY_CHECK - | LZMA_IGNORE_CHECK - | LZMA_CONCATENATED - | LZMA_FAIL_FAST; pub const LZIP_V0_FOOTER_SIZE: c_int = 12; pub const LZIP_V1_FOOTER_SIZE: c_int = 20; pub const LZIP_LC: c_int = 3; @@ -287,20 +99,20 @@ unsafe extern "C" fn lzip_decode( let lzip_id_string: [u8; 4] = [0x4c as u8, 0x5a as u8, 0x49 as u8, 0x50 as u8]; while (*coder).pos < core::mem::size_of::<[u8; 4]>() as usize { if *in_pos >= in_size { - return (if !(*coder).first_member && action == LZMA_FINISH { - LZMA_STREAM_END as c_int + return if !(*coder).first_member && action == LZMA_FINISH { + LZMA_STREAM_END } else { - LZMA_OK as c_int - }) as lzma_ret; + LZMA_OK + }; } if *in_0.offset(*in_pos as isize) as c_int != lzip_id_string[(*coder).pos as usize] as c_int { - return (if !(*coder).first_member { - LZMA_STREAM_END as c_int + return if !(*coder).first_member { + LZMA_STREAM_END } else { - LZMA_FORMAT_ERROR as c_int - }) as lzma_ret; + LZMA_FORMAT_ERROR + }; } *in_pos = (*in_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); @@ -371,7 +183,7 @@ unsafe extern "C" fn lzip_decode( (*coder).options.pb = LZIP_PB as u32; (*coder).memusage = lzma_lzma_decoder_memusage_nocheck(&raw mut (*coder).options as *const c_void) - .wrapping_add(LZMA_MEMUSAGE_BASE as u64); + .wrapping_add(LZMA_MEMUSAGE_BASE); (*coder).sequence = SEQ_CODER_INIT; current_block_80 = 15476230294461844687; } @@ -384,7 +196,7 @@ unsafe extern "C" fn lzip_decode( } let filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { - id: LZMA_FILTER_LZMA1 as lzma_vli, + id: LZMA_FILTER_LZMA1, init: Some( lzma_lzma_decoder_init as unsafe extern "C" fn( @@ -406,7 +218,7 @@ unsafe extern "C" fn lzip_decode( &raw mut (*coder).lzma_decoder, allocator, &raw const filters as *const lzma_filter_info, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -433,7 +245,7 @@ unsafe extern "C" fn lzip_decode( out_pos, out_size, action, - ) as lzma_ret; + ); let out_used: size_t = (*out_pos).wrapping_sub(out_start); (*coder).member_size = (*coder) .member_size @@ -562,8 +374,8 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( } let mut coder: *mut lzma_lzip_coder = (*next).coder as *mut lzma_lzip_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::() as size_t, allocator) - as *mut lzma_lzip_coder; + coder = + lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_lzip_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -595,7 +407,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( as Option lzma_ret>; (*coder).lzma_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -608,7 +420,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( } (*coder).sequence = SEQ_ID_STRING; (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; - (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; + (*coder).memusage = LZMA_MEMUSAGE_BASE; (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as u32 != 0; (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as u32 != 0; (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0; @@ -622,7 +434,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder( memlimit: u64, flags: u32, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -631,7 +443,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder( (*strm).allocator, memlimit, flags, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index e391d274..52c0063f 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -1,9 +1,7 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -18,161 +16,6 @@ extern "C" { ) -> lzma_ret; fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_microlzma_coder { @@ -183,26 +26,6 @@ pub struct lzma_microlzma_coder { pub uncomp_size_is_exact: bool, pub props_decoded: bool, } -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; unsafe extern "C" fn microlzma_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -268,7 +91,7 @@ unsafe extern "C" fn microlzma_decode( *in_pos = (*in_pos).wrapping_add(1); let mut filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { - id: LZMA_FILTER_LZMA1EXT as lzma_vli, + id: LZMA_FILTER_LZMA1EXT, init: Some( lzma_lzma_decoder_init as unsafe extern "C" fn( @@ -289,7 +112,7 @@ unsafe extern "C" fn microlzma_decode( &raw mut (*coder).lzma, allocator, &raw mut filters as *mut lzma_filter_info, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -408,10 +231,8 @@ unsafe extern "C" fn microlzma_decoder_init( )); let mut coder: *mut lzma_microlzma_coder = (*next).coder as *mut lzma_microlzma_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_microlzma_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_microlzma_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -435,7 +256,7 @@ unsafe extern "C" fn microlzma_decoder_init( ) as lzma_end_function; (*coder).lzma = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -464,7 +285,7 @@ pub unsafe extern "C" fn lzma_microlzma_decoder( uncomp_size_is_exact: lzma_bool, dict_size: u32, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -475,7 +296,7 @@ pub unsafe extern "C" fn lzma_microlzma_decoder( uncomp_size, uncomp_size_is_exact != 0, dict_size, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index edc98636..199d2464 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -1,9 +1,7 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -18,185 +16,12 @@ extern "C" { ) -> lzma_ret; fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_microlzma_coder { pub lzma: lzma_next_coder, pub props: u8, } -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; unsafe extern "C" fn microlzma_encode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -233,7 +58,7 @@ unsafe extern "C" fn microlzma_encode( out_pos, out_size, action, - ) as lzma_ret; + ); if ret != LZMA_STREAM_END { if ret == LZMA_OK { return LZMA_PROG_ERROR; @@ -296,10 +121,8 @@ unsafe extern "C" fn microlzma_encoder_init( )); let mut coder: *mut lzma_microlzma_coder = (*next).coder as *mut lzma_microlzma_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_microlzma_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_microlzma_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -323,7 +146,7 @@ unsafe extern "C" fn microlzma_encoder_init( ) as lzma_end_function; (*coder).lzma = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -339,7 +162,7 @@ unsafe extern "C" fn microlzma_encoder_init( } let filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { - id: LZMA_FILTER_LZMA1 as lzma_vli, + id: LZMA_FILTER_LZMA1, init: Some( lzma_lzma_encoder_init as unsafe extern "C" fn( @@ -367,7 +190,7 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( strm: *mut lzma_stream, options: *const lzma_options_lzma, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -375,7 +198,7 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( &raw mut (*(*strm).internal).next, (*strm).allocator, options, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index cad6fa6e..6b832257 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,8 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulong, c_void}; extern "C" { - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_bufcpy( in_0: *const u8, in_pos: *mut size_t, @@ -12,63 +10,6 @@ extern "C" { out_size: size_t, ) -> size_t; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_outbuf_s { - pub next: *mut lzma_outbuf, - pub worker: *mut c_void, - pub allocated: size_t, - pub pos: size_t, - pub decoder_in_pos: size_t, - pub finished: bool, - pub finish_ret: lzma_ret, - pub unpadded_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub buf: [u8; 0], -} -pub type lzma_outbuf = lzma_outbuf_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_outq { - pub head: *mut lzma_outbuf, - pub tail: *mut lzma_outbuf, - pub read_pos: size_t, - pub cache: *mut lzma_outbuf, - pub mem_allocated: u64, - pub mem_in_use: u64, - pub bufs_in_use: u32, - pub bufs_allocated: u32, - pub bufs_limit: u32, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const LZMA_THREADS_MAX: c_int = 16384; @@ -78,11 +19,11 @@ extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { } #[no_mangle] pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { - let limit: u64 = (UINT64_MAX as u64) + let limit: u64 = (UINT64_MAX) .wrapping_div((2 as c_int * 16384 as c_int) as u64) .wrapping_div(2); if threads > LZMA_THREADS_MAX as u32 || buf_size_max > limit { - return UINT64_MAX as u64; + return UINT64_MAX; } return ((2u32).wrapping_mul(threads) as u64) .wrapping_mul(lzma_outq_outbuf_memusage(buf_size_max as size_t)); @@ -223,7 +164,7 @@ pub unsafe extern "C" fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool { if (*outq).head.is_null() { return false; } - return (*outq).read_pos < (*(*outq).head).pos || (*(*outq).head).finished as c_int != 0; + return (*outq).read_pos < (*(*outq).head).pos || (*(*outq).head).finished; } #[no_mangle] pub unsafe extern "C" fn lzma_outq_read( diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index c5e111dc..cff292b0 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_ulonglong, c_void}; +use core::ffi::c_uint; extern "C" { fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_stream_decoder_init( @@ -9,87 +9,6 @@ extern "C" { flags: u32, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; #[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_decode( @@ -117,7 +36,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( } let mut stream_decoder: lzma_next_coder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 5fa163aa..607ec3fe 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_int; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -35,109 +35,11 @@ extern "C" { out_size: size_t, ) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} pub type lzma_index = lzma_index_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} -pub const LZMA_VLI_BYTES_MAX: c_int = 9; -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; pub const INDEX_BOUND: c_int = 1 as c_int + 1 as c_int + 2 as c_int * LZMA_VLI_BYTES_MAX + 4 as c_int + 3 as c_int & !(3 as c_int); pub const HEADERS_BOUND: c_int = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; -pub const LZMA_VLI_MAX: lzma_vli = u64::MAX / 2; #[no_mangle] pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { let block_bound: size_t = unsafe { lzma_block_buffer_bound(uncompressed_size) } as size_t; @@ -244,7 +146,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( out, &raw mut out_pos, out_size, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index fda6d293..ca12b834 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_void}; #[repr(C)] pub struct lzma_index_hash_s { _opaque: [u8; 0], @@ -38,8 +38,6 @@ extern "C" { in_size: size_t, ) -> lzma_ret; fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( @@ -56,126 +54,6 @@ extern "C" { block: *mut lzma_block, ) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { @@ -195,63 +73,7 @@ pub struct lzma_stream_coder { pub pos: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub type lzma_index_hash = lzma_index_hash_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} pub type C2RustUnnamed_0 = c_uint; pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 6; pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; @@ -260,22 +82,6 @@ pub const SEQ_BLOCK_RUN: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; -pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; -pub const LZMA_IGNORE_CHECK: c_uint = 0x10; -pub const LZMA_CONCATENATED: c_uint = 0x8; -pub const LZMA_FAIL_FAST: c_uint = 0x20; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; -pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK - | LZMA_TELL_UNSUPPORTED_CHECK - | LZMA_TELL_ANY_CHECK - | LZMA_IGNORE_CHECK - | LZMA_CONCATENATED - | LZMA_FAIL_FAST; pub const INDEX_INDICATOR: c_int = 0; unsafe extern "C" fn stream_decoder_reset( coder: *mut lzma_stream_coder, @@ -320,23 +126,21 @@ unsafe extern "C" fn stream_decode( let ret: lzma_ret = lzma_stream_header_decode( &raw mut (*coder).stream_flags, &raw mut (*coder).buffer as *mut u8, - ) as lzma_ret; + ); if ret != LZMA_OK { - return (if ret == LZMA_FORMAT_ERROR && !(*coder).first_stream { + return if ret == LZMA_FORMAT_ERROR && !(*coder).first_stream { LZMA_DATA_ERROR } else { ret - }) as lzma_ret; + }; } (*coder).first_stream = false; (*coder).block_options.check = (*coder).stream_flags.check; (*coder).sequence = SEQ_BLOCK_HEADER; - if (*coder).tell_no_check as c_int != 0 - && (*coder).stream_flags.check == LZMA_CHECK_NONE - { + if (*coder).tell_no_check && (*coder).stream_flags.check == LZMA_CHECK_NONE { return LZMA_NO_CHECK; } - if (*coder).tell_unsupported_check as c_int != 0 + if (*coder).tell_unsupported_check && lzma_check_is_supported((*coder).stream_flags.check) == 0 { return LZMA_UNSUPPORTED_CHECK; @@ -360,7 +164,7 @@ unsafe extern "C" fn stream_decode( return LZMA_OK; } let ret_2: lzma_ret = - lzma_index_hash_decode((*coder).index_hash, in_0, in_pos, in_size) as lzma_ret; + lzma_index_hash_decode((*coder).index_hash, in_0, in_pos, in_size); if ret_2 != LZMA_STREAM_END { return ret_2; } @@ -449,13 +253,13 @@ unsafe extern "C" fn stream_decode( let ret_3: lzma_ret = lzma_stream_footer_decode( &raw mut footer_flags, &raw mut (*coder).buffer as *mut u8, - ) as lzma_ret; + ); if ret_3 != LZMA_OK { - return (if ret_3 == LZMA_FORMAT_ERROR { + return if ret_3 == LZMA_FORMAT_ERROR { LZMA_DATA_ERROR } else { ret_3 - }) as lzma_ret; + }; } if lzma_index_hash_size((*coder).index_hash) != footer_flags.backward_size { return LZMA_DATA_ERROR; @@ -463,7 +267,7 @@ unsafe extern "C" fn stream_decode( let ret__1: lzma_ret = lzma_stream_flags_compare( &raw mut (*coder).stream_flags, &raw mut footer_flags, - ) as lzma_ret; + ); if ret__1 != LZMA_OK { return ret__1; } @@ -482,13 +286,13 @@ unsafe extern "C" fn stream_decode( if action != LZMA_FINISH { return LZMA_OK; } - return (if (*coder).pos == 0 { - LZMA_STREAM_END as c_int + return if (*coder).pos == 0 { + LZMA_STREAM_END } else { - LZMA_DATA_ERROR as c_int - }) as lzma_ret; + LZMA_DATA_ERROR + }; } - if *in_0.offset(*in_pos as isize) as c_int != 0 as c_int { + if *in_0.offset(*in_pos as isize) != 0 { break; } *in_pos = (*in_pos).wrapping_add(1); @@ -498,7 +302,7 @@ unsafe extern "C" fn stream_decode( *in_pos = (*in_pos).wrapping_add(1); return LZMA_DATA_ERROR; } - let ret__2: lzma_ret = stream_decoder_reset(coder, allocator) as lzma_ret; + let ret__2: lzma_ret = stream_decoder_reset(coder, allocator); if ret__2 != LZMA_OK { return ret__2; } @@ -515,7 +319,7 @@ unsafe extern "C" fn stream_decode( &raw mut (*coder).block_options, allocator, &raw mut (*coder).buffer as *mut u8, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -523,7 +327,7 @@ unsafe extern "C" fn stream_decode( let memusage: u64 = lzma_raw_decoder_memusage(&raw mut filters as *mut lzma_filter) as u64; let mut ret_0: lzma_ret = LZMA_OK; - if memusage == UINT64_MAX as u64 { + if memusage == UINT64_MAX { ret_0 = LZMA_OPTIONS_ERROR; } else { (*coder).memusage = memusage; @@ -562,7 +366,7 @@ unsafe extern "C" fn stream_decode( out_pos, out_size, action, - ) as lzma_ret; + ); if ret_1 != LZMA_STREAM_END { return ret_1; } @@ -570,7 +374,7 @@ unsafe extern "C" fn stream_decode( (*coder).index_hash, lzma_block_unpadded_size(&raw mut (*coder).block_options), (*coder).block_options.uncompressed_size, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { return ret__0; } @@ -652,10 +456,8 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( } let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_stream_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_stream_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -687,7 +489,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( as Option lzma_ret>; (*coder).block_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -700,7 +502,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( (*coder).index_hash = core::ptr::null_mut(); } (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; - (*coder).memusage = LZMA_MEMUSAGE_BASE as u64; + (*coder).memusage = LZMA_MEMUSAGE_BASE; (*coder).tell_no_check = flags & LZMA_TELL_NO_CHECK as u32 != 0; (*coder).tell_unsupported_check = flags & LZMA_TELL_UNSUPPORTED_CHECK as u32 != 0; (*coder).tell_any_check = flags & LZMA_TELL_ANY_CHECK as u32 != 0; @@ -715,7 +517,7 @@ pub unsafe extern "C" fn lzma_stream_decoder( memlimit: u64, flags: u32, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -724,7 +526,7 @@ pub unsafe extern "C" fn lzma_stream_decoder( (*strm).allocator, memlimit, flags, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index ec899579..940e9dc0 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -1,8 +1,7 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_long, c_uint, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_char, c_int, c_long, c_uint, c_ulong, c_void}; pub enum lzma_index_hash_s {} extern "C" { - fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> c_int; @@ -59,8 +58,6 @@ extern "C" { in_size: size_t, ) -> lzma_ret; fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( @@ -194,152 +191,6 @@ pub struct mythread_cond { pub clk_id: clockid_t, } pub type mythread_condtime = timespec; -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_mt { - pub flags: u32, - pub threads: u32, - pub block_size: u64, - pub timeout: u32, - pub preset: u32, - pub filters: *const lzma_filter, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: u32, - pub reserved_int4: u32, - pub memlimit_threading: u64, - pub memlimit_stop: u64, - pub reserved_int7: u64, - pub reserved_int8: u64, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { @@ -381,20 +232,6 @@ pub struct lzma_stream_coder { pub pos: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_outq { - pub head: *mut lzma_outbuf, - pub tail: *mut lzma_outbuf, - pub read_pos: size_t, - pub cache: *mut lzma_outbuf, - pub mem_allocated: u64, - pub mem_in_use: u64, - pub bufs_in_use: u32, - pub bufs_allocated: u32, - pub bufs_limit: u32, -} pub type lzma_outbuf = lzma_outbuf_s; #[derive(Copy, Clone)] #[repr(C)] @@ -434,66 +271,11 @@ pub struct worker_thread { pub cond: mythread_cond, pub thread_id: mythread, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} pub type worker_state = c_uint; pub const THR_EXIT: worker_state = 2; pub const THR_RUN: worker_state = 1; pub const THR_IDLE: worker_state = 0; pub type lzma_index_hash = lzma_index_hash_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} pub type C2RustUnnamed_0 = c_uint; pub const SEQ_ERROR: C2RustUnnamed_0 = 11; pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 10; @@ -507,14 +289,14 @@ pub const SEQ_BLOCK_THR_INIT: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const SIG_SETMASK: c_int = 3; pub const MYTHREAD_RET_VALUE: *mut c_void = core::ptr::null_mut(); #[inline] extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { - let _ret: c_int = unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; + let _ret: c_int = + unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; } #[inline] extern "C" fn mythread_create( @@ -582,9 +364,8 @@ extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { } #[inline] extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { - let _ret: c_int = unsafe { - pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) - }; + let _ret: c_int = + unsafe { pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) }; } #[inline] extern "C" fn mythread_cond_timedwait( @@ -623,22 +404,7 @@ extern "C" fn mythread_condtime_set( } } } -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; -pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; -pub const LZMA_IGNORE_CHECK: c_uint = 0x10; -pub const LZMA_CONCATENATED: c_uint = 0x8; -pub const LZMA_FAIL_FAST: c_uint = 0x20; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; pub const LZMA_THREADS_MAX: c_int = 16384; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; -pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK - | LZMA_TELL_UNSUPPORTED_CHECK - | LZMA_TELL_ANY_CHECK - | LZMA_IGNORE_CHECK - | LZMA_CONCATENATED - | LZMA_FAIL_FAST; pub const INDEX_INDICATOR: c_int = 0; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { @@ -700,7 +466,7 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { in_filled = (*thr).in_filled; partial_update_enabled = (*thr).partial_update_enabled; if !(in_filled == (*thr).in_pos - && !(partial_update_enabled as c_int != 0 && !(*thr).partial_update_started)) + && !(partial_update_enabled && !(*thr).partial_update_started)) { break; } @@ -882,8 +648,7 @@ unsafe extern "C" fn initialize_new_thread( ) -> lzma_ret { if (*coder).threads.is_null() { (*coder).threads = lzma_alloc( - ((*coder).threads_max as size_t) - .wrapping_mul(core::mem::size_of::() as size_t), + ((*coder).threads_max as size_t).wrapping_mul(core::mem::size_of::()), allocator, ) as *mut worker_thread; if (*coder).threads.is_null() { @@ -904,7 +669,7 @@ unsafe extern "C" fn initialize_new_thread( (*thr).outbuf = core::ptr::null_mut(); (*thr).block_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -959,7 +724,7 @@ unsafe extern "C" fn get_thread( mythread_i_608 = 1; } if (*coder).thr.is_null() { - let ret_: lzma_ret = initialize_new_thread(coder, allocator) as lzma_ret; + let ret_: lzma_ret = initialize_new_thread(coder, allocator); if ret_ != LZMA_OK { return ret_; } @@ -1041,7 +806,7 @@ unsafe extern "C" fn read_output_and_wait( .wrapping_sub((*coder).mem_in_use) .wrapping_sub((*coder).outq.mem_in_use) >= (*coder).mem_next_block - && lzma_outq_has_buf(&raw mut (*coder).outq) as c_int != 0 + && lzma_outq_has_buf(&raw mut (*coder).outq) && ((*coder).threads_initialized < (*coder).threads_max || !(*coder).threads_free.is_null()) { @@ -1057,9 +822,7 @@ unsafe extern "C" fn read_output_and_wait( if lzma_outq_is_readable(&raw mut (*coder).outq) { break; } - if !(*coder).thr.is_null() - && (*(*coder).thr).partial_update_enabled as c_int != 0 - { + if !(*coder).thr.is_null() && (*(*coder).thr).partial_update_enabled { if (*(*(*coder).thr).outbuf).decoder_in_pos == (*(*coder).thr).in_filled { break; } @@ -1077,7 +840,7 @@ unsafe extern "C" fn read_output_and_wait( &raw mut (*coder).cond, &raw mut (*coder).mutex, wait_abs, - ) != 0 as c_int + ) != 0 { ret = LZMA_RET_INTERNAL1; break; @@ -1135,7 +898,7 @@ unsafe extern "C" fn decode_block_header( &raw mut (*coder).block_options, allocator, &raw mut (*coder).buffer as *mut u8, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -1150,8 +913,7 @@ extern "C" fn comp_blk_size(coder: *const lzma_stream_coder) -> size_t { }; } extern "C" fn is_direct_mode_needed(size: lzma_vli) -> bool { - return size == LZMA_VLI_UNKNOWN as lzma_vli - || size > SIZE_MAX.wrapping_div(3 as c_ulong) as lzma_vli; + return size == LZMA_VLI_UNKNOWN || size > SIZE_MAX.wrapping_div(3 as c_ulong) as lzma_vli; } unsafe extern "C" fn stream_decoder_reset( coder: *mut lzma_stream_coder, @@ -1208,23 +970,21 @@ unsafe extern "C" fn stream_decode_mt( let ret: lzma_ret = lzma_stream_header_decode( &raw mut (*coder).stream_flags, &raw mut (*coder).buffer as *mut u8, - ) as lzma_ret; + ); if ret != LZMA_OK { - return (if ret == LZMA_FORMAT_ERROR && !(*coder).first_stream { + return if ret == LZMA_FORMAT_ERROR && !(*coder).first_stream { LZMA_DATA_ERROR } else { ret - }) as lzma_ret; + }; } (*coder).first_stream = false; (*coder).block_options.check = (*coder).stream_flags.check; (*coder).sequence = SEQ_BLOCK_HEADER; - if (*coder).tell_no_check as c_int != 0 - && (*coder).stream_flags.check == LZMA_CHECK_NONE - { + if (*coder).tell_no_check && (*coder).stream_flags.check == LZMA_CHECK_NONE { return LZMA_NO_CHECK; } - if (*coder).tell_unsupported_check as c_int != 0 + if (*coder).tell_unsupported_check && lzma_check_is_supported((*coder).stream_flags.check) == 0 { return LZMA_UNSUPPORTED_CHECK; @@ -1254,10 +1014,10 @@ unsafe extern "C" fn stream_decode_mt( out_pos, out_size, core::ptr::null_mut(), - 1 as c_int != 0, + true, &raw mut wait_abs, &raw mut has_blocked, - ) as lzma_ret; + ); if ret__3 != LZMA_OK { return ret__3; } @@ -1270,7 +1030,7 @@ unsafe extern "C" fn stream_decode_mt( &raw mut (*coder).block_decoder, allocator, &raw mut (*coder).block_options, - ) as lzma_ret; + ); lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); (*coder).block_options.filters = core::ptr::null_mut(); if ret_3 != LZMA_OK { @@ -1291,10 +1051,10 @@ unsafe extern "C" fn stream_decode_mt( out_pos, out_size, core::ptr::null_mut(), - 1 as c_int != 0, + true, &raw mut wait_abs, &raw mut has_blocked, - ) as lzma_ret; + ); if ret__5 != LZMA_OK { return ret__5; } @@ -1322,10 +1082,10 @@ unsafe extern "C" fn stream_decode_mt( out_pos, out_size, core::ptr::null_mut(), - 1 as c_int != 0, + true, &raw mut wait_abs, &raw mut has_blocked, - ) as lzma_ret; + ); if ret__8 != LZMA_OK { return ret__8; } @@ -1354,7 +1114,7 @@ unsafe extern "C" fn stream_decode_mt( out_pos, out_size, action, - ) as lzma_ret; + ); (*coder).progress_in = (*coder) .progress_in .wrapping_add((*in_pos).wrapping_sub(in_old_1) as u64); @@ -1368,7 +1128,7 @@ unsafe extern "C" fn stream_decode_mt( (*coder).index_hash, lzma_block_unpadded_size(&raw mut (*coder).block_options), (*coder).block_options.uncompressed_size, - ) as lzma_ret; + ); if ret__4 != LZMA_OK { return ret__4; } @@ -1377,13 +1137,12 @@ unsafe extern "C" fn stream_decode_mt( } 7149356873433890176 => { let in_old_0: size_t = *in_pos; - let ret_0: lzma_ret = - decode_block_header(coder, allocator, in_0, in_pos, in_size) as lzma_ret; + let ret_0: lzma_ret = decode_block_header(coder, allocator, in_0, in_pos, in_size); (*coder).progress_in = (*coder) .progress_in .wrapping_add((*in_pos).wrapping_sub(in_old_0) as u64); if ret_0 == LZMA_OK { - if action == LZMA_FINISH && (*coder).fail_fast as c_int != 0 { + if action == LZMA_FINISH && (*coder).fail_fast { threads_stop(coder); return LZMA_DATA_ERROR; } @@ -1397,7 +1156,7 @@ unsafe extern "C" fn stream_decode_mt( waiting_allowed, &raw mut wait_abs, &raw mut has_blocked, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -1417,7 +1176,7 @@ unsafe extern "C" fn stream_decode_mt( } else { (*coder).mem_next_filters = lzma_raw_decoder_memusage(&raw mut (*coder).filters as *mut lzma_filter); - if (*coder).mem_next_filters == UINT64_MAX as u64 { + if (*coder).mem_next_filters == UINT64_MAX { (*coder).pending_error = LZMA_OPTIONS_ERROR; (*coder).sequence = SEQ_ERROR; current_block_239 = 11639917216603986996; @@ -1433,7 +1192,7 @@ unsafe extern "C" fn stream_decode_mt( } let in_old_2: size_t = *in_pos; let ret_5: lzma_ret = - lzma_index_hash_decode((*coder).index_hash, in_0, in_pos, in_size) as lzma_ret; + lzma_index_hash_decode((*coder).index_hash, in_0, in_pos, in_size); (*coder).progress_in = (*coder) .progress_in .wrapping_add((*in_pos).wrapping_sub(in_old_2) as u64); @@ -1455,10 +1214,10 @@ unsafe extern "C" fn stream_decode_mt( out_pos, out_size, core::ptr::null_mut(), - 1 as c_int != 0, + true, &raw mut wait_abs, &raw mut has_blocked, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { return ret__0; } @@ -1467,8 +1226,8 @@ unsafe extern "C" fn stream_decode_mt( } return LZMA_MEMLIMIT_ERROR; } - if is_direct_mode_needed((*coder).block_options.compressed_size) as c_int != 0 - || is_direct_mode_needed((*coder).block_options.uncompressed_size) as c_int != 0 + if is_direct_mode_needed((*coder).block_options.compressed_size) + || is_direct_mode_needed((*coder).block_options.uncompressed_size) { (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; current_block_239 = 11639917216603986996; @@ -1478,7 +1237,7 @@ unsafe extern "C" fn stream_decode_mt( (*coder).mem_next_in.wrapping_add(lzma_outq_outbuf_memusage( (*coder).block_options.uncompressed_size as size_t, ) as u64); - if (UINT64_MAX as u64).wrapping_sub(mem_buffers) < (*coder).mem_next_filters { + if (UINT64_MAX).wrapping_sub(mem_buffers) < (*coder).mem_next_filters { (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; current_block_239 = 11639917216603986996; } else { @@ -1494,7 +1253,7 @@ unsafe extern "C" fn stream_decode_mt( (*coder).index_hash, lzma_block_unpadded_size(&raw mut (*coder).block_options), (*coder).block_options.uncompressed_size, - ) as lzma_ret; + ); if ret_1 != LZMA_OK { (*coder).pending_error = ret_1; (*coder).sequence = SEQ_ERROR; @@ -1546,13 +1305,13 @@ unsafe extern "C" fn stream_decode_mt( let ret_6: lzma_ret = lzma_stream_footer_decode( &raw mut footer_flags, &raw mut (*coder).buffer as *mut u8, - ) as lzma_ret; + ); if ret_6 != LZMA_OK { - return (if ret_6 == LZMA_FORMAT_ERROR { + return if ret_6 == LZMA_FORMAT_ERROR { LZMA_DATA_ERROR } else { ret_6 - }) as lzma_ret; + }; } if lzma_index_hash_size((*coder).index_hash) != footer_flags.backward_size { return LZMA_DATA_ERROR; @@ -1560,7 +1319,7 @@ unsafe extern "C" fn stream_decode_mt( let ret__6: lzma_ret = lzma_stream_flags_compare( &raw mut (*coder).stream_flags, &raw mut footer_flags, - ) as lzma_ret; + ); if ret__6 != LZMA_OK { return ret__6; } @@ -1579,13 +1338,13 @@ unsafe extern "C" fn stream_decode_mt( if action != LZMA_FINISH { return LZMA_OK; } - return (if (*coder).pos == 0 { - LZMA_STREAM_END as c_int + return if (*coder).pos == 0 { + LZMA_STREAM_END } else { - LZMA_DATA_ERROR as c_int - }) as lzma_ret; + LZMA_DATA_ERROR + }; } - if *in_0.offset(*in_pos as isize) as c_int != 0 as c_int { + if *in_0.offset(*in_pos as isize) != 0 { break; } *in_pos = (*in_pos).wrapping_add(1); @@ -1597,7 +1356,7 @@ unsafe extern "C" fn stream_decode_mt( (*coder).progress_in = (*coder).progress_in.wrapping_add(1); return LZMA_DATA_ERROR; } - let ret__7: lzma_ret = stream_decoder_reset(coder, allocator) as lzma_ret; + let ret__7: lzma_ret = stream_decoder_reset(coder, allocator); if ret__7 != LZMA_OK { return ret__7; } @@ -1612,10 +1371,10 @@ unsafe extern "C" fn stream_decode_mt( out_pos, out_size, &raw mut block_can_start, - 1 as c_int != 0, + true, &raw mut wait_abs, &raw mut has_blocked, - ) as lzma_ret; + ); if ret__1 != LZMA_OK { return ret__1; } @@ -1782,7 +1541,7 @@ unsafe extern "C" fn stream_decode_mt( } match current_block_239 { 7728257318064351663 => { - if action == LZMA_FINISH && (*coder).fail_fast as c_int != 0 { + if action == LZMA_FINISH && (*coder).fail_fast { let in_avail: size_t = in_size.wrapping_sub(*in_pos); let in_needed: size_t = (*(*coder).thr) .in_size @@ -1825,10 +1584,10 @@ unsafe extern "C" fn stream_decode_mt( out_pos, out_size, core::ptr::null_mut(), - waiting_allowed as c_int != 0 && *in_pos == in_size, + waiting_allowed && *in_pos == in_size, &raw mut wait_abs, &raw mut has_blocked, - ) as lzma_ret; + ); if ret__2 != LZMA_OK { return ret__2; } @@ -1891,8 +1650,8 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( } mythread_i_1829 = 1; } - if *memusage < LZMA_MEMUSAGE_BASE as u64 { - *memusage = LZMA_MEMUSAGE_BASE as u64; + if *memusage < LZMA_MEMUSAGE_BASE { + *memusage = LZMA_MEMUSAGE_BASE; } *old_memlimit = (*coder).memlimit_stop; if new_memlimit != 0 { @@ -2003,10 +1762,8 @@ unsafe extern "C" fn stream_decoder_mt_init( )); coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_stream_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_stream_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -2050,15 +1807,15 @@ unsafe extern "C" fn stream_decoder_mt_init( as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> (), ) as Option ()>; - (*coder).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters[0].id = LZMA_VLI_UNKNOWN; memset( &raw mut (*coder).outq as *mut c_void, 0 as c_int, - core::mem::size_of::() as size_t, + core::mem::size_of::(), ); (*coder).block_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -2109,8 +1866,7 @@ unsafe extern "C" fn stream_decoder_mt_init( (*coder).out_was_filled = false; (*coder).pos = 0; (*coder).threads_max = (*options).threads; - let ret_: lzma_ret = - lzma_outq_init(&raw mut (*coder).outq, allocator, (*coder).threads_max) as lzma_ret; + let ret_: lzma_ret = lzma_outq_init(&raw mut (*coder).outq, allocator, (*coder).threads_max); if ret_ != LZMA_OK { return ret_; } @@ -2121,7 +1877,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_mt( strm: *mut lzma_stream, options: *const lzma_mt, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -2129,7 +1885,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_mt( &raw mut (*(*strm).internal).next, (*strm).allocator, options, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 2447c119..5a1b0ed8 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -1,11 +1,10 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], } extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_end(strm: *mut lzma_stream); fn lzma_filters_copy( src: *const lzma_filter, @@ -27,8 +26,6 @@ extern "C" { uncompressed_size: lzma_vli, ) -> lzma_ret; fn lzma_index_size(i: *const lzma_index) -> lzma_vli; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( @@ -50,126 +47,6 @@ extern "C" { i: *const lzma_index, ) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { @@ -184,42 +61,7 @@ pub struct lzma_stream_coder { pub buffer_size: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; pub type lzma_index = lzma_index_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} pub type C2RustUnnamed_0 = c_uint; pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; pub const SEQ_INDEX_ENCODE: C2RustUnnamed_0 = 4; @@ -227,37 +69,13 @@ pub const SEQ_BLOCK_ENCODE: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; unsafe extern "C" fn block_encoder_init( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { - (*coder).block_options.compressed_size = LZMA_VLI_UNKNOWN as lzma_vli; - (*coder).block_options.uncompressed_size = LZMA_VLI_UNKNOWN as lzma_vli; - let ret_: lzma_ret = lzma_block_header_size(&raw mut (*coder).block_options) as lzma_ret; + (*coder).block_options.compressed_size = LZMA_VLI_UNKNOWN; + (*coder).block_options.uncompressed_size = LZMA_VLI_UNKNOWN; + let ret_: lzma_ret = lzma_block_header_size(&raw mut (*coder).block_options); if ret_ != LZMA_OK { return ret_; } @@ -302,24 +120,24 @@ unsafe extern "C" fn stream_encode( 1 => { if *in_pos == in_size { if action != LZMA_FINISH { - return (if action == LZMA_RUN { - LZMA_OK as c_int + return if action == LZMA_RUN { + LZMA_OK } else { - LZMA_STREAM_END as c_int - }) as lzma_ret; + LZMA_STREAM_END + }; } let ret_: lzma_ret = lzma_index_encoder_init( &raw mut (*coder).index_encoder, allocator, (*coder).index, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } (*coder).sequence = SEQ_INDEX_ENCODE; } else { if !(*coder).block_encoder_is_initialized { - let ret__0: lzma_ret = block_encoder_init(coder, allocator) as lzma_ret; + let ret__0: lzma_ret = block_encoder_init(coder, allocator); if ret__0 != LZMA_OK { return ret__0; } @@ -357,7 +175,7 @@ unsafe extern "C" fn stream_encode( out_pos, out_size, convert[action as usize], - ) as lzma_ret; + ); if ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH { return ret; } @@ -368,7 +186,7 @@ unsafe extern "C" fn stream_encode( allocator, unpadded_size, (*coder).block_options.uncompressed_size, - ) as lzma_ret; + ); if ret__1 != LZMA_OK { return ret__1; } @@ -388,7 +206,7 @@ unsafe extern "C" fn stream_encode( out_pos, out_size, LZMA_RUN, - ) as lzma_ret; + ); if ret_0 != LZMA_STREAM_END { return ret_0; } @@ -447,8 +265,7 @@ unsafe extern "C" fn stream_encoder_update( id: 0, options: core::ptr::null_mut(), }; 5]; - let ret_: lzma_ret = - lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator) as lzma_ret; + let ret_: lzma_ret = lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator); if ret_ != LZMA_OK { return ret_; } @@ -492,7 +309,7 @@ unsafe extern "C" fn stream_encoder_update( memcpy( &raw mut (*coder).filters as *mut lzma_filter as *mut c_void, &raw mut temp as *mut lzma_filter as *const c_void, - core::mem::size_of::<[lzma_filter; 5]>() as size_t, + core::mem::size_of::<[lzma_filter; 5]>(), ); return LZMA_OK; } @@ -550,10 +367,8 @@ unsafe extern "C" fn stream_encoder_init( } let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_stream_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_stream_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -592,10 +407,10 @@ unsafe extern "C" fn stream_encoder_init( *const lzma_filter, ) -> lzma_ret, >; - (*coder).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters[0].id = LZMA_VLI_UNKNOWN; (*coder).block_encoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -607,7 +422,7 @@ unsafe extern "C" fn stream_encoder_init( }; (*coder).index_encoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -647,8 +462,7 @@ unsafe extern "C" fn stream_encoder_init( reserved_int2: 0, }; let ret_: lzma_ret = - lzma_stream_header_encode(&raw mut stream_flags, &raw mut (*coder).buffer as *mut u8) - as lzma_ret; + lzma_stream_header_encode(&raw mut stream_flags, &raw mut (*coder).buffer as *mut u8); if ret_ != LZMA_OK { return ret_; } @@ -667,7 +481,7 @@ pub unsafe extern "C" fn lzma_stream_encoder( filters: *const lzma_filter, check: lzma_check, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -676,7 +490,7 @@ pub unsafe extern "C" fn lzma_stream_encoder( (*strm).allocator, filters, check, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index e2f2a5e5..10b6dba9 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -2,8 +2,6 @@ use crate::types::*; use core::ffi::{c_char, c_int, c_long, c_uint, c_ulonglong, c_void}; pub enum lzma_index_s {} extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> c_int; @@ -58,8 +56,6 @@ extern "C" { uncompressed_size: lzma_vli, ) -> lzma_ret; fn lzma_index_size(i: *const lzma_index) -> lzma_vli; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); fn lzma_bufcpy( @@ -191,187 +187,6 @@ pub struct mythread_cond { pub clk_id: clockid_t, } pub type mythread_condtime = timespec; -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_internal_s { - pub next: lzma_next_coder, - pub sequence: C2RustUnnamed, - pub avail_in: size_t, - pub supported_actions: [bool; 5], - pub allow_buf_error: bool, -} -pub type C2RustUnnamed = c_uint; -pub const ISEQ_ERROR: C2RustUnnamed = 6; -pub const ISEQ_END: C2RustUnnamed = 5; -pub const ISEQ_FULL_BARRIER: C2RustUnnamed = 4; -pub const ISEQ_FINISH: C2RustUnnamed = 3; -pub const ISEQ_FULL_FLUSH: C2RustUnnamed = 2; -pub const ISEQ_SYNC_FLUSH: C2RustUnnamed = 1; -pub const ISEQ_RUN: C2RustUnnamed = 0; -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub type lzma_internal = lzma_internal_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream { - pub next_in: *const u8, - pub avail_in: size_t, - pub total_in: u64, - pub next_out: *mut u8, - pub avail_out: size_t, - pub total_out: u64, - pub allocator: *const lzma_allocator, - pub internal: *mut lzma_internal, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, - pub seek_pos: u64, - pub reserved_int2: u64, - pub reserved_int3: size_t, - pub reserved_int4: size_t, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, -} -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_mt { - pub flags: u32, - pub threads: u32, - pub block_size: u64, - pub timeout: u32, - pub preset: u32, - pub filters: *const lzma_filter, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: u32, - pub reserved_int4: u32, - pub memlimit_threading: u64, - pub memlimit_stop: u64, - pub reserved_int7: u64, - pub reserved_int8: u64, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_ptr4: *mut c_void, -} pub type worker_thread = worker_thread_s; #[derive(Copy, Clone)] #[repr(C)] @@ -392,40 +207,6 @@ pub struct worker_thread_s { pub cond: mythread_cond, pub thread_id: mythread, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_block { - pub version: u32, - pub header_size: u32, - pub check: lzma_check, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub filters: *mut lzma_filter, - pub raw_check: [u8; 64], - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, - pub reserved_ptr3: *mut c_void, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: lzma_vli, - pub reserved_int4: lzma_vli, - pub reserved_int5: lzma_vli, - pub reserved_int6: lzma_vli, - pub reserved_int7: lzma_vli, - pub reserved_int8: lzma_vli, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub ignore_check: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, -} pub type lzma_stream_coder = lzma_stream_coder_s; #[derive(Copy, Clone)] #[repr(C)] @@ -453,19 +234,6 @@ pub struct lzma_stream_coder_s { pub mutex: mythread_mutex, pub cond: mythread_cond, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_outq { - pub head: *mut lzma_outbuf, - pub tail: *mut lzma_outbuf, - pub read_pos: size_t, - pub cache: *mut lzma_outbuf, - pub mem_allocated: u64, - pub mem_in_use: u64, - pub bufs_in_use: u32, - pub bufs_allocated: u32, - pub bufs_limit: u32, -} pub type lzma_outbuf = lzma_outbuf_s; #[derive(Copy, Clone)] #[repr(C)] @@ -481,27 +249,6 @@ pub struct lzma_outbuf_s { pub uncompressed_size: lzma_vli, pub buf: [u8; 0], } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} pub type lzma_index = lzma_index_s; pub type C2RustUnnamed_0 = c_uint; pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 3; @@ -514,18 +261,12 @@ pub const THR_STOP: worker_state = 3; pub const THR_FINISH: worker_state = 2; pub const THR_RUN: worker_state = 1; pub const THR_IDLE: worker_state = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_easy { - pub filters: [lzma_filter; 5], - pub opt_lzma: lzma_options_lzma, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const SIG_SETMASK: c_int = 3; pub const MYTHREAD_RET_VALUE: *mut c_void = core::ptr::null_mut(); #[inline] extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { - let _ret: c_int = unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; + let _ret: c_int = + unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; } #[inline] extern "C" fn mythread_create( @@ -593,9 +334,8 @@ extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { } #[inline] extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { - let _ret: c_int = unsafe { - pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) - }; + let _ret: c_int = + unsafe { pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) }; } #[inline] extern "C" fn mythread_cond_timedwait( @@ -634,11 +374,7 @@ extern "C" fn mythread_condtime_set( } } } -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; pub const LZMA_THREADS_MAX: c_int = 16384; -pub const LZMA_MEMUSAGE_BASE: c_ulonglong = 1 << 15; #[inline] extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { return unsafe { (*outq).bufs_in_use < (*outq).bufs_limit }; @@ -751,9 +487,9 @@ unsafe extern "C" fn worker_encode( return state; } let mut action: lzma_action = (if state == THR_FINISH { - LZMA_FINISH as c_int + LZMA_FINISH } else { - LZMA_RUN as c_int + LZMA_RUN }) as lzma_action; static mut in_chunk_max: size_t = 16384; let mut in_limit: size_t = in_size; @@ -1034,7 +770,7 @@ unsafe extern "C" fn initialize_new_thread( (*thr).progress_out = 0; (*thr).block_encoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -1044,7 +780,7 @@ unsafe extern "C" fn initialize_new_thread( update: None, set_out_limit: None, }; - (*thr).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*thr).filters[0].id = LZMA_VLI_UNKNOWN; if mythread_create( &raw mut (*thr).thread_id, Some(worker_start as unsafe extern "C" fn(*mut c_void) -> *mut c_void), @@ -1074,16 +810,16 @@ unsafe extern "C" fn get_thread( &raw mut (*coder).outq, allocator, (*coder).outbuf_alloc_size, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } - if (*coder).filters_cache[0].id == LZMA_VLI_UNKNOWN as lzma_vli { + if (*coder).filters_cache[0].id == LZMA_VLI_UNKNOWN { let ret__0: lzma_ret = lzma_filters_copy( &raw mut (*coder).filters as *mut lzma_filter, &raw mut (*coder).filters_cache as *mut lzma_filter, allocator, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { return ret__0; } @@ -1111,7 +847,7 @@ unsafe extern "C" fn get_thread( if (*coder).threads_initialized == (*coder).threads_max { return LZMA_OK; } - let ret__1: lzma_ret = initialize_new_thread(coder, allocator) as lzma_ret; + let ret__1: lzma_ret = initialize_new_thread(coder, allocator); if ret__1 != LZMA_OK { return ret__1; } @@ -1138,9 +874,9 @@ unsafe extern "C" fn get_thread( memcpy( &raw mut (*(*coder).thr).filters as *mut lzma_filter as *mut c_void, &raw mut (*coder).filters_cache as *mut lzma_filter as *const c_void, - core::mem::size_of::<[lzma_filter; 5]>() as size_t, + core::mem::size_of::<[lzma_filter; 5]>(), ); - (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; mythread_cond_signal(&raw mut (*(*coder).thr).cond); mythread_j_578 = 1; } @@ -1158,7 +894,7 @@ unsafe extern "C" fn stream_encode_in( ) -> lzma_ret { while *in_pos < in_size || !(*coder).thr.is_null() && action != LZMA_RUN { if (*coder).thr.is_null() { - let ret: lzma_ret = get_thread(coder, allocator) as lzma_ret; + let ret: lzma_ret = get_thread(coder, allocator); if (*coder).thr.is_null() { return ret; } @@ -1259,7 +995,7 @@ unsafe extern "C" fn wait_for_work( &raw mut (*coder).cond, &raw mut (*coder).mutex, wait_abs, - ) != 0 as c_int; + ) != 0; } else { mythread_cond_wait(&raw mut (*coder).cond, &raw mut (*coder).mutex); } @@ -1289,7 +1025,7 @@ unsafe extern "C" fn stream_encode_mt( lzma_bufcpy( &raw mut (*coder).header as *mut u8, &raw mut (*coder).header_pos, - core::mem::size_of::<[u8; 12]>() as size_t, + core::mem::size_of::<[u8; 12]>(), out, out_pos, out_size, @@ -1409,7 +1145,7 @@ unsafe extern "C" fn stream_encode_mt( &raw mut (*coder).index_encoder, allocator, (*coder).index, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -1438,7 +1174,7 @@ unsafe extern "C" fn stream_encode_mt( out_pos, out_size, LZMA_RUN, - ) as lzma_ret; + ); if ret_0 != LZMA_STREAM_END { return ret_0; } @@ -1457,16 +1193,16 @@ unsafe extern "C" fn stream_encode_mt( lzma_bufcpy( &raw mut (*coder).header as *mut u8, &raw mut (*coder).header_pos, - core::mem::size_of::<[u8; 12]>() as size_t, + core::mem::size_of::<[u8; 12]>(), out, out_pos, out_size, ); - return (if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() as usize { - LZMA_OK as c_int + return if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() as usize { + LZMA_OK } else { - LZMA_STREAM_END as c_int - }) as lzma_ret; + LZMA_STREAM_END + }; } return LZMA_PROG_ERROR; } @@ -1501,15 +1237,14 @@ unsafe extern "C" fn stream_encoder_mt_update( if !(*coder).thr.is_null() { return LZMA_PROG_ERROR; } - if lzma_raw_encoder_memusage(filters) == UINT64_MAX as u64 { + if lzma_raw_encoder_memusage(filters) == UINT64_MAX { return LZMA_OPTIONS_ERROR; } let mut temp: [lzma_filter; 5] = [lzma_filter { id: 0, options: core::ptr::null_mut(), }; 5]; - let ret_: lzma_ret = - lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator) as lzma_ret; + let ret_: lzma_ret = lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator); if ret_ != LZMA_OK { return ret_; } @@ -1521,7 +1256,7 @@ unsafe extern "C" fn stream_encoder_mt_update( memcpy( &raw mut (*coder).filters as *mut lzma_filter as *mut c_void, &raw mut temp as *mut lzma_filter as *const c_void, - core::mem::size_of::<[lzma_filter; 5]>() as size_t, + core::mem::size_of::<[lzma_filter; 5]>(), ); return LZMA_OK; } @@ -1554,7 +1289,7 @@ unsafe extern "C" fn get_options( } else { *block_size = lzma_mt_block_size(*filters); } - if *block_size > BLOCK_SIZE_MAX as u64 || *block_size == UINT64_MAX as u64 { + if *block_size > BLOCK_SIZE_MAX as u64 || *block_size == UINT64_MAX { return LZMA_OPTIONS_ERROR; } *outbuf_size_max = lzma_block_buffer_bound64(*block_size); @@ -1693,11 +1428,11 @@ unsafe extern "C" fn stream_encoder_mt_init( &raw mut filters, &raw mut block_size, &raw mut outbuf_size_max, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } - if lzma_raw_encoder_memusage(filters) == UINT64_MAX as u64 { + if lzma_raw_encoder_memusage(filters) == UINT64_MAX { return LZMA_OPTIONS_ERROR; } if (*options).check > LZMA_CHECK_ID_MAX { @@ -1708,10 +1443,8 @@ unsafe extern "C" fn stream_encoder_mt_init( } let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_stream_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_stream_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -1764,11 +1497,11 @@ unsafe extern "C" fn stream_encoder_mt_init( *const lzma_filter, ) -> lzma_ret, >; - (*coder).filters[0].id = LZMA_VLI_UNKNOWN as lzma_vli; - (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN as lzma_vli; + (*coder).filters[0].id = LZMA_VLI_UNKNOWN; + (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; (*coder).index_encoder = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -1782,7 +1515,7 @@ unsafe extern "C" fn stream_encoder_mt_init( memset( &raw mut (*coder).outq as *mut c_void, 0 as c_int, - core::mem::size_of::() as size_t, + core::mem::size_of::(), ); (*coder).threads = core::ptr::null_mut(); (*coder).threads_max = 0; @@ -1800,8 +1533,7 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).threads_initialized = 0; (*coder).threads_free = core::ptr::null_mut(); (*coder).threads = lzma_alloc( - ((*options).threads as size_t) - .wrapping_mul(core::mem::size_of::() as size_t), + ((*options).threads as size_t).wrapping_mul(core::mem::size_of::()), allocator, ) as *mut worker_thread; if (*coder).threads.is_null() { @@ -1811,8 +1543,7 @@ unsafe extern "C" fn stream_encoder_mt_init( } else { threads_stop(coder, true); } - let ret__0: lzma_ret = - lzma_outq_init(&raw mut (*coder).outq, allocator, (*options).threads) as lzma_ret; + let ret__0: lzma_ret = lzma_outq_init(&raw mut (*coder).outq, allocator, (*options).threads); if ret__0 != LZMA_OK { return ret__0; } @@ -1826,7 +1557,7 @@ unsafe extern "C" fn stream_encoder_mt_init( filters, &raw mut (*coder).filters as *mut lzma_filter, allocator, - ) as lzma_ret; + ); if ret__1 != LZMA_OK { return ret__1; } @@ -1840,7 +1571,7 @@ unsafe extern "C" fn stream_encoder_mt_init( let ret__2: lzma_ret = lzma_stream_header_encode( &raw mut (*coder).stream_flags, &raw mut (*coder).header as *mut u8, - ) as lzma_ret; + ); if ret__2 != LZMA_OK { return ret__2; } @@ -1854,7 +1585,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( strm: *mut lzma_stream, options: *const lzma_mt, ) -> lzma_ret { - let ret_: lzma_ret = lzma_strm_init(strm) as lzma_ret; + let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; } @@ -1862,7 +1593,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( &raw mut (*(*strm).internal).next, (*strm).allocator, options, - ) as lzma_ret; + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; @@ -1918,34 +1649,34 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt &raw mut outbuf_size_max, ) != LZMA_OK { - return UINT64_MAX as u64; + return UINT64_MAX; } let inbuf_memusage: u64 = ((*options).threads as u64).wrapping_mul(block_size); let mut filters_memusage: u64 = lzma_raw_encoder_memusage(filters); - if filters_memusage == UINT64_MAX as u64 { - return UINT64_MAX as u64; + if filters_memusage == UINT64_MAX { + return UINT64_MAX; } filters_memusage = filters_memusage.wrapping_mul((*options).threads as u64); let outq_memusage: u64 = lzma_outq_memusage(outbuf_size_max, (*options).threads) as u64; - if outq_memusage == UINT64_MAX as u64 { - return UINT64_MAX as u64; + if outq_memusage == UINT64_MAX { + return UINT64_MAX; } - let mut total_memusage: u64 = (LZMA_MEMUSAGE_BASE as u64) + let mut total_memusage: u64 = (LZMA_MEMUSAGE_BASE) .wrapping_add(core::mem::size_of::() as u64) .wrapping_add( ((*options).threads as usize) .wrapping_mul(core::mem::size_of::() as usize) as u64, ); - if (UINT64_MAX as u64).wrapping_sub(total_memusage) < inbuf_memusage { - return UINT64_MAX as u64; + if (UINT64_MAX).wrapping_sub(total_memusage) < inbuf_memusage { + return UINT64_MAX; } total_memusage = total_memusage.wrapping_add(inbuf_memusage); - if (UINT64_MAX as u64).wrapping_sub(total_memusage) < filters_memusage { - return UINT64_MAX as u64; + if (UINT64_MAX).wrapping_sub(total_memusage) < filters_memusage { + return UINT64_MAX; } total_memusage = total_memusage.wrapping_add(filters_memusage); - if (UINT64_MAX as u64).wrapping_sub(total_memusage) < outq_memusage { - return UINT64_MAX as u64; + if (UINT64_MAX).wrapping_sub(total_memusage) < outq_memusage { + return UINT64_MAX; } return total_memusage.wrapping_add(outq_memusage); } diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index aff79731..d232afb7 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -1,57 +1,4 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong}; -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4; -pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; #[inline] extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { return unsafe { @@ -80,9 +27,7 @@ pub unsafe extern "C" fn lzma_stream_flags_compare( if (*a).check != (*b).check { return LZMA_DATA_ERROR; } - if (*a).backward_size != LZMA_VLI_UNKNOWN as lzma_vli - && (*b).backward_size != LZMA_VLI_UNKNOWN as lzma_vli - { + if (*a).backward_size != LZMA_VLI_UNKNOWN && (*b).backward_size != LZMA_VLI_UNKNOWN { if !is_backward_size_valid(a) || !is_backward_size_valid(b) { return LZMA_PROG_ERROR; } diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 3d7f862d..9af0d4ef 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -1,59 +1,10 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { - fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; static lzma_header_magic: [u8; 6]; static lzma_footer_magic: [u8; 2]; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { @@ -64,12 +15,10 @@ extern "C" fn read32le(buf: *const u8) -> u32 { num }; } -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2; extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> bool { return unsafe { - if *in_0.offset(0) as c_int != 0 as c_int || *in_0.offset(1) as c_int & 0xf0 as c_int != 0 - { + if *in_0.offset(0) != 0 || *in_0.offset(1) as c_int & 0xf0 != 0 { return true; } (*options).version = 0; @@ -85,8 +34,8 @@ pub unsafe extern "C" fn lzma_stream_header_decode( if memcmp( in_0 as *const c_void, &raw const lzma_header_magic as *const u8 as *const c_void, - core::mem::size_of::<[u8; 6]>() as size_t, - ) != 0 as c_int + core::mem::size_of::<[u8; 6]>(), + ) != 0 { return LZMA_FORMAT_ERROR; } @@ -109,7 +58,7 @@ pub unsafe extern "C" fn lzma_stream_header_decode( ) { return LZMA_OPTIONS_ERROR; } - (*options).backward_size = LZMA_VLI_UNKNOWN as lzma_vli; + (*options).backward_size = LZMA_VLI_UNKNOWN; return LZMA_OK; } #[no_mangle] @@ -121,14 +70,14 @@ pub unsafe extern "C" fn lzma_stream_footer_decode( in_0.offset((core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *const c_void, &raw const lzma_footer_magic as *const u8 as *const c_void, - core::mem::size_of::<[u8; 2]>() as size_t, - ) != 0 as c_int + core::mem::size_of::<[u8; 2]>(), + ) != 0 { return LZMA_FORMAT_ERROR; } let crc: u32 = lzma_crc32( in_0.offset(core::mem::size_of::() as usize as isize), - (core::mem::size_of::() as size_t).wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), + (core::mem::size_of::()).wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), 0, ) as u32; if crc != read32le(in_0) { diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 94f8e67e..352bf5c9 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -1,58 +1,10 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; static lzma_header_magic: [u8; 6]; static lzma_footer_magic: [u8; 2]; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_stream_flags { - pub version: u32, - pub backward_size: lzma_vli, - pub check: lzma_check, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_bool1: lzma_bool, - pub reserved_bool2: lzma_bool, - pub reserved_bool3: lzma_bool, - pub reserved_bool4: lzma_bool, - pub reserved_bool5: lzma_bool, - pub reserved_bool6: lzma_bool, - pub reserved_bool7: lzma_bool, - pub reserved_bool8: lzma_bool, - pub reserved_int1: u32, - pub reserved_int2: u32, -} #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { @@ -62,9 +14,6 @@ extern "C" fn write32le(buf: *mut u8, num: u32) { *buf.offset(3) = (num >> 24) as u8; } } -pub const LZMA_CHECK_ID_MAX: lzma_check = 15; -pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4; -pub const LZMA_BACKWARD_SIZE_MAX: c_ulonglong = 1 << 34; pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2; #[inline] extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { @@ -95,7 +44,7 @@ pub unsafe extern "C" fn lzma_stream_header_encode( memcpy( out as *mut c_void, &raw const lzma_header_magic as *const u8 as *const c_void, - core::mem::size_of::<[u8; 6]>() as size_t, + core::mem::size_of::<[u8; 6]>(), ); if stream_flags_encode( options, @@ -146,7 +95,7 @@ pub unsafe extern "C" fn lzma_stream_footer_encode( out.offset((2 as c_int * 4) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut c_void, &raw const lzma_footer_magic as *const u8 as *const c_void, - core::mem::size_of::<[u8; 2]>() as size_t, + core::mem::size_of::<[u8; 2]>(), ); return LZMA_OK; } diff --git a/liblzma-rs/src/common/stream_mt.rs b/liblzma-rs/src/common/stream_mt.rs index 6273bc64..99f44eb2 100644 --- a/liblzma-rs/src/common/stream_mt.rs +++ b/liblzma-rs/src/common/stream_mt.rs @@ -1,4 +1,4 @@ -pub type lzma_mt = crate::common::stream_encoder_mt::lzma_mt; +pub type lzma_mt = crate::types::lzma_mt; pub use crate::common::stream_decoder_mt::lzma_stream_decoder_mt; pub use crate::common::stream_encoder_mt::{ diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 0dde3d36..29410e95 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -1,51 +1,9 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_long, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_char, c_int, c_uint, c_void}; extern "C" { - fn memchr(__s: *const c_void, __c: c_int, __n: size_t) -> *mut c_void; - fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn strlen(__s: *const c_char) -> size_t; fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_validate_chain(filters: *const lzma_filter, count: *mut size_t) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} #[derive(Copy, Clone)] #[repr(C)] pub struct C2RustUnnamed { @@ -87,103 +45,30 @@ pub struct name_value_map { pub name: [c_char; 12], pub value: u32, } -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; pub const OPTMAP_TYPE_LZMA_MATCH_FINDER: C2RustUnnamed_2 = 2; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; pub const OPTMAP_TYPE_LZMA_MODE: C2RustUnnamed_2 = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} pub const OPTMAP_TYPE_LZMA_PRESET: C2RustUnnamed_2 = 3; #[derive(Copy, Clone)] #[repr(C)] -pub struct lzma_options_delta { - pub type_0: lzma_delta_type, - pub dist: u32, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: u32, - pub reserved_int4: u32, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_bcj { - pub start_offset: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] pub struct lzma_str { pub buf: *mut c_char, pub pos: size_t, } pub type C2RustUnnamed_2 = c_uint; pub const OPTMAP_TYPE_UINT32: C2RustUnnamed_2 = 0; -pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const INT_MAX: c_int = c_int::MAX; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTERS_MAX: c_int = 4; pub const LZMA_STR_ALL_FILTERS: c_uint = 0x1; pub const LZMA_STR_NO_VALIDATION: c_uint = 0x2; pub const LZMA_STR_ENCODER: c_uint = 0x10; pub const LZMA_STR_DECODER: c_uint = 0x20; pub const LZMA_STR_GETOPT_LONG: c_uint = 0x40; pub const LZMA_STR_NO_SPACES: c_uint = 0x80; -pub const LZMA_FILTER_X86: c_ulonglong = 0x4; -pub const LZMA_FILTER_POWERPC: c_ulonglong = 0x5; -pub const LZMA_FILTER_IA64: c_ulonglong = 0x6; -pub const LZMA_FILTER_ARM: c_ulonglong = 0x7; -pub const LZMA_FILTER_ARMTHUMB: c_ulonglong = 0x8; -pub const LZMA_FILTER_SPARC: c_ulonglong = 0x9; -pub const LZMA_FILTER_ARM64: c_ulonglong = 0xa; -pub const LZMA_FILTER_RISCV: c_ulonglong = 0xb; -pub const LZMA_FILTER_DELTA: c_ulonglong = 0x3; pub const LZMA_DELTA_DIST_MIN: c_int = 1; -pub const LZMA_DELTA_DIST_MAX: c_int = 256; -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; -pub const LZMA_FILTER_LZMA2: c_ulonglong = 0x21; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; pub const LZMA_DICT_SIZE_DEFAULT: c_uint = 1u32 << 23; pub const LZMA_LCLP_MIN: c_int = 0; -pub const LZMA_LCLP_MAX: c_int = 4; pub const LZMA_PB_MIN: c_int = 0; -pub const LZMA_PB_MAX: c_int = 4; pub const LZMA_PRESET_DEFAULT: c_uint = 6; pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; -pub const LZMA_FILTER_RESERVED_START: c_ulonglong = 1 << 62; pub const STR_ALLOC_SIZE: c_int = 800; unsafe extern "C" fn str_init(str: *mut lzma_str, allocator: *const lzma_allocator) -> lzma_ret { (*str).buf = lzma_alloc(STR_ALLOC_SIZE as size_t, allocator) as *mut c_char; @@ -250,7 +135,7 @@ unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suf } let mut buf: [c_char; 16] = ::core::mem::transmute::<[u8; 16], [c_char; 16]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); - let mut pos: size_t = (core::mem::size_of::<[c_char; 16]>() as size_t).wrapping_sub(1); + let mut pos: size_t = (core::mem::size_of::<[c_char; 16]>()).wrapping_sub(1); loop { pos = pos.wrapping_sub(1); buf[pos as usize] = ('0' as i32 as u32).wrapping_add(v.wrapping_rem(10)) as c_char; @@ -296,8 +181,8 @@ extern "C" fn parse_bcj( str_end, filter_options, &raw const bcj_optmap as *const option_map, - (core::mem::size_of::<[option_map; 1]>() as size_t) - .wrapping_div(core::mem::size_of::() as size_t), + (core::mem::size_of::<[option_map; 1]>()) + .wrapping_div(core::mem::size_of::()), ) }; } @@ -329,8 +214,8 @@ extern "C" fn parse_delta( str_end, filter_options, &raw const delta_optmap as *const option_map, - (core::mem::size_of::<[option_map; 1]>() as size_t) - .wrapping_div(core::mem::size_of::() as size_t), + (core::mem::size_of::<[option_map; 1]>()) + .wrapping_div(core::mem::size_of::()), ) }; } @@ -442,8 +327,7 @@ unsafe extern "C" fn parse_lzma12( str_end, filter_options, &raw const lzma12_optmap as *const option_map, - (core::mem::size_of::<[option_map; 9]>() as size_t) - .wrapping_div(core::mem::size_of::() as size_t), + (core::mem::size_of::<[option_map; 9]>()).wrapping_div(core::mem::size_of::()), ); if !errmsg.is_null() { return errmsg; @@ -458,7 +342,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma1\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_LZMA1 as lzma_vli, + id: LZMA_FILTER_LZMA1, parse: Some( parse_lzma12 as unsafe extern "C" fn( @@ -475,7 +359,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma2\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_LZMA2 as lzma_vli, + id: LZMA_FILTER_LZMA2, parse: Some( parse_lzma12 as unsafe extern "C" fn( @@ -492,7 +376,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"x86\0\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_X86 as lzma_vli, + id: LZMA_FILTER_X86, parse: Some( parse_bcj as unsafe extern "C" fn( @@ -509,7 +393,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm\0\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_ARM as lzma_vli, + id: LZMA_FILTER_ARM, parse: Some( parse_bcj as unsafe extern "C" fn( @@ -526,7 +410,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"armthumb\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_ARMTHUMB as lzma_vli, + id: LZMA_FILTER_ARMTHUMB, parse: Some( parse_bcj as unsafe extern "C" fn( @@ -543,7 +427,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm64\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_ARM64 as lzma_vli, + id: LZMA_FILTER_ARM64, parse: Some( parse_bcj as unsafe extern "C" fn( @@ -560,7 +444,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"riscv\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_RISCV as lzma_vli, + id: LZMA_FILTER_RISCV, parse: Some( parse_bcj as unsafe extern "C" fn( @@ -577,7 +461,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"powerpc\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_POWERPC as lzma_vli, + id: LZMA_FILTER_POWERPC, parse: Some( parse_bcj as unsafe extern "C" fn( @@ -594,7 +478,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"ia64\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_IA64 as lzma_vli, + id: LZMA_FILTER_IA64, parse: Some( parse_bcj as unsafe extern "C" fn( @@ -611,7 +495,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"sparc\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_SPARC as lzma_vli, + id: LZMA_FILTER_SPARC, parse: Some( parse_bcj as unsafe extern "C" fn( @@ -628,7 +512,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { C2RustUnnamed { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"delta\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, - id: LZMA_FILTER_DELTA as lzma_vli, + id: LZMA_FILTER_DELTA, parse: Some( parse_delta as unsafe extern "C" fn( @@ -655,7 +539,7 @@ unsafe extern "C" fn parse_options( if **str as c_int == ',' as i32 { *str = (*str).offset(1); } else { - let str_len: size_t = str_end.offset_from(*str) as c_long as size_t; + let str_len: size_t = str_end.offset_from(*str) as size_t; let mut name_eq_value_end: *const c_char = memchr(*str as *const c_void, ',' as i32, str_len) as *const c_char; if name_eq_value_end.is_null() { @@ -664,13 +548,13 @@ unsafe extern "C" fn parse_options( let equals_sign: *const c_char = memchr( *str as *const c_void, '=' as i32, - name_eq_value_end.offset_from(*str) as c_long as size_t, + name_eq_value_end.offset_from(*str) as size_t, ) as *const c_char; if equals_sign.is_null() || **str as c_int == '=' as i32 { return b"Options must be 'name=value' pairs separated with commas\0" as *const u8 as *const c_char; } - let name_len: size_t = equals_sign.offset_from(*str) as c_long as size_t; + let name_len: size_t = equals_sign.offset_from(*str) as size_t; if name_len > NAME_LEN_MAX as size_t { return b"Unknown option name\0" as *const u8 as *const c_char; } @@ -691,7 +575,7 @@ unsafe extern "C" fn parse_options( i = i.wrapping_add(1); } *str = equals_sign.offset(1); - let value_len: size_t = name_eq_value_end.offset_from(*str) as c_long as size_t; + let value_len: size_t = name_eq_value_end.offset_from(*str) as size_t; if value_len == 0 { return b"Option value cannot be empty\0" as *const u8 as *const c_char; } @@ -841,7 +725,7 @@ unsafe extern "C" fn parse_filter( p = p.offset(1); } } - let name_len: size_t = name_end.offset_from(*str) as c_long as size_t; + let name_len: size_t = name_end.offset_from(*str) as size_t; if name_len > NAME_LEN_MAX as size_t { return b"Unknown filter name\0" as *const u8 as *const c_char; } @@ -858,9 +742,7 @@ unsafe extern "C" fn parse_filter( ) == 0 as c_int && filter_name_map[i as usize].name[name_len as usize] as c_int == '\0' as i32 { - if only_xz as c_int != 0 - && filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START as lzma_vli - { + if only_xz && filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START { return b"This filter cannot be used in the .xz format\0" as *const u8 as *const c_char; } @@ -928,10 +810,9 @@ unsafe extern "C" fn str_to_filters( if !errmsg.is_null() { return errmsg; } - let opts: *mut lzma_options_lzma = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_options_lzma; + let opts: *mut lzma_options_lzma = + lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_options_lzma; if opts.is_null() { return b"Memory allocation failed\0" as *const u8 as *const c_char; } @@ -939,10 +820,10 @@ unsafe extern "C" fn str_to_filters( lzma_free(opts as *mut c_void, allocator); return b"Unsupported preset\0" as *const u8 as *const c_char; } - (*filters.offset(0)).id = LZMA_FILTER_LZMA2 as lzma_vli; + (*filters.offset(0)).id = LZMA_FILTER_LZMA2; let ref mut fresh0 = (*filters.offset(0)).options; *fresh0 = opts as *mut c_void; - (*filters.offset(1)).id = LZMA_VLI_UNKNOWN as lzma_vli; + (*filters.offset(1)).id = LZMA_VLI_UNKNOWN; let ref mut fresh1 = (*filters.offset(1)).options; *fresh1 = core::ptr::null_mut(); return ::core::ptr::null::(); @@ -1003,13 +884,12 @@ unsafe extern "C" fn str_to_filters( } match current_block { 15090052786889560393 => { - temp_filters[i_0 as usize].id = LZMA_VLI_UNKNOWN as lzma_vli; + temp_filters[i_0 as usize].id = LZMA_VLI_UNKNOWN; temp_filters[i_0 as usize].options = core::ptr::null_mut(); if flags & LZMA_STR_NO_VALIDATION as u32 == 0 { let mut dummy: size_t = 0; let ret: lzma_ret = - lzma_validate_chain(&raw mut temp_filters as *mut lzma_filter, &raw mut dummy) - as lzma_ret; + lzma_validate_chain(&raw mut temp_filters as *mut lzma_filter, &raw mut dummy); if ret != LZMA_OK { errmsg = b"Invalid filter chain ('lzma2' missing at the end?)\0" as *const u8 as *const c_char; @@ -1027,7 +907,7 @@ unsafe extern "C" fn str_to_filters( filters as *mut c_void, &raw mut temp_filters as *mut lzma_filter as *const c_void, i_0.wrapping_add(1) - .wrapping_mul(core::mem::size_of::() as size_t), + .wrapping_mul(core::mem::size_of::()), ); return ::core::ptr::null::(); } @@ -1067,7 +947,7 @@ pub unsafe extern "C" fn lzma_str_to_filters( let mut used: *const c_char = str; let errmsg: *const c_char = str_to_filters(&raw mut used, filters, flags, allocator); if !error_pos.is_null() { - let n: size_t = used.offset_from(str) as c_long as size_t; + let n: size_t = used.offset_from(str) as size_t; *error_pos = if n > INT_MAX as size_t { INT_MAX } else { @@ -1160,14 +1040,14 @@ pub unsafe extern "C" fn lzma_str_from_filters( if flags & !supported_flags != 0 { return LZMA_OPTIONS_ERROR; } - if (*filters.offset(0)).id == LZMA_VLI_UNKNOWN as lzma_vli { + if (*filters.offset(0)).id == LZMA_VLI_UNKNOWN { return LZMA_OPTIONS_ERROR; } let mut dest: lzma_str = lzma_str { buf: core::ptr::null_mut(), pos: 0, }; - let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; + let ret_: lzma_ret = str_init(&raw mut dest, allocator); if ret_ != LZMA_OK { return ret_; } @@ -1178,7 +1058,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( b":\0" as *const u8 as *const c_char }; let mut i: size_t = 0; - while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN as lzma_vli { + while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN { if i == LZMA_FILTERS_MAX as size_t { str_free(&raw mut dest, allocator); return LZMA_OPTIONS_ERROR; @@ -1260,12 +1140,12 @@ pub unsafe extern "C" fn lzma_str_list_filters( buf: core::ptr::null_mut(), pos: 0, }; - let ret_: lzma_ret = str_init(&raw mut dest, allocator) as lzma_ret; + let ret_: lzma_ret = str_init(&raw mut dest, allocator); if ret_ != LZMA_OK { return ret_; } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; - let filter_delim: *const c_char = if show_opts as c_int != 0 { + let filter_delim: *const c_char = if show_opts { b"\n\0" as *const u8 as *const c_char } else { b" \0" as *const u8 as *const c_char @@ -1281,12 +1161,10 @@ pub unsafe extern "C" fn lzma_str_list_filters( < (core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) .wrapping_div(core::mem::size_of::() as usize) { - if !(filter_id != LZMA_VLI_UNKNOWN as lzma_vli - && filter_id != filter_name_map[i as usize].id) - { - if !(filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START as lzma_vli + if !(filter_id != LZMA_VLI_UNKNOWN && filter_id != filter_name_map[i as usize].id) { + if !(filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START && flags & LZMA_STR_ALL_FILTERS as u32 == 0 - && filter_id == LZMA_VLI_UNKNOWN as lzma_vli) + && filter_id == LZMA_VLI_UNKNOWN) { if first_filter_printed { str_append_str(&raw mut dest, filter_delim); diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index ae3cfa31..335a833a 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -1,27 +1,5 @@ use crate::types::*; use core::ffi::c_int; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_VLI_BYTES_MAX: c_int = 9; #[no_mangle] pub unsafe extern "C" fn lzma_vli_decode( vli: *mut lzma_vli, @@ -61,11 +39,11 @@ pub unsafe extern "C" fn lzma_vli_decode( if byte as c_int == 0 as c_int && *vli_pos > 1 { return LZMA_DATA_ERROR; } - return (if vli_pos == &raw mut vli_pos_internal { - LZMA_OK as c_int + return if vli_pos == &raw mut vli_pos_internal { + LZMA_OK } else { - LZMA_STREAM_END as c_int - }) as lzma_ret; + LZMA_STREAM_END + }; } if *vli_pos == LZMA_VLI_BYTES_MAX as size_t { return LZMA_DATA_ERROR; @@ -74,9 +52,9 @@ pub unsafe extern "C" fn lzma_vli_decode( break; } } - return (if vli_pos == &raw mut vli_pos_internal { - LZMA_DATA_ERROR as c_int + return if vli_pos == &raw mut vli_pos_internal { + LZMA_DATA_ERROR } else { - LZMA_OK as c_int - }) as lzma_ret; + LZMA_OK + }; } diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index 8b8e933d..77e19747 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -1,29 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong}; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); -pub const LZMA_VLI_BYTES_MAX: c_int = 9; +use core::ffi::c_int; #[no_mangle] pub unsafe extern "C" fn lzma_vli_encode( mut vli: lzma_vli, @@ -41,7 +17,7 @@ pub unsafe extern "C" fn lzma_vli_encode( } else if *out_pos >= out_size { return LZMA_BUF_ERROR; } - if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || vli > LZMA_VLI_MAX as lzma_vli { + if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || vli > LZMA_VLI_MAX { return LZMA_PROG_ERROR; } vli >>= (*vli_pos).wrapping_mul(7); @@ -51,19 +27,19 @@ pub unsafe extern "C" fn lzma_vli_encode( vli >>= 7 as c_int; *out_pos = (*out_pos).wrapping_add(1); if *out_pos == out_size { - return (if vli_pos == &raw mut vli_pos_internal { - LZMA_PROG_ERROR as c_int + return if vli_pos == &raw mut vli_pos_internal { + LZMA_PROG_ERROR } else { - LZMA_OK as c_int - }) as lzma_ret; + LZMA_OK + }; } } *out.offset(*out_pos as isize) = vli as u8; *out_pos = (*out_pos).wrapping_add(1); *vli_pos = (*vli_pos).wrapping_add(1); - return (if vli_pos == &raw mut vli_pos_internal { - LZMA_OK as c_int + return if vli_pos == &raw mut vli_pos_internal { + LZMA_OK } else { - LZMA_STREAM_END as c_int - }) as lzma_ret; + LZMA_STREAM_END + }; } diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index c1df75d5..b11f4ee3 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -1,10 +1,8 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong}; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_MAX: c_ulonglong = UINT64_MAX.wrapping_div(2); +use core::ffi::c_int; #[no_mangle] pub extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { - if vli > LZMA_VLI_MAX as lzma_vli { + if vli > LZMA_VLI_MAX { return 0; } let mut i: u32 = 0; diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index 5d8df537..c4f3d9e8 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -1,9 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { - fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -11,125 +8,7 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_delta { - pub type_0: lzma_delta_type, - pub dist: u32, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: u32, - pub reserved_int4: u32, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_delta_coder { - pub next: lzma_next_coder, - pub distance: size_t, - pub pos: u8, - pub history: [u8; LZMA_DELTA_DIST_MAX as usize], -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_DELTA_DIST_MIN: c_int = 1; -pub const LZMA_DELTA_DIST_MAX: c_int = 256; unsafe extern "C" fn delta_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; lzma_next_end(&raw mut (*coder).next, allocator); @@ -143,10 +22,8 @@ pub unsafe extern "C" fn lzma_delta_coder_init( ) -> lzma_ret { let mut coder: *mut lzma_delta_coder = (*next).coder as *mut lzma_delta_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_delta_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_delta_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -156,7 +33,7 @@ pub unsafe extern "C" fn lzma_delta_coder_init( as lzma_end_function; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -167,7 +44,7 @@ pub unsafe extern "C" fn lzma_delta_coder_init( set_out_limit: None, }; } - if lzma_delta_coder_memusage((*filters.offset(0)).options) == UINT64_MAX as u64 { + if lzma_delta_coder_memusage((*filters.offset(0)).options) == UINT64_MAX { return LZMA_OPTIONS_ERROR; } let opt: *const lzma_options_delta = (*filters.offset(0)).options as *const lzma_options_delta; @@ -188,7 +65,7 @@ pub unsafe extern "C" fn lzma_delta_coder_memusage(options: *const c_void) -> u6 || (*opt).dist < LZMA_DELTA_DIST_MIN as u32 || (*opt).dist > LZMA_DELTA_DIST_MAX as u32 { - return UINT64_MAX as u64; + return UINT64_MAX; } return core::mem::size_of::() as u64; } diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 5ab5e72b..4ff970fa 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -1,129 +1,12 @@ use crate::types::*; use core::ffi::{c_int, c_void}; extern "C" { - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; fn lzma_delta_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_delta { - pub type_0: lzma_delta_type, - pub dist: u32, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: u32, - pub reserved_int4: u32, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_delta_coder { - pub next: lzma_next_coder, - pub distance: size_t, - pub pos: u8, - pub history: [u8; LZMA_DELTA_DIST_MAX as usize], -} -pub const LZMA_DELTA_DIST_MAX: c_int = 256; unsafe extern "C" fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { let distance: size_t = (*coder).distance; let mut i: size_t = 0; @@ -162,7 +45,7 @@ unsafe extern "C" fn delta_decode( out_pos, out_size, action, - ) as lzma_ret; + ); let size: size_t = (*out_pos).wrapping_sub(out_start); if size > 0 { decode_buffer(coder, out.offset(out_start as isize), size); @@ -201,10 +84,9 @@ pub unsafe extern "C" fn lzma_delta_props_decode( if props_size != 1 { return LZMA_OPTIONS_ERROR; } - let opt: *mut lzma_options_delta = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_options_delta; + let opt: *mut lzma_options_delta = + lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_options_delta; if opt.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index 5ba5efec..14329c5e 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::{c_int, c_void}; extern "C" { fn lzma_next_filter_update( next: *mut lzma_next_coder, @@ -13,123 +13,6 @@ extern "C" { filters: *const lzma_filter_info, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_delta { - pub type_0: lzma_delta_type, - pub dist: u32, - pub reserved_int1: u32, - pub reserved_int2: u32, - pub reserved_int3: u32, - pub reserved_int4: u32, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_delta_coder { - pub next: lzma_next_coder, - pub distance: size_t, - pub pos: u8, - pub history: [u8; LZMA_DELTA_DIST_MAX as usize], -} -pub const LZMA_DELTA_DIST_MAX: c_int = 256; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const LZMA_DELTA_DIST_MIN: c_int = 1; unsafe extern "C" fn copy_and_encode( coder: *mut lzma_delta_coder, @@ -194,11 +77,11 @@ unsafe extern "C" fn delta_encode( } *in_pos = (*in_pos).wrapping_add(size); *out_pos = (*out_pos).wrapping_add(size); - ret = (if action != LZMA_RUN && *in_pos == in_size { - LZMA_STREAM_END as c_int + ret = if action != LZMA_RUN && *in_pos == in_size { + LZMA_STREAM_END } else { - LZMA_OK as c_int - }) as lzma_ret; + LZMA_OK + }; } else { let out_start: size_t = *out_pos; ret = (*coder).next.code.expect("non-null function pointer")( @@ -273,7 +156,7 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( } #[no_mangle] pub unsafe extern "C" fn lzma_delta_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { - if lzma_delta_coder_memusage(options) == UINT64_MAX as u64 { + if lzma_delta_coder_memusage(options) == UINT64_MAX { return LZMA_PROG_ERROR; } let opt: *const lzma_options_delta = options as *const lzma_options_delta; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 549631b9..d73c7710 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -1,9 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_int, c_ulong, c_void}; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -11,111 +8,6 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_dict { - pub buf: *mut u8, - pub pos: size_t, - pub full: size_t, - pub limit: size_t, - pub size: size_t, - pub has_wrapped: bool, - pub need_reset: bool, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -125,23 +17,6 @@ pub struct lzma_lz_options { } #[derive(Copy, Clone)] #[repr(C)] -pub struct lzma_lz_decoder { - pub coder: *mut c_void, - pub code: Option< - unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret, - >, - pub reset: Option ()>, - pub set_uncompressed: Option ()>, - pub end: Option ()>, -} -#[derive(Copy, Clone)] -#[repr(C)] pub struct lzma_coder { pub dict: lzma_dict, pub lz: lzma_lz_decoder, @@ -157,10 +32,8 @@ pub struct C2RustUnnamed { pub size: size_t, pub buffer: [u8; LZMA_BUFFER_SIZE as usize], } -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; pub const LZMA_BUFFER_SIZE: c_int = 4096; pub const LZ_DICT_EXTRA: c_int = 0; pub const LZ_DICT_REPEAT_MAX: c_int = 288; @@ -220,7 +93,7 @@ unsafe extern "C" fn decode_buffer( in_0, in_pos, in_size, - ) as lzma_ret; + ); let copy_size: size_t = (*coder).dict.pos.wrapping_sub(dict_start); if copy_size > 0 { memcpy( @@ -269,7 +142,7 @@ unsafe extern "C" fn lz_decode( &raw mut (*coder).temp.size, LZMA_BUFFER_SIZE as size_t, action, - ) as lzma_ret; + ); if ret == LZMA_STREAM_END { (*coder).next_finished = true; } else if ret != LZMA_OK || (*coder).temp.size == 0 { @@ -293,12 +166,12 @@ unsafe extern "C" fn lz_decode( out, out_pos, out_size, - ) as lzma_ret; + ); if ret_0 == LZMA_STREAM_END { (*coder).this_finished = true; } else if ret_0 != LZMA_OK { return ret_0; - } else if (*coder).next_finished as c_int != 0 && *out_pos < out_size { + } else if (*coder).next_finished && *out_pos < out_size { return LZMA_DATA_ERROR; } } @@ -332,8 +205,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( ) -> lzma_ret { let mut coder: *mut lzma_coder = (*next).coder as *mut lzma_coder; if coder.is_null() { - coder = - lzma_alloc(core::mem::size_of::() as size_t, allocator) as *mut lzma_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -360,7 +232,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( (*coder).lz = LZMA_LZ_DECODER_INIT; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -382,7 +254,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( (*filters.offset(0)).id, (*filters.offset(0)).options, &raw mut lz_options, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index ddfedb50..cb05ad82 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -1,12 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn memmove(__dst: *mut c_void, __src: *const c_void, __len: size_t) -> *mut c_void; - fn memset(__b: *mut c_void, __c: c_int, __len: size_t) -> *mut c_void; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -37,139 +31,6 @@ extern "C" { fn lzma_mf_bt4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; fn lzma_mf_bt4_skip(dict: *mut lzma_mf, amount: u32); } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_match { - pub len: u32, - pub dist: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_mf_s { - pub buffer: *mut u8, - pub size: u32, - pub keep_size_before: u32, - pub keep_size_after: u32, - pub offset: u32, - pub read_pos: u32, - pub read_ahead: u32, - pub read_limit: u32, - pub write_pos: u32, - pub pending: u32, - pub find: Option u32>, - pub skip: Option ()>, - pub hash: *mut u32, - pub son: *mut u32, - pub cyclic_pos: u32, - pub cyclic_size: u32, - pub hash_mask: u32, - pub depth: u32, - pub nice_len: u32, - pub match_len_max: u32, - pub action: lzma_action, - pub hash_count: u32, - pub sons_count: u32, -} -pub type lzma_mf = lzma_mf_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -185,25 +46,11 @@ pub struct lzma_lz_options { } #[derive(Copy, Clone)] #[repr(C)] -pub struct lzma_lz_encoder { - pub coder: *mut c_void, - pub code: Option< - unsafe extern "C" fn(*mut c_void, *mut lzma_mf, *mut u8, *mut size_t, size_t) -> lzma_ret, - >, - pub end: Option ()>, - pub options_update: Option lzma_ret>, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] pub struct lzma_coder { pub lz: lzma_lz_encoder, pub mf: lzma_mf, pub next: lzma_next_coder, } -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; #[inline] extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { return match_finder as u32 & 0xf as u32; @@ -246,11 +93,11 @@ unsafe extern "C" fn fill_window( &raw mut write_pos, (*coder).mf.size as size_t, ); - ret = (if action != LZMA_RUN && *in_pos == in_size { - LZMA_STREAM_END as c_int + ret = if action != LZMA_RUN && *in_pos == in_size { + LZMA_STREAM_END } else { - LZMA_OK as c_int - }) as lzma_ret; + LZMA_OK + }; } else { ret = (*coder).next.code.expect("non-null function pointer")( (*coder).next.coder, @@ -302,8 +149,7 @@ unsafe extern "C" fn lz_encode( let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; while *out_pos < out_size && (*in_pos < in_size || action != LZMA_RUN) { if (*coder).mf.action == LZMA_RUN && (*coder).mf.read_pos >= (*coder).mf.read_limit { - let ret_: lzma_ret = - fill_window(coder, allocator, in_0, in_pos, in_size, action) as lzma_ret; + let ret_: lzma_ret = fill_window(coder, allocator, in_0, in_pos, in_size, action); if ret_ != LZMA_OK { return ret_; } @@ -314,7 +160,7 @@ unsafe extern "C" fn lz_encode( out, out_pos, out_size, - ) as lzma_ret; + ); if ret != LZMA_OK { (*coder).mf.action = LZMA_RUN; return ret; @@ -485,11 +331,11 @@ unsafe extern "C" fn lz_encoder_init( (*mf).pending = 0; if (*mf).hash.is_null() { (*mf).hash = lzma_alloc_zero( - ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::() as size_t), + ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::()), allocator, ) as *mut u32; (*mf).son = lzma_alloc( - ((*mf).sons_count as size_t).wrapping_mul(core::mem::size_of::() as size_t), + ((*mf).sons_count as size_t).wrapping_mul(core::mem::size_of::()), allocator, ) as *mut u32; if (*mf).hash.is_null() || (*mf).son.is_null() { @@ -503,7 +349,7 @@ unsafe extern "C" fn lz_encoder_init( memset( (*mf).hash as *mut c_void, 0 as c_int, - ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::() as size_t), + ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::()), ); } (*mf).cyclic_pos = 0; @@ -561,7 +407,7 @@ pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) - lz_options, ) } { - return UINT64_MAX as u64; + return UINT64_MAX; } return (mf.hash_count as u64) .wrapping_add(mf.sons_count as u64) @@ -592,12 +438,11 @@ unsafe extern "C" fn lz_encoder_update( if (*coder).lz.options_update.is_none() { return LZMA_PROG_ERROR; } - let ret_: lzma_ret = (*coder) - .lz - .options_update - .expect("non-null function pointer")( - (*coder).lz.coder, reversed_filters - ) as lzma_ret; + let ret_: lzma_ret = + (*coder) + .lz + .options_update + .expect("non-null function pointer")((*coder).lz.coder, reversed_filters); if ret_ != LZMA_OK { return ret_; } @@ -640,8 +485,7 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( ) -> lzma_ret { let mut coder: *mut lzma_coder = (*next).coder as *mut lzma_coder; if coder.is_null() { - coder = - lzma_alloc(core::mem::size_of::() as size_t, allocator) as *mut lzma_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -698,7 +542,7 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( (*coder).mf.sons_count = 0; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, @@ -726,7 +570,7 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( (*filters.offset(0)).id, (*filters.offset(0)).options, &raw mut lz_options, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 2f6960f2..fa09f79f 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -1,48 +1,8 @@ use crate::types::*; -use core::ffi::{c_int, c_long, c_uint}; +use core::ffi::{c_int, c_uint}; extern "C" { static lzma_crc32_table: [[u32; 256]; 8]; } -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_match { - pub len: u32, - pub dist: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_mf_s { - pub buffer: *mut u8, - pub size: u32, - pub keep_size_before: u32, - pub keep_size_after: u32, - pub offset: u32, - pub read_pos: u32, - pub read_ahead: u32, - pub read_limit: u32, - pub write_pos: u32, - pub pending: u32, - pub find: Option u32>, - pub skip: Option ()>, - pub hash: *mut u32, - pub son: *mut u32, - pub cyclic_pos: u32, - pub cyclic_size: u32, - pub hash_mask: u32, - pub depth: u32, - pub nice_len: u32, - pub match_len_max: u32, - pub action: lzma_action, - pub hash_count: u32, - pub sons_count: u32, -} -pub type lzma_mf = lzma_mf_s; -pub const UINT32_MAX: c_uint = 4294967295; #[inline] unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); @@ -128,7 +88,7 @@ unsafe extern "C" fn move_pos(mf: *mut lzma_mf) { (*mf).cyclic_pos = 0; } (*mf).read_pos = (*mf).read_pos.wrapping_add(1); - if ((*mf).read_pos.wrapping_add((*mf).offset) == 4294967295) as c_int as c_long != 0 { + if (*mf).read_pos.wrapping_add((*mf).offset) == 4294967295 { normalize(mf); } } @@ -184,7 +144,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 3 || 0 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 3 || false && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0; } @@ -226,7 +186,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m matches.offset(matches_count as isize), len_best, ) - .offset_from(matches) as c_long as u32; + .offset_from(matches) as u32; move_pos(mf); return matches_count; } @@ -262,7 +222,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 4 || 0 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 4 || false && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0; } @@ -332,7 +292,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m matches.offset(matches_count as isize), len_best, ) - .offset_from(matches) as c_long as u32; + .offset_from(matches) as u32; move_pos(mf); return matches_count; } @@ -487,7 +447,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 2 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 2 || true && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0; } @@ -509,7 +469,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_m matches.offset(matches_count as isize), 1, ) - .offset_from(matches) as c_long as u32; + .offset_from(matches) as u32; move_pos(mf); return matches_count; } @@ -521,7 +481,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_8 = 11875828834189669668; - } else if len_limit < 2 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 2 || true && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_8 = 18088007599891946824; } else { @@ -559,7 +519,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 3 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 3 || true && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0; } @@ -610,7 +570,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m matches.offset(matches_count as isize), len_best, ) - .offset_from(matches) as c_long as u32; + .offset_from(matches) as u32; move_pos(mf); return matches_count; } @@ -622,7 +582,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_9 = 11875828834189669668; - } else if len_limit < 3 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 3 || true && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_9 = 18088007599891946824; } else { @@ -668,7 +628,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - } else if len_limit < 4 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 4 || true && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); return 0; } @@ -747,7 +707,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m matches.offset(matches_count as isize), len_best, ) - .offset_from(matches) as c_long as u32; + .offset_from(matches) as u32; move_pos(mf); return matches_count; } @@ -759,7 +719,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; current_block_10 = 11875828834189669668; - } else if len_limit < 4 || 1 as c_int != 0 && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 4 || true && (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); current_block_10 = 18088007599891946824; } else { diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index 2b6e645b..1002a6f4 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -1,8 +1,6 @@ use crate::types::*; use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_bufcpy( in_0: *const u8, in_pos: *mut size_t, @@ -34,136 +32,6 @@ extern "C" { lz_options: *mut lzma_lz_options, ) -> lzma_ret; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -173,34 +41,6 @@ pub struct lzma_lz_options { } #[derive(Copy, Clone)] #[repr(C)] -pub struct lzma_lz_decoder { - pub coder: *mut c_void, - pub code: Option< - unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret, - >, - pub reset: Option ()>, - pub set_uncompressed: Option ()>, - pub end: Option ()>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_dict { - pub buf: *mut u8, - pub pos: size_t, - pub full: size_t, - pub limit: size_t, - pub size: size_t, - pub has_wrapped: bool, - pub need_reset: bool, -} -#[derive(Copy, Clone)] -#[repr(C)] pub struct lzma_lzma2_coder { pub sequence: sequence, pub next_sequence: sequence, @@ -220,7 +60,6 @@ pub const SEQ_COMPRESSED_0: sequence = 3; pub const SEQ_UNCOMPRESSED_2: sequence = 2; pub const SEQ_UNCOMPRESSED_1: sequence = 1; pub const SEQ_CONTROL: sequence = 0; -pub const UINT32_MAX: c_uint = 4294967295; pub const LZ_DICT_REPEAT_MAX: c_int = 288; pub const LZ_DICT_INIT_POS: c_int = 2 * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { @@ -368,7 +207,7 @@ unsafe extern "C" fn lzma2_decode( in_0, in_pos, in_size, - ) as lzma_ret; + ); let in_used: size_t = (*in_pos).wrapping_sub(in_start); if in_used > (*coder).compressed_size { return LZMA_DATA_ERROR; @@ -414,10 +253,8 @@ unsafe extern "C" fn lzma2_decoder_init( ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_lzma2_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_lzma2_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -491,16 +328,14 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if props_size != 1 { return LZMA_OPTIONS_ERROR; } - if *props.offset(0) as c_int & 0xc0 as c_int != 0 { + if *props.offset(0) as c_int & 0xc0 != 0 { return LZMA_OPTIONS_ERROR; } if *props.offset(0) as c_int > 40 as c_int { return LZMA_OPTIONS_ERROR; } - let opt: *mut lzma_options_lzma = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_options_lzma; + let opt: *mut lzma_options_lzma = + lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_options_lzma; if opt.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index d9fe0485..2db3a488 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -1,13 +1,10 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_uint, c_void}; #[repr(C)] pub struct lzma_lzma1_encoder_s { _opaque: [u8; 0], } extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_bufcpy( in_0: *const u8, in_pos: *mut size_t, @@ -53,170 +50,6 @@ extern "C" { ) -> lzma_ret; static lzma_fastpos: [u8; 8192]; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_match { - pub len: u32, - pub dist: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_mf_s { - pub buffer: *mut u8, - pub size: u32, - pub keep_size_before: u32, - pub keep_size_after: u32, - pub offset: u32, - pub read_pos: u32, - pub read_ahead: u32, - pub read_limit: u32, - pub write_pos: u32, - pub pending: u32, - pub find: Option u32>, - pub skip: Option ()>, - pub hash: *mut u32, - pub son: *mut u32, - pub cyclic_pos: u32, - pub cyclic_size: u32, - pub hash_mask: u32, - pub depth: u32, - pub nice_len: u32, - pub match_len_max: u32, - pub action: lzma_action, - pub hash_count: u32, - pub sons_count: u32, -} -pub type lzma_mf = lzma_mf_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -230,17 +63,6 @@ pub struct lzma_lz_options { pub preset_dict: *const u8, pub preset_dict_size: u32, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_lz_encoder { - pub coder: *mut c_void, - pub code: Option< - unsafe extern "C" fn(*mut c_void, *mut lzma_mf, *mut u8, *mut size_t, size_t) -> lzma_ret, - >, - pub end: Option ()>, - pub options_update: Option lzma_ret>, - pub set_out_limit: Option lzma_ret>, -} pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; #[derive(Copy, Clone)] #[repr(C)] @@ -262,11 +84,6 @@ pub const SEQ_UNCOMPRESSED_HEADER: C2RustUnnamed = 3; pub const SEQ_LZMA_COPY: C2RustUnnamed = 2; pub const SEQ_LZMA_ENCODE: C2RustUnnamed = 1; pub const SEQ_INIT: C2RustUnnamed = 0; -pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; -pub const LZMA_LCLP_MAX: c_int = 4; -pub const LZMA_PB_MAX: c_int = 4; #[inline] unsafe extern "C" fn mf_unencoded(mf: *const lzma_mf) -> u32 { return (*mf) @@ -395,17 +212,17 @@ unsafe extern "C" fn lzma2_encode( *out_pos = (*out_pos).wrapping_add(1); *out.offset(fresh0 as isize) = 0; } - return (if (*mf).action == LZMA_RUN { - LZMA_OK as c_int + return if (*mf).action == LZMA_RUN { + LZMA_OK } else { - LZMA_STREAM_END as c_int - }) as lzma_ret; + LZMA_STREAM_END + }; } if (*coder).need_state_reset { let ret_: lzma_ret = lzma_lzma_encoder_reset( (*coder).lzma as *mut lzma_lzma1_encoder, &raw mut (*coder).opt_cur, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -480,7 +297,7 @@ unsafe extern "C" fn lzma2_encode( &raw mut (*coder).compressed_size, LZMA2_CHUNK_MAX as size_t, limit, - ) as lzma_ret; + ); (*coder).uncompressed_size = (*coder).uncompressed_size.wrapping_add( (*mf) .read_pos @@ -572,10 +389,8 @@ unsafe extern "C" fn lzma2_encoder_init( } let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; if coder.is_null() { - coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_lzma2_coder; + coder = lzma_alloc(core::mem::size_of::(), allocator) + as *mut lzma_lzma2_coder; if coder.is_null() { return LZMA_MEM_ERROR; } @@ -622,7 +437,7 @@ unsafe extern "C" fn lzma2_encoder_init( 0x21 as lzma_vli, &raw mut (*coder).opt_cur, lz_options, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -661,8 +476,8 @@ pub unsafe extern "C" fn lzma_lzma2_encoder_init( #[no_mangle] pub extern "C" fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64 { let lzma_mem: u64 = unsafe { lzma_lzma_encoder_memusage(options) } as u64; - if lzma_mem == UINT64_MAX as u64 { - return UINT64_MAX as u64; + if lzma_mem == UINT64_MAX { + return UINT64_MAX; } return (core::mem::size_of::() as u64).wrapping_add(lzma_mem); } @@ -696,7 +511,7 @@ pub unsafe extern "C" fn lzma_lzma2_block_size(options: *const c_void) -> u64 { if !((*opt).dict_size >= LZMA_DICT_SIZE_MIN as u32 && (*opt).dict_size <= (1u32 << 30).wrapping_add((1) << 29)) { - return UINT64_MAX as u64; + return UINT64_MAX; } return if ((*opt).dict_size as u64).wrapping_mul(3) > (1) << 20 { ((*opt).dict_size as u64).wrapping_mul(3) diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 10271286..788992e0 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -1,9 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_long, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_long, c_uint, c_void}; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_lz_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -20,147 +17,6 @@ extern "C" { ) -> lzma_ret; fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_dict { - pub buf: *mut u8, - pub pos: size_t, - pub full: size_t, - pub limit: size_t, - pub size: size_t, - pub has_wrapped: bool, - pub need_reset: bool, -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -170,35 +26,6 @@ pub struct lzma_lz_options { } #[derive(Copy, Clone)] #[repr(C)] -pub struct lzma_lz_decoder { - pub coder: *mut c_void, - pub code: Option< - unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret, - >, - pub reset: Option ()>, - pub set_uncompressed: Option ()>, - pub end: Option ()>, -} -pub const STATE_NONLIT_REP: lzma_lzma_state = 11; -pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; -pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; -pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; -pub const STATE_LIT_MATCH: lzma_lzma_state = 7; -pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; -pub const STATE_REP_LIT: lzma_lzma_state = 5; -pub const STATE_MATCH_LIT: lzma_lzma_state = 4; -pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; -pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; -pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; -pub const STATE_LIT_LIT: lzma_lzma_state = 0; -#[derive(Copy, Clone)] -#[repr(C)] pub struct lzma_lzma1_decoder { pub literal: [probability; 12288], pub is_match: [[probability; 16]; 12], @@ -270,8 +97,6 @@ pub struct lzma_length_decoder { pub mid: [[probability; 8]; 16], pub high: [probability; 256], } -pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { @@ -282,10 +107,6 @@ extern "C" fn read32le(buf: *const u8) -> u32 { num }; } -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; -pub const LZMA_LCLP_MAX: c_int = 4; -pub const LZMA_PB_MAX: c_int = 4; pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; pub const LZ_DICT_REPEAT_MAX: c_int = 288; pub const LZ_DICT_INIT_POS: c_int = 2 * LZ_DICT_REPEAT_MAX; @@ -418,7 +239,7 @@ unsafe extern "C" fn rc_read_init( if *in_pos == in_size { return LZMA_OK; } - if (*rc).init_bytes_left == 5 && *in_0.offset(*in_pos as isize) as c_int != 0 as c_int { + if (*rc).init_bytes_left == 5 && *in_0.offset(*in_pos as isize) != 0 { return LZMA_DATA_ERROR; } (*rc).code = (*rc).code << 8 | *in_0.offset(*in_pos as isize) as u32; @@ -436,7 +257,7 @@ unsafe extern "C" fn lzma_decode( ) -> lzma_ret { let mut current_block: u64; let coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; - let ret: lzma_ret = rc_read_init(&raw mut (*coder).rc, in_0, in_pos, in_size) as lzma_ret; + let ret: lzma_ret = rc_read_init(&raw mut (*coder).rc, in_0, in_pos, in_size); if ret != LZMA_STREAM_END { return ret; } @@ -466,9 +287,9 @@ unsafe extern "C" fn lzma_decode( let literal_context_bits: u32 = (*coder).literal_context_bits; let mut pos_state: u32 = (dict.pos & pos_mask as size_t) as u32; let mut ret_0: lzma_ret = LZMA_OK; - let mut eopm_is_valid: bool = (*coder).uncompressed_size == LZMA_VLI_UNKNOWN as lzma_vli; + let mut eopm_is_valid: bool = (*coder).uncompressed_size == LZMA_VLI_UNKNOWN; let mut might_finish_without_eopm: bool = false; - if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli + if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN && (*coder).uncompressed_size <= dict.limit.wrapping_sub(dict.pos) as lzma_vli { dict.limit = dict.pos.wrapping_add((*coder).uncompressed_size as size_t); @@ -791,7 +612,7 @@ unsafe extern "C" fn lzma_decode( (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as c_int - ((*coder).is_rep[state as usize] as c_int >> RC_MOVE_BITS)) as probability; - if !(!dict_is_distance_valid(&raw mut dict, 0) as c_int as c_long != 0) { + if !(!dict_is_distance_valid(&raw mut dict, 0)) { current_block = 4420799852307653083; continue; } @@ -813,11 +634,11 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *fresh137 as u32; } } - ret_0 = (if rc.code == 0 { - LZMA_STREAM_END as c_int + ret_0 = if rc.code == 0 { + LZMA_STREAM_END } else { - LZMA_DATA_ERROR as c_int - }) as lzma_ret; + LZMA_DATA_ERROR + }; current_block = 4609795085482299213; continue; } @@ -1179,9 +1000,7 @@ unsafe extern "C" fn lzma_decode( } } 5979571030476392895 => { - if (might_finish_without_eopm as c_int != 0 && dict.pos == dict.limit) as c_long - != 0 - { + if (might_finish_without_eopm && dict.pos == dict.limit) as c_long != 0 { if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_NORMALIZE; @@ -1402,8 +1221,7 @@ unsafe extern "C" fn lzma_decode( } match current_block { 13383302701878543647 => { - if !(!dict_is_distance_valid(&raw mut dict, rep0 as size_t) as c_int as c_long != 0) - { + if !(!dict_is_distance_valid(&raw mut dict, rep0 as size_t)) { current_block = 17340485688450593529; continue; } @@ -1413,8 +1231,7 @@ unsafe extern "C" fn lzma_decode( } 4956146061682418353 => loop { pos_state = (dict.pos & pos_mask as size_t) as u32; - if (!(rc_in_ptr < rc_in_fast_end) || dict.pos == dict.limit) as c_int as c_long != 0 - { + if !(rc_in_ptr < rc_in_fast_end) || dict.pos == dict.limit { current_block = 5979571030476392895; continue 'c_9380; } @@ -2931,7 +2748,7 @@ unsafe extern "C" fn lzma_decode( (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as c_int - ((*coder).is_rep[state as usize] as c_int >> RC_MOVE_BITS)) as probability; - if !dict_is_distance_valid(&raw mut dict, 0) as c_int as c_long != 0 { + if !dict_is_distance_valid(&raw mut dict, 0) { ret_0 = LZMA_DATA_ERROR; current_block = 4609795085482299213; continue 'c_9380; @@ -3719,7 +3536,7 @@ unsafe extern "C" fn lzma_decode( } (*dictptr).full = dict.full; (*coder).rc = rc; - *in_pos = rc_in_ptr.offset_from(in_0) as c_long as size_t; + *in_pos = rc_in_ptr.offset_from(in_0) as size_t; (*coder).state = state as lzma_lzma_state; (*coder).rep0 = rep0; (*coder).rep1 = rep1; @@ -3730,7 +3547,7 @@ unsafe extern "C" fn lzma_decode( (*coder).limit = limit; (*coder).offset = offset; (*coder).len = len; - if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN as lzma_vli { + if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN { (*coder).uncompressed_size = (*coder) .uncompressed_size .wrapping_sub(dict.pos.wrapping_sub(dict_start) as lzma_vli); @@ -3874,10 +3691,7 @@ pub unsafe extern "C" fn lzma_lzma_decoder_create( lz_options: *mut lzma_lz_options, ) -> lzma_ret { if (*lz).coder.is_null() { - (*lz).coder = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ); + (*lz).coder = lzma_alloc(core::mem::size_of::(), allocator); if (*lz).coder.is_null() { return LZMA_MEM_ERROR; } @@ -3923,9 +3737,9 @@ unsafe extern "C" fn lzma_decoder_init( if !is_lclppb_valid(options as *const lzma_options_lzma) { return LZMA_PROG_ERROR; } - let mut uncomp_size: lzma_vli = LZMA_VLI_UNKNOWN as lzma_vli; + let mut uncomp_size: lzma_vli = LZMA_VLI_UNKNOWN; let mut allow_eopm: bool = true; - if id == LZMA_FILTER_LZMA1EXT as lzma_vli { + if id == LZMA_FILTER_LZMA1EXT { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; if (*opt).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; @@ -3933,14 +3747,14 @@ unsafe extern "C" fn lzma_decoder_init( uncomp_size = ((*opt).ext_size_low as u64).wrapping_add(((*opt).ext_size_high as u64) << 32) as lzma_vli; allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 - || uncomp_size == LZMA_VLI_UNKNOWN as lzma_vli; + || uncomp_size == LZMA_VLI_UNKNOWN; } let ret_: lzma_ret = lzma_lzma_decoder_create( lz, allocator, options as *const lzma_options_lzma, lz_options, - ) as lzma_ret; + ); if ret_ != LZMA_OK { return ret_; } @@ -3995,7 +3809,7 @@ pub extern "C" fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> #[no_mangle] pub extern "C" fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64 { if !unsafe { is_lclppb_valid(options as *const lzma_options_lzma) } { - return UINT64_MAX as u64; + return UINT64_MAX; } return lzma_lzma_decoder_memusage_nocheck(options); } @@ -4009,10 +3823,8 @@ pub unsafe extern "C" fn lzma_lzma_props_decode( if props_size != 5 { return LZMA_OPTIONS_ERROR; } - let opt: *mut lzma_options_lzma = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_options_lzma; + let opt: *mut lzma_options_lzma = + lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_options_lzma; if opt.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 3fb6eea7..d115de95 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,7 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_long, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_int, c_long, c_uint, c_void}; extern "C" { - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; fn lzma_lz_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -33,170 +32,6 @@ extern "C" { ); static lzma_fastpos: [u8; 8192]; } -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_match { - pub len: u32, - pub dist: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_mf_s { - pub buffer: *mut u8, - pub size: u32, - pub keep_size_before: u32, - pub keep_size_after: u32, - pub offset: u32, - pub read_pos: u32, - pub read_ahead: u32, - pub read_limit: u32, - pub write_pos: u32, - pub pending: u32, - pub find: Option u32>, - pub skip: Option ()>, - pub hash: *mut u32, - pub son: *mut u32, - pub cyclic_pos: u32, - pub cyclic_size: u32, - pub hash_mask: u32, - pub depth: u32, - pub nice_len: u32, - pub match_len_max: u32, - pub action: lzma_action, - pub hash_count: u32, - pub sons_count: u32, -} -pub type lzma_mf = lzma_mf_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -212,17 +47,6 @@ pub struct lzma_lz_options { } #[derive(Copy, Clone)] #[repr(C)] -pub struct lzma_lz_encoder { - pub coder: *mut c_void, - pub code: Option< - unsafe extern "C" fn(*mut c_void, *mut lzma_mf, *mut u8, *mut size_t, size_t) -> lzma_ret, - >, - pub end: Option ()>, - pub options_update: Option lzma_ret>, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] pub struct lzma_range_encoder { pub low: u64, pub cache_size: u64, @@ -240,18 +64,6 @@ pub const RC_DIRECT_1: C2RustUnnamed = 3; pub const RC_DIRECT_0: C2RustUnnamed = 2; pub const RC_BIT_1: C2RustUnnamed = 1; pub const RC_BIT_0: C2RustUnnamed = 0; -pub const STATE_NONLIT_REP: lzma_lzma_state = 11; -pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; -pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; -pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; -pub const STATE_LIT_MATCH: lzma_lzma_state = 7; -pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; -pub const STATE_REP_LIT: lzma_lzma_state = 5; -pub const STATE_MATCH_LIT: lzma_lzma_state = 4; -pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; -pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; -pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; -pub const STATE_LIT_LIT: lzma_lzma_state = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma1_encoder_s { @@ -319,8 +131,6 @@ pub struct lzma_length_encoder { pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const UINT32_MAX: c_uint = 4294967295; -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { @@ -330,10 +140,6 @@ extern "C" fn write32le(buf: *mut u8, num: u32) { *buf.offset(3) = (num >> 24) as u8; } } -pub const LZMA_FILTER_LZMA1: c_ulonglong = 0x4000000000000001; -pub const LZMA_FILTER_LZMA1EXT: c_ulonglong = 0x4000000000000002; -pub const LZMA_LCLP_MAX: c_int = 4; -pub const LZMA_PB_MAX: c_int = 4; pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; #[inline] @@ -1150,9 +956,7 @@ pub unsafe extern "C" fn lzma_lzma_encode( ); } encode_symbol(coder, mf, back, len, (*coder).uncomp_size as u32); - if (*coder).out_limit != 0 - && rc_encode_dummy(&raw mut (*coder).rc, (*coder).out_limit) as c_int != 0 - { + if (*coder).out_limit != 0 && rc_encode_dummy(&raw mut (*coder).rc, (*coder).out_limit) { rc_forget(&raw mut (*coder).rc); break; } else { @@ -1210,16 +1014,13 @@ unsafe extern "C" fn lzma_lzma_set_out_limit( } extern "C" fn is_options_valid(options: *const lzma_options_lzma) -> bool { return unsafe { - is_lclppb_valid(options) as c_int != 0 + is_lclppb_valid(options) && (*options).nice_len >= MATCH_LEN_MIN as u32 && (*options).nice_len <= MATCH_LEN_MAX as u32 && ((*options).mode == LZMA_MODE_FAST || (*options).mode == LZMA_MODE_NORMAL) }; } -extern "C" fn set_lz_options( - lz_options: *mut lzma_lz_options, - options: *const lzma_options_lzma, -) { +extern "C" fn set_lz_options(lz_options: *mut lzma_lz_options, options: *const lzma_options_lzma) { unsafe { (*lz_options).before_size = OPTS as size_t; (*lz_options).dict_size = (*options).dict_size as size_t; @@ -1356,10 +1157,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( lz_options: *mut lzma_lz_options, ) -> lzma_ret { if (*coder_ptr).is_null() { - *coder_ptr = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ); + *coder_ptr = lzma_alloc(core::mem::size_of::(), allocator); if (*coder_ptr).is_null() { return LZMA_MEM_ERROR; } @@ -1398,8 +1196,8 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( (*coder).uncomp_size = 0; (*coder).uncomp_size_ptr = core::ptr::null_mut(); (*coder).out_limit = 0; - (*coder).use_eopm = id == LZMA_FILTER_LZMA1 as lzma_vli; - if id == LZMA_FILTER_LZMA1EXT as lzma_vli { + (*coder).use_eopm = id == LZMA_FILTER_LZMA1; + if id == LZMA_FILTER_LZMA1EXT { if (*options).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; } @@ -1474,7 +1272,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_init( #[no_mangle] pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { if !is_options_valid(options as *const lzma_options_lzma) { - return UINT64_MAX as u64; + return UINT64_MAX; } let mut lz_options: lzma_lz_options = lzma_lz_options { before_size: 0, @@ -1489,8 +1287,8 @@ pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { }; set_lz_options(&raw mut lz_options, options as *const lzma_options_lzma); let lz_memusage: u64 = unsafe { lzma_lz_encoder_memusage(&raw mut lz_options) } as u64; - if lz_memusage == UINT64_MAX as u64 { - return UINT64_MAX as u64; + if lz_memusage == UINT64_MAX { + return UINT64_MAX; } return (core::mem::size_of::() as u64).wrapping_add(lz_memusage); } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index d540d358..4722af37 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -1,48 +1,8 @@ use crate::types::*; use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn memcmp(__s1: *const c_void, __s2: *const c_void, __n: size_t) -> c_int; fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; } -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_match { - pub len: u32, - pub dist: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_mf_s { - pub buffer: *mut u8, - pub size: u32, - pub keep_size_before: u32, - pub keep_size_after: u32, - pub offset: u32, - pub read_pos: u32, - pub read_ahead: u32, - pub read_limit: u32, - pub write_pos: u32, - pub pending: u32, - pub find: Option u32>, - pub skip: Option ()>, - pub hash: *mut u32, - pub son: *mut u32, - pub cyclic_pos: u32, - pub cyclic_size: u32, - pub hash_mask: u32, - pub depth: u32, - pub nice_len: u32, - pub match_len_max: u32, - pub action: lzma_action, - pub hash_count: u32, - pub sons_count: u32, -} -pub type lzma_mf = lzma_mf_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_range_encoder { @@ -62,18 +22,6 @@ pub const RC_DIRECT_1: C2RustUnnamed = 3; pub const RC_DIRECT_0: C2RustUnnamed = 2; pub const RC_BIT_1: C2RustUnnamed = 1; pub const RC_BIT_0: C2RustUnnamed = 0; -pub const STATE_NONLIT_REP: lzma_lzma_state = 11; -pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; -pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; -pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; -pub const STATE_LIT_MATCH: lzma_lzma_state = 7; -pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; -pub const STATE_REP_LIT: lzma_lzma_state = 5; -pub const STATE_MATCH_LIT: lzma_lzma_state = 4; -pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; -pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; -pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; -pub const STATE_LIT_LIT: lzma_lzma_state = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma1_encoder_s { @@ -142,7 +90,6 @@ pub struct lzma_length_encoder { pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const UINT32_MAX: c_uint = 4294967295; #[inline] unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 4a783ce1..98ebebc0 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -1,50 +1,10 @@ use crate::types::*; use core::ffi::{c_int, c_uint, c_void}; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; static lzma_rc_prices: [u8; 128]; static lzma_fastpos: [u8; 8192]; } -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_match { - pub len: u32, - pub dist: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_mf_s { - pub buffer: *mut u8, - pub size: u32, - pub keep_size_before: u32, - pub keep_size_after: u32, - pub offset: u32, - pub read_pos: u32, - pub read_ahead: u32, - pub read_limit: u32, - pub write_pos: u32, - pub pending: u32, - pub find: Option u32>, - pub skip: Option ()>, - pub hash: *mut u32, - pub son: *mut u32, - pub cyclic_pos: u32, - pub cyclic_size: u32, - pub hash_mask: u32, - pub depth: u32, - pub nice_len: u32, - pub match_len_max: u32, - pub action: lzma_action, - pub hash_count: u32, - pub sons_count: u32, -} -pub type lzma_mf = lzma_mf_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_range_encoder { @@ -64,18 +24,6 @@ pub const RC_DIRECT_1: C2RustUnnamed = 3; pub const RC_DIRECT_0: C2RustUnnamed = 2; pub const RC_BIT_1: C2RustUnnamed = 1; pub const RC_BIT_0: C2RustUnnamed = 0; -pub const STATE_NONLIT_REP: lzma_lzma_state = 11; -pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; -pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; -pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; -pub const STATE_LIT_MATCH: lzma_lzma_state = 7; -pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; -pub const STATE_REP_LIT: lzma_lzma_state = 5; -pub const STATE_MATCH_LIT: lzma_lzma_state = 4; -pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; -pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; -pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; -pub const STATE_LIT_LIT: lzma_lzma_state = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma1_encoder_s { @@ -144,7 +92,6 @@ pub struct lzma_length_encoder { pub counters: [u32; 16], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -pub const UINT32_MAX: c_uint = 4294967295; #[inline] unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { return (*mf).buffer.offset((*mf).read_pos as isize); @@ -345,11 +292,7 @@ unsafe extern "C" fn get_literal_price( return price; } #[inline] -extern "C" fn get_len_price( - lencoder: *const lzma_length_encoder, - len: u32, - pos_state: u32, -) -> u32 { +extern "C" fn get_len_price(lencoder: *const lzma_length_encoder, len: u32, pos_state: u32) -> u32 { return unsafe { (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN as u32) as usize] }; @@ -811,9 +754,7 @@ unsafe extern "C" fn helper2( } } else { let mut pos: u32 = 0; - if (*coder).opts[cur as usize].prev_1_is_literal as c_int != 0 - && (*coder).opts[cur as usize].prev_2 as c_int != 0 - { + if (*coder).opts[cur as usize].prev_1_is_literal && (*coder).opts[cur as usize].prev_2 { pos_prev = (*coder).opts[cur as usize].pos_prev_2; pos = (*coder).opts[cur as usize].back_prev_2; state = (if (state as u32) < LIT_STATES as u32 { @@ -1230,7 +1171,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( memcpy( &raw mut reps as *mut u32 as *mut c_void, &raw mut (*coder).reps as *mut u32 as *const c_void, - core::mem::size_of::<[u32; 4]>() as size_t, + core::mem::size_of::<[u32; 4]>(), ); let mut cur: u32 = 0; cur = 1; diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index 244457dc..be281c25 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -1,41 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; -pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; -pub const LZMA_MF_BT4: lzma_match_finder = 20; -pub const LZMA_MF_BT3: lzma_match_finder = 19; -pub const LZMA_MF_BT2: lzma_match_finder = 18; -pub const LZMA_MF_HC4: lzma_match_finder = 4; -pub const LZMA_MF_HC3: lzma_match_finder = 3; -pub const LZMA_MODE_NORMAL: lzma_mode = 2; -pub const LZMA_MODE_FAST: lzma_mode = 1; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_lzma { - pub dict_size: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, - pub lc: u32, - pub lp: u32, - pub pb: u32, - pub mode: lzma_mode, - pub nice_len: u32, - pub mf: lzma_match_finder, - pub depth: u32, - pub ext_flags: u32, - pub ext_size_low: u32, - pub ext_size_high: u32, - pub reserved_int4: u32, - pub reserved_int5: u32, - pub reserved_int6: u32, - pub reserved_int7: u32, - pub reserved_int8: u32, - pub reserved_enum1: lzma_reserved_enum, - pub reserved_enum2: lzma_reserved_enum, - pub reserved_enum3: lzma_reserved_enum, - pub reserved_enum4: lzma_reserved_enum, - pub reserved_ptr1: *mut c_void, - pub reserved_ptr2: *mut c_void, -} +use core::ffi::{c_int, c_uint}; pub const LZMA_LC_DEFAULT: c_int = 3; pub const LZMA_LP_DEFAULT: c_int = 0; pub const LZMA_PB_DEFAULT: c_int = 2; diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index bbf72fdb..0d94c24e 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -12,100 +12,6 @@ extern "C" { is_encoder: bool, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; unsafe extern "C" fn arm_code( _simple: *mut c_void, now_pos: u32, @@ -152,7 +58,7 @@ extern "C" fn arm_coder_init( allocator, filters, Some( - arm_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + arm_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), 0, 4, diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index 0e9c34f9..e2186fb7 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -12,100 +12,6 @@ extern "C" { is_encoder: bool, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { @@ -180,7 +86,7 @@ extern "C" fn arm64_coder_init( filters, Some( arm64_code - as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), 0, 4, diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index 0b76c3cd..2347129a 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -12,100 +12,6 @@ extern "C" { is_encoder: bool, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; unsafe extern "C" fn armthumb_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 4fa20f9b..571c53d0 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -12,100 +12,6 @@ extern "C" { is_encoder: bool, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; unsafe extern "C" fn ia64_code( _simple: *mut c_void, now_pos: u32, @@ -182,7 +88,8 @@ extern "C" fn ia64_coder_init( allocator, filters, Some( - ia64_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + ia64_code + as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), 0, 16, diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index 095c093e..1526ebdd 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -12,100 +12,6 @@ extern "C" { is_encoder: bool, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; unsafe extern "C" fn powerpc_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 7c186db1..edd35d1b 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -12,100 +12,6 @@ extern "C" { is_encoder: bool, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; #[inline] extern "C" fn read32be(buf: *const u8) -> u32 { return unsafe { diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index b518dd05..acc0359a 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -1,10 +1,6 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong, c_void}; +use core::ffi::c_void; extern "C" { - fn memcpy(__dst: *mut c_void, __src: *const c_void, __n: size_t) -> *mut c_void; - fn memmove(__dst: *mut c_void, __src: *const c_void, __len: size_t) -> *mut c_void; - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -25,122 +21,6 @@ extern "C" { out_size: size_t, ) -> size_t; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_bcj { - pub start_offset: u32, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_simple_coder { - pub next: lzma_next_coder, - pub end_was_reached: bool, - pub is_encoder: bool, - pub filter: Option size_t>, - pub simple: *mut c_void, - pub now_pos: u32, - pub allocated: size_t, - pub pos: size_t, - pub filtered: size_t, - pub size: size_t, - pub buffer: [u8; 0], -} -pub const UINT64_MAX: c_ulonglong = u64::MAX as c_ulonglong; -pub const LZMA_VLI_UNKNOWN: c_ulonglong = UINT64_MAX; unsafe extern "C" fn copy_or_code( coder: *mut lzma_simple_coder, allocator: *const lzma_allocator, @@ -154,7 +34,7 @@ unsafe extern "C" fn copy_or_code( ) -> lzma_ret { if (*coder).next.code.is_none() { lzma_bufcpy(in_0, in_pos, in_size, out, out_pos, out_size); - if (*coder).is_encoder as c_int != 0 && action == LZMA_FINISH && *in_pos == in_size { + if (*coder).is_encoder && action == LZMA_FINISH && *in_pos == in_size { (*coder).end_was_reached = true; } } else { @@ -168,7 +48,7 @@ unsafe extern "C" fn copy_or_code( out_pos, out_size, action, - ) as lzma_ret; + ); if ret == LZMA_STREAM_END { (*coder).end_was_reached = true; } else if ret != LZMA_OK { @@ -239,7 +119,7 @@ unsafe extern "C" fn simple_code( *out_pos = (*out_pos).wrapping_add(buf_avail); let ret: lzma_ret = copy_or_code( coder, allocator, in_0, in_pos, in_size, out, out_pos, out_size, action, - ) as lzma_ret; + ); if ret != LZMA_OK { return ret; } @@ -282,7 +162,7 @@ unsafe extern "C" fn simple_code( &raw mut (*coder).size, (*coder).allocated, action, - ) as lzma_ret; + ); if ret_0 != LZMA_OK { return ret_0; } @@ -299,7 +179,7 @@ unsafe extern "C" fn simple_code( out_size, ); } - if (*coder).end_was_reached as c_int != 0 && (*coder).pos == (*coder).size { + if (*coder).end_was_reached && (*coder).pos == (*coder).size { return LZMA_STREAM_END; } return LZMA_OK; @@ -337,7 +217,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; if coder.is_null() { coder = lzma_alloc( - (core::mem::size_of::() as size_t) + (core::mem::size_of::()) .wrapping_add((2 as size_t).wrapping_mul(unfiltered_max)), allocator, ) as *mut lzma_simple_coder; @@ -381,7 +261,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( >; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN as lzma_vli, + id: LZMA_VLI_UNKNOWN, init: 0, code: None, end: None, diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs index 3230f2f6..e0bdef43 100644 --- a/liblzma-rs/src/simple/simple_decoder.rs +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -1,42 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); -} -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_bcj { - pub start_offset: u32, -} #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { @@ -60,10 +23,8 @@ pub unsafe extern "C" fn lzma_simple_props_decode( if props_size != 4 { return LZMA_OPTIONS_ERROR; } - let opt: *mut lzma_options_bcj = lzma_alloc( - core::mem::size_of::() as size_t, - allocator, - ) as *mut lzma_options_bcj; + let opt: *mut lzma_options_bcj = + lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_options_bcj; if opt.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index 523d7397..9af3b2ab 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -1,31 +1,5 @@ use crate::types::*; use core::ffi::{c_int, c_void}; -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_options_bcj { - pub start_offset: u32, -} #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index b703dc75..280d722c 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -12,100 +12,6 @@ extern "C" { is_encoder: bool, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; unsafe extern "C" fn sparc_code( _simple: *mut c_void, now_pos: u32, @@ -159,7 +65,8 @@ extern "C" fn sparc_coder_init( allocator, filters, Some( - sparc_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + sparc_code + as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), 0, 4, diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index 3fcddf81..9df80e2f 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -12,121 +12,12 @@ extern "C" { is_encoder: bool, ) -> lzma_ret; } -pub const LZMA_RET_INTERNAL8: lzma_ret = 108; -pub const LZMA_RET_INTERNAL7: lzma_ret = 107; -pub const LZMA_RET_INTERNAL6: lzma_ret = 106; -pub const LZMA_RET_INTERNAL5: lzma_ret = 105; -pub const LZMA_RET_INTERNAL4: lzma_ret = 104; -pub const LZMA_RET_INTERNAL3: lzma_ret = 103; -pub const LZMA_RET_INTERNAL2: lzma_ret = 102; -pub const LZMA_RET_INTERNAL1: lzma_ret = 101; -pub const LZMA_SEEK_NEEDED: lzma_ret = 12; -pub const LZMA_PROG_ERROR: lzma_ret = 11; -pub const LZMA_BUF_ERROR: lzma_ret = 10; -pub const LZMA_DATA_ERROR: lzma_ret = 9; -pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; -pub const LZMA_FORMAT_ERROR: lzma_ret = 7; -pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; -pub const LZMA_MEM_ERROR: lzma_ret = 5; -pub const LZMA_GET_CHECK: lzma_ret = 4; -pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; -pub const LZMA_NO_CHECK: lzma_ret = 2; -pub const LZMA_STREAM_END: lzma_ret = 1; -pub const LZMA_OK: lzma_ret = 0; -pub const LZMA_FINISH: lzma_action = 3; -pub const LZMA_FULL_BARRIER: lzma_action = 4; -pub const LZMA_FULL_FLUSH: lzma_action = 2; -pub const LZMA_SYNC_FLUSH: lzma_action = 1; -pub const LZMA_RUN: lzma_action = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_allocator { - pub alloc: Option *mut c_void>, - pub free: Option ()>, - pub opaque: *mut c_void, -} -pub type lzma_next_coder = lzma_next_coder_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_next_coder_s { - pub coder: *mut c_void, - pub id: lzma_vli, - pub init: uintptr_t, - pub code: lzma_code_function, - pub end: lzma_end_function, - pub get_progress: Option ()>, - pub get_check: Option lzma_check>, - pub memconfig: Option lzma_ret>, - pub update: Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >, - pub set_out_limit: Option lzma_ret>, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter { - pub id: lzma_vli, - pub options: *mut c_void, -} -pub const LZMA_CHECK_SHA256: lzma_check = 10; -pub const LZMA_CHECK_CRC64: lzma_check = 4; -pub const LZMA_CHECK_CRC32: lzma_check = 1; -pub const LZMA_CHECK_NONE: lzma_check = 0; -pub type lzma_end_function = Option ()>; -pub type lzma_code_function = Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, ->; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_simple_x86 { pub prev_mask: u32, pub prev_pos: u32, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_filter_info_s { - pub id: lzma_vli, - pub init: lzma_init_function, - pub options: *mut c_void, -} -pub type lzma_init_function = Option< - unsafe extern "C" fn( - *mut lzma_next_coder, - *const lzma_allocator, - *const lzma_filter_info, - ) -> lzma_ret, ->; -pub type lzma_filter_info = lzma_filter_info_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_simple_coder { - pub next: lzma_next_coder, - pub end_was_reached: bool, - pub is_encoder: bool, - pub filter: Option size_t>, - pub simple: *mut c_void, - pub now_pos: u32, - pub allocated: size_t, - pub pos: size_t, - pub filtered: size_t, - pub size: size_t, - pub buffer: [u8; 0], -} unsafe extern "C" fn x86_code( simple_ptr: *mut c_void, now_pos: u32, @@ -226,13 +117,13 @@ extern "C" fn x86_coder_init( allocator, filters, Some( - x86_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t + x86_code as unsafe extern "C" fn(*mut c_void, u32, bool, *mut u8, size_t) -> size_t, ), - core::mem::size_of::() as size_t, + core::mem::size_of::(), 5, 1, is_encoder, - ) as lzma_ret; + ); if ret == LZMA_OK { let coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; let simple: *mut lzma_simple_x86 = (*coder).simple as *mut lzma_simple_x86; diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 96e5cdfc..8390f27c 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -1,4 +1,4 @@ -use core::ffi::{c_uchar, c_uint}; +use core::ffi::{c_char, c_int, c_uchar, c_uint, c_void}; // Platform-dependent type aliases pub type size_t = libc::size_t; @@ -16,3 +16,590 @@ pub type lzma_match_finder = c_uint; pub type lzma_lzma_state = c_uint; pub type lzma_delta_type = c_uint; pub type probability = u16; + +// Common struct shared across all modules +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_allocator { + pub alloc: Option *mut c_void>, + pub free: Option ()>, + pub opaque: *mut c_void, +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter { + pub id: lzma_vli, + pub options: *mut c_void, +} + +pub type lzma_end_function = Option ()>; +pub type lzma_code_function = Option< + unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const u8, + *mut size_t, + size_t, + *mut u8, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, +>; +pub type lzma_next_coder = lzma_next_coder_s; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_next_coder_s { + pub coder: *mut c_void, + pub id: lzma_vli, + pub init: uintptr_t, + pub code: lzma_code_function, + pub end: lzma_end_function, + pub get_progress: Option ()>, + pub get_check: Option lzma_check>, + pub memconfig: Option lzma_ret>, + pub update: Option< + unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + >, + pub set_out_limit: Option lzma_ret>, +} + +pub type lzma_init_function = Option< + unsafe extern "C" fn( + *mut lzma_next_coder, + *const lzma_allocator, + *const lzma_filter_info, + ) -> lzma_ret, +>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_info_s { + pub id: lzma_vli, + pub init: lzma_init_function, + pub options: *mut c_void, +} +pub type lzma_filter_info = lzma_filter_info_s; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_lzma { + pub dict_size: u32, + pub preset_dict: *const u8, + pub preset_dict_size: u32, + pub lc: u32, + pub lp: u32, + pub pb: u32, + pub mode: lzma_mode, + pub nice_len: u32, + pub mf: lzma_match_finder, + pub depth: u32, + pub ext_flags: u32, + pub ext_size_low: u32, + pub ext_size_high: u32, + pub reserved_int4: u32, + pub reserved_int5: u32, + pub reserved_int6: u32, + pub reserved_int7: u32, + pub reserved_int8: u32, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, +} + +// lzma_internal sequence enum (C2RustUnnamed in lzma_internal_s) +pub type lzma_internal_sequence = c_uint; +pub const ISEQ_RUN: lzma_internal_sequence = 0; +pub const ISEQ_SYNC_FLUSH: lzma_internal_sequence = 1; +pub const ISEQ_FULL_FLUSH: lzma_internal_sequence = 2; +pub const ISEQ_FINISH: lzma_internal_sequence = 3; +pub const ISEQ_FULL_BARRIER: lzma_internal_sequence = 4; +pub const ISEQ_END: lzma_internal_sequence = 5; +pub const ISEQ_ERROR: lzma_internal_sequence = 6; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_internal_s { + pub next: lzma_next_coder, + pub sequence: lzma_internal_sequence, + pub avail_in: size_t, + pub supported_actions: [bool; 5], + pub allow_buf_error: bool, +} +pub type lzma_internal = lzma_internal_s; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream { + pub next_in: *const u8, + pub avail_in: size_t, + pub total_in: u64, + pub next_out: *mut u8, + pub avail_out: size_t, + pub total_out: u64, + pub allocator: *const lzma_allocator, + pub internal: *mut lzma_internal, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, + pub seek_pos: u64, + pub reserved_int2: u64, + pub reserved_int3: size_t, + pub reserved_int4: size_t, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, +} + +// lzma_ret constants +pub const LZMA_OK: lzma_ret = 0; +pub const LZMA_STREAM_END: lzma_ret = 1; +pub const LZMA_NO_CHECK: lzma_ret = 2; +pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; +pub const LZMA_GET_CHECK: lzma_ret = 4; +pub const LZMA_MEM_ERROR: lzma_ret = 5; +pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; +pub const LZMA_FORMAT_ERROR: lzma_ret = 7; +pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; +pub const LZMA_DATA_ERROR: lzma_ret = 9; +pub const LZMA_BUF_ERROR: lzma_ret = 10; +pub const LZMA_PROG_ERROR: lzma_ret = 11; +pub const LZMA_SEEK_NEEDED: lzma_ret = 12; +pub const LZMA_RET_INTERNAL1: lzma_ret = 101; +pub const LZMA_RET_INTERNAL2: lzma_ret = 102; +pub const LZMA_RET_INTERNAL3: lzma_ret = 103; +pub const LZMA_RET_INTERNAL4: lzma_ret = 104; +pub const LZMA_RET_INTERNAL5: lzma_ret = 105; +pub const LZMA_RET_INTERNAL6: lzma_ret = 106; +pub const LZMA_RET_INTERNAL7: lzma_ret = 107; +pub const LZMA_RET_INTERNAL8: lzma_ret = 108; + +// lzma_action constants +pub const LZMA_RUN: lzma_action = 0; +pub const LZMA_SYNC_FLUSH: lzma_action = 1; +pub const LZMA_FULL_FLUSH: lzma_action = 2; +pub const LZMA_FINISH: lzma_action = 3; +pub const LZMA_FULL_BARRIER: lzma_action = 4; + +// lzma_check constants +pub const LZMA_CHECK_NONE: lzma_check = 0; +pub const LZMA_CHECK_CRC32: lzma_check = 1; +pub const LZMA_CHECK_CRC64: lzma_check = 4; +pub const LZMA_CHECK_SHA256: lzma_check = 10; + +// lzma_reserved_enum constant +pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; + +// Integer max constants +pub const UINT32_MAX: c_uint = u32::MAX; +pub const UINT64_MAX: u64 = u64::MAX; + +// VLI constants +pub const LZMA_VLI_MAX: lzma_vli = u64::MAX / 2; +pub const LZMA_VLI_UNKNOWN: lzma_vli = u64::MAX; + +// lzma_match_finder constants +pub const LZMA_MF_HC3: lzma_match_finder = 3; +pub const LZMA_MF_HC4: lzma_match_finder = 4; +pub const LZMA_MF_BT2: lzma_match_finder = 18; +pub const LZMA_MF_BT3: lzma_match_finder = 19; +pub const LZMA_MF_BT4: lzma_match_finder = 20; + +// lzma_mode constants +pub const LZMA_MODE_FAST: lzma_mode = 1; +pub const LZMA_MODE_NORMAL: lzma_mode = 2; + +// lzma_check additional constants +pub const LZMA_CHECK_ID_MAX: lzma_check = 15; + +// lzma_delta_type constants +pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; + +// LZMA filter IDs +pub const LZMA_FILTER_DELTA: lzma_vli = 0x3; +pub const LZMA_FILTER_X86: lzma_vli = 0x4; +pub const LZMA_FILTER_POWERPC: lzma_vli = 0x5; +pub const LZMA_FILTER_IA64: lzma_vli = 0x6; +pub const LZMA_FILTER_ARM: lzma_vli = 0x7; +pub const LZMA_FILTER_ARMTHUMB: lzma_vli = 0x8; +pub const LZMA_FILTER_SPARC: lzma_vli = 0x9; +pub const LZMA_FILTER_ARM64: lzma_vli = 0xa; +pub const LZMA_FILTER_RISCV: lzma_vli = 0xb; +pub const LZMA_FILTER_LZMA1: lzma_vli = 0x4000000000000001; +pub const LZMA_FILTER_LZMA1EXT: lzma_vli = 0x4000000000000002; +pub const LZMA_FILTER_LZMA2: lzma_vli = 0x21; +pub const LZMA_FILTER_RESERVED_START: lzma_vli = 1 << 62; + +// Decoder flags +pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; +pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; +pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; +pub const LZMA_CONCATENATED: c_uint = 0x8; +pub const LZMA_IGNORE_CHECK: c_uint = 0x10; +pub const LZMA_FAIL_FAST: c_uint = 0x20; + +// Stream/block size constants +pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; +pub const LZMA_MEMUSAGE_BASE: u64 = 1 << 15; +pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; + +// lzma_lzma_state constants +pub const STATE_LIT_LIT: lzma_lzma_state = 0; +pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; +pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; +pub const STATE_SHORTREP_LIT_LIT: lzma_lzma_state = 3; +pub const STATE_MATCH_LIT: lzma_lzma_state = 4; +pub const STATE_REP_LIT: lzma_lzma_state = 5; +pub const STATE_SHORTREP_LIT: lzma_lzma_state = 6; +pub const STATE_LIT_MATCH: lzma_lzma_state = 7; +pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; +pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; +pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; +pub const STATE_NONLIT_REP: lzma_lzma_state = 11; + +// VLI encoding constants +pub const LZMA_VLI_BYTES_MAX: c_int = 9; + +// Filter chain limit +pub const LZMA_FILTERS_MAX: c_int = 4; + +// LZMA option limits +pub const LZMA_LCLP_MAX: c_int = 4; +pub const LZMA_PB_MAX: c_int = 4; + +// Delta filter +pub const LZMA_DELTA_DIST_MAX: c_int = 256; + +// Stream flags +pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4; +pub const LZMA_BACKWARD_SIZE_MAX: u64 = 1 << 34; + +// Decoder supported flags +pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK + | LZMA_TELL_UNSUPPORTED_CHECK + | LZMA_TELL_ANY_CHECK + | LZMA_IGNORE_CHECK + | LZMA_CONCATENATED + | LZMA_FAIL_FAST; + +// lzma_block struct (shared across 12 modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_block { + pub version: u32, + pub header_size: u32, + pub check: lzma_check, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub filters: *mut lzma_filter, + pub raw_check: [u8; 64], + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: lzma_vli, + pub reserved_int4: lzma_vli, + pub reserved_int5: lzma_vli, + pub reserved_int6: lzma_vli, + pub reserved_int7: lzma_vli, + pub reserved_int8: lzma_vli, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub ignore_check: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, +} + +// lzma_stream_flags struct (shared across 11 modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_stream_flags { + pub version: u32, + pub backward_size: lzma_vli, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_enum4: lzma_reserved_enum, + pub reserved_bool1: lzma_bool, + pub reserved_bool2: lzma_bool, + pub reserved_bool3: lzma_bool, + pub reserved_bool4: lzma_bool, + pub reserved_bool5: lzma_bool, + pub reserved_bool6: lzma_bool, + pub reserved_bool7: lzma_bool, + pub reserved_bool8: lzma_bool, + pub reserved_int1: u32, + pub reserved_int2: u32, +} + +// lzma_sha256_state struct (shared across check modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_sha256_state { + pub state: [u32; 8], + pub size: u64, +} + +// lzma_check_state unions and struct (shared across check/block modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub union lzma_check_state_buffer { + pub u8_0: [u8; 64], + pub u32_0: [u32; 16], + pub u64_0: [u64; 8], +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub union lzma_check_state_inner { + pub crc32: u32, + pub crc64: u64, + pub sha256: lzma_sha256_state, +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_check_state { + pub buffer: lzma_check_state_buffer, + pub state: lzma_check_state_inner, +} + +// lzma_options_delta struct (shared across delta modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_delta { + pub type_0: lzma_delta_type, + pub dist: u32, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, +} + +// lzma_options_easy struct (shared across easy modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_easy { + pub filters: [lzma_filter; 5], + pub opt_lzma: lzma_options_lzma, +} + +// lzma_dict struct (shared across decoder modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_dict { + pub buf: *mut u8, + pub pos: size_t, + pub full: size_t, + pub limit: size_t, + pub size: size_t, + pub has_wrapped: bool, + pub need_reset: bool, +} + +// lzma_lz_decoder struct (shared across decoder modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_decoder { + pub coder: *mut c_void, + pub code: Option< + unsafe extern "C" fn( + *mut c_void, + *mut lzma_dict, + *const u8, + *mut size_t, + size_t, + ) -> lzma_ret, + >, + pub reset: Option ()>, + pub set_uncompressed: Option ()>, + pub end: Option ()>, +} + +// lzma_match struct (shared across encoder modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_match { + pub len: u32, + pub dist: u32, +} + +// lzma_mf_s struct (shared across encoder modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mf_s { + pub buffer: *mut u8, + pub size: u32, + pub keep_size_before: u32, + pub keep_size_after: u32, + pub offset: u32, + pub read_pos: u32, + pub read_ahead: u32, + pub read_limit: u32, + pub write_pos: u32, + pub pending: u32, + pub find: Option u32>, + pub skip: Option ()>, + pub hash: *mut u32, + pub son: *mut u32, + pub cyclic_pos: u32, + pub cyclic_size: u32, + pub hash_mask: u32, + pub depth: u32, + pub nice_len: u32, + pub match_len_max: u32, + pub action: lzma_action, + pub hash_count: u32, + pub sons_count: u32, +} +pub type lzma_mf = lzma_mf_s; + +// lzma_delta_coder struct (shared across delta modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_delta_coder { + pub next: lzma_next_coder, + pub distance: size_t, + pub pos: u8, + pub history: [u8; LZMA_DELTA_DIST_MAX as usize], +} + +// lzma_lz_encoder struct (shared across encoder modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lz_encoder { + pub coder: *mut c_void, + pub code: Option< + unsafe extern "C" fn(*mut c_void, *mut lzma_mf, *mut u8, *mut size_t, size_t) -> lzma_ret, + >, + pub end: Option ()>, + pub options_update: Option lzma_ret>, + pub set_out_limit: Option lzma_ret>, +} + +// lzma_outbuf_s struct (shared across mt modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_outbuf_s { + pub next: *mut lzma_outbuf, + pub worker: *mut c_void, + pub allocated: size_t, + pub pos: size_t, + pub decoder_in_pos: size_t, + pub finished: bool, + pub finish_ret: lzma_ret, + pub unpadded_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub buf: [u8; 0], +} +pub type lzma_outbuf = lzma_outbuf_s; + +// lzma_outq struct (shared across mt modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_outq { + pub head: *mut lzma_outbuf, + pub tail: *mut lzma_outbuf, + pub read_pos: size_t, + pub cache: *mut lzma_outbuf, + pub mem_allocated: u64, + pub mem_in_use: u64, + pub bufs_in_use: u32, + pub bufs_allocated: u32, + pub bufs_limit: u32, +} + +// lzma_options_bcj struct (shared across simple/filter modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_options_bcj { + pub start_offset: u32, +} + +// lzma_mt struct (shared across mt modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_mt { + pub flags: u32, + pub threads: u32, + pub block_size: u64, + pub timeout: u32, + pub preset: u32, + pub filters: *const lzma_filter, + pub check: lzma_check, + pub reserved_enum1: lzma_reserved_enum, + pub reserved_enum2: lzma_reserved_enum, + pub reserved_enum3: lzma_reserved_enum, + pub reserved_int1: u32, + pub reserved_int2: u32, + pub reserved_int3: u32, + pub reserved_int4: u32, + pub memlimit_threading: u64, + pub memlimit_stop: u64, + pub reserved_int7: u64, + pub reserved_int8: u64, + pub reserved_ptr1: *mut c_void, + pub reserved_ptr2: *mut c_void, + pub reserved_ptr3: *mut c_void, + pub reserved_ptr4: *mut c_void, +} + +// lzma_filter_coder struct (shared across filter modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_filter_coder { + pub id: lzma_vli, + pub init: lzma_init_function, + pub memusage: Option u64>, +} +pub type lzma_filter_find = Option *const lzma_filter_coder>; + +// lzma_simple_coder struct (shared across simple modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_simple_coder { + pub next: lzma_next_coder, + pub end_was_reached: bool, + pub is_encoder: bool, + pub filter: Option size_t>, + pub simple: *mut c_void, + pub now_pos: u32, + pub allocated: size_t, + pub pos: size_t, + pub filtered: size_t, + pub size: size_t, + pub buffer: [u8; 0], +} + +// Common extern functions used across many modules +extern "C" { + pub fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + pub fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; + pub fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); + pub fn memcpy(dst: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memmove(dst: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; + pub fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn strlen(s: *const c_char) -> size_t; +} diff --git a/src/stream.rs b/src/stream.rs index 1ae9551e..24c4bdf8 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -490,7 +490,7 @@ impl Stream { /// This is only supported if the underlying stream supports a memlimit. #[inline] pub fn memlimit(&self) -> u64 { - unsafe { liblzma_sys::lzma_memlimit_get(&self.raw) } + liblzma_sys::lzma_memlimit_get(&self.raw) } /// Set the current memory usage limit. From 6c78150d46bd803118153f08058416b7219aa188 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 1 Mar 2026 19:00:22 +0900 Subject: [PATCH 07/51] remove redundant c_int and other type casts --- liblzma-rs/src/check/check.rs | 2 +- liblzma-rs/src/check/crc64_fast.rs | 6 +- liblzma-rs/src/check/sha256.rs | 6 +- liblzma-rs/src/common/alone_decoder.rs | 6 +- liblzma-rs/src/common/alone_encoder.rs | 6 +- liblzma-rs/src/common/auto_decoder.rs | 4 +- liblzma-rs/src/common/block_buffer_encoder.rs | 14 +- liblzma-rs/src/common/block_decoder.rs | 10 +- liblzma-rs/src/common/block_encoder.rs | 6 +- liblzma-rs/src/common/block_header_decoder.rs | 9 +- liblzma-rs/src/common/block_header_encoder.rs | 14 +- liblzma-rs/src/common/block_util.rs | 10 +- liblzma-rs/src/common/common.rs | 4 +- liblzma-rs/src/common/file_info.rs | 22 +- liblzma-rs/src/common/filter_common.rs | 2 +- liblzma-rs/src/common/filter_flags_decoder.rs | 2 +- liblzma-rs/src/common/index.rs | 77 +- liblzma-rs/src/common/index_decoder.rs | 28 +- liblzma-rs/src/common/index_encoder.rs | 8 +- liblzma-rs/src/common/index_hash.rs | 48 +- liblzma-rs/src/common/lzip_decoder.rs | 6 +- liblzma-rs/src/common/microlzma_decoder.rs | 13 +- liblzma-rs/src/common/microlzma_encoder.rs | 4 +- liblzma-rs/src/common/outqueue.rs | 6 +- .../src/common/stream_buffer_encoder.rs | 6 +- liblzma-rs/src/common/stream_decoder.rs | 6 +- liblzma-rs/src/common/stream_decoder_mt.rs | 74 +- liblzma-rs/src/common/stream_encoder_mt.rs | 76 +- liblzma-rs/src/common/stream_flags_common.rs | 2 +- liblzma-rs/src/common/stream_flags_decoder.rs | 9 +- liblzma-rs/src/common/stream_flags_encoder.rs | 17 +- liblzma-rs/src/common/string_conversion.rs | 158 ++-- liblzma-rs/src/common/vli_decoder.rs | 17 +- liblzma-rs/src/common/vli_encoder.rs | 7 +- liblzma-rs/src/common/vli_size.rs | 5 +- liblzma-rs/src/delta/delta_common.rs | 6 +- liblzma-rs/src/delta/delta_decoder.rs | 12 +- liblzma-rs/src/delta/delta_encoder.rs | 12 +- liblzma-rs/src/lz/lz_decoder.rs | 11 +- liblzma-rs/src/lz/lz_encoder.rs | 16 +- liblzma-rs/src/lz/lz_encoder_mf.rs | 33 +- liblzma-rs/src/lzma/lzma2_decoder.rs | 18 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 37 +- liblzma-rs/src/lzma/lzma_decoder.rs | 842 +++++++----------- liblzma-rs/src/lzma/lzma_encoder.rs | 92 +- .../src/lzma/lzma_encoder_optimum_fast.rs | 34 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 172 ++-- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 20 +- liblzma-rs/src/simple/arm.rs | 12 +- liblzma-rs/src/simple/arm64.rs | 22 +- liblzma-rs/src/simple/armthumb.rs | 18 +- liblzma-rs/src/simple/ia64.rs | 18 +- liblzma-rs/src/simple/powerpc.rs | 14 +- liblzma-rs/src/simple/riscv.rs | 80 +- liblzma-rs/src/simple/simple_coder.rs | 4 +- liblzma-rs/src/simple/simple_encoder.rs | 6 +- liblzma-rs/src/simple/sparc.rs | 25 +- liblzma-rs/src/simple/x86.rs | 25 +- 58 files changed, 947 insertions(+), 1272 deletions(-) diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index e037cd47..8813ef7e 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -34,7 +34,7 @@ pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { #[no_mangle] pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { if type_0 > LZMA_CHECK_ID_MAX { - return UINT32_MAX as u32; + return UINT32_MAX; } static check_sizes: [u8; 16] = [ 0, 4 as u8, 4 as u8, 4 as u8, 8 as u8, 8 as u8, 8 as u8, 16 as u8, 16 as u8, 16 as u8, diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index ffc1860a..f7067afb 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1052,10 +1052,10 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu while buf < limit { let tmp: u32 = crc as u32 ^ aligned_read32ne(buf) as u32; buf = buf.offset(4); - crc = lzma_crc64_table[3][(tmp & 0xff as u32) as usize] - ^ lzma_crc64_table[2][(tmp >> 8 & 0xff as u32) as usize] + crc = lzma_crc64_table[3][(tmp & 0xff) as usize] + ^ lzma_crc64_table[2][(tmp >> 8 & 0xff) as usize] ^ crc >> 32 - ^ lzma_crc64_table[1][(tmp >> 16 & 0xff as u32) as usize] + ^ lzma_crc64_table[1][(tmp >> 16 & 0xff) as usize] ^ lzma_crc64_table[0][(tmp >> 24) as usize]; } } diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index c90f50a3..eeaa3432 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; #[inline] extern "C" fn rotr_32(num: u32, amount: c_uint) -> u32 { return num >> amount | num << 32u32.wrapping_sub(amount); @@ -566,7 +566,7 @@ pub unsafe extern "C" fn lzma_sha256_update( ) { while size > 0 { let copy_start: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; - let mut copy_size: size_t = (64 as size_t).wrapping_sub(copy_start); + let mut copy_size: size_t = (64_usize).wrapping_sub(copy_start); if copy_size > size { copy_size = size; } @@ -589,7 +589,7 @@ pub unsafe extern "C" fn lzma_sha256_finish(check: *mut lzma_check_state) { let fresh8 = pos; pos = pos.wrapping_add(1); (*check).buffer.u8_0[fresh8 as usize] = 0x80 as u8; - while pos != (64 as c_int - 8 as c_int) as size_t { + while pos != (64 - 8) as size_t { if pos == 64 { process(check); pos = 0; diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index a636fb16..90603a37 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -68,7 +68,7 @@ unsafe extern "C" fn alone_decode( as u32; (*coder).pos = (*coder).pos.wrapping_add(1); if (*coder).pos == 4 { - if (*coder).picky && (*coder).options.dict_size != UINT32_MAX as u32 { + if (*coder).picky && (*coder).options.dict_size != UINT32_MAX { let mut d: u32 = (*coder).options.dict_size.wrapping_sub(1); d |= d >> 2; d |= d >> 3; @@ -96,7 +96,7 @@ unsafe extern "C" fn alone_decode( } else { if (*coder).picky && (*coder).uncompressed_size != LZMA_VLI_UNKNOWN - && (*coder).uncompressed_size >= (1 as lzma_vli) << 38 + && (*coder).uncompressed_size >= (1) << 38 { return LZMA_FORMAT_ERROR; } @@ -289,7 +289,7 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( (*coder).options.dict_size = 0; (*coder).options.preset_dict = ::core::ptr::null::(); (*coder).options.preset_dict_size = 0; - (*coder).uncompressed_size = 0 as lzma_vli; + (*coder).uncompressed_size = 0; (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).memusage = LZMA_MEMUSAGE_BASE; return LZMA_OK; diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index 5afe9d3e..4323a9de 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -44,7 +44,7 @@ extern "C" fn write32le(buf: *mut u8, num: u32) { *buf.offset(3) = (num >> 24) as u8; } } -pub const ALONE_HEADER_SIZE: c_int = 1 + 4 as c_int + 8 as c_int; +pub const ALONE_HEADER_SIZE: c_int = 1 + 4 + 8; unsafe extern "C" fn alone_encode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -190,13 +190,13 @@ unsafe extern "C" fn alone_encoder_init( d |= d >> 4; d |= d >> 8; d |= d >> 16; - if d != UINT32_MAX as u32 { + if d != UINT32_MAX { d = d.wrapping_add(1); } write32le((&raw mut (*coder).header as *mut u8).offset(1), d); memset( (&raw mut (*coder).header as *mut u8).offset(1).offset(4) as *mut c_void, - 0xff as c_int, + 0xff, 8, ); let filters: [lzma_filter_info; 2] = [ diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 65fd4fcb..5a1c0380 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -48,7 +48,7 @@ unsafe extern "C" fn auto_decode( return LZMA_OK; } (*coder).sequence = SEQ_CODE; - if *in_0.offset(*in_pos as isize) as c_int == 0xfd as c_int { + if *in_0.offset(*in_pos as isize) == 0xfd { let ret_: lzma_ret = lzma_stream_decoder_init( &raw mut (*coder).next, allocator, diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 8c012ba2..dbad77e7 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -27,14 +27,8 @@ pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3; -pub const HEADERS_BOUND: c_int = 1 - + 1 as c_int - + 2 as c_int * LZMA_VLI_BYTES_MAX - + 3 as c_int - + 4 as c_int - + LZMA_CHECK_SIZE_MAX - + 3 as c_int - & !(3 as c_int); +pub const HEADERS_BOUND: c_int = + 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 + LZMA_CHECK_SIZE_MAX + 3 & !(3); extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { if uncompressed_size > COMPRESSED_SIZE_MAX as u64 { return 0; @@ -140,7 +134,7 @@ unsafe extern "C" fn block_encode_uncompressed( *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1) >> 8) as u8; let fresh3 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1) & 0xff as size_t) as u8; + *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1) & 0xff) as u8; memcpy( out.offset(*out_pos as isize) as *mut c_void, in_0.offset(in_pos as isize) as *const c_void, @@ -255,7 +249,7 @@ unsafe extern "C" fn block_buffer_encode( out_size = out_size.wrapping_sub(check_size); (*block).uncompressed_size = in_size as lzma_vli; (*block).compressed_size = lzma2_bound(in_size as u64) as lzma_vli; - if (*block).compressed_size == 0 as lzma_vli { + if (*block).compressed_size == 0 { return LZMA_DATA_ERROR; } let mut ret: lzma_ret = LZMA_BUF_ERROR; diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 1e176971..3ef30688 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -164,7 +164,7 @@ unsafe extern "C" fn block_decode( } match current_block_40 { 17473121293339793080 => { - while (*coder).compressed_size & 3 as lzma_vli != 0 { + while (*coder).compressed_size & 3 != 0 { if *in_pos >= in_size { return LZMA_OK; } @@ -259,7 +259,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( *mut lzma_block, ) -> lzma_ret, )); - if lzma_block_unpadded_size(block) == 0 as lzma_vli + if lzma_block_unpadded_size(block) == 0 || !((*block).uncompressed_size <= LZMA_VLI_MAX || (*block).uncompressed_size == LZMA_VLI_UNKNOWN) { @@ -305,10 +305,10 @@ pub unsafe extern "C" fn lzma_block_decoder_init( } (*coder).sequence = SEQ_CODE; (*coder).block = block; - (*coder).compressed_size = 0 as lzma_vli; - (*coder).uncompressed_size = 0 as lzma_vli; + (*coder).compressed_size = 0; + (*coder).uncompressed_size = 0; (*coder).compressed_limit = if (*block).compressed_size == LZMA_VLI_UNKNOWN { - (LZMA_VLI_MAX & !(3 as lzma_vli)) + (LZMA_VLI_MAX & !(3)) .wrapping_sub((*block).header_size as lzma_vli) .wrapping_sub(lzma_check_size((*block).check) as lzma_vli) } else { diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 306513dd..a73bff61 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -126,7 +126,7 @@ unsafe extern "C" fn block_encode( } match current_block_34 { 6470892831169497455 => { - while (*coder).compressed_size & 3 as lzma_vli != 0 { + while (*coder).compressed_size & 3 != 0 { if *out_pos >= out_size { return LZMA_OK; } @@ -292,8 +292,8 @@ pub unsafe extern "C" fn lzma_block_encoder_init( } (*coder).sequence = SEQ_CODE; (*coder).block = block; - (*coder).compressed_size = 0 as lzma_vli; - (*coder).uncompressed_size = 0 as lzma_vli; + (*coder).compressed_size = 0; + (*coder).uncompressed_size = 0; (*coder).pos = 0; lzma_check_init(&raw mut (*coder).check, (*block).check); return lzma_raw_encoder_init(&raw mut (*coder).next, allocator, (*block).filters); diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index bf86229f..7ee932af 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_int; extern "C" { fn lzma_vli_decode( vli: *mut lzma_vli, @@ -58,11 +57,11 @@ pub unsafe extern "C" fn lzma_block_header_decode( if lzma_crc32(in_0, in_size, 0) != read32le(in_0.offset(in_size as isize)) { return LZMA_DATA_ERROR; } - if *in_0.offset(1) as c_int & 0x3c != 0 { + if *in_0.offset(1) & 0x3c != 0 { return LZMA_OPTIONS_ERROR; } let mut in_pos: size_t = 2; - if *in_0.offset(1) as c_int & 0x40 != 0 { + if *in_0.offset(1) & 0x40 != 0 { let ret_: lzma_ret = lzma_vli_decode( &raw mut (*block).compressed_size, core::ptr::null_mut(), @@ -73,13 +72,13 @@ pub unsafe extern "C" fn lzma_block_header_decode( if ret_ != LZMA_OK { return ret_; } - if lzma_block_unpadded_size(block) == 0 as lzma_vli { + if lzma_block_unpadded_size(block) == 0 { return LZMA_DATA_ERROR; } } else { (*block).compressed_size = LZMA_VLI_UNKNOWN; } - if *in_0.offset(1) as c_int & 0x80 != 0 { + if *in_0.offset(1) & 0x80 != 0 { let ret__0: lzma_ret = lzma_vli_decode( &raw mut (*block).uncompressed_size, core::ptr::null_mut(), diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 46e544d5..46b869b8 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_vli_encode( vli: lzma_vli, @@ -33,10 +33,10 @@ pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ if (*block).version > 1 { return LZMA_OPTIONS_ERROR; } - let mut size: u32 = (1 as c_int + 1 as c_int + 4 as c_int) as u32; + let mut size: u32 = (1 + 1 + 4) as u32; if (*block).compressed_size != LZMA_VLI_UNKNOWN { let add: u32 = lzma_vli_size((*block).compressed_size) as u32; - if add == 0 || (*block).compressed_size == 0 as lzma_vli { + if add == 0 || (*block).compressed_size == 0 { return LZMA_PROG_ERROR; } size = size.wrapping_add(add); @@ -73,7 +73,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( block: *const lzma_block, out: *mut u8, ) -> lzma_ret { - if lzma_block_unpadded_size(block) == 0 as lzma_vli + if lzma_block_unpadded_size(block) == 0 || !((*block).uncompressed_size <= LZMA_VLI_MAX || (*block).uncompressed_size == LZMA_VLI_UNKNOWN) { @@ -95,7 +95,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( return ret_; } let ref mut fresh0 = *out.offset(1); - *fresh0 = (*fresh0 as c_int | 0x40 as c_int) as u8; + *fresh0 |= 0x40; } if (*block).uncompressed_size != LZMA_VLI_UNKNOWN { let ret__0: lzma_ret = lzma_vli_encode( @@ -109,7 +109,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( return ret__0; } let ref mut fresh1 = *out.offset(1); - *fresh1 = (*fresh1 as c_int | 0x80 as c_int) as u8; + *fresh1 |= 0x80; } if (*block).filters.is_null() || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; @@ -137,7 +137,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( *fresh2 = (*fresh2 as size_t | filter_count.wrapping_sub(1)) as u8; memset( out.offset(out_pos as isize) as *mut c_void, - 0 as c_int, + 0, out_size.wrapping_sub(out_pos), ); write32le(out.offset(out_size as isize), lzma_crc32(out, out_size, 0)); diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 93d844f8..402cce40 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -7,14 +7,14 @@ pub const LZMA_BLOCK_HEADER_SIZE_MIN: c_int = 8; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); + return vli.wrapping_add(3) & !(3); } #[no_mangle] pub unsafe extern "C" fn lzma_block_compressed_size( block: *mut lzma_block, unpadded_size: lzma_vli, ) -> lzma_ret { - if lzma_block_unpadded_size(block) == 0 as lzma_vli { + if lzma_block_unpadded_size(block) == 0 { return LZMA_PROG_ERROR; } let container_size: u32 = (*block) @@ -39,10 +39,10 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> l || (*block).header_size & 3 != 0 || !((*block).compressed_size <= LZMA_VLI_MAX || (*block).compressed_size == LZMA_VLI_UNKNOWN) - || (*block).compressed_size == 0 as lzma_vli + || (*block).compressed_size == 0 || (*block).check > LZMA_CHECK_ID_MAX { - return 0 as lzma_vli; + return 0; } if (*block).compressed_size == LZMA_VLI_UNKNOWN { return LZMA_VLI_UNKNOWN; @@ -52,7 +52,7 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> l .wrapping_add((*block).header_size as lzma_vli) .wrapping_add(lzma_check_size((*block).check) as lzma_vli); if unpadded_size > UNPADDED_SIZE_MAX as lzma_vli { - return 0 as lzma_vli; + return 0; } return unpadded_size; } diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index 07ae98eb..d44428b5 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -52,7 +52,7 @@ pub unsafe extern "C" fn lzma_alloc_zero( if !allocator.is_null() && (*allocator).alloc.is_some() { ptr = (*allocator).alloc.expect("non-null function pointer")((*allocator).opaque, 1, size); if !ptr.is_null() { - memset(ptr, 0 as c_int, size); + memset(ptr, 0, size); } } else { ptr = calloc(1, size); @@ -186,7 +186,7 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { } memset( &raw mut (*(*strm).internal).supported_actions as *mut bool as *mut c_void, - 0 as c_int, + 0, core::mem::size_of::<[bool; 5]>(), ); (*(*strm).internal).sequence = ISEQ_RUN; diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 383ca4f6..3e1f68ef 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -122,7 +122,7 @@ unsafe extern "C" fn reverse_seek( in_pos: *mut size_t, in_size: size_t, ) -> lzma_ret { - if (*coder).file_target_pos < (2 as c_int * LZMA_STREAM_HEADER_SIZE) as u64 { + if (*coder).file_target_pos < (2 * LZMA_STREAM_HEADER_SIZE) as u64 { return LZMA_DATA_ERROR; } (*coder).temp_pos = 0; @@ -154,7 +154,7 @@ unsafe extern "C" fn get_padding_size(buf: *const u8, mut buf_size: size_t) -> s let mut padding: size_t = 0; while buf_size > 0 && { buf_size = buf_size.wrapping_sub(1); - *buf.offset(buf_size as isize) as c_int == 0 as c_int + *buf.offset(buf_size as isize) == 0 } { padding = padding.wrapping_add(1); } @@ -292,7 +292,7 @@ unsafe extern "C" fn file_info_decode( (*coder).sequence = SEQ_PADDING_SEEK; current_block_142 = 13014351284863956202; } else { - if (*coder).stream_padding & 3 as lzma_vli != 0 { + if (*coder).stream_padding & 3 != 0 { return LZMA_DATA_ERROR; } (*coder).sequence = SEQ_FOOTER; @@ -399,13 +399,13 @@ unsafe extern "C" fn file_info_decode( } match ret { 0 => { - if (*coder).index_remaining == 0 as lzma_vli { + if (*coder).index_remaining == 0 { return LZMA_DATA_ERROR; } return LZMA_OK; } 1 => { - if (*coder).index_remaining != 0 as lzma_vli { + if (*coder).index_remaining != 0 { return LZMA_DATA_ERROR; } } @@ -491,7 +491,7 @@ unsafe extern "C" fn file_info_decode( { return LZMA_PROG_ERROR; } - (*coder).stream_padding = 0 as lzma_vli; + (*coder).stream_padding = 0; if !(*coder).combined_index.is_null() { let ret__7: lzma_ret = lzma_index_cat((*coder).this_index, (*coder).combined_index, allocator); @@ -508,9 +508,9 @@ unsafe extern "C" fn file_info_decode( return LZMA_STREAM_END; } (*coder).sequence = (if (*coder).temp_size > 0 { - SEQ_PADDING_DECODE as c_int + SEQ_PADDING_DECODE } else { - SEQ_PADDING_SEEK as c_int + SEQ_PADDING_SEEK }) as C2RustUnnamed_0; } _ => {} @@ -548,7 +548,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( } *memusage = combined_index_memusage.wrapping_add(this_index_memusage); if *memusage == 0 { - *memusage = lzma_index_memusage(1 as lzma_vli, 0 as lzma_vli); + *memusage = lzma_index_memusage(1, 0); } *old_memlimit = (*coder).memlimit; if new_memlimit != 0 { @@ -699,7 +699,7 @@ unsafe extern "C" fn lzma_file_info_decoder_init( (*coder).this_index = core::ptr::null_mut(); lzma_index_end((*coder).combined_index, allocator); (*coder).combined_index = core::ptr::null_mut(); - (*coder).stream_padding = 0 as lzma_vli; + (*coder).stream_padding = 0; (*coder).dest_index = dest_index; (*coder).external_seek_pos = seek_pos; (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 817d9181..9fa21389 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -324,7 +324,7 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( return UINT64_MAX; } if (*fc).memusage.is_none() { - total = total.wrapping_add(1024 as u64); + total = total.wrapping_add(1024); } else { let usage: u64 = (*fc).memusage.expect("non-null function pointer")( (*filters.offset(i as isize)).options, diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 47f1595f..2f046c5d 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -56,6 +56,6 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( in_0.offset(*in_pos as isize), props_size as size_t, ); - *in_pos = (*in_pos as lzma_vli).wrapping_add(props_size) as size_t as size_t; + *in_pos = (*in_pos as lzma_vli).wrapping_add(props_size) as size_t; return ret; } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index b7c95f7c..9058e710 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -156,13 +156,13 @@ pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); + return vli.wrapping_add(3) & !(3); } #[inline] extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { return (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) .wrapping_add(index_list_size) - .wrapping_add(4 as lzma_vli); + .wrapping_add(4); } #[inline] extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { @@ -284,10 +284,10 @@ unsafe extern "C" fn index_stream_init( (*s).number = stream_number; (*s).block_number_base = block_number_base; index_tree_init(&raw mut (*s).groups); - (*s).record_count = 0 as lzma_vli; - (*s).index_list_size = 0 as lzma_vli; - (*s).stream_flags.version = UINT32_MAX as u32; - (*s).stream_padding = 0 as lzma_vli; + (*s).record_count = 0; + (*s).index_list_size = 0; + (*s).stream_flags.version = UINT32_MAX; + (*s).stream_padding = 0; return s; } unsafe extern "C" fn index_stream_end(node: *mut c_void, allocator: *const lzma_allocator) { @@ -304,10 +304,10 @@ unsafe extern "C" fn index_init_plain(allocator: *const lzma_allocator) -> *mut lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_index; if !i.is_null() { index_tree_init(&raw mut (*i).streams); - (*i).uncompressed_size = 0 as lzma_vli; - (*i).total_size = 0 as lzma_vli; - (*i).record_count = 0 as lzma_vli; - (*i).index_list_size = 0 as lzma_vli; + (*i).uncompressed_size = 0; + (*i).total_size = 0; + (*i).record_count = 0; + (*i).index_list_size = 0; (*i).prealloc = INDEX_GROUP_SIZE as size_t; (*i).checks = 0; } @@ -319,8 +319,7 @@ pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *m if i.is_null() { return core::ptr::null_mut(); } - let s: *mut index_stream = - index_stream_init(0 as lzma_vli, 0 as lzma_vli, 1, 0 as lzma_vli, allocator); + let s: *mut index_stream = index_stream_init(0, 0, 1, 0, allocator); if s.is_null() { lzma_free(i as *mut c_void, allocator); return core::ptr::null_mut(); @@ -350,10 +349,10 @@ pub unsafe extern "C" fn lzma_index_prealloc(i: *mut lzma_index, mut records: lz } #[no_mangle] pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64 { - let alloc_overhead: size_t = (4 as size_t).wrapping_mul(core::mem::size_of::<*mut c_void>()); + let alloc_overhead: size_t = (4_usize).wrapping_mul(core::mem::size_of::<*mut c_void>()); let stream_base: size_t = (core::mem::size_of::()) .wrapping_add(core::mem::size_of::()) - .wrapping_add((2 as size_t).wrapping_mul(alloc_overhead)); + .wrapping_add((2_usize).wrapping_mul(alloc_overhead)); let group_base: size_t = (core::mem::size_of::()) .wrapping_add( (INDEX_GROUP_SIZE as size_t).wrapping_mul(core::mem::size_of::()), @@ -361,14 +360,14 @@ pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u6 .wrapping_add(alloc_overhead); let groups: lzma_vli = blocks .wrapping_add(INDEX_GROUP_SIZE as lzma_vli) - .wrapping_sub(1 as lzma_vli) + .wrapping_sub(1) .wrapping_div(INDEX_GROUP_SIZE as lzma_vli); let streams_mem: u64 = (streams as u64).wrapping_mul(stream_base as u64); let groups_mem: u64 = (groups as u64).wrapping_mul(group_base as u64); let index_base: u64 = (core::mem::size_of::() as usize).wrapping_add(alloc_overhead as usize) as u64; let limit: u64 = (UINT64_MAX).wrapping_sub(index_base); - if streams == 0 as lzma_vli + if streams == 0 || streams > UINT32_MAX as lzma_vli || blocks > LZMA_VLI_MAX || streams > limit.wrapping_div(stream_base as u64) @@ -418,7 +417,7 @@ unsafe extern "C" fn index_file_size( stream_padding: lzma_vli, ) -> lzma_vli { let mut file_size: lzma_vli = compressed_base - .wrapping_add((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) + .wrapping_add((2 * LZMA_STREAM_HEADER_SIZE) as lzma_vli) .wrapping_add(stream_padding) .wrapping_add(vli_ceil4(unpadded_sum)); if file_size > LZMA_VLI_MAX { @@ -437,7 +436,7 @@ pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli return index_file_size( (*s).node.compressed_base, if g.is_null() { - 0 as lzma_vli + 0 } else { (*(&raw const (*g).records as *const index_record).offset((*g).last as isize)) .unpadded_sum @@ -455,16 +454,15 @@ pub unsafe extern "C" fn lzma_index_uncompressed_size(i: *const lzma_index) -> l pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { let mut checks: u32 = (*i).checks; let s: *const index_stream = (*i).streams.rightmost as *const index_stream; - if (*s).stream_flags.version != UINT32_MAX as u32 { + if (*s).stream_flags.version != UINT32_MAX { checks = (checks | 1u32 << (*s).stream_flags.check) as u32; } return checks; } #[no_mangle] pub unsafe extern "C" fn lzma_index_padding_size(i: *const lzma_index) -> u32 { - return ((4 as lzma_vli) - .wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) - & 3 as lzma_vli) as u32; + return ((4_u64).wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) & 3) + as u32; } #[no_mangle] pub unsafe extern "C" fn lzma_index_stream_flags( @@ -487,15 +485,12 @@ pub unsafe extern "C" fn lzma_index_stream_padding( i: *mut lzma_index, stream_padding: lzma_vli, ) -> lzma_ret { - if i.is_null() - || stream_padding > LZMA_VLI_MAX - || stream_padding & 3 as lzma_vli != 0 as lzma_vli - { + if i.is_null() || stream_padding > LZMA_VLI_MAX || stream_padding & 3 != 0 { return LZMA_PROG_ERROR; } let s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; let old_stream_padding: lzma_vli = (*s).stream_padding; - (*s).stream_padding = 0 as lzma_vli; + (*s).stream_padding = 0; if lzma_index_file_size(i).wrapping_add(stream_padding) > LZMA_VLI_MAX { (*s).stream_padding = old_stream_padding; return LZMA_DATA_ERROR; @@ -520,14 +515,14 @@ pub unsafe extern "C" fn lzma_index_append( let s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; let mut g: *mut index_group = (*s).groups.rightmost as *mut index_group; let compressed_base: lzma_vli = if g.is_null() { - 0 as lzma_vli + 0 } else { vli_ceil4( (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).unpadded_sum, ) as lzma_vli }; let uncompressed_base: lzma_vli = if g.is_null() { - 0 as lzma_vli + 0 } else { (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).uncompressed_sum }; @@ -542,7 +537,7 @@ pub unsafe extern "C" fn lzma_index_append( if index_file_size( (*s).node.compressed_base, compressed_base.wrapping_add(unpadded_size), - (*s).record_count.wrapping_add(1 as lzma_vli), + (*s).record_count.wrapping_add(1), (*s).index_list_size .wrapping_add(index_list_size_add as lzma_vli), (*s).stream_padding, @@ -551,7 +546,7 @@ pub unsafe extern "C" fn lzma_index_append( return LZMA_DATA_ERROR; } if index_size( - (*i).record_count.wrapping_add(1 as lzma_vli), + (*i).record_count.wrapping_add(1), (*i).index_list_size .wrapping_add(index_list_size_add as lzma_vli), ) > LZMA_BACKWARD_SIZE_MAX as lzma_vli @@ -576,7 +571,7 @@ pub unsafe extern "C" fn lzma_index_append( (*i).prealloc = INDEX_GROUP_SIZE as size_t; (*g).node.uncompressed_base = uncompressed_base; (*g).node.compressed_base = compressed_base; - (*g).number_base = (*s).record_count.wrapping_add(1 as lzma_vli); + (*g).number_base = (*s).record_count.wrapping_add(1); index_tree_append(&raw mut (*s).groups, &raw mut (*g).node); } (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).uncompressed_sum = @@ -730,11 +725,11 @@ unsafe extern "C" fn index_dup_stream( index_stream_end(dest as *mut c_void, allocator); return core::ptr::null_mut(); } - (*destg).node.uncompressed_base = 0 as lzma_vli; - (*destg).node.compressed_base = 0 as lzma_vli; - (*destg).number_base = 1 as lzma_vli; + (*destg).node.uncompressed_base = 0; + (*destg).node.compressed_base = 0; + (*destg).number_base = 1; (*destg).allocated = (*src).record_count as size_t; - (*destg).last = (*src).record_count.wrapping_sub(1 as lzma_vli) as size_t; + (*destg).last = (*src).record_count.wrapping_sub(1) as size_t; let mut srcg: *const index_group = (*src).groups.leftmost as *const index_group; let mut i: size_t = 0; loop { @@ -806,19 +801,19 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { (*iter).stream.block_count = (*stream).record_count; (*iter).stream.compressed_offset = (*stream).node.compressed_base; (*iter).stream.uncompressed_offset = (*stream).node.uncompressed_base; - (*iter).stream.flags = if (*stream).stream_flags.version == UINT32_MAX as u32 { + (*iter).stream.flags = if (*stream).stream_flags.version == UINT32_MAX { ::core::ptr::null::() } else { &raw const (*stream).stream_flags }; (*iter).stream.padding = (*stream).stream_padding; if (*stream).groups.rightmost.is_null() { - (*iter).stream.compressed_size = index_size(0 as lzma_vli, 0 as lzma_vli) - .wrapping_add((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli); - (*iter).stream.uncompressed_size = 0 as lzma_vli; + (*iter).stream.compressed_size = + index_size(0, 0).wrapping_add((2 * LZMA_STREAM_HEADER_SIZE) as lzma_vli); + (*iter).stream.uncompressed_size = 0; } else { let g: *const index_group = (*stream).groups.rightmost as *const index_group; - (*iter).stream.compressed_size = ((2 as c_int * LZMA_STREAM_HEADER_SIZE) as lzma_vli) + (*iter).stream.compressed_size = ((2 * LZMA_STREAM_HEADER_SIZE) as lzma_vli) .wrapping_add(index_size( (*stream).record_count, (*stream).index_list_size, diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 9932beda..bb43452b 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_ulonglong, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -53,7 +53,7 @@ pub const SEQ_COUNT: C2RustUnnamed_0 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; -pub const INDEX_INDICATOR: c_int = 0; +pub const INDEX_INDICATOR: u8 = 0; unsafe extern "C" fn index_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -74,7 +74,7 @@ unsafe extern "C" fn index_decode( 0 => { let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) as c_int != INDEX_INDICATOR { + if *in_0.offset(fresh0 as isize) != INDEX_INDICATOR { return LZMA_DATA_ERROR; } (*coder).sequence = SEQ_COUNT; @@ -128,10 +128,10 @@ unsafe extern "C" fn index_decode( return ret_; } (*coder).count = (*coder).count.wrapping_sub(1); - (*coder).sequence = (if (*coder).count == 0 as lzma_vli { - SEQ_PADDING_INIT as c_int + (*coder).sequence = (if (*coder).count == 0 { + SEQ_PADDING_INIT } else { - SEQ_UNPADDED as c_int + SEQ_UNPADDED }) as C2RustUnnamed_0; } continue; @@ -169,16 +169,16 @@ unsafe extern "C" fn index_decode( } } 7642845755631126846 => { - if lzma_index_memusage(1 as lzma_vli, (*coder).count) > (*coder).memlimit { + if lzma_index_memusage(1, (*coder).count) > (*coder).memlimit { ret = LZMA_MEMLIMIT_ERROR; break; } else { lzma_index_prealloc((*coder).index, (*coder).count); ret = LZMA_OK; - (*coder).sequence = (if (*coder).count == 0 as lzma_vli { - SEQ_PADDING_INIT as c_int + (*coder).sequence = (if (*coder).count == 0 { + SEQ_PADDING_INIT } else { - SEQ_UNPADDED as c_int + SEQ_UNPADDED }) as C2RustUnnamed_0; continue; } @@ -191,7 +191,7 @@ unsafe extern "C" fn index_decode( } let fresh2 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if (*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff as u32 + if (*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff != *in_0.offset(fresh2 as isize) as u32 { return LZMA_DATA_ERROR; @@ -223,7 +223,7 @@ unsafe extern "C" fn index_decoder_memconfig( new_memlimit: u64, ) -> lzma_ret { let coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; - *memusage = lzma_index_memusage(1 as lzma_vli, (*coder).count); + *memusage = lzma_index_memusage(1, (*coder).count); *old_memlimit = (*coder).memlimit; if new_memlimit != 0 { if new_memlimit < *memusage { @@ -247,7 +247,7 @@ unsafe extern "C" fn index_decoder_reset( } (*coder).sequence = SEQ_INDICATOR; (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; - (*coder).count = 0 as lzma_vli; + (*coder).count = 0; (*coder).pos = 0; (*coder).crc32 = 0; return LZMA_OK; @@ -417,7 +417,7 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( if ret == LZMA_OK { ret = LZMA_DATA_ERROR; } else if ret == LZMA_MEMLIMIT_ERROR { - *memlimit = lzma_index_memusage(1 as lzma_vli, coder.count); + *memlimit = lzma_index_memusage(1, coder.count); } } return ret; diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index 85f1ecf2..ecde36a8 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -99,7 +99,7 @@ pub const SEQ_UNCOMPRESSED: C2RustUnnamed_3 = 3; pub const SEQ_UNPADDED: C2RustUnnamed_3 = 2; pub const SEQ_COUNT: C2RustUnnamed_3 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_3 = 0; -pub const INDEX_INDICATOR: c_int = 0; +pub const INDEX_INDICATOR: u8 = 0; unsafe extern "C" fn index_encode( coder_ptr: *mut c_void, _allocator: *const lzma_allocator, @@ -118,7 +118,7 @@ unsafe extern "C" fn index_encode( while *out_pos < out_size { match (*coder).sequence { 0 => { - *out.offset(*out_pos as isize) = INDEX_INDICATOR as u8; + *out.offset(*out_pos as isize) = INDEX_INDICATOR; *out_pos = (*out_pos).wrapping_add(1); (*coder).sequence = SEQ_COUNT; continue; @@ -190,7 +190,7 @@ unsafe extern "C" fn index_encode( return LZMA_OK; } *out.offset(*out_pos as isize) = - ((*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff as u32) as u8; + ((*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff) as u8; *out_pos = (*out_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); if !((*coder).pos < 4) { diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 3e98a1ae..f8b31c24 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_vli_decode( vli: *mut lzma_vli, @@ -52,16 +52,16 @@ pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; pub type lzma_index_hash = lzma_index_hash_s; pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; -pub const INDEX_INDICATOR: c_int = 0; +pub const INDEX_INDICATOR: u8 = 0; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); + return vli.wrapping_add(3) & !(3); } #[inline] extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { return (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) .wrapping_add(index_list_size) - .wrapping_add(4 as lzma_vli); + .wrapping_add(4); } #[inline] extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { @@ -91,16 +91,16 @@ pub unsafe extern "C" fn lzma_index_hash_init( } } (*index_hash).sequence = SEQ_BLOCK; - (*index_hash).blocks.blocks_size = 0 as lzma_vli; - (*index_hash).blocks.uncompressed_size = 0 as lzma_vli; - (*index_hash).blocks.count = 0 as lzma_vli; - (*index_hash).blocks.index_list_size = 0 as lzma_vli; - (*index_hash).records.blocks_size = 0 as lzma_vli; - (*index_hash).records.uncompressed_size = 0 as lzma_vli; - (*index_hash).records.count = 0 as lzma_vli; - (*index_hash).records.index_list_size = 0 as lzma_vli; - (*index_hash).unpadded_size = 0 as lzma_vli; - (*index_hash).uncompressed_size = 0 as lzma_vli; + (*index_hash).blocks.blocks_size = 0; + (*index_hash).blocks.uncompressed_size = 0; + (*index_hash).blocks.count = 0; + (*index_hash).blocks.index_list_size = 0; + (*index_hash).records.blocks_size = 0; + (*index_hash).records.uncompressed_size = 0; + (*index_hash).records.count = 0; + (*index_hash).records.index_list_size = 0; + (*index_hash).unpadded_size = 0; + (*index_hash).uncompressed_size = 0; (*index_hash).pos = 0; (*index_hash).crc32 = 0; lzma_check_init(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); @@ -195,7 +195,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( 0 => { let fresh0 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) as c_int != INDEX_INDICATOR { + if *in_0.offset(fresh0 as isize) != INDEX_INDICATOR { return LZMA_DATA_ERROR; } (*index_hash).sequence = SEQ_COUNT; @@ -217,10 +217,10 @@ pub unsafe extern "C" fn lzma_index_hash_decode( } ret = LZMA_OK; (*index_hash).pos = 0; - (*index_hash).sequence = (if (*index_hash).remaining == 0 as lzma_vli { - SEQ_PADDING_INIT as c_int + (*index_hash).sequence = (if (*index_hash).remaining == 0 { + SEQ_PADDING_INIT } else { - SEQ_UNPADDED as c_int + SEQ_UNPADDED }) as C2RustUnnamed_1; continue; } @@ -258,19 +258,19 @@ pub unsafe extern "C" fn lzma_index_hash_decode( return LZMA_DATA_ERROR; } (*index_hash).remaining = (*index_hash).remaining.wrapping_sub(1); - (*index_hash).sequence = (if (*index_hash).remaining == 0 as lzma_vli { - SEQ_PADDING_INIT as c_int + (*index_hash).sequence = (if (*index_hash).remaining == 0 { + SEQ_PADDING_INIT } else { - SEQ_UNPADDED as c_int + SEQ_UNPADDED }) as C2RustUnnamed_1; } continue; } 4 => { - (*index_hash).pos = ((4 as lzma_vli).wrapping_sub(index_size_unpadded( + (*index_hash).pos = ((4_u64).wrapping_sub(index_size_unpadded( (*index_hash).records.count, (*index_hash).records.index_list_size, - )) & 3 as lzma_vli) as size_t; + )) & 3) as size_t; (*index_hash).sequence = SEQ_PADDING; current_block = 12753679906265593574; } @@ -328,7 +328,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( } let fresh2 = *in_pos; *in_pos = (*in_pos).wrapping_add(1); - if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8) & 0xff as u32 + if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8) & 0xff != *in_0.offset(fresh2 as isize) as u32 { return LZMA_DATA_ERROR; diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 10cfef02..4c17ae52 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -105,9 +105,7 @@ unsafe extern "C" fn lzip_decode( LZMA_OK }; } - if *in_0.offset(*in_pos as isize) as c_int - != lzip_id_string[(*coder).pos as usize] as c_int - { + if *in_0.offset(*in_pos as isize) != lzip_id_string[(*coder).pos as usize] { return if !(*coder).first_member { LZMA_STREAM_END } else { @@ -170,7 +168,7 @@ unsafe extern "C" fn lzip_decode( *in_pos = (*in_pos).wrapping_add(1); let ds: u32 = *in_0.offset(fresh1 as isize) as u32; (*coder).member_size = (*coder).member_size.wrapping_add(1); - let b2log: u32 = ds & 0x1f as u32; + let b2log: u32 = ds & 0x1f; let fracnum: u32 = ds >> 5; if b2log < 12 || b2log > 29 || b2log == 12 && fracnum > 0 { return LZMA_DATA_ERROR; diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index 52c0063f..01567844 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -64,8 +64,8 @@ unsafe extern "C" fn microlzma_decode( mf: 0 as lzma_match_finder, depth: 0, ext_flags: 0, - ext_size_low: UINT32_MAX as u32, - ext_size_high: UINT32_MAX as u32, + ext_size_low: UINT32_MAX, + ext_size_high: UINT32_MAX, reserved_int4: 0, reserved_int5: 0, reserved_int6: 0, @@ -82,10 +82,7 @@ unsafe extern "C" fn microlzma_decode( options.ext_size_low = (*coder).uncomp_size as u32; options.ext_size_high = ((*coder).uncomp_size >> 32) as u32; } - if lzma_lzma_lclppb_decode( - &raw mut options, - !(*in_0.offset(*in_pos as isize) as c_int) as u8, - ) { + if lzma_lzma_lclppb_decode(&raw mut options, !*in_0.offset(*in_pos as isize)) { return LZMA_OPTIONS_ERROR; } *in_pos = (*in_pos).wrapping_add(1); @@ -158,7 +155,7 @@ unsafe extern "C" fn microlzma_decode( .wrapping_sub((*out_pos).wrapping_sub(out_start) as lzma_vli); if ret == LZMA_STREAM_END { ret = LZMA_DATA_ERROR; - } else if (*coder).uncomp_size == 0 as lzma_vli { + } else if (*coder).uncomp_size == 0 { ret = LZMA_STREAM_END; } } diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index 199d2464..e2e105c2 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -65,7 +65,7 @@ unsafe extern "C" fn microlzma_encode( } return ret; } - *out.offset(out_start as isize) = !((*coder).props as c_int) as u8; + *out.offset(out_start as isize) = !(*coder).props; *in_pos = in_start.wrapping_add(uncomp_size as size_t); return ret; } diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index 6b832257..291158cd 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -20,7 +20,7 @@ extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { #[no_mangle] pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { let limit: u64 = (UINT64_MAX) - .wrapping_div((2 as c_int * 16384 as c_int) as u64) + .wrapping_div((2 * 16384) as u64) .wrapping_div(2); if threads > LZMA_THREADS_MAX as u32 || buf_size_max > limit { return UINT64_MAX; @@ -151,8 +151,8 @@ pub unsafe extern "C" fn lzma_outq_get_buf( (*buf).finish_ret = LZMA_STREAM_END; (*buf).pos = 0; (*buf).decoder_in_pos = 0; - (*buf).unpadded_size = 0 as lzma_vli; - (*buf).uncompressed_size = 0 as lzma_vli; + (*buf).unpadded_size = 0; + (*buf).uncompressed_size = 0; (*outq).bufs_in_use = (*outq).bufs_in_use.wrapping_add(1); (*outq).mem_in_use = (*outq) .mem_in_use diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 607ec3fe..1729b9f5 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -36,9 +36,7 @@ extern "C" { ) -> lzma_ret; } pub type lzma_index = lzma_index_s; -pub const INDEX_BOUND: c_int = - 1 as c_int + 1 as c_int + 2 as c_int * LZMA_VLI_BYTES_MAX + 4 as c_int + 3 as c_int - & !(3 as c_int); +pub const INDEX_BOUND: c_int = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3 & !(3); pub const HEADERS_BOUND: c_int = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; #[no_mangle] pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { @@ -78,7 +76,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( return LZMA_UNSUPPORTED_CHECK; } let mut out_pos: size_t = *out_pos_ptr; - if out_size.wrapping_sub(out_pos) <= (2 as c_int * LZMA_STREAM_HEADER_SIZE) as size_t { + if out_size.wrapping_sub(out_pos) <= (2 * LZMA_STREAM_HEADER_SIZE) as size_t { return LZMA_BUF_ERROR; } out_size = out_size.wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index ca12b834..d6318b6c 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; #[repr(C)] pub struct lzma_index_hash_s { _opaque: [u8; 0], @@ -82,7 +82,7 @@ pub const SEQ_BLOCK_RUN: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub const INDEX_INDICATOR: c_int = 0; +pub const INDEX_INDICATOR: u8 = 0; unsafe extern "C" fn stream_decoder_reset( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, @@ -185,7 +185,7 @@ unsafe extern "C" fn stream_decode( return LZMA_OK; } if (*coder).pos == 0 { - if *in_0.offset(*in_pos as isize) as c_int == INDEX_INDICATOR { + if *in_0.offset(*in_pos as isize) == INDEX_INDICATOR { (*coder).sequence = SEQ_INDEX; current_block_100 = 16789764818708874114; } else { diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 940e9dc0..30486383 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -314,7 +314,7 @@ extern "C" fn mythread_create( ::core::ptr::null::(), func as Option *mut c_void>, arg as *mut c_void, - ) as c_int + ) }; mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); return ret; @@ -405,10 +405,10 @@ extern "C" fn mythread_condtime_set( } } pub const LZMA_THREADS_MAX: c_int = 16384; -pub const INDEX_INDICATOR: c_int = 0; +pub const INDEX_INDICATOR: u8 = 0; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - return vli.wrapping_add(3 as lzma_vli) & !(3 as lzma_vli); + return vli.wrapping_add(3) & !(3); } #[inline] extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { @@ -427,10 +427,10 @@ unsafe extern "C" fn worker_enable_partial_update(thr_ptr: *mut c_void) { let mut mythread_i_325: c_uint = 0; while if mythread_i_325 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_325: c_uint = 0; @@ -498,10 +498,10 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { let mut mythread_i_415: c_uint = 0; while if mythread_i_415 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_415: c_uint = 0; @@ -518,10 +518,10 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { let mut mythread_i_434: c_uint = 0; while if mythread_i_434 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_434: c_uint = 0; @@ -543,10 +543,10 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { let mut mythread_i_458: c_uint = 0; while if mythread_i_458 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_458: c_uint = 0; @@ -592,10 +592,10 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons let mut mythread_i_502: c_uint = 0; while if mythread_i_502 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_502: c_uint = 0; @@ -626,10 +626,10 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder) { let mut mythread_i_538: c_uint = 0; while if mythread_i_538 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_538: c_uint = 0; @@ -704,10 +704,10 @@ unsafe extern "C" fn get_thread( let mut mythread_i_608: c_uint = 0; while if mythread_i_608 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_608: c_uint = 0; @@ -753,10 +753,10 @@ unsafe extern "C" fn read_output_and_wait( let mut mythread_i_654: c_uint = 0; while if mythread_i_654 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_654: c_uint = 0; @@ -873,7 +873,7 @@ unsafe extern "C" fn decode_block_header( return LZMA_OK; } if (*coder).pos == 0 { - if *in_0.offset(*in_pos as isize) as c_int == INDEX_INDICATOR { + if *in_0.offset(*in_pos as isize) == INDEX_INDICATOR { return LZMA_RET_INTERNAL2; } (*coder).block_options.header_size = (*in_0.offset(*in_pos as isize) as u32) @@ -1391,10 +1391,10 @@ unsafe extern "C" fn stream_decode_mt( let mut mythread_i_1347: c_uint = 0; while if mythread_i_1347 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1347: c_uint = 0; @@ -1440,10 +1440,10 @@ unsafe extern "C" fn stream_decode_mt( let mut mythread_i_1410: c_uint = 0; while if mythread_i_1410 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1410: c_uint = 0; @@ -1496,10 +1496,10 @@ unsafe extern "C" fn stream_decode_mt( let mut mythread_i_1478: c_uint = 0; while if mythread_i_1478 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1478: c_uint = 0; @@ -1513,10 +1513,10 @@ unsafe extern "C" fn stream_decode_mt( let mut mythread_i_1486: c_uint = 0; while if mythread_i_1486 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1486: c_uint = 0; @@ -1563,10 +1563,10 @@ unsafe extern "C" fn stream_decode_mt( let mut mythread_i_1517: c_uint = 0; while if mythread_i_1517 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1517: c_uint = 0; @@ -1633,10 +1633,10 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( let mut mythread_i_1829: c_uint = 0; while if mythread_i_1829 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1829: c_uint = 0; @@ -1671,10 +1671,10 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( let mut mythread_i_1862: c_uint = 0; while if mythread_i_1862 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1862: c_uint = 0; @@ -1686,10 +1686,10 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( let mut mythread_i_1867: c_uint = 0; while if mythread_i_1867 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1867: c_uint = 0; @@ -1810,7 +1810,7 @@ unsafe extern "C" fn stream_decoder_mt_init( (*coder).filters[0].id = LZMA_VLI_UNKNOWN; memset( &raw mut (*coder).outq as *mut c_void, - 0 as c_int, + 0, core::mem::size_of::(), ); (*coder).block_decoder = lzma_next_coder_s { diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 10b6dba9..96f2bedd 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -284,7 +284,7 @@ extern "C" fn mythread_create( ::core::ptr::null::(), func as Option *mut c_void>, arg as *mut c_void, - ) as c_int + ) }; mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); return ret; @@ -388,10 +388,10 @@ unsafe extern "C" fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { let mut mythread_i_207: c_uint = 0; while if mythread_i_207 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_207: c_uint = 0; @@ -464,10 +464,10 @@ unsafe extern "C" fn worker_encode( let mut mythread_i_258: c_uint = 0; while if mythread_i_258 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_258: c_uint = 0; @@ -530,10 +530,10 @@ unsafe extern "C" fn worker_encode( let mut mythread_i_321: c_uint = 0; while if mythread_i_321 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_321: c_uint = 0; @@ -580,10 +580,10 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { let mut mythread_i_370: c_uint = 0; while if mythread_i_370 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_370: c_uint = 0; @@ -613,10 +613,10 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { let mut mythread_i_401: c_uint = 0; while if mythread_i_401 != 0 { mythread_mutex_unlock(&raw mut (*thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_401: c_uint = 0; @@ -632,10 +632,10 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { let mut mythread_i_408: c_uint = 0; while if mythread_i_408 != 0 { mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_408: c_uint = 0; @@ -675,10 +675,10 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_thread let mut mythread_i_449: c_uint = 0; while if mythread_i_449 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_449: c_uint = 0; @@ -699,10 +699,10 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_thread let mut mythread_i_460: c_uint = 0; while if mythread_i_460 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i_0 as isize)).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i_0 as isize)).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_460: c_uint = 0; @@ -726,10 +726,10 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons let mut mythread_i_477: c_uint = 0; while if mythread_i_477 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_477: c_uint = 0; @@ -827,10 +827,10 @@ unsafe extern "C" fn get_thread( let mut mythread_i_560: c_uint = 0; while if mythread_i_560 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_560: c_uint = 0; @@ -855,10 +855,10 @@ unsafe extern "C" fn get_thread( let mut mythread_i_578: c_uint = 0; while if mythread_i_578 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_578: c_uint = 0; @@ -914,10 +914,10 @@ unsafe extern "C" fn stream_encode_in( let mut mythread_i_628: c_uint = 0; while if mythread_i_628 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_628: c_uint = 0; @@ -940,10 +940,10 @@ unsafe extern "C" fn stream_encode_in( let mut mythread_i_649: c_uint = 0; while if mythread_i_649 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_649: c_uint = 0; @@ -975,10 +975,10 @@ unsafe extern "C" fn wait_for_work( let mut mythread_i_689: c_uint = 0; while if mythread_i_689 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_689: c_uint = 0; @@ -1052,8 +1052,8 @@ unsafe extern "C" fn stream_encode_mt( } match current_block_53 { 18046538441878631153 => { - let mut unpadded_size: lzma_vli = 0 as lzma_vli; - let mut uncompressed_size: lzma_vli = 0 as lzma_vli; + let mut unpadded_size: lzma_vli = 0; + let mut uncompressed_size: lzma_vli = 0; let mut ret: lzma_ret = LZMA_OK; let mut has_blocked: bool = false; let mut wait_abs: mythread_condtime = timespec { @@ -1064,10 +1064,10 @@ unsafe extern "C" fn stream_encode_mt( let mut mythread_i_747: c_uint = 0; while if mythread_i_747 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_747: c_uint = 0; @@ -1307,10 +1307,10 @@ unsafe extern "C" fn get_progress( let mut mythread_i_1010: c_uint = 0; while if mythread_i_1010 != 0 { mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*coder).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1010: c_uint = 0; @@ -1322,10 +1322,10 @@ unsafe extern "C" fn get_progress( let mut mythread_i_1015: c_uint = 0; while if mythread_i_1015 != 0 { mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 0 as c_int + 0 } else { mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); - 1 as c_int + 1 } != 0 { let mut mythread_j_1015: c_uint = 0; @@ -1514,7 +1514,7 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).index = core::ptr::null_mut(); memset( &raw mut (*coder).outq as *mut c_void, - 0 as c_int, + 0, core::mem::size_of::(), ); (*coder).threads = core::ptr::null_mut(); diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index d232afb7..8f8244b2 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -4,7 +4,7 @@ extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool return unsafe { (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli - && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli + && (*options).backward_size & 3 == 0 }; } #[no_mangle] diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 9af0d4ef..fd5d1475 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -18,11 +18,11 @@ extern "C" fn read32le(buf: *const u8) -> u32 { pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2; extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> bool { return unsafe { - if *in_0.offset(0) != 0 || *in_0.offset(1) as c_int & 0xf0 != 0 { + if *in_0.offset(0) != 0 || *in_0.offset(1) & 0xf0 != 0 { return true; } (*options).version = 0; - (*options).check = (*in_0.offset(1) as c_int & 0xf as c_int) as lzma_check; + (*options).check = (*in_0.offset(1) & 0xf) as lzma_check; false }; } @@ -91,9 +91,6 @@ pub unsafe extern "C" fn lzma_stream_footer_decode( } (*options).backward_size = read32le(in_0.offset(core::mem::size_of::() as usize as isize)) as lzma_vli; - (*options).backward_size = (*options) - .backward_size - .wrapping_add(1 as lzma_vli) - .wrapping_mul(4 as lzma_vli); + (*options).backward_size = (*options).backward_size.wrapping_add(1).wrapping_mul(4); return LZMA_OK; } diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 352bf5c9..0fdba749 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -20,7 +20,7 @@ extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool return unsafe { (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli - && (*options).backward_size & 3 as lzma_vli == 0 as lzma_vli + && (*options).backward_size & 3 == 0 }; } extern "C" fn stream_flags_encode(options: *const lzma_stream_flags, out: *mut u8) -> bool { @@ -77,22 +77,15 @@ pub unsafe extern "C" fn lzma_stream_footer_encode( } write32le( out.offset(4), - (*options) - .backward_size - .wrapping_div(4 as lzma_vli) - .wrapping_sub(1 as lzma_vli) as u32, + (*options).backward_size.wrapping_div(4).wrapping_sub(1) as u32, ); - if stream_flags_encode(options, out.offset((2 as c_int * 4) as isize)) { + if stream_flags_encode(options, out.offset((2 * 4) as isize)) { return LZMA_PROG_ERROR; } - let crc: u32 = lzma_crc32( - out.offset(4), - (4 as c_int + LZMA_STREAM_FLAGS_SIZE) as size_t, - 0, - ) as u32; + let crc: u32 = lzma_crc32(out.offset(4), (4 + LZMA_STREAM_FLAGS_SIZE) as size_t, 0) as u32; write32le(out, crc); memcpy( - out.offset((2 as c_int * 4) as isize) + out.offset((2 * 4) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut c_void, &raw const lzma_footer_magic as *const u8 as *const c_void, core::mem::size_of::<[u8; 2]>(), diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 29410e95..00d8528d 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -54,7 +54,7 @@ pub struct lzma_str { pub buf: *mut c_char, pub pos: size_t, } -pub type C2RustUnnamed_2 = c_uint; +pub type C2RustUnnamed_2 = u8; pub const OPTMAP_TYPE_UINT32: C2RustUnnamed_2 = 0; pub const INT_MAX: c_int = c_int::MAX; pub const LZMA_STR_ALL_FILTERS: c_uint = 0x1; @@ -82,7 +82,7 @@ unsafe extern "C" fn str_free(str: *mut lzma_str, allocator: *const lzma_allocat lzma_free((*str).buf as *mut c_void, allocator); } unsafe extern "C" fn str_is_full(str: *const lzma_str) -> bool { - return (*str).pos == (STR_ALLOC_SIZE - 1 as c_int) as size_t; + return (*str).pos == (STR_ALLOC_SIZE - 1) as size_t; } unsafe extern "C" fn str_finish( dest: *mut *mut c_char, @@ -100,7 +100,7 @@ unsafe extern "C" fn str_finish( } unsafe extern "C" fn str_append_str(str: *mut lzma_str, s: *const c_char) { let len: size_t = strlen(s) as size_t; - let limit: size_t = ((STR_ALLOC_SIZE - 1 as c_int) as size_t).wrapping_sub((*str).pos); + let limit: size_t = ((STR_ALLOC_SIZE - 1) as size_t).wrapping_sub((*str).pos); let copy_size: size_t = if len < limit { len } else { limit }; memcpy( (*str).buf.offset((*str).pos as isize) as *mut c_void, @@ -129,7 +129,7 @@ unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suf .wrapping_div(core::mem::size_of::<[c_char; 4]>() as usize) .wrapping_sub(1 as usize) { - v >>= 10 as c_int; + v >>= 10; suf = suf.wrapping_add(1); } } @@ -153,9 +153,9 @@ unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suf }; } pub const NAME_LEN_MAX: c_int = 11; -pub const OPTMAP_USE_NAME_VALUE_MAP: c_int = 0x1 as c_int; -pub const OPTMAP_USE_BYTE_SUFFIX: c_int = 0x2 as c_int; -pub const OPTMAP_NO_STRFY_ZERO: c_int = 0x4 as c_int; +pub const OPTMAP_USE_NAME_VALUE_MAP: u8 = 0x1; +pub const OPTMAP_USE_BYTE_SUFFIX: u8 = 0x2; +pub const OPTMAP_NO_STRFY_ZERO: u8 = 0x4; static mut bcj_optmap: [option_map; 1] = unsafe { [option_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"start\0\0\0\0\0\0\0"), @@ -165,7 +165,7 @@ static mut bcj_optmap: [option_map; 1] = unsafe { u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: 0, - max: UINT32_MAX as u32, + max: UINT32_MAX, }, }, }] @@ -226,16 +226,16 @@ unsafe extern "C" fn parse_lzma12_preset( str_end: *const c_char, preset: *mut u32, ) -> *const c_char { - if !(**str as c_int >= '0' as i32 && **str as c_int <= '9' as i32) { + if !(**str as u8 >= b'0' && **str as u8 <= b'9') { return b"Unsupported preset\0" as *const u8 as *const c_char; } - *preset = (**str as c_int - '0' as i32) as u32; + *preset = (**str as u8 - b'0') as u32; loop { *str = (*str).offset(1); if !(*str < str_end) { break; } - match **str as c_int { + match **str { 101 => { *preset = (*preset | LZMA_PRESET_EXTREME) as u32; } @@ -535,8 +535,8 @@ unsafe extern "C" fn parse_options( optmap: *const option_map, optmap_size: size_t, ) -> *const c_char { - while *str < str_end && **str as c_int != '\0' as i32 { - if **str as c_int == ',' as i32 { + while *str < str_end && **str != 0 { + if **str as u8 == b',' { *str = (*str).offset(1); } else { let str_len: size_t = str_end.offset_from(*str) as size_t; @@ -550,7 +550,7 @@ unsafe extern "C" fn parse_options( '=' as i32, name_eq_value_end.offset_from(*str) as size_t, ) as *const c_char; - if equals_sign.is_null() || **str as c_int == '=' as i32 { + if equals_sign.is_null() || **str as u8 == b'=' { return b"Options must be 'name=value' pairs separated with commas\0" as *const u8 as *const c_char; } @@ -567,8 +567,8 @@ unsafe extern "C" fn parse_options( *str as *const c_void, &raw const (*optmap.offset(i as isize)).name as *const c_char as *const c_void, name_len, - ) == 0 as c_int - && (*optmap.offset(i as isize)).name[name_len as usize] as c_int == '\0' as i32 + ) == 0 + && (*optmap.offset(i as isize)).name[name_len as usize] == 0 { break; } @@ -579,7 +579,7 @@ unsafe extern "C" fn parse_options( if value_len == 0 { return b"Option value cannot be empty\0" as *const u8 as *const c_char; } - if (*optmap.offset(i as isize)).type_0 as c_int == OPTMAP_TYPE_LZMA_PRESET as c_int { + if (*optmap.offset(i as isize)).type_0 == OPTMAP_TYPE_LZMA_PRESET { let errmsg: *const c_char = set_lzma12_preset(str, name_eq_value_end, filter_options); if !errmsg.is_null() { @@ -587,14 +587,14 @@ unsafe extern "C" fn parse_options( } } else { let mut v: u32 = 0; - if (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_NAME_VALUE_MAP != 0 { + if (*optmap.offset(i as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP != 0 { if value_len > NAME_LEN_MAX as size_t { return b"Invalid option value\0" as *const u8 as *const c_char; } let map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0; loop { - if (*map.offset(j as isize)).name[0] as c_int == '\0' as i32 { + if (*map.offset(j as isize)).name[0] == 0 { return b"Invalid option value\0" as *const u8 as *const c_char; } if memcmp( @@ -602,9 +602,8 @@ unsafe extern "C" fn parse_options( &raw const (*map.offset(j as isize)).name as *const c_char as *const c_void, value_len, - ) == 0 as c_int - && (*map.offset(j as isize)).name[value_len as usize] as c_int - == '\0' as i32 + ) == 0 + && (*map.offset(j as isize)).name[value_len as usize] == 0 { v = (*map.offset(j as isize)).value; break; @@ -612,41 +611,36 @@ unsafe extern "C" fn parse_options( j = j.wrapping_add(1); } } - } else if (**str as c_int) < '0' as i32 || **str as c_int > '9' as i32 { + } else if (**str as u8) < b'0' || **str as u8 > b'9' { return b"Value is not a non-negative decimal integer\0" as *const u8 as *const c_char; } else { let mut p: *const c_char = *str; v = 0; loop { - if v > (UINT32_MAX as u32).wrapping_div(10) { + if v > (UINT32_MAX).wrapping_div(10) { return b"Value out of range\0" as *const u8 as *const c_char; } v = v.wrapping_mul(10); - let add: u32 = (*p as c_int - '0' as i32) as u32; - if (UINT32_MAX as u32).wrapping_sub(add) < v { + let add: u32 = (*p as u8 - b'0') as u32; + if (UINT32_MAX).wrapping_sub(add) < v { return b"Value out of range\0" as *const u8 as *const c_char; } v = v.wrapping_add(add); p = p.offset(1); - if !(p < name_eq_value_end - && *p as c_int >= '0' as i32 - && *p as c_int <= '9' as i32) - { + if !(p < name_eq_value_end && *p as u8 >= b'0' && *p as u8 <= b'9') { break; } } if p < name_eq_value_end { let multiplier_start: *const c_char = p; - if (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_BYTE_SUFFIX - == 0 as c_int - { + if (*optmap.offset(i as isize)).flags & OPTMAP_USE_BYTE_SUFFIX == 0 { *str = multiplier_start; return b"This option does not support any multiplier suffixes\0" as *const u8 as *const c_char; } let mut shift: u32 = 0; - match *p as c_int { + match *p { 107 | 75 => { shift = 10; } @@ -664,10 +658,10 @@ unsafe extern "C" fn parse_options( } } p = p.offset(1); - if p < name_eq_value_end && *p as c_int == 'i' as i32 { + if p < name_eq_value_end && *p as u8 == b'i' { p = p.offset(1); } - if p < name_eq_value_end && *p as c_int == 'B' as i32 { + if p < name_eq_value_end && *p as u8 == b'B' { p = p.offset(1); } if p < name_eq_value_end { @@ -675,7 +669,7 @@ unsafe extern "C" fn parse_options( return b"Invalid multiplier suffix (KiB, MiB, or GiB)\0" as *const u8 as *const c_char; } - if v > UINT32_MAX as u32 >> shift { + if v > UINT32_MAX >> shift { return b"Value out of range\0" as *const u8 as *const c_char; } v <<= shift; @@ -689,7 +683,7 @@ unsafe extern "C" fn parse_options( let ptr: *mut c_void = (filter_options as *mut c_char) .offset((*optmap.offset(i as isize)).offset as isize) as *mut c_void; - match (*optmap.offset(i as isize)).type_0 as c_int { + match (*optmap.offset(i as isize)).type_0 { 1 => { *(ptr as *mut lzma_mode) = v as lzma_mode; } @@ -717,7 +711,7 @@ unsafe extern "C" fn parse_filter( let mut opts_start: *const c_char = str_end; let mut p: *const c_char = *str; while p < str_end { - if *p as c_int == ':' as i32 || *p as c_int == '=' as i32 { + if *p as u8 == b':' || *p as u8 == b'=' { name_end = p; opts_start = p.offset(1); break; @@ -739,8 +733,8 @@ unsafe extern "C" fn parse_filter( &raw const (*(&raw const filter_name_map as *const C2RustUnnamed).offset(i as isize)) .name as *const c_char as *const c_void, name_len, - ) == 0 as c_int - && filter_name_map[i as usize].name[name_len as usize] as c_int == '\0' as i32 + ) == 0 + && filter_name_map[i as usize].name[name_len as usize] == 0 { if only_xz && filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START { return b"This filter cannot be used in the .xz format\0" as *const u8 @@ -776,19 +770,18 @@ unsafe extern "C" fn str_to_filters( ) -> *const c_char { let mut current_block: u64; let mut errmsg: *const c_char = ::core::ptr::null::(); - while **str as c_int == ' ' as i32 { + while **str as u8 == b' ' { *str = (*str).offset(1); } - if **str as c_int == '\0' as i32 { + if **str == 0 { return b"Empty string is not allowed, try '6' if a default value is needed\0" as *const u8 as *const c_char; } - if **str as c_int >= '0' as i32 && **str as c_int <= '9' as i32 - || **str as c_int == '-' as i32 - && (*(*str).offset(1) as c_int >= '0' as i32 - && *(*str).offset(1) as c_int <= '9' as i32) + if **str as u8 >= b'0' && **str as u8 <= b'9' + || **str as u8 == b'-' + && (*(*str).offset(1) as u8 >= b'0' && *(*str).offset(1) as u8 <= b'9') { - if **str as c_int == '-' as i32 { + if **str as u8 == b'-' { *str = (*str).offset(1); } let str_len: size_t = strlen(*str) as size_t; @@ -796,8 +789,8 @@ unsafe extern "C" fn str_to_filters( memchr(*str as *const c_void, ' ' as i32, str_len) as *const c_char; if !str_end.is_null() { let mut i: size_t = 1; - while *str_end.offset(i as isize) as c_int != '\0' as i32 { - if *str_end.offset(i as isize) as c_int != ' ' as i32 { + while *str_end.offset(i as isize) != 0 { + if *str_end.offset(i as isize) as u8 != b' ' { return b"Unsupported preset\0" as *const u8 as *const c_char; } i = i.wrapping_add(1); @@ -840,15 +833,13 @@ unsafe extern "C" fn str_to_filters( current_block = 6100283484465977373; break; } else { - if *(*str).offset(0) as c_int == '-' as i32 && *(*str).offset(1) as c_int == '-' as i32 - { + if *(*str).offset(0) as u8 == b'-' && *(*str).offset(1) as u8 == b'-' { *str = (*str).offset(2); } let mut filter_end: *const c_char = *str; - while *filter_end.offset(0) as c_int != '\0' as i32 { - if *filter_end.offset(0) as c_int == '-' as i32 - && *filter_end.offset(1) as c_int == '-' as i32 - || *filter_end.offset(0) as c_int == ' ' as i32 + while *filter_end.offset(0) != 0 { + if *filter_end.offset(0) as u8 == b'-' && *filter_end.offset(1) as u8 == b'-' + || *filter_end.offset(0) as u8 == b' ' { break; } @@ -871,11 +862,11 @@ unsafe extern "C" fn str_to_filters( current_block = 6100283484465977373; break; } - while **str as c_int == ' ' as i32 { + while **str as u8 == b' ' { *str = (*str).offset(1); } i_0 = i_0.wrapping_add(1); - if !(**str as c_int != '\0' as i32) { + if !(**str != 0) { current_block = 15090052786889560393; break; } @@ -934,7 +925,7 @@ pub unsafe extern "C" fn lzma_str_to_filters( allocator: *const lzma_allocator, ) -> *const c_char { if !error_pos.is_null() { - *error_pos = 0 as c_int; + *error_pos = 0; } if str.is_null() || filters.is_null() { return b"Unexpected core::ptr::null_mut() pointer argument(s) to lzma_str_to_filters()\0" @@ -965,12 +956,12 @@ unsafe extern "C" fn strfy_filter( ) { let mut i: size_t = 0; while i < optmap_count { - if !((*optmap.offset(i as isize)).type_0 as c_int == OPTMAP_TYPE_LZMA_PRESET as c_int) { + if !((*optmap.offset(i as isize)).type_0 == OPTMAP_TYPE_LZMA_PRESET) { let mut v: u32 = 0; let ptr: *const c_void = (filter_options as *const c_char) .offset((*optmap.offset(i as isize)).offset as isize) as *const c_void; - match (*optmap.offset(i as isize)).type_0 as c_int { + match (*optmap.offset(i as isize)).type_0 { 1 => { v = *(ptr as *const lzma_mode) as u32; } @@ -981,8 +972,7 @@ unsafe extern "C" fn strfy_filter( v = *(ptr as *const u32); } } - if !(v == 0 && (*optmap.offset(i as isize)).flags as c_int & OPTMAP_NO_STRFY_ZERO != 0) - { + if !(v == 0 && (*optmap.offset(i as isize)).flags & OPTMAP_NO_STRFY_ZERO != 0) { str_append_str(dest, delimiter); delimiter = b",\0" as *const u8 as *const c_char; str_append_str( @@ -990,11 +980,11 @@ unsafe extern "C" fn strfy_filter( &raw const (*optmap.offset(i as isize)).name as *const c_char, ); str_append_str(dest, b"=\0" as *const u8 as *const c_char); - if (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_NAME_VALUE_MAP != 0 { + if (*optmap.offset(i as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP != 0 { let map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0; loop { - if (*map.offset(j as isize)).name[0] as c_int == '\0' as i32 { + if (*map.offset(j as isize)).name[0] == 0 { str_append_str(dest, b"UNKNOWN\0" as *const u8 as *const c_char); break; } else if (*map.offset(j as isize)).value == v { @@ -1011,7 +1001,7 @@ unsafe extern "C" fn strfy_filter( str_append_u32( dest, v, - (*optmap.offset(i as isize)).flags as c_int & OPTMAP_USE_BYTE_SUFFIX != 0, + (*optmap.offset(i as isize)).flags & OPTMAP_USE_BYTE_SUFFIX != 0, ); } } @@ -1097,9 +1087,9 @@ pub unsafe extern "C" fn lzma_str_from_filters( break; } else { let optmap_count: size_t = (if flags & LZMA_STR_ENCODER as u32 != 0 { - filter_name_map[j as usize].strfy_encoder as c_int + filter_name_map[j as usize].strfy_encoder } else { - filter_name_map[j as usize].strfy_decoder as c_int + filter_name_map[j as usize].strfy_decoder }) as size_t; strfy_filter( &raw mut dest, @@ -1183,9 +1173,9 @@ pub unsafe extern "C" fn lzma_str_list_filters( let optmap: *const option_map = filter_name_map[i as usize].optmap; let mut d: *const c_char = opt_delim; let end: size_t = (if flags & LZMA_STR_ENCODER as u32 != 0 { - filter_name_map[i as usize].strfy_encoder as c_int + filter_name_map[i as usize].strfy_encoder } else { - filter_name_map[i as usize].strfy_decoder as c_int + filter_name_map[i as usize].strfy_decoder }) as size_t; let mut j: size_t = 0; while j < end { @@ -1196,17 +1186,14 @@ pub unsafe extern "C" fn lzma_str_list_filters( &raw const (*optmap.offset(j as isize)).name as *const c_char, ); str_append_str(&raw mut dest, b"=<\0" as *const u8 as *const c_char); - if (*optmap.offset(j as isize)).type_0 as c_int - == OPTMAP_TYPE_LZMA_PRESET as c_int - { + if (*optmap.offset(j as isize)).type_0 == OPTMAP_TYPE_LZMA_PRESET { str_append_str(&raw mut dest, LZMA12_PRESET_STR.as_ptr()); - } else if (*optmap.offset(j as isize)).flags as c_int - & OPTMAP_USE_NAME_VALUE_MAP + } else if (*optmap.offset(j as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP != 0 { let m: *const name_value_map = (*optmap.offset(j as isize)).u.map; let mut k: size_t = 0; - while (*m.offset(k as isize)).name[0] as c_int != '\0' as i32 { + while (*m.offset(k as isize)).name[0] != 0 { if k > 0 { str_append_str( &raw mut dest, @@ -1220,9 +1207,8 @@ pub unsafe extern "C" fn lzma_str_list_filters( k = k.wrapping_add(1); } } else { - let use_byte_suffix: bool = (*optmap.offset(j as isize)).flags as c_int - & OPTMAP_USE_BYTE_SUFFIX - != 0; + let use_byte_suffix: bool = + (*optmap.offset(j as isize)).flags & OPTMAP_USE_BYTE_SUFFIX != 0; str_append_u32( &raw mut dest, (*optmap.offset(j as isize)).u.range.min, @@ -1253,7 +1239,7 @@ unsafe extern "C" fn run_static_initializers() { lzma12_optmap = [ option_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"preset\0\0\0\0\0\0"), - type_0: OPTMAP_TYPE_LZMA_PRESET as u8, + type_0: OPTMAP_TYPE_LZMA_PRESET, flags: 0, offset: 0, u: C2RustUnnamed_0 { @@ -1263,7 +1249,7 @@ unsafe extern "C" fn run_static_initializers() { option_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dict\0\0\0\0\0\0\0\0"), type_0: 0, - flags: OPTMAP_USE_BYTE_SUFFIX as u8, + flags: OPTMAP_USE_BYTE_SUFFIX, offset: 0, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { @@ -1310,8 +1296,8 @@ unsafe extern "C" fn run_static_initializers() { }, option_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mode\0\0\0\0\0\0\0\0"), - type_0: OPTMAP_TYPE_LZMA_MODE as u8, - flags: OPTMAP_USE_NAME_VALUE_MAP as u8, + type_0: OPTMAP_TYPE_LZMA_MODE, + flags: OPTMAP_USE_NAME_VALUE_MAP, offset: 32, u: C2RustUnnamed_0 { map: &raw const lzma12_mode_map as *const name_value_map, @@ -1328,8 +1314,8 @@ unsafe extern "C" fn run_static_initializers() { }, option_map { name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mf\0\0\0\0\0\0\0\0\0\0"), - type_0: OPTMAP_TYPE_LZMA_MATCH_FINDER as u8, - flags: OPTMAP_USE_NAME_VALUE_MAP as u8, + type_0: OPTMAP_TYPE_LZMA_MATCH_FINDER, + flags: OPTMAP_USE_NAME_VALUE_MAP, offset: 40, u: C2RustUnnamed_0 { map: &raw const lzma12_mf_map as *const name_value_map, @@ -1343,7 +1329,7 @@ unsafe extern "C" fn run_static_initializers() { u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: 0, - max: UINT32_MAX as u32, + max: UINT32_MAX, }, }, }, diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index 335a833a..beacd6c3 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_int; #[no_mangle] pub unsafe extern "C" fn lzma_vli_decode( vli: *mut lzma_vli, @@ -11,17 +10,15 @@ pub unsafe extern "C" fn lzma_vli_decode( let mut vli_pos_internal: size_t = 0; if vli_pos.is_null() { vli_pos = &raw mut vli_pos_internal; - *vli = 0 as lzma_vli; + *vli = 0; if *in_pos >= in_size { return LZMA_DATA_ERROR; } } else { if *vli_pos == 0 { - *vli = 0 as lzma_vli; + *vli = 0; } - if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t - || *vli >> (*vli_pos).wrapping_mul(7) != 0 as lzma_vli - { + if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || *vli >> (*vli_pos).wrapping_mul(7) != 0 { return LZMA_PROG_ERROR; } if *in_pos >= in_size { @@ -31,12 +28,10 @@ pub unsafe extern "C" fn lzma_vli_decode( loop { let byte: u8 = *in_0.offset(*in_pos as isize); *in_pos = (*in_pos).wrapping_add(1); - *vli = (*vli).wrapping_add( - ((byte as c_int & 0x7f as c_int) as lzma_vli) << (*vli_pos).wrapping_mul(7), - ); + *vli = (*vli).wrapping_add(((byte & 0x7f) as lzma_vli) << (*vli_pos).wrapping_mul(7)); *vli_pos = (*vli_pos).wrapping_add(1); - if byte as c_int & 0x80 as c_int == 0 as c_int { - if byte as c_int == 0 as c_int && *vli_pos > 1 { + if byte & 0x80 == 0 { + if byte == 0 && *vli_pos > 1 { return LZMA_DATA_ERROR; } return if vli_pos == &raw mut vli_pos_internal { diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index 77e19747..4b8e996c 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_int; #[no_mangle] pub unsafe extern "C" fn lzma_vli_encode( mut vli: lzma_vli, @@ -21,10 +20,10 @@ pub unsafe extern "C" fn lzma_vli_encode( return LZMA_PROG_ERROR; } vli >>= (*vli_pos).wrapping_mul(7); - while vli >= 0x80 as lzma_vli { + while vli >= 0x80 { *vli_pos = (*vli_pos).wrapping_add(1); - *out.offset(*out_pos as isize) = (vli as u8 as c_int | 0x80 as c_int) as u8; - vli >>= 7 as c_int; + *out.offset(*out_pos as isize) = vli as u8 | 0x80; + vli >>= 7; *out_pos = (*out_pos).wrapping_add(1); if *out_pos == out_size { return if vli_pos == &raw mut vli_pos_internal { diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index b11f4ee3..3751ca7a 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_int; #[no_mangle] pub extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { if vli > LZMA_VLI_MAX { @@ -7,9 +6,9 @@ pub extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { } let mut i: u32 = 0; loop { - vli >>= 7 as c_int; + vli >>= 7; i = i.wrapping_add(1); - if !(vli != 0 as lzma_vli) { + if !(vli != 0) { break; } } diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index c4f3d9e8..49d2ebee 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -50,11 +50,7 @@ pub unsafe extern "C" fn lzma_delta_coder_init( let opt: *const lzma_options_delta = (*filters.offset(0)).options as *const lzma_options_delta; (*coder).distance = (*opt).dist as size_t; (*coder).pos = 0; - memset( - &raw mut (*coder).history as *mut u8 as *mut c_void, - 0 as c_int, - 256, - ); + memset(&raw mut (*coder).history as *mut u8 as *mut c_void, 0, 256); return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); } #[no_mangle] diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 4ff970fa..822a0b50 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_delta_coder_init( next: *mut lzma_next_coder, @@ -12,13 +12,13 @@ unsafe extern "C" fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8 let mut i: size_t = 0; while i < size { let ref mut fresh0 = *buffer.offset(i as isize); - *fresh0 = (*fresh0 as c_int - + (*coder).history - [(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) as usize] - as c_int) as u8; + *fresh0 = (*fresh0).wrapping_add( + (*coder).history + [(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize], + ); let fresh1 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder).history[(fresh1 as c_int & 0xff as c_int) as usize] = *buffer.offset(i as isize); + (*coder).history[(fresh1 & 0xff) as usize] = *buffer.offset(i as isize); i = i.wrapping_add(1); } } diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index 14329c5e..adffe88e 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -24,11 +24,11 @@ unsafe extern "C" fn copy_and_encode( let mut i: size_t = 0; while i < size { let tmp: u8 = (*coder).history - [(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) as usize]; + [(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize]; let fresh2 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder).history[(fresh2 as c_int & 0xff as c_int) as usize] = *in_0.offset(i as isize); - *out.offset(i as isize) = (*in_0.offset(i as isize) as c_int - tmp as c_int) as u8; + (*coder).history[(fresh2 & 0xff) as usize] = *in_0.offset(i as isize); + *out.offset(i as isize) = (*in_0.offset(i as isize)).wrapping_sub(tmp); i = i.wrapping_add(1); } } @@ -37,12 +37,12 @@ unsafe extern "C" fn encode_in_place(coder: *mut lzma_delta_coder, buffer: *mut let mut i: size_t = 0; while i < size { let tmp: u8 = (*coder).history - [(distance.wrapping_add((*coder).pos as size_t) & 0xff as size_t) as usize]; + [(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize]; let fresh0 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder).history[(fresh0 as c_int & 0xff as c_int) as usize] = *buffer.offset(i as isize); + (*coder).history[(fresh0 & 0xff) as usize] = *buffer.offset(i as isize); let ref mut fresh1 = *buffer.offset(i as isize); - *fresh1 = (*fresh1 as c_int - tmp as c_int) as u8; + *fresh1 = (*fresh1).wrapping_sub(tmp); i = i.wrapping_add(1); } } diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index d73c7710..183247b1 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -48,10 +48,7 @@ pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { unsafe extern "C" fn lz_decoder_reset(coder: *mut lzma_coder) { (*coder).dict.pos = LZ_DICT_INIT_POS as size_t; (*coder).dict.full = 0; - *(*coder) - .dict - .buf - .offset((LZ_DICT_INIT_POS - 1 as c_int) as isize) = '\0' as i32 as u8; + *(*coder).dict.buf.offset((LZ_DICT_INIT_POS - 1) as isize) = '\0' as i32 as u8; (*coder).dict.has_wrapped = false; (*coder).dict.need_reset = false; } @@ -264,7 +261,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( if lz_options.dict_size > (SIZE_MAX as size_t) .wrapping_sub(15) - .wrapping_sub((2 as c_int * LZ_DICT_REPEAT_MAX) as size_t) + .wrapping_sub((2 * LZ_DICT_REPEAT_MAX) as size_t) .wrapping_sub(LZ_DICT_EXTRA as size_t) { return LZMA_MEM_ERROR; @@ -272,7 +269,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( lz_options.dict_size = lz_options.dict_size.wrapping_add(15) & !(15); let alloc_size: size_t = lz_options .dict_size - .wrapping_add((2 as c_int * LZ_DICT_REPEAT_MAX) as size_t); + .wrapping_add((2 * LZ_DICT_REPEAT_MAX) as size_t); if (*coder).dict.size != alloc_size { lzma_free((*coder).dict.buf as *mut c_void, allocator); (*coder).dict.buf = @@ -308,6 +305,6 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( pub extern "C" fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64 { return (core::mem::size_of::() as u64) .wrapping_add(dictionary_size as u64) - .wrapping_add((2 as c_int * LZ_DICT_REPEAT_MAX) as u64) + .wrapping_add((2 * LZ_DICT_REPEAT_MAX) as u64) .wrapping_add(LZ_DICT_EXTRA as u64); } diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index cb05ad82..dd9d6cba 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -53,7 +53,7 @@ pub struct lzma_coder { } #[inline] extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { - return match_finder as u32 & 0xf as u32; + return match_finder as u32 & 0xf; } pub const HASH_2_SIZE: c_uint = 1u32 << 10; pub const HASH_3_SIZE: c_uint = 1u32 << 16; @@ -114,7 +114,7 @@ unsafe extern "C" fn fill_window( (*coder).mf.write_pos = write_pos as u32; memset( (*coder).mf.buffer.offset(write_pos as isize) as *mut c_void, - 0 as c_int, + 0, 0, ); if ret == LZMA_STREAM_END { @@ -256,20 +256,20 @@ unsafe extern "C" fn lz_encoder_prepare( let is_bt: bool = (*lz_options).match_finder & 0x10 != 0; let mut hs: u32 = 0; if hash_bytes == 2 { - hs = 0xffff as u32; + hs = 0xffff; } else { hs = (*lz_options).dict_size.wrapping_sub(1) as u32; hs |= hs >> 1; hs |= hs >> 2; hs |= hs >> 4; hs |= hs >> 8; - hs >>= 1 as c_int; - hs |= 0xffff as u32; + hs >>= 1; + hs |= 0xffff; if hs > (1) << 24 { if hash_bytes == 3 { hs = (1u32 << 24).wrapping_sub(1) as u32; } else { - hs >>= 1 as c_int; + hs >>= 1; } } } @@ -319,7 +319,7 @@ unsafe extern "C" fn lz_encoder_init( } memset( (*mf).buffer.offset((*mf).size as isize) as *mut c_void, - 0 as c_int, + 0, 0, ); } @@ -348,7 +348,7 @@ unsafe extern "C" fn lz_encoder_init( } else { memset( (*mf).hash as *mut c_void, - 0 as c_int, + 0, ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::()), ); } diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index fa09f79f..0eb6aed4 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -24,8 +24,7 @@ unsafe extern "C" fn lzma_memcmplen( mut len: u32, limit: u32, ) -> u32 { - while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int - { + while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { len = len.wrapping_add(1); } return len; @@ -123,8 +122,8 @@ unsafe extern "C" fn hc_find_func( .wrapping_add(if delta > cyclic_pos { cyclic_size } else { 0 }) as isize, ); - if *pb.offset(len_best as isize) as c_int == *cur.offset(len_best as isize) as c_int - && *pb.offset(0) as c_int == *cur.offset(0) as c_int + if *pb.offset(len_best as isize) == *cur.offset(len_best as isize) + && *pb.offset(0) == *cur.offset(0) { let len: u32 = lzma_memcmplen(pb, cur, 1, len_limit); if len_best < len { @@ -163,7 +162,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m .hash .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; let mut len_best: u32 = 2; - if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { + if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); (*matches.offset(0)).len = len_best; (*matches.offset(0)).dist = delta2.wrapping_sub(1); @@ -252,16 +251,13 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m .hash .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; let mut len_best: u32 = 1; - if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { + if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = 2; (*matches.offset(0)).len = 2; (*matches.offset(0)).dist = delta2.wrapping_sub(1); matches_count = 1; } - if delta2 != delta3 - && delta3 < (*mf).cyclic_size - && *cur.offset(-(delta3 as isize)) as c_int == *cur as c_int - { + if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) == *cur { len_best = 3; let fresh3 = matches_count; matches_count = matches_count.wrapping_add(1); @@ -363,7 +359,7 @@ unsafe extern "C" fn bt_find_func( ); let pb: *const u8 = cur.offset(-(delta as isize)); let mut len: u32 = if len0 < len1 { len0 } else { len1 }; - if *pb.offset(len as isize) as c_int == *cur.offset(len as isize) as c_int { + if *pb.offset(len as isize) == *cur.offset(len as isize) { len = lzma_memcmplen(pb, cur, len.wrapping_add(1), len_limit); if len_best < len { len_best = len; @@ -377,7 +373,7 @@ unsafe extern "C" fn bt_find_func( } } } - if (*pb.offset(len as isize) as c_int) < *cur.offset(len as isize) as c_int { + if (*pb.offset(len as isize)) < *cur.offset(len as isize) { *ptr1 = cur_match; ptr1 = pair.offset(1); cur_match = *ptr1; @@ -421,7 +417,7 @@ unsafe extern "C" fn bt_skip_func( ); let pb: *const u8 = cur.offset(-(delta as isize)); let mut len: u32 = if len0 < len1 { len0 } else { len1 }; - if *pb.offset(len as isize) as c_int == *cur.offset(len as isize) as c_int { + if *pb.offset(len as isize) == *cur.offset(len as isize) { len = lzma_memcmplen(pb, cur, len.wrapping_add(1), len_limit); if len == len_limit { *ptr1 = *pair.offset(0); @@ -429,7 +425,7 @@ unsafe extern "C" fn bt_skip_func( return; } } - if (*pb.offset(len as isize) as c_int) < *cur.offset(len as isize) as c_int { + if (*pb.offset(len as isize)) < *cur.offset(len as isize) { *ptr1 = cur_match; ptr1 = pair.offset(1); cur_match = *ptr1; @@ -538,7 +534,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m .hash .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; let mut len_best: u32 = 2; - if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { + if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); (*matches.offset(0)).len = len_best; (*matches.offset(0)).dist = delta2.wrapping_sub(1); @@ -658,16 +654,13 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m .hash .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; let mut len_best: u32 = 1; - if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) as c_int == *cur as c_int { + if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = 2; (*matches.offset(0)).len = 2; (*matches.offset(0)).dist = delta2.wrapping_sub(1); matches_count = 1; } - if delta2 != delta3 - && delta3 < (*mf).cyclic_size - && *cur.offset(-(delta3 as isize)) as c_int == *cur as c_int - { + if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) == *cur { len_best = 3; let fresh6 = matches_count; matches_count = matches_count.wrapping_add(1); diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index 1002a6f4..635b2f38 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -112,23 +112,23 @@ unsafe extern "C" fn lzma2_decode( if control == 0 { return LZMA_STREAM_END; } - if control >= 0xe0 as u32 || control == 1 { + if control >= 0xe0 || control == 1 { (*coder).need_properties = true; (*coder).need_dictionary_reset = true; } else if (*coder).need_dictionary_reset { return LZMA_DATA_ERROR; } - if control >= 0x80 as u32 { - (*coder).uncompressed_size = ((control & 0x1f as u32) << 16) as size_t; + if control >= 0x80 { + (*coder).uncompressed_size = ((control & 0x1f) << 16) as size_t; (*coder).sequence = SEQ_UNCOMPRESSED_1; - if control >= 0xc0 as u32 { + if control >= 0xc0 { (*coder).need_properties = false; (*coder).next_sequence = SEQ_PROPERTIES; } else if (*coder).need_properties { return LZMA_DATA_ERROR; } else { (*coder).next_sequence = SEQ_LZMA; - if control >= 0xa0 as u32 { + if control >= 0xa0 { (*coder).lzma.reset.expect("non-null function pointer")( (*coder).lzma.coder, &raw mut (*coder).options as *const c_void, @@ -328,10 +328,10 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if props_size != 1 { return LZMA_OPTIONS_ERROR; } - if *props.offset(0) as c_int & 0xc0 != 0 { + if *props.offset(0) & 0xc0 != 0 { return LZMA_OPTIONS_ERROR; } - if *props.offset(0) as c_int > 40 as c_int { + if *props.offset(0) > 40 { return LZMA_OPTIONS_ERROR; } let opt: *mut lzma_options_lzma = @@ -339,8 +339,8 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if opt.is_null() { return LZMA_MEM_ERROR; } - if *props.offset(0) as c_int == 40 as c_int { - (*opt).dict_size = UINT32_MAX as u32; + if *props.offset(0) == 40 { + (*opt).dict_size = UINT32_MAX; } else { (*opt).dict_size = 2u32 | (u32::from(*props.offset(0)) & 1); (*opt).dict_size <<= u32::from(*props.offset(0)).wrapping_div(2).wrapping_add(11); diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 2db3a488..ff650869 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -115,20 +115,15 @@ unsafe extern "C" fn mf_read( pub const FASTPOS_BITS: c_int = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < (1) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { + if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { - return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] - as u32) - .wrapping_add( - (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + if dist < (1) << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { + return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); } - return (lzma_fastpos[(dist >> 0 + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) - .wrapping_add( - (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + return (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32); } pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; pub const LZMA2_UNCOMPRESSED_MAX: c_uint = 1u32 << 21; @@ -139,14 +134,14 @@ unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { if (*coder).need_properties { pos = 0; if (*coder).need_dictionary_reset { - (*coder).buf[pos as usize] = (0x80 as c_int + ((3 as c_int) << 5)) as u8; + (*coder).buf[pos as usize] = (0x80 + ((3) << 5)) as u8; } else { - (*coder).buf[pos as usize] = (0x80 as c_int + ((2 as c_int) << 5)) as u8; + (*coder).buf[pos as usize] = (0x80 + ((2) << 5)) as u8; } } else { pos = 1; if (*coder).need_state_reset { - (*coder).buf[pos as usize] = (0x80 as c_int + ((1 as c_int) << 5)) as u8; + (*coder).buf[pos as usize] = (0x80 + ((1) << 5)) as u8; } else { (*coder).buf[pos as usize] = 0x80 as u8; } @@ -156,20 +151,20 @@ unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { let fresh1 = pos; pos = pos.wrapping_add(1); (*coder).buf[fresh1 as usize] = - ((*coder).buf[fresh1 as usize] as size_t).wrapping_add(size >> 16) as u8 as u8; + ((*coder).buf[fresh1 as usize] as size_t).wrapping_add(size >> 16) as u8; let fresh2 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh2 as usize] = (size >> 8 & 0xff as size_t) as u8; + (*coder).buf[fresh2 as usize] = (size >> 8 & 0xff) as u8; let fresh3 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh3 as usize] = (size & 0xff as size_t) as u8; + (*coder).buf[fresh3 as usize] = (size & 0xff) as u8; size = (*coder).compressed_size.wrapping_sub(1); let fresh4 = pos; pos = pos.wrapping_add(1); (*coder).buf[fresh4 as usize] = (size >> 8) as u8; let fresh5 = pos; pos = pos.wrapping_add(1); - (*coder).buf[fresh5 as usize] = (size & 0xff as size_t) as u8; + (*coder).buf[fresh5 as usize] = (size & 0xff) as u8; if (*coder).need_properties { lzma_lzma_lclppb_encode( &raw mut (*coder).opt_cur, @@ -191,7 +186,7 @@ unsafe extern "C" fn lzma2_header_uncompressed(coder: *mut lzma_lzma2_coder) { } (*coder).need_dictionary_reset = false; (*coder).buf[1] = ((*coder).uncompressed_size.wrapping_sub(1) >> 8) as u8; - (*coder).buf[2] = ((*coder).uncompressed_size.wrapping_sub(1) & 0xff as size_t) as u8; + (*coder).buf[2] = ((*coder).uncompressed_size.wrapping_sub(1) & 0xff) as u8; (*coder).buf_pos = 0; } unsafe extern "C" fn lzma2_encode( @@ -434,7 +429,7 @@ unsafe extern "C" fn lzma2_encoder_init( let ret_: lzma_ret = lzma_lzma_encoder_create( &raw mut (*coder).lzma, allocator, - 0x21 as lzma_vli, + 0x21, &raw mut (*coder).opt_cur, lz_options, ); @@ -498,7 +493,7 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *m d |= d >> 4; d |= d >> 8; d |= d >> 16; - if d == UINT32_MAX as u32 { + if d == UINT32_MAX { *out.offset(0) = 40; } else { *out.offset(0) = get_dist_slot(d.wrapping_add(1)).wrapping_sub(24) as u8; diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 788992e0..b3fa4b2f 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -389,11 +389,11 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).rep_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice = - ((*coder).rep_len_decoder.choice as u32).wrapping_add( + (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice as u32) + .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).rep_len_decoder.choice as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; probs = &raw mut *(&raw mut (*coder).rep_len_decoder.low as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; @@ -402,9 +402,8 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice as c_int - - ((*coder).rep_len_decoder.choice as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).rep_len_decoder.choice = (*coder).rep_len_decoder.choice + - ((*coder).rep_len_decoder.choice >> RC_MOVE_BITS); current_block = 6834592846991627977; continue; } @@ -427,12 +426,12 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).is_rep2[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep2[state as usize] = - ((*coder).is_rep2[state as usize] as u32).wrapping_add( + (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] as u32) + .wrapping_add( RC_BIT_MODEL_TOTAL .wrapping_sub((*coder).is_rep2[state as usize] as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; let distance_3: u32 = rep2; rep2 = rep1; rep1 = rep0; @@ -440,9 +439,8 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] as c_int - - ((*coder).is_rep2[state as usize] as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).is_rep2[state as usize] = (*coder).is_rep2[state as usize] + - ((*coder).is_rep2[state as usize] >> RC_MOVE_BITS); let distance_4: u32 = rep3; rep3 = rep2; rep2 = rep1; @@ -468,21 +466,20 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).is_rep1[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep1[state as usize] = - ((*coder).is_rep1[state as usize] as u32).wrapping_add( + (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] as u32) + .wrapping_add( RC_BIT_MODEL_TOTAL .wrapping_sub((*coder).is_rep1[state as usize] as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; let distance_2: u32 = rep1; rep1 = rep0; rep0 = distance_2; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] as c_int - - ((*coder).is_rep1[state as usize] as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).is_rep1[state as usize] = (*coder).is_rep1[state as usize] + - ((*coder).is_rep1[state as usize] >> RC_MOVE_BITS); current_block = 3996983927318648760; continue; } @@ -521,21 +518,21 @@ unsafe extern "C" fn lzma_decode( (*coder).is_rep0_long[state as usize][pos_state as usize] as u32, ) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; state = (if state < LIT_STATES as u32 { - STATE_LIT_SHORTREP as c_int + STATE_LIT_SHORTREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as u32; current_block = 5341942013764523046; continue; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep0_long[state as usize][pos_state as usize] = - ((*coder).is_rep0_long[state as usize][pos_state as usize] as c_int - - ((*coder).is_rep0_long[state as usize][pos_state as usize] as c_int - >> RC_MOVE_BITS)) as probability; + (*coder).is_rep0_long[state as usize][pos_state as usize] = (*coder) + .is_rep0_long[state as usize][pos_state as usize] + - ((*coder).is_rep0_long[state as usize][pos_state as usize] + >> RC_MOVE_BITS); } current_block = 15498320742470848828; } @@ -556,20 +553,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).is_rep0[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep0[state as usize] = - ((*coder).is_rep0[state as usize] as u32).wrapping_add( + (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] as u32) + .wrapping_add( RC_BIT_MODEL_TOTAL .wrapping_sub((*coder).is_rep0[state as usize] as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; current_block = 1698084742280242340; continue; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] as c_int - - ((*coder).is_rep0[state as usize] as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).is_rep0[state as usize] = (*coder).is_rep0[state as usize] + - ((*coder).is_rep0[state as usize] >> RC_MOVE_BITS); current_block = 11808118301119257848; continue; } @@ -591,15 +587,15 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).is_rep[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep[state as usize] = - ((*coder).is_rep[state as usize] as u32).wrapping_add( + (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as u32) + .wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).is_rep[state as usize] as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; state = (if state < LIT_STATES as u32 { - STATE_LIT_MATCH as c_int + STATE_LIT_MATCH } else { - STATE_NONLIT_MATCH as c_int + STATE_NONLIT_MATCH }) as u32; rep3 = rep2; rep2 = rep1; @@ -609,9 +605,8 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as c_int - - ((*coder).is_rep[state as usize] as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] + - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); if !(!dict_is_distance_valid(&raw mut dict, 0)) { current_block = 4420799852307653083; continue; @@ -665,23 +660,23 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32, ) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[offset.wrapping_add(symbol) as usize] = - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as c_int - - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as c_int - >> RC_MOVE_BITS)) as probability; + (*coder).pos_align[offset.wrapping_add(symbol) as usize] = (*coder).pos_align + [offset.wrapping_add(symbol) as usize] + - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] + >> RC_MOVE_BITS); symbol = symbol.wrapping_add(offset); } - offset <<= 1 as c_int; + offset <<= 1; if offset < ALIGN_SIZE as u32 { current_block = 10510472849010538284; continue; } rep0 = rep0.wrapping_add(symbol); - if rep0 == UINT32_MAX as u32 { + if rep0 == UINT32_MAX { current_block = 12043253436139097694; } else { current_block = 13383302701878543647; @@ -700,7 +695,7 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *fresh135 as u32; } } - rc.range >>= 1 as c_int; + rc.range >>= 1; rc.code = rc.code.wrapping_sub(rc.range); rc_bound = 0u32.wrapping_sub(rc.code >> 31); rc.code = rc.code.wrapping_add(rc.range & rc_bound); @@ -737,15 +732,13 @@ unsafe extern "C" fn lzma_decode( *fresh133 = (*fresh133 as u32).wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh134 = *probs.offset(symbol as isize); - *fresh134 = (*fresh134 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh134 = *fresh134 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); rep0 = (rep0 as u32).wrapping_add(1u32 << offset) as u32; } @@ -777,15 +770,13 @@ unsafe extern "C" fn lzma_decode( *fresh130 = (*fresh130 as u32).wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh131 = *probs.offset(symbol as isize); - *fresh131 = (*fresh131 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh131 = *fresh131 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if symbol < DIST_SLOTS as u32 { @@ -837,15 +828,13 @@ unsafe extern "C" fn lzma_decode( *fresh127 = (*fresh127 as u32).wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh128 = *probs.offset(symbol as isize); - *fresh128 = (*fresh128 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh128 = *fresh128 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if symbol < limit { @@ -857,7 +846,7 @@ unsafe extern "C" fn lzma_decode( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { len.wrapping_sub(MATCH_LEN_MIN as u32) } else { - (DIST_STATES - 1 as c_int) as u32 + (DIST_STATES - 1) as u32 }) as isize, ) as *mut probability; symbol = 1; @@ -881,12 +870,12 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).match_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice2 = - ((*coder).match_len_decoder.choice2 as u32).wrapping_add( + (*coder).match_len_decoder.choice2 = ((*coder).match_len_decoder.choice2 as u32) + .wrapping_add( RC_BIT_MODEL_TOTAL .wrapping_sub((*coder).match_len_decoder.choice2 as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; probs = &raw mut *(&raw mut (*coder).match_len_decoder.mid as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; @@ -895,10 +884,8 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.choice2 = ((*coder).match_len_decoder.choice2 - as c_int - - ((*coder).match_len_decoder.choice2 as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).match_len_decoder.choice2 = (*coder).match_len_decoder.choice2 + - ((*coder).match_len_decoder.choice2 >> RC_MOVE_BITS); probs = &raw mut (*coder).match_len_decoder.high as *mut probability; limit = LEN_HIGH_SYMBOLS as u32; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32; @@ -922,12 +909,12 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).match_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice = - ((*coder).match_len_decoder.choice as u32).wrapping_add( + (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice as u32) + .wrapping_add( RC_BIT_MODEL_TOTAL .wrapping_sub((*coder).match_len_decoder.choice as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; probs = &raw mut *(&raw mut (*coder).match_len_decoder.low as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; @@ -936,9 +923,8 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice as c_int - - ((*coder).match_len_decoder.choice as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).match_len_decoder.choice = (*coder).match_len_decoder.choice + - ((*coder).match_len_decoder.choice >> RC_MOVE_BITS); current_block = 13912927785247575907; continue; } @@ -977,21 +963,20 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; offset &= !match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh122 = *probs.offset(subcoder_index as isize); - *fresh122 = (*fresh122 as c_int - - (*probs.offset(subcoder_index as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh122 = + *fresh122 - (*probs.offset(subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); offset &= match_bit; } - len <<= 1 as c_int; - if symbol < ((1 as c_int) << 8) as u32 { + len <<= 1; + if symbol < ((1) << 8) as u32 { current_block = 18125716024132132232; continue; } else { @@ -1052,7 +1037,7 @@ unsafe extern "C" fn lzma_decode( as probability as probability; probs = (&raw mut (*coder).literal as *mut probability).offset( - (3 as size_t).wrapping_mul( + (3_usize).wrapping_mul( ((dict.pos << 8).wrapping_add(dict_get0(&raw mut dict) as size_t) & literal_mask as size_t) << literal_context_bits, @@ -1074,17 +1059,16 @@ unsafe extern "C" fn lzma_decode( state.wrapping_sub(6) }; len = (dict_get(&raw mut dict, rep0) as u32) << 1; - offset = 0x100 as u32; + offset = 0x100; current_block = 18125716024132132232; continue; } } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_match[state as usize][pos_state as usize] = - ((*coder).is_match[state as usize][pos_state as usize] as c_int - - ((*coder).is_match[state as usize][pos_state as usize] as c_int - >> RC_MOVE_BITS)) as probability; + (*coder).is_match[state as usize][pos_state as usize] = (*coder).is_match + [state as usize][pos_state as usize] + - ((*coder).is_match[state as usize][pos_state as usize] >> RC_MOVE_BITS); current_block = 3469750012682708893; continue; } @@ -1110,18 +1094,16 @@ unsafe extern "C" fn lzma_decode( *fresh118 = (*fresh118 as u32).wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh119 = *probs.offset(symbol as isize); - *fresh119 = (*fresh119 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh119 = *fresh119 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - if symbol < ((1 as c_int) << 8) as u32 { + if symbol < ((1) << 8) as u32 { current_block = 13844743919235296534; continue; } else { @@ -1150,15 +1132,13 @@ unsafe extern "C" fn lzma_decode( *fresh145 = (*fresh145 as u32).wrapping_add( RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh146 = *probs.offset(symbol as isize); - *fresh146 = (*fresh146 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh146 = *fresh146 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if symbol < limit { @@ -1195,12 +1175,12 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul((*coder).rep_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice2 = - ((*coder).rep_len_decoder.choice2 as u32).wrapping_add( + (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 as u32) + .wrapping_add( RC_BIT_MODEL_TOTAL .wrapping_sub((*coder).rep_len_decoder.choice2 as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; probs = &raw mut *(&raw mut (*coder).rep_len_decoder.mid as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; @@ -1209,9 +1189,8 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 as c_int - - ((*coder).rep_len_decoder.choice2 as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).rep_len_decoder.choice2 = (*coder).rep_len_decoder.choice2 + - ((*coder).rep_len_decoder.choice2 >> RC_MOVE_BITS); probs = &raw mut (*coder).rep_len_decoder.high as *mut probability; limit = LEN_HIGH_SYMBOLS as u32; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32; @@ -1256,7 +1235,7 @@ unsafe extern "C" fn lzma_decode( as probability as probability; probs = (&raw mut (*coder).literal as *mut probability).offset( - (3 as size_t).wrapping_mul( + (3_usize).wrapping_mul( ((dict.pos << 8).wrapping_add(dict_get0(&raw mut dict) as size_t) & literal_mask as size_t) << literal_context_bits, @@ -1284,15 +1263,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh6 = *probs.offset(symbol as isize); - *fresh6 = (*fresh6 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh6 = *fresh6 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1310,15 +1287,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh9 = *probs.offset(symbol as isize); - *fresh9 = (*fresh9 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh9 = *fresh9 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1336,15 +1311,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh12 = *probs.offset(symbol as isize); - *fresh12 = (*fresh12 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh12 = *fresh12 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1362,15 +1335,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh15 = *probs.offset(symbol as isize); - *fresh15 = (*fresh15 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh15 = *fresh15 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1388,15 +1359,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh18 = *probs.offset(symbol as isize); - *fresh18 = (*fresh18 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh18 = *fresh18 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1414,15 +1383,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh21 = *probs.offset(symbol as isize); - *fresh21 = (*fresh21 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh21 = *fresh21 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1440,15 +1407,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh24 = *probs.offset(symbol as isize); - *fresh24 = (*fresh24 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh24 = *fresh24 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1466,18 +1431,16 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh27 = *probs.offset(symbol as isize); - *fresh27 = (*fresh27 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh27 = *fresh27 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add(0); + } else { state = if state <= STATE_LIT_SHORTREP as u32 { state.wrapping_sub(3) @@ -1487,9 +1450,9 @@ unsafe extern "C" fn lzma_decode( let mut t_match_byte: u32 = dict_get(&raw mut dict, rep0) as u32; let mut t_match_bit: u32 = 0; let mut t_subcoder_index: u32 = 0; - let mut t_offset: u32 = 0x100 as u32; + let mut t_offset: u32 = 0x100; symbol = 1; - t_match_byte <<= 1 as c_int; + t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { @@ -1507,21 +1470,19 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh30 = *probs.offset(t_subcoder_index as isize); - *fresh30 = (*fresh30 as c_int - - (*probs.offset(t_subcoder_index as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh30 = *fresh30 + - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } - t_match_byte <<= 1 as c_int; + t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { @@ -1539,21 +1500,19 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh33 = *probs.offset(t_subcoder_index as isize); - *fresh33 = (*fresh33 as c_int - - (*probs.offset(t_subcoder_index as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh33 = *fresh33 + - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } - t_match_byte <<= 1 as c_int; + t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { @@ -1571,21 +1530,19 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh36 = *probs.offset(t_subcoder_index as isize); - *fresh36 = (*fresh36 as c_int - - (*probs.offset(t_subcoder_index as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh36 = *fresh36 + - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } - t_match_byte <<= 1 as c_int; + t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { @@ -1603,21 +1560,19 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh39 = *probs.offset(t_subcoder_index as isize); - *fresh39 = (*fresh39 as c_int - - (*probs.offset(t_subcoder_index as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh39 = *fresh39 + - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } - t_match_byte <<= 1 as c_int; + t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { @@ -1635,21 +1590,19 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh42 = *probs.offset(t_subcoder_index as isize); - *fresh42 = (*fresh42 as c_int - - (*probs.offset(t_subcoder_index as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh42 = *fresh42 + - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } - t_match_byte <<= 1 as c_int; + t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { @@ -1667,21 +1620,19 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh45 = *probs.offset(t_subcoder_index as isize); - *fresh45 = (*fresh45 as c_int - - (*probs.offset(t_subcoder_index as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh45 = *fresh45 + - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } - t_match_byte <<= 1 as c_int; + t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { @@ -1699,21 +1650,19 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh48 = *probs.offset(t_subcoder_index as isize); - *fresh48 = (*fresh48 as c_int - - (*probs.offset(t_subcoder_index as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh48 = *fresh48 + - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } - t_match_byte <<= 1 as c_int; + t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { @@ -1731,17 +1680,15 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh51 = *probs.offset(t_subcoder_index as isize); - *fresh51 = (*fresh51 as c_int - - (*probs.offset(t_subcoder_index as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh51 = *fresh51 + - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1750,10 +1697,9 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_match[state as usize][pos_state as usize] = - ((*coder).is_match[state as usize][pos_state as usize] as c_int - - ((*coder).is_match[state as usize][pos_state as usize] as c_int - >> RC_MOVE_BITS)) as probability; + (*coder).is_match[state as usize][pos_state as usize] = (*coder).is_match + [state as usize][pos_state as usize] + - ((*coder).is_match[state as usize][pos_state as usize] >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh52 = rc_in_ptr; @@ -1769,11 +1715,11 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub((*coder).is_rep[state as usize] as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; state = (if state < LIT_STATES as u32 { - STATE_LIT_MATCH as c_int + STATE_LIT_MATCH } else { - STATE_NONLIT_MATCH as c_int + STATE_NONLIT_MATCH }) as u32; rep3 = rep2; rep2 = rep1; @@ -1794,7 +1740,7 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub((*coder).match_len_decoder.choice as u32) >> RC_MOVE_BITS, - ) as probability as probability; + ) as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1821,19 +1767,16 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.low[pos_state as usize] - [symbol as usize] = ((*coder).match_len_decoder.low + [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as c_int - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1861,19 +1804,16 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.low[pos_state as usize] - [symbol as usize] = ((*coder).match_len_decoder.low + [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as c_int - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1901,31 +1841,25 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.low[pos_state as usize] - [symbol as usize] = ((*coder).match_len_decoder.low + [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as c_int - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = - symbol.wrapping_add((-((1 as c_int) << 3) + 2 as c_int) as u32); + symbol = symbol.wrapping_add((-((1_i32) << 3) + 2) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice - as c_int - - ((*coder).match_len_decoder.choice as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).match_len_decoder.choice = (*coder).match_len_decoder.choice + - ((*coder).match_len_decoder.choice >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh57 = rc_in_ptr; @@ -1971,20 +1905,17 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.mid[pos_state as usize] - [symbol as usize] = ((*coder).match_len_decoder.mid + [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_int - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2014,20 +1945,17 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.mid[pos_state as usize] - [symbol as usize] = ((*coder).match_len_decoder.mid + [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_int - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2057,35 +1985,28 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.mid[pos_state as usize] - [symbol as usize] = ((*coder).match_len_decoder.mid + [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_int - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add( - (-((1 as c_int) << 3) + 2 as c_int + ((1 as c_int) << 3)) - as u32, - ); + symbol = + symbol.wrapping_add((-((1_i32) << 3) + 2 + ((1) << 3)) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.choice2 = - ((*coder).match_len_decoder.choice2 as c_int - - ((*coder).match_len_decoder.choice2 as c_int - >> RC_MOVE_BITS)) - as probability; + (*coder).match_len_decoder.choice2 + - ((*coder).match_len_decoder.choice2 >> RC_MOVE_BITS); symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2107,16 +2028,14 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as c_int + (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2139,16 +2058,14 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as c_int + (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2171,16 +2088,14 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as c_int + (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2203,16 +2118,14 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as c_int + (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2235,16 +2148,14 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as c_int + (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2267,16 +2178,14 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as c_int + (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2299,16 +2208,14 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as c_int + (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2331,24 +2238,18 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as c_int + (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add( - (-((1 as c_int) << 8) - + 2 as c_int - + ((1 as c_int) << 3) - + ((1 as c_int) << 3)) - as u32, + (-((1_i32) << 8) + 2 + ((1) << 3) + ((1) << 3)) as u32, ); len = symbol; } @@ -2358,7 +2259,7 @@ unsafe extern "C" fn lzma_decode( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { len.wrapping_sub(MATCH_LEN_MIN as u32) } else { - (DIST_STATES - 1 as c_int) as u32 + (DIST_STATES - 1) as u32 }) as isize, ) as *mut probability; symbol = 1; @@ -2377,15 +2278,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh71 = *probs.offset(symbol as isize); - *fresh71 = (*fresh71 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh71 = *fresh71 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2403,15 +2302,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh74 = *probs.offset(symbol as isize); - *fresh74 = (*fresh74 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh74 = *fresh74 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2429,15 +2326,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh77 = *probs.offset(symbol as isize); - *fresh77 = (*fresh77 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh77 = *fresh77 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2455,15 +2350,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh80 = *probs.offset(symbol as isize); - *fresh80 = (*fresh80 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh80 = *fresh80 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2481,15 +2374,13 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh83 = *probs.offset(symbol as isize); - *fresh83 = (*fresh83 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh83 = *fresh83 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2507,18 +2398,16 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL .wrapping_sub(*probs.offset(symbol as isize) as u32) >> RC_MOVE_BITS, - ) as probability as probability; - symbol <<= 1 as c_int; + ) as probability; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh86 = *probs.offset(symbol as isize); - *fresh86 = (*fresh86 as c_int - - (*probs.offset(symbol as isize) as c_int >> RC_MOVE_BITS)) - as probability; + *fresh86 = *fresh86 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add(-((1 as c_int) << 6) as u32); + symbol = symbol.wrapping_add(-((1_i32) << 6) as u32); if symbol < DIST_MODEL_START as u32 { rep0 = symbol; } else { @@ -2551,19 +2440,17 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); let ref mut fresh89 = *probs.offset(symbol as isize); - *fresh89 = (*fresh89 as c_int - - (*probs.offset(symbol as isize) as c_int - >> RC_MOVE_BITS)) - as probability; + *fresh89 = *fresh89 + - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); rep0 = rep0.wrapping_add(offset); } - offset <<= 1 as c_int; + offset <<= 1; limit = limit.wrapping_sub(1); if !(limit > 0) { break; @@ -2579,7 +2466,7 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); rc.code = rc.code << RC_SHIFT_BITS | *fresh90 as u32; } - rc.range >>= 1 as c_int; + rc.range >>= 1; rc.code = rc.code.wrapping_sub(rc.range); rc_bound = 0u32.wrapping_sub(rc.code >> 31); rep0 = rep0.wrapping_add(rc_bound); @@ -2618,12 +2505,9 @@ unsafe extern "C" fn lzma_decode( rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).pos_align[symbol.wrapping_add(1) as usize] = - ((*coder).pos_align[symbol.wrapping_add(1) as usize] - as c_int + (*coder).pos_align[symbol.wrapping_add(1) as usize] - ((*coder).pos_align[symbol.wrapping_add(1) as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = symbol.wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2653,12 +2537,9 @@ unsafe extern "C" fn lzma_decode( rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).pos_align[symbol.wrapping_add(2) as usize] = - ((*coder).pos_align[symbol.wrapping_add(2) as usize] - as c_int + (*coder).pos_align[symbol.wrapping_add(2) as usize] - ((*coder).pos_align[symbol.wrapping_add(2) as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = symbol.wrapping_add(2); } if rc.range < RC_TOP_VALUE as u32 { @@ -2688,12 +2569,9 @@ unsafe extern "C" fn lzma_decode( rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).pos_align[symbol.wrapping_add(4) as usize] = - ((*coder).pos_align[symbol.wrapping_add(4) as usize] - as c_int + (*coder).pos_align[symbol.wrapping_add(4) as usize] - ((*coder).pos_align[symbol.wrapping_add(4) as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = symbol.wrapping_add(4); } if rc.range < RC_TOP_VALUE as u32 { @@ -2723,16 +2601,13 @@ unsafe extern "C" fn lzma_decode( rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).pos_align[symbol.wrapping_add(8) as usize] = - ((*coder).pos_align[symbol.wrapping_add(8) as usize] - as c_int + (*coder).pos_align[symbol.wrapping_add(8) as usize] - ((*coder).pos_align[symbol.wrapping_add(8) as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = symbol.wrapping_add(8); } rep0 = rep0.wrapping_add(symbol); - if rep0 == UINT32_MAX as u32 { + if rep0 == UINT32_MAX { break; } } @@ -2745,9 +2620,8 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as c_int - - ((*coder).is_rep[state as usize] as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] + - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); if !dict_is_distance_valid(&raw mut dict, 0) { ret_0 = LZMA_DATA_ERROR; current_block = 4609795085482299213; @@ -2794,9 +2668,9 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; state = (if state < LIT_STATES as u32 { - STATE_LIT_SHORTREP as c_int + STATE_LIT_SHORTREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as u32; dict_put(&raw mut dict, dict_get(&raw mut dict, rep0)); continue; @@ -2804,21 +2678,16 @@ unsafe extern "C" fn lzma_decode( rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep0_long[state as usize][pos_state as usize] = - ((*coder).is_rep0_long[state as usize][pos_state as usize] - as c_int + (*coder).is_rep0_long[state as usize][pos_state as usize] - ((*coder).is_rep0_long[state as usize] [pos_state as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); } } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] - as c_int - - ((*coder).is_rep0[state as usize] as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).is_rep0[state as usize] = (*coder).is_rep0[state as usize] + - ((*coder).is_rep0[state as usize] >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh97 = rc_in_ptr; @@ -2842,11 +2711,9 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep1[state as usize] = - ((*coder).is_rep1[state as usize] as c_int - - ((*coder).is_rep1[state as usize] as c_int - >> RC_MOVE_BITS)) - as probability; + (*coder).is_rep1[state as usize] = (*coder).is_rep1 + [state as usize] + - ((*coder).is_rep1[state as usize] >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh98 = rc_in_ptr; @@ -2872,11 +2739,9 @@ unsafe extern "C" fn lzma_decode( } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).is_rep2[state as usize] = - ((*coder).is_rep2[state as usize] as c_int - - ((*coder).is_rep2[state as usize] as c_int - >> RC_MOVE_BITS)) - as probability; + (*coder).is_rep2[state as usize] = (*coder).is_rep2 + [state as usize] + - ((*coder).is_rep2[state as usize] >> RC_MOVE_BITS); let distance_1: u32 = rep3; rep3 = rep2; rep2 = rep1; @@ -2886,9 +2751,9 @@ unsafe extern "C" fn lzma_decode( } } state = (if state < LIT_STATES as u32 { - STATE_LIT_LONGREP as c_int + STATE_LIT_LONGREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as u32; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -2935,20 +2800,17 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.low[pos_state as usize] - [symbol as usize] = ((*coder).rep_len_decoder.low + [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] [symbol as usize] - as c_int - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2977,20 +2839,17 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.low[pos_state as usize] - [symbol as usize] = ((*coder).rep_len_decoder.low + [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] [symbol as usize] - as c_int - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3019,32 +2878,26 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.low[pos_state as usize] - [symbol as usize] = ((*coder).rep_len_decoder.low + [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] [symbol as usize] - as c_int - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = - symbol.wrapping_add((-((1 as c_int) << 3) + 2 as c_int) as u32); + symbol = symbol.wrapping_add((-((1_i32) << 3) + 2) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice - as c_int - - ((*coder).rep_len_decoder.choice as c_int >> RC_MOVE_BITS)) - as probability; + (*coder).rep_len_decoder.choice = (*coder).rep_len_decoder.choice + - ((*coder).rep_len_decoder.choice >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; let fresh103 = rc_in_ptr; @@ -3090,20 +2943,17 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.mid[pos_state as usize] - [symbol as usize] = ((*coder).rep_len_decoder.mid + [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_int - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3133,20 +2983,17 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.mid[pos_state as usize] - [symbol as usize] = ((*coder).rep_len_decoder.mid + [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_int - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3176,35 +3023,28 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.mid[pos_state as usize] - [symbol as usize] = ((*coder).rep_len_decoder.mid + [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as c_int - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add( - (-((1 as c_int) << 3) + 2 as c_int + ((1 as c_int) << 3)) - as u32, - ); + symbol = symbol + .wrapping_add((-((1_i32) << 3) + 2 + ((1) << 3)) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.choice2 = - ((*coder).rep_len_decoder.choice2 as c_int - - ((*coder).rep_len_decoder.choice2 as c_int - >> RC_MOVE_BITS)) - as probability; + (*coder).rep_len_decoder.choice2 + - ((*coder).rep_len_decoder.choice2 >> RC_MOVE_BITS); symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -3228,17 +3068,14 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int + (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3263,17 +3100,14 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int + (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3298,17 +3132,14 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int + (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3333,17 +3164,14 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int + (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3368,17 +3196,14 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int + (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3403,17 +3228,14 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int + (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3438,17 +3260,14 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int + (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -3473,25 +3292,18 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - symbol <<= 1 as c_int; + symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int + (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] - as c_int - >> RC_MOVE_BITS)) - as probability; + >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add( - (-((1 as c_int) << 8) - + 2 as c_int - + ((1 as c_int) << 3) - + ((1 as c_int) << 3)) - as u32, + (-((1_i32) << 8) + 2 + ((1) << 3) + ((1) << 3)) as u32, ); len = symbol; } @@ -3513,9 +3325,9 @@ unsafe extern "C" fn lzma_decode( } 15498320742470848828 => { state = (if state < LIT_STATES as u32 { - STATE_LIT_LONGREP as c_int + STATE_LIT_LONGREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as u32; current_block = 12043352250568755004; continue; @@ -3551,7 +3363,7 @@ unsafe extern "C" fn lzma_decode( (*coder).uncompressed_size = (*coder) .uncompressed_size .wrapping_sub(dict.pos.wrapping_sub(dict_start) as lzma_vli); - if (*coder).uncompressed_size == 0 as lzma_vli + if (*coder).uncompressed_size == 0 && ret_0 == LZMA_OK && ((*coder).sequence == SEQ_LITERAL_WRITE || (*coder).sequence == SEQ_SHORTREP @@ -3561,7 +3373,7 @@ unsafe extern "C" fn lzma_decode( } } if ret_0 == LZMA_STREAM_END { - (*coder).rc.range = UINT32_MAX as u32; + (*coder).rc.range = UINT32_MAX; (*coder).rc.code = 0; (*coder).rc.init_bytes_left = 5; (*coder).sequence = SEQ_IS_MATCH; @@ -3588,14 +3400,14 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo ); (*coder).literal_context_bits = (*options).lc; (*coder).literal_mask = - ((0x100 as u32) << (*options).lp).wrapping_sub(0x100 >> (*options).lc) as u32; + (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); (*coder).state = STATE_LIT_LIT; (*coder).rep0 = 0; (*coder).rep1 = 0; (*coder).rep2 = 0; (*coder).rep3 = 0; (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; - (*coder).rc.range = UINT32_MAX as u32; + (*coder).rc.range = UINT32_MAX; (*coder).rc.code = 0; (*coder).rc.init_bytes_left = 5; let mut i: u32 = 0; @@ -3616,7 +3428,7 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo let mut i_0: u32 = 0; while i_0 < DIST_STATES as u32 { let mut bt_i: u32 = 0; - while bt_i < ((1 as c_int) << 6) as u32 { + while bt_i < ((1) << 6) as u32 { (*coder).dist_slot[i_0 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i = bt_i.wrapping_add(1); @@ -3629,7 +3441,7 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo i_1 = i_1.wrapping_add(1); } let mut bt_i_0: u32 = 0; - while bt_i_0 < ((1 as c_int) << 4) as u32 { + while bt_i_0 < ((1) << 4) as u32 { (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } @@ -3641,25 +3453,25 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo let mut pos_state: u32 = 0; while pos_state < num_pos_states { let mut bt_i_1: u32 = 0; - while bt_i_1 < ((1 as c_int) << 3) as u32 { + while bt_i_1 < ((1) << 3) as u32 { (*coder).match_len_decoder.low[pos_state as usize][bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_1 = bt_i_1.wrapping_add(1); } let mut bt_i_2: u32 = 0; - while bt_i_2 < ((1 as c_int) << 3) as u32 { + while bt_i_2 < ((1) << 3) as u32 { (*coder).match_len_decoder.mid[pos_state as usize][bt_i_2 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_2 = bt_i_2.wrapping_add(1); } let mut bt_i_3: u32 = 0; - while bt_i_3 < ((1 as c_int) << 3) as u32 { + while bt_i_3 < ((1) << 3) as u32 { (*coder).rep_len_decoder.low[pos_state as usize][bt_i_3 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_3 = bt_i_3.wrapping_add(1); } let mut bt_i_4: u32 = 0; - while bt_i_4 < ((1 as c_int) << 3) as u32 { + while bt_i_4 < ((1) << 3) as u32 { (*coder).rep_len_decoder.mid[pos_state as usize][bt_i_4 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_4 = bt_i_4.wrapping_add(1); @@ -3667,12 +3479,12 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo pos_state = pos_state.wrapping_add(1); } let mut bt_i_5: u32 = 0; - while bt_i_5 < ((1 as c_int) << 8) as u32 { + while bt_i_5 < ((1) << 8) as u32 { (*coder).match_len_decoder.high[bt_i_5 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_5 = bt_i_5.wrapping_add(1); } let mut bt_i_6: u32 = 0; - while bt_i_6 < ((1 as c_int) << 8) as u32 { + while bt_i_6 < ((1) << 8) as u32 { (*coder).rep_len_decoder.high[bt_i_6 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_6 = bt_i_6.wrapping_add(1); } @@ -3789,12 +3601,12 @@ pub unsafe extern "C" fn lzma_lzma_lclppb_decode( options: *mut lzma_options_lzma, mut byte: u8, ) -> bool { - if byte as c_int > (4 as c_int * 5 as c_int + 4 as c_int) * 9 as c_int + 8 as c_int { + if byte > (4 * 5 + 4) * 9 + 8 { return true; } - (*options).pb = (byte as c_int / (9 as c_int * 5 as c_int)) as u32; - byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9u32).wrapping_mul(5)) as u8 as u8; - (*options).lp = (byte as c_int / 9 as c_int) as u32; + (*options).pb = (byte / (9 * 5)) as u32; + byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9u32).wrapping_mul(5)) as u8; + (*options).lp = (byte / 9) as u32; (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9)); return (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX as u32; } diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index d115de95..7a5d8970 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -144,7 +144,7 @@ pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; #[inline] extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { - return match_finder as u32 & 0xf as u32; + return match_finder as u32 & 0xf; } #[inline] unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { @@ -170,7 +170,7 @@ extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { } #[inline] extern "C" fn rc_bit_0_price(prob: probability) -> u32 { - return unsafe { lzma_rc_prices[(prob as c_int >> RC_MOVE_REDUCING_BITS) as usize] as u32 }; + return unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 }; } #[inline] extern "C" fn rc_bit_1_price(prob: probability) -> u32 { @@ -190,7 +190,7 @@ unsafe extern "C" fn rc_bittree_price( symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; loop { let bit: u32 = symbol & 1; - symbol >>= 1 as c_int; + symbol >>= 1; price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); if !(symbol != 1) { break; @@ -202,7 +202,7 @@ unsafe extern "C" fn rc_bittree_price( unsafe extern "C" fn rc_reset(rc: *mut lzma_range_encoder) { (*rc).low = 0; (*rc).cache_size = 1; - (*rc).range = UINT32_MAX as u32; + (*rc).range = UINT32_MAX; (*rc).cache = 0; (*rc).out_total = 0; (*rc).count = 0; @@ -250,7 +250,7 @@ unsafe extern "C" fn rc_bittree_reverse( let mut model_index: u32 = 1; loop { let bit: u32 = symbol & 1; - symbol >>= 1 as c_int; + symbol >>= 1; rc_bit( rc, probs.offset(model_index as isize) as *mut probability, @@ -293,16 +293,15 @@ unsafe extern "C" fn rc_shift_low( out_pos: *mut size_t, out_size: size_t, ) -> bool { - if ((*rc).low as u32) < 0xff000000 as u32 || ((*rc).low >> 32) as u32 != 0 { + if ((*rc).low as u32) < 0xff000000 || ((*rc).low >> 32) as u32 != 0 { loop { if *out_pos == out_size { return true; } - *out.offset(*out_pos as isize) = - ((*rc).cache as c_int + ((*rc).low >> 32) as u8 as c_int) as u8; + *out.offset(*out_pos as isize) = (*rc).cache.wrapping_add(((*rc).low >> 32) as u8); *out_pos = (*out_pos).wrapping_add(1); (*rc).out_total = (*rc).out_total.wrapping_add(1); - (*rc).cache = 0xff as u8; + (*rc).cache = 0xff; (*rc).cache_size = (*rc).cache_size.wrapping_sub(1); if !((*rc).cache_size != 0) { break; @@ -322,13 +321,13 @@ unsafe extern "C" fn rc_shift_low_dummy( out_pos: *mut u64, out_size: u64, ) -> bool { - if (*low as u32) < 0xff000000 as u32 || (*low >> 32) as u32 != 0 { + if (*low as u32) < 0xff000000 || (*low >> 32) as u32 != 0 { loop { if *out_pos == out_size { return true; } *out_pos = (*out_pos).wrapping_add(1); - *cache = 0xff as u8; + *cache = 0xff; *cache_size = (*cache_size).wrapping_sub(1); if !(*cache_size != 0) { break; @@ -360,7 +359,7 @@ unsafe extern "C" fn rc_encode( (*rc).range = ((*rc).range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul(prob as u32); prob = (prob as u32) .wrapping_add(RC_BIT_MODEL_TOTAL.wrapping_sub(prob as u32) >> RC_MOVE_BITS) - as probability as probability; + as probability; *(*rc).probs[(*rc).pos as usize] = prob; } 1 => { @@ -369,18 +368,18 @@ unsafe extern "C" fn rc_encode( (prob_0 as u32).wrapping_mul((*rc).range >> RC_BIT_MODEL_TOTAL_BITS); (*rc).low = (*rc).low.wrapping_add(bound as u64); (*rc).range = (*rc).range.wrapping_sub(bound); - prob_0 = (prob_0 as c_int - (prob_0 as c_int >> RC_MOVE_BITS)) as probability; + prob_0 -= prob_0 >> RC_MOVE_BITS; *(*rc).probs[(*rc).pos as usize] = prob_0; } 2 => { - (*rc).range >>= 1 as c_int; + (*rc).range >>= 1; } 3 => { - (*rc).range >>= 1 as c_int; + (*rc).range >>= 1; (*rc).low = (*rc).low.wrapping_add((*rc).range as u64); } 4 => { - (*rc).range = UINT32_MAX as u32; + (*rc).range = UINT32_MAX; loop { if rc_shift_low(rc, out, out_pos, out_size) { return true; @@ -437,10 +436,10 @@ unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u range = range.wrapping_sub(bound); } 2 => { - range >>= 1 as c_int; + range >>= 1; } 3 => { - range >>= 1 as c_int; + range >>= 1; low = low.wrapping_add(range as u64); } 4 | _ => {} @@ -508,20 +507,15 @@ pub const OPTS: c_int = (1) << 12; pub const FASTPOS_BITS: c_int = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < (1) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { + if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { - return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] - as u32) - .wrapping_add( - (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + if dist < (1) << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { + return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); } - return (lzma_fastpos[(dist >> 0 + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) - .wrapping_add( - (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + return (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32); } #[inline] unsafe extern "C" fn literal_matched( @@ -530,10 +524,10 @@ unsafe extern "C" fn literal_matched( mut match_byte: u32, mut symbol: u32, ) { - let mut offset: u32 = 0x100 as u32; + let mut offset: u32 = 0x100; symbol = (symbol as u32).wrapping_add(1u32 << 8) as u32; loop { - match_byte <<= 1 as c_int; + match_byte <<= 1; let match_bit: u32 = match_byte & offset; let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol >> 8); let bit: u32 = symbol >> 7 & 1; @@ -542,7 +536,7 @@ unsafe extern "C" fn literal_matched( subcoder.offset(subcoder_index as isize) as *mut probability, bit, ); - symbol <<= 1 as c_int; + symbol <<= 1; offset &= !(match_byte ^ symbol); if !(symbol < (1) << 16) { break; @@ -690,9 +684,9 @@ unsafe extern "C" fn match_0( len: u32, ) { (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { - STATE_LIT_MATCH as c_int + STATE_LIT_MATCH } else { - STATE_NONLIT_MATCH as c_int + STATE_NONLIT_MATCH }) as lzma_lzma_state; length( &raw mut (*coder).rc, @@ -705,7 +699,7 @@ unsafe extern "C" fn match_0( let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { len.wrapping_sub(MATCH_LEN_MIN as u32) } else { - (DIST_STATES - 1 as c_int) as u32 + (DIST_STATES - 1) as u32 }; rc_bittree( &raw mut (*coder).rc, @@ -803,9 +797,9 @@ unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, r } if len == 1 { (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { - STATE_LIT_SHORTREP as c_int + STATE_LIT_SHORTREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as lzma_lzma_state; } else { length( @@ -816,9 +810,9 @@ unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, r (*coder).fast_mode, ); (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { - STATE_LIT_LONGREP as c_int + STATE_LIT_LONGREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as lzma_lzma_state; }; } @@ -830,7 +824,7 @@ unsafe extern "C" fn encode_symbol( position: u32, ) { let pos_state: u32 = position & (*coder).pos_mask; - if back == UINT32_MAX as u32 { + if back == UINT32_MAX { rc_bit( &raw mut (*coder).rc, (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) @@ -908,7 +902,7 @@ unsafe extern "C" fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) as *mut probability, 0, ); - match_0(coder, pos_state, UINT32_MAX as u32, MATCH_LEN_MIN as u32); + match_0(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN as u32); } pub const LOOP_INPUT_MAX: c_int = OPTS + 1; #[no_mangle] @@ -929,7 +923,7 @@ pub unsafe extern "C" fn lzma_lzma_encode( if (*coder).is_flushed { return LZMA_STREAM_END; } - while !(limit != UINT32_MAX as u32 + while !(limit != UINT32_MAX && ((*mf).read_pos.wrapping_sub((*mf).read_ahead) >= limit || (*out_pos as u64).wrapping_add(rc_pending(&raw mut (*coder).rc)) >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX as u32) as u64)) @@ -995,7 +989,7 @@ unsafe extern "C" fn lzma_encode( out, out_pos, out_size, - UINT32_MAX as u32, + UINT32_MAX, ); } unsafe extern "C" fn lzma_lzma_set_out_limit( @@ -1047,13 +1041,13 @@ unsafe extern "C" fn length_encoder_reset( let mut pos_state: size_t = 0; while pos_state < num_pos_states as size_t { let mut bt_i: u32 = 0; - while bt_i < ((1 as c_int) << 3) as u32 { + while bt_i < ((1) << 3) as u32 { (*lencoder).low[pos_state as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i = bt_i.wrapping_add(1); } let mut bt_i_0: u32 = 0; - while bt_i_0 < ((1 as c_int) << 3) as u32 { + while bt_i_0 < ((1) << 3) as u32 { (*lencoder).mid[pos_state as usize][bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 = bt_i_0.wrapping_add(1); @@ -1061,7 +1055,7 @@ unsafe extern "C" fn length_encoder_reset( pos_state = pos_state.wrapping_add(1); } let mut bt_i_1: u32 = 0; - while bt_i_1 < ((1 as c_int) << 8) as u32 { + while bt_i_1 < ((1) << 8) as u32 { (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_1 = bt_i_1.wrapping_add(1); } @@ -1084,7 +1078,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; (*coder).literal_context_bits = (*options).lc; (*coder).literal_mask = - ((0x100 as u32) << (*options).lp).wrapping_sub(0x100 >> (*options).lc) as u32; + (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); rc_reset(&raw mut (*coder).rc); (*coder).state = STATE_LIT_LIT; let mut i: size_t = 0; @@ -1120,7 +1114,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( let mut i_2: size_t = 0; while i_2 < DIST_STATES as size_t { let mut bt_i: u32 = 0; - while bt_i < ((1 as c_int) << 6) as u32 { + while bt_i < ((1) << 6) as u32 { (*coder).dist_slot[i_2 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i = bt_i.wrapping_add(1); @@ -1128,7 +1122,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( i_2 = i_2.wrapping_add(1); } let mut bt_i_0: u32 = 0; - while bt_i_0 < ((1 as c_int) << 4) as u32 { + while bt_i_0 < ((1) << 4) as u32 { (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 = bt_i_0.wrapping_add(1); } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 4722af37..766ae556 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -113,8 +113,7 @@ unsafe extern "C" fn lzma_memcmplen( mut len: u32, limit: u32, ) -> u32 { - while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int - { + while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { len = len.wrapping_add(1); } return len; @@ -140,17 +139,14 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( matches_count = (*coder).matches_count; } let mut buf: *const u8 = mf_ptr(mf).offset(-1); - let buf_avail: u32 = if mf_avail(mf).wrapping_add(1) - < (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - - 1 as c_int) as u32 - { - (mf_avail(mf) as u32).wrapping_add(1) - } else { - (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - - 1 as c_int) as u32 - }; + let buf_avail: u32 = + if mf_avail(mf).wrapping_add(1) < (2 + (((1) << 3) + ((1) << 3) + ((1) << 8)) - 1) as u32 { + (mf_avail(mf) as u32).wrapping_add(1) + } else { + (2 + (((1) << 3) + ((1) << 3) + ((1) << 8)) - 1) as u32 + }; if buf_avail < 2 { - *back_res = UINT32_MAX as u32; + *back_res = UINT32_MAX; *len_res = 1; return; } @@ -159,9 +155,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( let mut i: u32 = 0; while i < REPS as u32 { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); - if !(*buf.offset(0) as c_int != *buf_back.offset(0) as c_int - || *buf.offset(1) as c_int != *buf_back.offset(1) as c_int) - { + if !(*buf.offset(0) != *buf_back.offset(0) || *buf.offset(1) != *buf_back.offset(1)) { let len: u32 = lzma_memcmplen(buf, buf_back, 2, buf_avail) as u32; if len >= nice_len { *back_res = i; @@ -200,7 +194,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( len_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].len; back_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].dist; } - if len_main == 2 && back_main >= 0x80 as u32 { + if len_main == 2 && back_main >= 0x80 { len_main = 1; } } @@ -216,7 +210,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( } } if len_main < 2 || buf_avail <= 2 { - *back_res = UINT32_MAX as u32; + *back_res = UINT32_MAX; *len_res = 1; return; } @@ -235,7 +229,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( && len_main >= 3 && back_main >> 7 > new_dist { - *back_res = UINT32_MAX as u32; + *back_res = UINT32_MAX; *len_res = 1; return; } @@ -253,9 +247,9 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( buf.offset(-((*coder).reps[i_0 as usize] as isize)) .offset(-1) as *const c_void, limit as size_t, - ) == 0 as c_int + ) == 0 { - *back_res = UINT32_MAX as u32; + *back_res = UINT32_MAX; *len_res = 1; return; } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 98ebebc0..7be6a9dd 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -122,7 +122,7 @@ extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { } #[inline] extern "C" fn rc_bit_0_price(prob: probability) -> u32 { - return unsafe { lzma_rc_prices[(prob as c_int >> RC_MOVE_REDUCING_BITS) as usize] as u32 }; + return unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 }; } #[inline] extern "C" fn rc_bit_1_price(prob: probability) -> u32 { @@ -142,7 +142,7 @@ unsafe extern "C" fn rc_bittree_price( symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; loop { let bit: u32 = symbol & 1; - symbol >>= 1 as c_int; + symbol >>= 1; price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); if !(symbol != 1) { break; @@ -160,7 +160,7 @@ unsafe extern "C" fn rc_bittree_reverse_price( let mut model_index: u32 = 1; loop { let bit: u32 = symbol & 1; - symbol >>= 1 as c_int; + symbol >>= 1; price = price.wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); model_index = (model_index << 1).wrapping_add(bit); bit_levels = bit_levels.wrapping_sub(1); @@ -189,59 +189,28 @@ pub const REPS: c_int = 4; pub const FASTPOS_BITS: c_int = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < (1) << FASTPOS_BITS + (0 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) { + if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1) << FASTPOS_BITS + (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) { - return (lzma_fastpos[(dist >> 0 + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] - as u32) - .wrapping_add( - (2 as c_int * (0 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + if dist < (1) << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { + return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); } - return (lzma_fastpos[(dist >> 0 + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] as u32) - .wrapping_add( - (2 as c_int * (0 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + return (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32); } #[inline] unsafe extern "C" fn get_dist_slot_2(dist: u32) -> u32 { - if dist - < (1) - << FASTPOS_BITS - + (14 as c_int / 2 as c_int - 1 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) - { - return (lzma_fastpos[(dist - >> 14 / 2 as c_int - 1 as c_int + 0 as c_int * (FASTPOS_BITS - 1 as c_int)) - as usize] as u32) - .wrapping_add( - (2 as c_int - * (14 as c_int / 2 as c_int - 1 as c_int - + 0 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + if dist < (1) << FASTPOS_BITS + (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1)) { + return (lzma_fastpos[(dist >> 14 / 2 - 1 + 0 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1))) as u32); } - if dist - < (1) - << FASTPOS_BITS - + (14 as c_int / 2 as c_int - 1 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) - { - return (lzma_fastpos[(dist - >> 14 / 2 as c_int - 1 as c_int + 1 as c_int * (FASTPOS_BITS - 1 as c_int)) - as usize] as u32) - .wrapping_add( - (2 as c_int - * (14 as c_int / 2 as c_int - 1 as c_int - + 1 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + if dist < (1) << FASTPOS_BITS + (14 / 2 - 1 + 1 * (FASTPOS_BITS - 1)) { + return (lzma_fastpos[(dist >> 14 / 2 - 1 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (14 / 2 - 1 + 1 * (FASTPOS_BITS - 1))) as u32); } - return (lzma_fastpos - [(dist >> 14 / 2 as c_int - 1 as c_int + 2 as c_int * (FASTPOS_BITS - 1 as c_int)) as usize] - as u32) - .wrapping_add( - (2 as c_int - * (14 as c_int / 2 as c_int - 1 as c_int - + 2 as c_int * (FASTPOS_BITS - 1 as c_int))) as u32, - ); + return (lzma_fastpos[(dist >> 14 / 2 - 1 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (14 / 2 - 1 + 2 * (FASTPOS_BITS - 1))) as u32); } #[inline(always)] unsafe extern "C" fn lzma_memcmplen( @@ -250,8 +219,7 @@ unsafe extern "C" fn lzma_memcmplen( mut len: u32, limit: u32, ) -> u32 { - while len < limit && *buf1.offset(len as isize) as c_int == *buf2.offset(len as isize) as c_int - { + while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { len = len.wrapping_add(1); } return len; @@ -273,16 +241,16 @@ unsafe extern "C" fn get_literal_price( if !match_mode { price = rc_bittree_price(subcoder, 8, symbol); } else { - let mut offset: u32 = 0x100 as u32; + let mut offset: u32 = 0x100; symbol = (symbol as u32).wrapping_add(1u32 << 8) as u32; loop { - match_byte <<= 1 as c_int; + match_byte <<= 1; let match_bit: u32 = match_byte & offset; let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol >> 8); let bit: u32 = symbol >> 7 & 1; price = price.wrapping_add(rc_bit_price(*subcoder.offset(subcoder_index as isize), bit)); - symbol <<= 1 as c_int; + symbol <<= 1; offset &= !(match_byte ^ symbol); if !(symbol < (1) << 16) { break; @@ -362,7 +330,7 @@ extern "C" fn get_dist_len_price( let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { len.wrapping_sub(MATCH_LEN_MIN as u32) } else { - (DIST_STATES - 1 as c_int) as u32 + (DIST_STATES - 1) as u32 }; let mut price: u32 = 0; if dist < FULL_DISTANCES as u32 { @@ -452,7 +420,7 @@ unsafe extern "C" fn fill_align_prices(coder: *mut lzma_lzma1_encoder) { } #[inline] unsafe extern "C" fn make_literal(optimal: *mut lzma_optimal) { - (*optimal).back_prev = UINT32_MAX as u32; + (*optimal).back_prev = UINT32_MAX; (*optimal).prev_1_is_literal = false; } #[inline] @@ -520,19 +488,16 @@ unsafe extern "C" fn helper1( len_main = (*coder).longest_match_length; matches_count = (*coder).matches_count; } - let buf_avail: u32 = if mf_avail(mf).wrapping_add(1) - < (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - - 1 as c_int) as u32 - { - (mf_avail(mf) as u32).wrapping_add(1) - } else { - (2 as c_int + (((1 as c_int) << 3) + ((1 as c_int) << 3) + ((1 as c_int) << 8)) - - 1 as c_int) as u32 - }; + let buf_avail: u32 = + if mf_avail(mf).wrapping_add(1) < (2 + (((1) << 3) + ((1) << 3) + ((1) << 8)) - 1) as u32 { + (mf_avail(mf) as u32).wrapping_add(1) + } else { + (2 + (((1) << 3) + ((1) << 3) + ((1) << 8)) - 1) as u32 + }; if buf_avail < 2 { - *back_res = UINT32_MAX as u32; + *back_res = UINT32_MAX; *len_res = 1; - return UINT32_MAX as u32; + return UINT32_MAX; } let buf: *const u8 = mf_ptr(mf).offset(-1); let mut rep_lens: [u32; 4] = [0; 4]; @@ -540,9 +505,7 @@ unsafe extern "C" fn helper1( let mut i: u32 = 0; while i < REPS as u32 { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); - if *buf.offset(0) as c_int != *buf_back.offset(0) as c_int - || *buf.offset(1) as c_int != *buf_back.offset(1) as c_int - { + if *buf.offset(0) != *buf_back.offset(0) || *buf.offset(1) != *buf_back.offset(1) { rep_lens[i as usize] = 0; } else { rep_lens[i as usize] = lzma_memcmplen(buf, buf_back, 2, buf_avail); @@ -556,7 +519,7 @@ unsafe extern "C" fn helper1( *back_res = rep_max_index; *len_res = rep_lens[rep_max_index as usize]; mf_skip(mf, (*len_res).wrapping_sub(1)); - return UINT32_MAX as u32; + return UINT32_MAX; } if len_main >= nice_len { *back_res = (*coder).matches[matches_count.wrapping_sub(1) as usize] @@ -564,17 +527,14 @@ unsafe extern "C" fn helper1( .wrapping_add(REPS as u32); *len_res = len_main; mf_skip(mf, len_main.wrapping_sub(1)); - return UINT32_MAX as u32; + return UINT32_MAX; } let current_byte: u8 = *buf; let match_byte: u8 = *buf.offset(-((*coder).reps[0] as isize)).offset(-1); - if len_main < 2 - && current_byte as c_int != match_byte as c_int - && rep_lens[rep_max_index as usize] < 2 - { - *back_res = UINT32_MAX as u32; + if len_main < 2 && current_byte != match_byte && rep_lens[rep_max_index as usize] < 2 { + *back_res = UINT32_MAX; *len_res = 1; - return UINT32_MAX as u32; + return UINT32_MAX; } (*coder).opts[0].state = (*coder).state; let pos_state: u32 = position & (*coder).pos_mask; @@ -583,7 +543,7 @@ unsafe extern "C" fn helper1( .wrapping_add(get_literal_price( coder, position, - *buf.offset(-(1 as c_int) as isize) as u32, + *buf.offset(-(1) as isize) as u32, !(((*coder).state as u32) < LIT_STATES as u32), match_byte as u32, current_byte as u32, @@ -593,7 +553,7 @@ unsafe extern "C" fn helper1( rc_bit_1_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) as u32; let rep_match_price: u32 = match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[(*coder).state as usize]) as u32); - if match_byte as c_int == current_byte as c_int { + if match_byte == current_byte { let short_rep_price: u32 = rep_match_price .wrapping_add(get_short_rep_price(coder, (*coder).state, pos_state) as u32); @@ -612,7 +572,7 @@ unsafe extern "C" fn helper1( if len_end < 2 { *back_res = (*coder).opts[1].back_prev; *len_res = 1; - return UINT32_MAX as u32; + return UINT32_MAX; } (*coder).opts[1].pos_prev = 0; let mut i_0: u32 = 0; @@ -712,15 +672,15 @@ unsafe extern "C" fn helper2( state = (*coder).opts[(*coder).opts[cur as usize].pos_prev_2 as usize].state; if (*coder).opts[cur as usize].back_prev_2 < REPS as u32 { state = (if (state as u32) < LIT_STATES as u32 { - STATE_LIT_LONGREP as c_int + STATE_LIT_LONGREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as lzma_lzma_state; } else { state = (if (state as u32) < LIT_STATES as u32 { - STATE_LIT_MATCH as c_int + STATE_LIT_MATCH } else { - STATE_NONLIT_MATCH as c_int + STATE_NONLIT_MATCH }) as lzma_lzma_state; } } else { @@ -739,9 +699,9 @@ unsafe extern "C" fn helper2( if pos_prev == cur.wrapping_sub(1) { if (*coder).opts[cur as usize].back_prev == 0 { state = (if (state as u32) < LIT_STATES as u32 { - STATE_LIT_SHORTREP as c_int + STATE_LIT_SHORTREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as lzma_lzma_state; } else { state = (if state <= STATE_SHORTREP_LIT_LIT { @@ -758,23 +718,23 @@ unsafe extern "C" fn helper2( pos_prev = (*coder).opts[cur as usize].pos_prev_2; pos = (*coder).opts[cur as usize].back_prev_2; state = (if (state as u32) < LIT_STATES as u32 { - STATE_LIT_LONGREP as c_int + STATE_LIT_LONGREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as lzma_lzma_state; } else { pos = (*coder).opts[cur as usize].back_prev; if pos < REPS as u32 { state = (if (state as u32) < LIT_STATES as u32 { - STATE_LIT_LONGREP as c_int + STATE_LIT_LONGREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as lzma_lzma_state; } else { state = (if (state as u32) < LIT_STATES as u32 { - STATE_LIT_MATCH as c_int + STATE_LIT_MATCH } else { - STATE_NONLIT_MATCH as c_int + STATE_NONLIT_MATCH }) as lzma_lzma_state; } } @@ -816,7 +776,7 @@ unsafe extern "C" fn helper2( .wrapping_add(get_literal_price( coder, position, - *buf.offset(-(1 as c_int) as isize) as u32, + *buf.offset(-(1) as isize) as u32, !((state as u32) < LIT_STATES as u32), match_byte as u32, current_byte as u32, @@ -835,7 +795,7 @@ unsafe extern "C" fn helper2( .wrapping_add(rc_bit_1_price((*coder).is_match[state as usize][pos_state as usize]) as u32); let rep_match_price: u32 = match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[state as usize]) as u32); - if match_byte as c_int == current_byte as c_int + if match_byte == current_byte && !((*coder).opts[cur.wrapping_add(1) as usize].pos_prev < cur && (*coder).opts[cur.wrapping_add(1) as usize].back_prev == 0) { @@ -859,7 +819,7 @@ unsafe extern "C" fn helper2( } else { nice_len }; - if !next_is_literal && match_byte as c_int != current_byte as c_int { + if !next_is_literal && match_byte != current_byte { let buf_back: *const u8 = buf.offset(-(*reps.offset(0) as isize)).offset(-1); let limit: u32 = if buf_avail_full < nice_len.wrapping_add(1) { buf_avail_full @@ -909,9 +869,7 @@ unsafe extern "C" fn helper2( let buf_back_0: *const u8 = buf .offset(-(*reps.offset(rep_index as isize) as isize)) .offset(-1); - if !(*buf.offset(0) as c_int != *buf_back_0.offset(0) as c_int - || *buf.offset(1) as c_int != *buf_back_0.offset(1) as c_int) - { + if !(*buf.offset(0) != *buf_back_0.offset(0) || *buf.offset(1) != *buf_back_0.offset(1)) { let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2, buf_avail); while len_end < cur.wrapping_add(len_test_0) { len_end = len_end.wrapping_add(1); @@ -956,9 +914,9 @@ unsafe extern "C" fn helper2( if len_test_2 >= 2 { let mut state_2_0: lzma_lzma_state = state; state_2_0 = (if (state_2_0 as u32) < LIT_STATES as u32 { - STATE_LIT_LONGREP as c_int + STATE_LIT_LONGREP } else { - STATE_NONLIT_REP as c_int + STATE_NONLIT_REP }) as lzma_lzma_state; let mut pos_state_next_0: u32 = position.wrapping_add(len_test_0) & (*coder).pos_mask; @@ -1071,9 +1029,9 @@ unsafe extern "C" fn helper2( if len_test_2_0 >= 2 { let mut state_2_1: lzma_lzma_state = state; state_2_1 = (if (state_2_1 as u32) < LIT_STATES as u32 { - STATE_LIT_MATCH as c_int + STATE_LIT_MATCH } else { - STATE_NONLIT_MATCH as c_int + STATE_NONLIT_MATCH }) as lzma_lzma_state; let mut pos_state_next_1: u32 = position.wrapping_add(len_test_1) & (*coder).pos_mask; @@ -1156,7 +1114,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( return; } if (*mf).read_ahead == 0 { - if (*coder).match_price_count >= ((1 as c_int) << 7) as u32 { + if (*coder).match_price_count >= ((1) << 7) as u32 { fill_dist_prices(coder); } if (*coder).align_price_count >= ALIGN_SIZE as u32 { @@ -1164,7 +1122,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( } } let mut len_end: u32 = helper1(coder, mf, back_res, len_res, position); - if len_end == UINT32_MAX as u32 { + if len_end == UINT32_MAX { return; } let mut reps: [u32; 4] = [0; 4]; @@ -1192,12 +1150,10 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( position.wrapping_add(cur), cur, (*mf).nice_len, - if mf_avail(mf).wrapping_add(1) - < ((((1 as c_int) << 12) - 1 as c_int) as u32).wrapping_sub(cur) - { + if mf_avail(mf).wrapping_add(1) < ((((1) << 12) - 1) as u32).wrapping_sub(cur) { mf_avail(mf).wrapping_add(1) } else { - ((((1 as c_int) << 12) - 1 as c_int) as u32).wrapping_sub(cur) + ((((1) << 12) - 1) as u32).wrapping_sub(cur) }, ); cur = cur.wrapping_add(1); diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index be281c25..b61651e3 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -22,30 +22,22 @@ pub unsafe extern "C" fn lzma_lzma_preset( (*options).lp = LZMA_LP_DEFAULT as u32; (*options).pb = LZMA_PB_DEFAULT as u32; static mut dict_pow2: [u8; 10] = [18, 20, 21, 22, 22, 23, 23, 24, 25, 26]; - (*options).dict_size = (1u32 << dict_pow2[level as usize] as c_int) as u32; + (*options).dict_size = 1u32 << dict_pow2[level as usize]; if level <= 3 { (*options).mode = LZMA_MODE_FAST; - (*options).mf = (if level == 0 { - LZMA_MF_HC3 as c_int - } else { - LZMA_MF_HC4 as c_int - }) as lzma_match_finder; - (*options).nice_len = (if level <= 1 { - 128 as c_int - } else { - 273 as c_int - }) as u32; + (*options).mf = (if level == 0 { LZMA_MF_HC3 } else { LZMA_MF_HC4 }) as lzma_match_finder; + (*options).nice_len = (if level <= 1 { 128 } else { 273 }) as u32; static mut depths: [u8; 4] = [4, 8, 24, 48]; (*options).depth = depths[level as usize] as u32; } else { (*options).mode = LZMA_MODE_NORMAL; (*options).mf = LZMA_MF_BT4; (*options).nice_len = (if level == 4 { - 16 as c_int + 16 } else if level == 5 { - 32 as c_int + 32 } else { - 64 as c_int + 64 }) as u32; (*options).depth = 0; } diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index 0d94c24e..2feccb57 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -23,11 +23,11 @@ unsafe extern "C" fn arm_code( let mut i: size_t = 0; i = 0; while i < size { - if *buffer.offset(i.wrapping_add(3) as isize) as c_int == 0xeb as c_int { + if *buffer.offset(i.wrapping_add(3) as isize) == 0xeb { let mut src: u32 = (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16 | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8 - | *buffer.offset(i.wrapping_add(0) as isize) as u32; - src <<= 2 as c_int; + | *buffer.offset(i as isize) as u32; + src <<= 2; let mut dest: u32 = 0; if is_encoder { dest = now_pos @@ -37,10 +37,10 @@ unsafe extern "C" fn arm_code( } else { dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(8)); } - dest >>= 2 as c_int; + dest >>= 2; *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 16) as u8; *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 8) as u8; - *buffer.offset(i.wrapping_add(0) as isize) = dest as u8; + *buffer.offset(i as isize) = dest as u8; } i = i.wrapping_add(4); } diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index e2186fb7..b04c1563 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -44,28 +44,28 @@ unsafe extern "C" fn arm64_code( while i < size { let mut pc: u32 = (now_pos as size_t).wrapping_add(i) as u32; let mut instr: u32 = read32le(buffer.offset(i as isize)); - if instr >> 26 == 0x25 as u32 { + if instr >> 26 == 0x25 { let src: u32 = instr; - instr = 0x94000000 as u32; - pc >>= 2 as c_int; + instr = 0x94000000; + pc >>= 2; if !is_encoder { pc = 0u32.wrapping_sub(pc); } - instr |= src.wrapping_add(pc) & 0x3ffffff as u32; + instr |= src.wrapping_add(pc) & 0x3ffffff; write32le(buffer.offset(i as isize), instr); - } else if instr & 0x9f000000 as u32 == 0x90000000 as u32 { - let src_0: u32 = instr >> 29 & 3 | instr >> 3 & 0x1ffffc as u32; - if !(src_0.wrapping_add(0x20000 as u32) & 0x1c0000 as u32 != 0) { + } else if instr & 0x9f000000 == 0x90000000 { + let src_0: u32 = instr >> 29 & 3 | instr >> 3 & 0x1ffffc; + if !(src_0.wrapping_add(0x20000) & 0x1c0000 != 0) { instr = (instr & 0x9000001f) as u32; - pc >>= 12 as c_int; + pc >>= 12; if !is_encoder { pc = 0u32.wrapping_sub(pc); } let dest: u32 = src_0.wrapping_add(pc); instr |= (dest & 3) << 29; - instr |= (dest & 0x3fffc as u32) << 3; + instr |= (dest & 0x3fffc) << 3; instr = - (instr | (0u32.wrapping_sub(dest & 0x20000 as u32) & 0xe00000 as u32)) as u32; + (instr | (0u32.wrapping_sub(dest & 0x20000) & 0xe00000)) as u32; write32le(buffer.offset(i as isize), instr); } } diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index 2347129a..ae982320 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -26,14 +26,14 @@ unsafe extern "C" fn armthumb_code( let mut i: size_t = 0; i = 0; while i <= size { - if *buffer.offset(i.wrapping_add(1) as isize) as c_int & 0xf8 as c_int == 0xf0 as c_int - && *buffer.offset(i.wrapping_add(3) as isize) as c_int & 0xf8 as c_int == 0xf8 as c_int + if *buffer.offset(i.wrapping_add(1) as isize) & 0xf8 == 0xf0 + && *buffer.offset(i.wrapping_add(3) as isize) & 0xf8 == 0xf8 { let mut src: u32 = (*buffer.offset(i.wrapping_add(1) as isize) as u32 & 7) << 19 - | (*buffer.offset(i.wrapping_add(0) as isize) as u32) << 11 + | (*buffer.offset(i as isize) as u32) << 11 | (*buffer.offset(i.wrapping_add(3) as isize) as u32 & 7) << 8 | *buffer.offset(i.wrapping_add(2) as isize) as u32; - src <<= 1 as c_int; + src <<= 1; let mut dest: u32 = 0; if is_encoder { dest = now_pos @@ -43,12 +43,12 @@ unsafe extern "C" fn armthumb_code( } else { dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(4)); } - dest >>= 1 as c_int; + dest >>= 1; *buffer.offset(i.wrapping_add(1) as isize) = - (0xf0 as u32 | dest >> 19 & 0x7 as u32) as u8; - *buffer.offset(i.wrapping_add(0) as isize) = (dest >> 11) as u8; + (0xf0 | dest >> 19 & 0x7) as u8; + *buffer.offset(i as isize) = (dest >> 11) as u8; *buffer.offset(i.wrapping_add(3) as isize) = - (0xf8 as u32 | dest >> 8 & 0x7 as u32) as u8; + (0xf8 | dest >> 8 & 0x7) as u8; *buffer.offset(i.wrapping_add(2) as isize) = dest as u8; i = i.wrapping_add(2); } diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 571c53d0..7d3353a3 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -27,20 +27,20 @@ unsafe extern "C" fn ia64_code( let mut i: size_t = 0; i = 0; while i < size { - let instr_template: u32 = (*buffer.offset(i as isize) as c_int & 0x1f as c_int) as u32; + let instr_template: u32 = (*buffer.offset(i as isize) & 0x1f) as u32; let mask: u32 = BRANCH_TABLE[instr_template as usize]; let mut bit_pos: u32 = 5; let mut slot: size_t = 0; while slot < 3 { if !(mask >> slot & 1 == 0) { let byte_pos: size_t = (bit_pos >> 3) as size_t; - let bit_res: u32 = bit_pos & 0x7 as u32; + let bit_res: u32 = bit_pos & 0x7; let mut instruction: u64 = 0; let mut j: size_t = 0; while j < 6 { instruction = instruction.wrapping_add( (*buffer.offset(i.wrapping_add(j).wrapping_add(byte_pos) as isize) as u64) - << (8 as size_t).wrapping_mul(j), + << (8_usize).wrapping_mul(j), ); j = j.wrapping_add(1); } @@ -48,23 +48,23 @@ unsafe extern "C" fn ia64_code( if inst_norm >> 37 & 0xf as u64 == 0x5 as u64 && inst_norm >> 9 & 0x7 as u64 == 0 { let mut src: u32 = (inst_norm >> 13 & 0xfffff as u64) as u32; src = (src as u64 | (inst_norm >> 36 & 1) << 20) as u32; - src <<= 4 as c_int; + src <<= 4; let mut dest: u32 = 0; if is_encoder { dest = now_pos.wrapping_add(i as u32).wrapping_add(src); } else { dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } - dest >>= 4 as c_int; + dest >>= 4; inst_norm &= !((0x8fffff as u64) << 13); - inst_norm |= ((dest & 0xfffff as u32) as u64) << 13; - inst_norm |= ((dest & 0x100000 as u32) as u64) << 36 - 20 as c_int; + inst_norm |= ((dest & 0xfffff) as u64) << 13; + inst_norm |= ((dest & 0x100000) as u64) << 36 - 20; instruction &= (1u32 << bit_res).wrapping_sub(1) as u64; instruction |= inst_norm << bit_res; let mut j_0: size_t = 0; while j_0 < 6 { *buffer.offset(i.wrapping_add(j_0).wrapping_add(byte_pos) as isize) = - (instruction >> (8 as size_t).wrapping_mul(j_0)) as u8; + (instruction >> (8_usize).wrapping_mul(j_0)) as u8; j_0 = j_0.wrapping_add(1); } } diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index 1526ebdd..3f6929be 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -23,10 +23,10 @@ unsafe extern "C" fn powerpc_code( let mut i: size_t = 0; i = 0; while i < size { - if *buffer.offset(i as isize) as c_int >> 2 == 0x12 as c_int - && *buffer.offset(i.wrapping_add(3) as isize) as c_int & 3 as c_int == 1 as c_int + if *buffer.offset(i as isize) >> 2 == 0x12 + && *buffer.offset(i.wrapping_add(3) as isize) & 3 == 1 { - let src: u32 = (*buffer.offset(i.wrapping_add(0) as isize) as u32 & 3) << 24 + let src: u32 = (*buffer.offset(i as isize) as u32 & 3) << 24 | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 16 | (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 8 | *buffer.offset(i.wrapping_add(3) as isize) as u32 & !(3); @@ -36,12 +36,12 @@ unsafe extern "C" fn powerpc_code( } else { dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } - *buffer.offset(i.wrapping_add(0) as isize) = - (0x48 as u32 | dest >> 24 & 0x3 as u32) as u8; + *buffer.offset(i as isize) = + (0x48 | dest >> 24 & 0x3) as u8; *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 16) as u8; *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 8) as u8; let ref mut fresh0 = *buffer.offset(i.wrapping_add(3) as isize); - *fresh0 = (*fresh0 as c_int & 0x3 as c_int) as u8; + *fresh0 = (*fresh0 & 0x3) as u8; let ref mut fresh1 = *buffer.offset(i.wrapping_add(3) as isize); *fresh1 = (*fresh1 as u32 | dest) as u8; } diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index edd35d1b..8dd91a4d 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -66,53 +66,53 @@ unsafe extern "C" fn riscv_encode( i = 0; while i <= size { let mut inst: u32 = *buffer.offset(i as isize) as u32; - if inst == 0xef as u32 { + if inst == 0xef { let b1: u32 = *buffer.offset(i.wrapping_add(1) as isize) as u32; - if !(b1 & 0xd as u32 != 0) { + if !(b1 & 0xd != 0) { let b2: u32 = *buffer.offset(i.wrapping_add(2) as isize) as u32; let b3: u32 = *buffer.offset(i.wrapping_add(3) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); - let mut addr: u32 = (b1 & 0xf0 as u32) << 8 - | (b2 & 0xf as u32) << 16 - | (b2 & 0x10 as u32) << 7 - | (b2 & 0xe0 as u32) >> 4 - | (b3 & 0x7f as u32) << 4 - | (b3 & 0x80 as u32) << 13; + let mut addr: u32 = (b1 & 0xf0) << 8 + | (b2 & 0xf) << 16 + | (b2 & 0x10) << 7 + | (b2 & 0xe0) >> 4 + | (b3 & 0x7f) << 4 + | (b3 & 0x80) << 13; addr = addr.wrapping_add(pc); *buffer.offset(i.wrapping_add(1) as isize) = - (b1 & 0xf as u32 | addr >> 13 & 0xf0 as u32) as u8; + (b1 & 0xf | addr >> 13 & 0xf0) as u8; *buffer.offset(i.wrapping_add(2) as isize) = (addr >> 9) as u8; *buffer.offset(i.wrapping_add(3) as isize) = (addr >> 1) as u8; - i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); + i = i.wrapping_add((4 - 2) as size_t); } - } else if inst & 0x7f as u32 == 0x17 as u32 { + } else if inst & 0x7f == 0x17 { inst |= (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8; inst |= (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16; inst |= (*buffer.offset(i.wrapping_add(3) as isize) as u32) << 24; - if inst & 0xe80 as u32 != 0 { + if inst & 0xe80 != 0 { let inst2: u32 = read32le(buffer.offset(i as isize).offset(4)); - if (inst << 8 ^ inst2.wrapping_sub(3)) & 0xf8003 as u32 != 0 { - i = i.wrapping_add((6 as c_int - 2 as c_int) as size_t); + if (inst << 8 ^ inst2.wrapping_sub(3)) & 0xf8003 != 0 { + i = i.wrapping_add((6 - 2) as size_t); current_block_22 = 12517898123489920830; } else { - let mut addr_0: u32 = inst & 0xfffff000 as u32; + let mut addr_0: u32 = inst & 0xfffff000; addr_0 = addr_0 - .wrapping_add((inst2 >> 20).wrapping_sub(inst2 >> 19 & 0x1000 as u32)); + .wrapping_add((inst2 >> 20).wrapping_sub(inst2 >> 19 & 0x1000)); addr_0 = addr_0.wrapping_add(now_pos.wrapping_add(i as u32)); - inst = (0x17 as c_int | (2 as c_int) << 7) as u32 | inst2 << 12; + inst = (0x17 | (2) << 7) as u32 | inst2 << 12; write32le(buffer.offset(i as isize), inst); write32be(buffer.offset(i as isize).offset(4), addr_0); current_block_22 = 15125582407903384992; } } else { let fake_rs1: u32 = inst >> 27; - if inst.wrapping_sub(0x3117 as u32) << 18 >= fake_rs1 & 0x1d as u32 { - i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); + if inst.wrapping_sub(0x3117) << 18 >= fake_rs1 & 0x1d { + i = i.wrapping_add((4 - 2) as size_t); current_block_22 = 12517898123489920830; } else { let fake_addr: u32 = read32le(buffer.offset(i as isize).offset(4)) as u32; let fake_inst2: u32 = inst >> 12 | fake_addr << 20; - inst = 0x17 as u32 | fake_rs1 << 7 | fake_addr & 0xfffff000 as u32; + inst = 0x17 | fake_rs1 << 7 | fake_addr & 0xfffff000; write32le(buffer.offset(i as isize), inst); write32le(buffer.offset(i as isize).offset(4), fake_inst2); current_block_22 = 15125582407903384992; @@ -121,7 +121,7 @@ unsafe extern "C" fn riscv_encode( match current_block_22 { 12517898123489920830 => {} _ => { - i = i.wrapping_add((8 as c_int - 2 as c_int) as size_t); + i = i.wrapping_add((8 - 2) as size_t); } } } @@ -173,52 +173,52 @@ unsafe extern "C" fn riscv_decode( i = 0; while i <= size { let mut inst: u32 = *buffer.offset(i as isize) as u32; - if inst == 0xef as u32 { + if inst == 0xef { let b1: u32 = *buffer.offset(i.wrapping_add(1) as isize) as u32; - if !(b1 & 0xd as u32 != 0) { + if !(b1 & 0xd != 0) { let b2: u32 = *buffer.offset(i.wrapping_add(2) as isize) as u32; let b3: u32 = *buffer.offset(i.wrapping_add(3) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); - let mut addr: u32 = (b1 & 0xf0 as u32) << 13 | b2 << 9 | b3 << 1; + let mut addr: u32 = (b1 & 0xf0) << 13 | b2 << 9 | b3 << 1; addr = addr.wrapping_sub(pc); *buffer.offset(i.wrapping_add(1) as isize) = - (b1 & 0xf as u32 | addr >> 8 & 0xf0 as u32) as u8; + (b1 & 0xf | addr >> 8 & 0xf0) as u8; *buffer.offset(i.wrapping_add(2) as isize) = - (addr >> 16 & 0xf as u32 | addr >> 7 & 0x10 as u32 | addr << 4 & 0xe0 as u32) + (addr >> 16 & 0xf | addr >> 7 & 0x10 | addr << 4 & 0xe0) as u8; *buffer.offset(i.wrapping_add(3) as isize) = - (addr >> 4 & 0x7f as u32 | addr >> 13 & 0x80 as u32) as u8; - i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); + (addr >> 4 & 0x7f | addr >> 13 & 0x80) as u8; + i = i.wrapping_add((4 - 2) as size_t); } - } else if inst & 0x7f as u32 == 0x17 as u32 { + } else if inst & 0x7f == 0x17 { let mut inst2: u32 = 0; inst |= (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8; inst |= (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16; inst |= (*buffer.offset(i.wrapping_add(3) as isize) as u32) << 24; - if inst & 0xe80 as u32 != 0 { + if inst & 0xe80 != 0 { inst2 = read32le(buffer.offset(i as isize).offset(4)); - if (inst << 8 ^ inst2.wrapping_sub(3)) & 0xf8003 as u32 != 0 { - i = i.wrapping_add((6 as c_int - 2 as c_int) as size_t); + if (inst << 8 ^ inst2.wrapping_sub(3)) & 0xf8003 != 0 { + i = i.wrapping_add((6 - 2) as size_t); current_block_23 = 12517898123489920830; } else { - let mut addr_0: u32 = inst & 0xfffff000 as u32; + let mut addr_0: u32 = inst & 0xfffff000; addr_0 = addr_0.wrapping_add(inst2 >> 20); - inst = (0x17 as c_int | (2 as c_int) << 7) as u32 | inst2 << 12; + inst = (0x17 | (2) << 7) as u32 | inst2 << 12; inst2 = addr_0; current_block_23 = 6669252993407410313; } } else { let inst2_rs1: u32 = inst >> 27; - if inst.wrapping_sub(0x3117 as u32) << 18 >= inst2_rs1 & 0x1d as u32 { - i = i.wrapping_add((4 as c_int - 2 as c_int) as size_t); + if inst.wrapping_sub(0x3117) << 18 >= inst2_rs1 & 0x1d { + i = i.wrapping_add((4 - 2) as size_t); current_block_23 = 12517898123489920830; } else { let mut addr_1: u32 = read32be(buffer.offset(i as isize).offset(4)); addr_1 = addr_1.wrapping_sub(now_pos.wrapping_add(i as u32)); inst2 = inst >> 12 | addr_1 << 20; - inst = 0x17 as u32 + inst = 0x17 | inst2_rs1 << 7 - | addr_1.wrapping_add(0x800 as u32) & 0xfffff000 as u32; + | addr_1.wrapping_add(0x800) & 0xfffff000; current_block_23 = 6669252993407410313; } } @@ -227,7 +227,7 @@ unsafe extern "C" fn riscv_decode( _ => { write32le(buffer.offset(i as isize), inst); write32le(buffer.offset(i as isize).offset(4), inst2); - i = i.wrapping_add((8 as c_int - 2 as c_int) as size_t); + i = i.wrapping_add((8 - 2) as size_t); } } } diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index acc0359a..4ad660e4 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -218,7 +218,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( if coder.is_null() { coder = lzma_alloc( (core::mem::size_of::()) - .wrapping_add((2 as size_t).wrapping_mul(unfiltered_max)), + .wrapping_add((2_usize).wrapping_mul(unfiltered_max)), allocator, ) as *mut lzma_simple_coder; if coder.is_null() { @@ -272,7 +272,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( set_out_limit: None, }; (*coder).filter = filter; - (*coder).allocated = (2 as size_t).wrapping_mul(unfiltered_max); + (*coder).allocated = (2_usize).wrapping_mul(unfiltered_max); if simple_size > 0 { (*coder).simple = lzma_alloc(simple_size, allocator); if (*coder).simple.is_null() { diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index 9af3b2ab..f05ec3d5 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { @@ -16,9 +16,9 @@ pub unsafe extern "C" fn lzma_simple_props_size( ) -> lzma_ret { let opt: *const lzma_options_bcj = options as *const lzma_options_bcj; *size = (if opt.is_null() || (*opt).start_offset == 0 { - 0 as c_int + 0 } else { - 4 as c_int + 4 }) as u32; return LZMA_OK; } diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index 280d722c..3d2c88c9 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -23,28 +23,27 @@ unsafe extern "C" fn sparc_code( let mut i: size_t = 0; i = 0; while i < size { - if *buffer.offset(i as isize) as c_int == 0x40 as c_int - && *buffer.offset(i.wrapping_add(1) as isize) as c_int & 0xc0 as c_int == 0 as c_int - || *buffer.offset(i as isize) as c_int == 0x7f as c_int - && *buffer.offset(i.wrapping_add(1) as isize) as c_int & 0xc0 as c_int - == 0xc0 as c_int + if *buffer.offset(i as isize) == 0x40 + && *buffer.offset(i.wrapping_add(1) as isize) & 0xc0 == 0 + || *buffer.offset(i as isize) == 0x7f + && *buffer.offset(i.wrapping_add(1) as isize) & 0xc0 == 0xc0 { - let mut src: u32 = (*buffer.offset(i.wrapping_add(0) as isize) as u32) << 24 + let mut src: u32 = (*buffer.offset(i as isize) as u32) << 24 | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 16 | (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 8 | *buffer.offset(i.wrapping_add(3) as isize) as u32; - src <<= 2 as c_int; + src <<= 2; let mut dest: u32 = 0; if is_encoder { dest = now_pos.wrapping_add(i as u32).wrapping_add(src); } else { dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } - dest >>= 2 as c_int; - dest = 0u32.wrapping_sub(dest >> 22 & 1) << 22 & 0x3fffffff as u32 - | dest & 0x3fffff as u32 - | 0x40000000 as u32; - *buffer.offset(i.wrapping_add(0) as isize) = (dest >> 24) as u8; + dest >>= 2; + dest = 0u32.wrapping_sub(dest >> 22 & 1) << 22 & 0x3fffffff + | dest & 0x3fffff + | 0x40000000; + *buffer.offset(i as isize) = (dest >> 24) as u8; *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 16) as u8; *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 8) as u8; *buffer.offset(i.wrapping_add(3) as isize) = dest as u8; diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index 9df80e2f..77893b31 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_simple_coder_init( next: *mut lzma_next_coder, @@ -39,7 +39,7 @@ unsafe extern "C" fn x86_code( let mut buffer_pos: size_t = 0; while buffer_pos <= limit { let mut b: u8 = *buffer.offset(buffer_pos as isize); - if b as c_int != 0xe8 as c_int && b as c_int != 0xe9 as c_int { + if b != 0xe8 && b != 0xe9 { buffer_pos = buffer_pos.wrapping_add(1); } else { let offset: u32 = now_pos @@ -51,16 +51,13 @@ unsafe extern "C" fn x86_code( } else { let mut i: u32 = 0; while i < offset { - prev_mask &= 0x77 as u32; - prev_mask <<= 1 as c_int; + prev_mask &= 0x77; + prev_mask <<= 1; i = i.wrapping_add(1); } } b = *buffer.offset(buffer_pos.wrapping_add(4) as isize); - if (b as c_int == 0 as c_int || b as c_int == 0xff as c_int) - && prev_mask >> 1 <= 4 - && prev_mask >> 1 != 3 - { + if (b == 0 || b == 0xff) && prev_mask >> 1 <= 4 && prev_mask >> 1 != 3 { let mut src: u32 = (b as u32) << 24 | (*buffer.offset(buffer_pos.wrapping_add(3) as isize) as u32) << 16 | (*buffer.offset(buffer_pos.wrapping_add(2) as isize) as u32) << 8 @@ -79,7 +76,7 @@ unsafe extern "C" fn x86_code( } let i_0: u32 = MASK_TO_BIT_NUMBER[(prev_mask >> 1) as usize]; b = (dest >> (24u32).wrapping_sub(i_0.wrapping_mul(8))) as u8; - if !(b as c_int == 0 as c_int || b as c_int == 0xff as c_int) { + if !(b == 0 || b == 0xff) { break; } src = @@ -95,8 +92,8 @@ unsafe extern "C" fn x86_code( } else { buffer_pos = buffer_pos.wrapping_add(1); prev_mask |= 1; - if b as c_int == 0 as c_int || b as c_int == 0xff as c_int { - prev_mask |= 0x10 as u32; + if b == 0 || b == 0xff { + prev_mask |= 0x10; } } } @@ -128,7 +125,7 @@ extern "C" fn x86_coder_init( let coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; let simple: *mut lzma_simple_x86 = (*coder).simple as *mut lzma_simple_x86; (*simple).prev_mask = 0; - (*simple).prev_pos = -(5 as c_int) as u32; + (*simple).prev_pos = (-5_i32) as u32; } ret }; @@ -149,7 +146,7 @@ pub unsafe extern "C" fn lzma_bcj_x86_encode( ) -> size_t { let mut simple: lzma_simple_x86 = lzma_simple_x86 { prev_mask: 0, - prev_pos: -(5 as c_int) as u32, + prev_pos: (-5_i32) as u32, }; return x86_code( &raw mut simple as *mut c_void, @@ -175,7 +172,7 @@ pub unsafe extern "C" fn lzma_bcj_x86_decode( ) -> size_t { let mut simple: lzma_simple_x86 = lzma_simple_x86 { prev_mask: 0, - prev_pos: -(5 as c_int) as u32, + prev_pos: (-5_i32) as u32, }; return x86_code( &raw mut simple as *mut c_void, From fede580098210a1bd98c82fa510e0195df8b0879 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 1 Mar 2026 21:18:46 +0900 Subject: [PATCH 08/51] replace c2rust patterns: let ref mut, c_int constants to u32, wrapping arithmetic --- liblzma-rs/src/check/crc32_fast.rs | 2 +- liblzma-rs/src/check/crc64_fast.rs | 2 +- liblzma-rs/src/check/sha256.rs | 25 +- liblzma-rs/src/common/alone_decoder.rs | 2 +- liblzma-rs/src/common/alone_encoder.rs | 6 +- liblzma-rs/src/common/block_buffer_encoder.rs | 10 +- liblzma-rs/src/common/block_encoder.rs | 4 +- liblzma-rs/src/common/block_header_decoder.rs | 9 +- liblzma-rs/src/common/block_header_encoder.rs | 13 +- liblzma-rs/src/common/block_util.rs | 8 +- liblzma-rs/src/common/common.rs | 20 +- liblzma-rs/src/common/file_info.rs | 4 +- liblzma-rs/src/common/filter_common.rs | 21 +- liblzma-rs/src/common/filter_decoder.rs | 2 +- liblzma-rs/src/common/filter_encoder.rs | 8 +- liblzma-rs/src/common/index.rs | 8 +- liblzma-rs/src/common/lzip_decoder.rs | 18 +- liblzma-rs/src/common/outqueue.rs | 8 +- .../src/common/stream_buffer_encoder.rs | 5 +- liblzma-rs/src/common/stream_decoder_mt.rs | 12 +- liblzma-rs/src/common/stream_encoder_mt.rs | 17 +- liblzma-rs/src/common/stream_flags_decoder.rs | 4 +- liblzma-rs/src/common/stream_flags_encoder.rs | 4 +- liblzma-rs/src/common/string_conversion.rs | 64 +- liblzma-rs/src/common/vli_size.rs | 2 +- liblzma-rs/src/delta/delta_common.rs | 8 +- liblzma-rs/src/delta/delta_decoder.rs | 8 +- liblzma-rs/src/delta/delta_encoder.rs | 21 +- liblzma-rs/src/lz/lz_decoder.rs | 10 +- liblzma-rs/src/lz/lz_encoder.rs | 8 +- liblzma-rs/src/lz/lz_encoder_mf.rs | 46 +- liblzma-rs/src/lzma/lzma2_decoder.rs | 6 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 28 +- liblzma-rs/src/lzma/lzma_decoder.rs | 643 +++++++++--------- liblzma-rs/src/lzma/lzma_encoder.rs | 191 +++--- .../src/lzma/lzma_encoder_optimum_fast.rs | 22 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 195 +++--- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 14 +- liblzma-rs/src/simple/arm64.rs | 3 +- liblzma-rs/src/simple/armthumb.rs | 6 +- liblzma-rs/src/simple/ia64.rs | 6 +- liblzma-rs/src/simple/powerpc.rs | 10 +- liblzma-rs/src/simple/riscv.rs | 16 +- liblzma-rs/src/simple/sparc.rs | 5 +- liblzma-rs/src/simple/x86.rs | 6 +- liblzma-rs/src/types.rs | 16 +- 46 files changed, 744 insertions(+), 802 deletions(-) diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index 3196fe41..d7e7dae2 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -325,7 +325,7 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu let fresh0 = buf; buf = buf.offset(1); crc = lzma_crc32_table[0][(*fresh0 as u32 ^ crc & 0xff) as usize] ^ crc >> 8; - size = size.wrapping_sub(1); + size -= 1; } let limit: *const u8 = buf.offset((size & !(7)) as isize); size &= 7; diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index f7067afb..3f902a12 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1045,7 +1045,7 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu let fresh0 = buf; buf = buf.offset(1); crc = lzma_crc64_table[0][(*fresh0 as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; - size = size.wrapping_sub(1); + size -= 1; } let limit: *const u8 = buf.offset((size & !(3)) as isize); size &= 3; diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index eeaa3432..ca908320 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -522,22 +522,9 @@ unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { ); j = j.wrapping_add(16); } - let ref mut fresh0 = *state.offset(0); - *fresh0 = (*fresh0).wrapping_add(T[0]); - let ref mut fresh1 = *state.offset(1); - *fresh1 = (*fresh1).wrapping_add(T[1]); - let ref mut fresh2 = *state.offset(2); - *fresh2 = (*fresh2).wrapping_add(T[2]); - let ref mut fresh3 = *state.offset(3); - *fresh3 = (*fresh3).wrapping_add(T[3]); - let ref mut fresh4 = *state.offset(4); - *fresh4 = (*fresh4).wrapping_add(T[4]); - let ref mut fresh5 = *state.offset(5); - *fresh5 = (*fresh5).wrapping_add(T[5]); - let ref mut fresh6 = *state.offset(6); - *fresh6 = (*fresh6).wrapping_add(T[6]); - let ref mut fresh7 = *state.offset(7); - *fresh7 = (*fresh7).wrapping_add(T[7]); + for i in 0..8 { + *state.offset(i as isize) = (*state.offset(i as isize)).wrapping_add(T[i]); + } } unsafe extern "C" fn process(check: *mut lzma_check_state) { transform( @@ -587,7 +574,7 @@ pub unsafe extern "C" fn lzma_sha256_update( pub unsafe extern "C" fn lzma_sha256_finish(check: *mut lzma_check_state) { let mut pos: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; let fresh8 = pos; - pos = pos.wrapping_add(1); + pos += 1; (*check).buffer.u8_0[fresh8 as usize] = 0x80 as u8; while pos != (64 - 8) as size_t { if pos == 64 { @@ -595,7 +582,7 @@ pub unsafe extern "C" fn lzma_sha256_finish(check: *mut lzma_check_state) { pos = 0; } let fresh9 = pos; - pos = pos.wrapping_add(1); + pos += 1; (*check).buffer.u8_0[fresh9 as usize] = 0; } (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8); @@ -614,6 +601,6 @@ pub unsafe extern "C" fn lzma_sha256_finish(check: *mut lzma_check_state) { | ((*check).state.sha256.state[i as usize] & 0xff00) << 8 | ((*check).state.sha256.state[i as usize] & 0xff0000) >> 8 | ((*check).state.sha256.state[i as usize] & 0xff000000) >> 24; - i = i.wrapping_add(1); + i += 1; } } diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 90603a37..b76d8bbc 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -75,7 +75,7 @@ unsafe extern "C" fn alone_decode( d |= d >> 4; d |= d >> 8; d |= d >> 16; - d = d.wrapping_add(1); + d += 1; if d != (*coder).options.dict_size { return LZMA_FORMAT_ERROR; } diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index 4323a9de..58b8c462 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; @@ -44,7 +44,7 @@ extern "C" fn write32le(buf: *mut u8, num: u32) { *buf.offset(3) = (num >> 24) as u8; } } -pub const ALONE_HEADER_SIZE: c_int = 1 + 4 + 8; +pub const ALONE_HEADER_SIZE: u32 = 1 + 4 + 8; unsafe extern "C" fn alone_encode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -191,7 +191,7 @@ unsafe extern "C" fn alone_encoder_init( d |= d >> 8; d |= d >> 16; if d != UINT32_MAX { - d = d.wrapping_add(1); + d += 1; } write32le((&raw mut (*coder).header as *mut u8).offset(1), d); memset( diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index dbad77e7..841cb839 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; fn lzma_check_size(check: lzma_check) -> u32; @@ -20,14 +20,14 @@ extern "C" { ); fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); } -pub const LZMA_CHECK_SIZE_MAX: c_int = 64; +pub const LZMA_CHECK_SIZE_MAX: u32 = 64; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) & !3; pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; -pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3; -pub const HEADERS_BOUND: c_int = +pub const LZMA2_HEADER_UNCOMPRESSED: u32 = 3; +pub const HEADERS_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 + LZMA_CHECK_SIZE_MAX + 3 & !(3); extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { if uncompressed_size > COMPRESSED_SIZE_MAX as u64 { @@ -271,7 +271,7 @@ unsafe extern "C" fn block_buffer_encode( let fresh0 = *out_pos; *out_pos = (*out_pos).wrapping_add(1); *out.offset(fresh0 as isize) = 0; - i = i.wrapping_add(1); + i += 1; } if check_size > 0 { let mut check: lzma_check_state = lzma_check_state { diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index a73bff61..d1a43eee 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; @@ -48,7 +48,7 @@ pub type C2RustUnnamed_2 = c_uint; pub const SEQ_CHECK: C2RustUnnamed_2 = 2; pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; -pub const LZMA_CHECK_SIZE_MAX: c_int = 64; +pub const LZMA_CHECK_SIZE_MAX: u32 = 64; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 7ee932af..44f3a3fc 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -40,9 +40,8 @@ pub unsafe extern "C" fn lzma_block_header_decode( let mut i: size_t = 0; while i <= LZMA_FILTERS_MAX as size_t { (*(*block).filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN; - let ref mut fresh0 = (*(*block).filters.offset(i as isize)).options; - *fresh0 = core::ptr::null_mut(); - i = i.wrapping_add(1); + (*(*block).filters.offset(i as isize)).options = core::ptr::null_mut(); + i += 1; } if (*block).version > 1 { (*block).version = 1; @@ -106,11 +105,11 @@ pub unsafe extern "C" fn lzma_block_header_decode( lzma_filters_free((*block).filters, allocator); return ret; } - i_0 = i_0.wrapping_add(1); + i_0 += 1; } while in_pos < in_size { let fresh1 = in_pos; - in_pos = in_pos.wrapping_add(1); + in_pos += 1; if *in_0.offset(fresh1 as isize) != 0 { lzma_filters_free((*block).filters, allocator); return LZMA_OPTIONS_ERROR; diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 46b869b8..0cc71b95 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -63,7 +63,7 @@ pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ return ret_; } size = size.wrapping_add(add_1); - i = i.wrapping_add(1); + i += 1; } (*block).header_size = size.wrapping_add(3) & !(3); return LZMA_OK; @@ -94,8 +94,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( if ret_ != LZMA_OK { return ret_; } - let ref mut fresh0 = *out.offset(1); - *fresh0 |= 0x40; + *out.offset(1) |= 0x40; } if (*block).uncompressed_size != LZMA_VLI_UNKNOWN { let ret__0: lzma_ret = lzma_vli_encode( @@ -108,8 +107,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( if ret__0 != LZMA_OK { return ret__0; } - let ref mut fresh1 = *out.offset(1); - *fresh1 |= 0x80; + *out.offset(1) |= 0x80; } if (*block).filters.is_null() || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; @@ -128,13 +126,12 @@ pub unsafe extern "C" fn lzma_block_header_encode( if ret__1 != LZMA_OK { return ret__1; } - filter_count = filter_count.wrapping_add(1); + filter_count += 1; if !((*(*block).filters.offset(filter_count as isize)).id != LZMA_VLI_UNKNOWN) { break; } } - let ref mut fresh2 = *out.offset(1); - *fresh2 = (*fresh2 as size_t | filter_count.wrapping_sub(1)) as u8; + *out.offset(1) |= filter_count.wrapping_sub(1) as u8; memset( out.offset(out_pos as isize) as *mut c_void, 0, diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 402cce40..20ad989b 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -1,9 +1,9 @@ use crate::types::*; -use core::ffi::{c_int, c_ulonglong}; +use core::ffi::c_ulonglong; extern "C" { fn lzma_check_size(check: lzma_check) -> u32; } -pub const LZMA_BLOCK_HEADER_SIZE_MIN: c_int = 8; +pub const LZMA_BLOCK_HEADER_SIZE_MIN: u32 = 8; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { @@ -34,8 +34,8 @@ pub unsafe extern "C" fn lzma_block_compressed_size( pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli { if block.is_null() || (*block).version > 1 - || (*block).header_size < LZMA_BLOCK_HEADER_SIZE_MIN as u32 - || (*block).header_size > LZMA_BLOCK_HEADER_SIZE_MAX as u32 + || (*block).header_size < LZMA_BLOCK_HEADER_SIZE_MIN + || (*block).header_size > LZMA_BLOCK_HEADER_SIZE_MAX || (*block).header_size & 3 != 0 || !((*block).compressed_size <= LZMA_VLI_MAX || (*block).compressed_size == LZMA_VLI_UNKNOWN) diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index d44428b5..ebf39463 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -1,20 +1,20 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_uint, c_void}; +use core::ffi::{c_char, c_uint, c_void}; extern "C" { fn malloc(__size: size_t) -> *mut c_void; fn calloc(__count: size_t, __size: size_t) -> *mut c_void; fn free(_: *mut c_void); } -pub const LZMA_VERSION_MAJOR: c_int = 5; -pub const LZMA_VERSION_MINOR: c_int = 8; -pub const LZMA_VERSION_PATCH: c_int = 2; -pub const LZMA_VERSION_STABILITY: c_int = LZMA_VERSION_STABILITY_STABLE; -pub const LZMA_VERSION_STABILITY_STABLE: c_int = 2; -pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR as u32) +pub const LZMA_VERSION_MAJOR: u32 = 5; +pub const LZMA_VERSION_MINOR: u32 = 8; +pub const LZMA_VERSION_PATCH: u32 = 2; +pub const LZMA_VERSION_STABILITY: u32 = LZMA_VERSION_STABILITY_STABLE; +pub const LZMA_VERSION_STABILITY_STABLE: u32 = 2; +pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR) .wrapping_mul(10000000) - .wrapping_add((LZMA_VERSION_MINOR as u32).wrapping_mul(10000)) - .wrapping_add((LZMA_VERSION_PATCH as u32).wrapping_mul(10)) - .wrapping_add(LZMA_VERSION_STABILITY as u32); + .wrapping_add((LZMA_VERSION_MINOR).wrapping_mul(10000)) + .wrapping_add((LZMA_VERSION_PATCH).wrapping_mul(10)) + .wrapping_add(LZMA_VERSION_STABILITY); pub const LZMA_TIMED_OUT: c_uint = 101; #[no_mangle] pub extern "C" fn lzma_version_number() -> u32 { diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 3e1f68ef..696c9a96 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -153,10 +153,10 @@ unsafe extern "C" fn reverse_seek( unsafe extern "C" fn get_padding_size(buf: *const u8, mut buf_size: size_t) -> size_t { let mut padding: size_t = 0; while buf_size > 0 && { - buf_size = buf_size.wrapping_sub(1); + buf_size -= 1; *buf.offset(buf_size as isize) == 0 } { - padding = padding.wrapping_add(1); + padding += 1; } return padding; } diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 9fa21389..57ebe75c 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -149,7 +149,7 @@ pub unsafe extern "C" fn lzma_filters_copy( current_block = 6392083060350426025; break 's_15; } else { - j = j.wrapping_add(1); + j += 1; } } dest[i as usize].options = lzma_alloc(features[j as usize].options_size, allocator); @@ -165,13 +165,13 @@ pub unsafe extern "C" fn lzma_filters_copy( ); } } - i = i.wrapping_add(1); + i += 1; } } match current_block { 6392083060350426025 => { while i > 0 { - i = i.wrapping_sub(1); + i -= 1; lzma_free(dest[i as usize].options, allocator); } return ret; @@ -203,10 +203,9 @@ pub unsafe extern "C" fn lzma_filters_free( break; } lzma_free((*filters.offset(i as isize)).options, allocator); - let ref mut fresh0 = (*filters.offset(i as isize)).options; - *fresh0 = core::ptr::null_mut(); + (*filters.offset(i as isize)).options = core::ptr::null_mut(); (*filters.offset(i as isize)).id = LZMA_VLI_UNKNOWN; - i = i.wrapping_add(1); + i += 1; } } #[no_mangle] @@ -228,7 +227,7 @@ pub unsafe extern "C" fn lzma_validate_chain( if features[j as usize].id == LZMA_VLI_UNKNOWN { return LZMA_OPTIONS_ERROR; } - j = j.wrapping_add(1); + j += 1; } if !non_last_ok { return LZMA_OPTIONS_ERROR; @@ -237,7 +236,7 @@ pub unsafe extern "C" fn lzma_validate_chain( last_ok = features[j as usize].last_ok; changes_size_count = changes_size_count.wrapping_add(features[j as usize].changes_size as size_t); - i = i.wrapping_add(1); + i += 1; if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN) { break; } @@ -279,7 +278,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( filters[j as usize].id = (*options.offset(i as isize)).id; filters[j as usize].init = (*fc).init; filters[j as usize].options = (*options.offset(i as isize)).options; - i = i.wrapping_add(1); + i += 1; } } else { let mut i_0: size_t = 0; @@ -293,7 +292,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( filters[i_0 as usize].id = (*options.offset(i_0 as isize)).id; filters[i_0 as usize].init = (*fc_0).init; filters[i_0 as usize].options = (*options.offset(i_0 as isize)).options; - i_0 = i_0.wrapping_add(1); + i_0 += 1; } } filters[count as usize].id = LZMA_VLI_UNKNOWN; @@ -334,7 +333,7 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( } total = total.wrapping_add(usage); } - i = i.wrapping_add(1); + i += 1; if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN) { break; } diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index a824c428..ccbc3b35 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -372,7 +372,7 @@ extern "C" fn decoder_find(id: lzma_vli) -> *const lzma_filter_decoder { if decoders[i as usize].id == id { return decoders.as_ptr().wrapping_add(i as usize); } - i = i.wrapping_add(1); + i += 1; } return ::core::ptr::null::(); } diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index 87b5e279..869bc693 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -330,7 +330,7 @@ extern "C" fn encoder_find(id: lzma_vli) -> *const lzma_filter_encoder { if encoders[i as usize].id == id { return encoders.as_ptr().wrapping_add(i as usize); } - i = i.wrapping_add(1); + i += 1; } return ::core::ptr::null::(); } @@ -354,7 +354,7 @@ pub unsafe extern "C" fn lzma_filters_update( } let mut count: size_t = 1; while (*filters.offset(count as isize)).id != LZMA_VLI_UNKNOWN { - count = count.wrapping_add(1); + count += 1; } let mut reversed_filters: [lzma_filter; 5] = [lzma_filter { id: 0, @@ -364,7 +364,7 @@ pub unsafe extern "C" fn lzma_filters_update( while i < count { reversed_filters[count.wrapping_sub(i).wrapping_sub(1) as usize] = *filters.offset(i as isize); - i = i.wrapping_add(1); + i += 1; } reversed_filters[count as usize].id = LZMA_VLI_UNKNOWN; return (*(*strm).internal) @@ -444,7 +444,7 @@ pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 max = size; } } - i = i.wrapping_add(1); + i += 1; } return if max == 0 { UINT64_MAX } else { max }; } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 9058e710..f6d1f2d1 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulong, c_ulonglong, c_void}; +use core::ffi::{c_uint, c_ulong, c_ulonglong, c_void}; extern "C" { fn lzma_vli_size(vli: lzma_vli) -> u32; fn lzma_stream_flags_compare( @@ -168,7 +168,7 @@ extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { return vli_ceil4(index_size_unpadded(count, index_list_size)); } -pub const INDEX_GROUP_SIZE: c_int = 512; +pub const INDEX_GROUP_SIZE: u32 = 512; pub const PREALLOC_MAX: usize = (SIZE_MAX as usize) .wrapping_sub(core::mem::size_of::() as usize) .wrapping_div(core::mem::size_of::() as usize); @@ -218,7 +218,7 @@ unsafe extern "C" fn index_tree_append(tree: *mut index_tree, mut node: *mut ind up = ctz32((*tree).count).wrapping_add(2); loop { node = (*node).parent; - up = up.wrapping_sub(1); + up -= 1; if !(up > 0) { break; } @@ -926,7 +926,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( group = (*stream).groups.leftmost as *const index_group; record = 0; } else if !group.is_null() && record < (*group).last { - record = record.wrapping_add(1); + record += 1; } else { record = 0; if !group.is_null() { diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 4c17ae52..b8da4c7e 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_end(strm: *mut lzma_stream); fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; @@ -75,11 +75,11 @@ extern "C" fn read64le(buf: *const u8) -> u64 { num }; } -pub const LZIP_V0_FOOTER_SIZE: c_int = 12; -pub const LZIP_V1_FOOTER_SIZE: c_int = 20; -pub const LZIP_LC: c_int = 3; -pub const LZIP_LP: c_int = 0; -pub const LZIP_PB: c_int = 2; +pub const LZIP_V0_FOOTER_SIZE: u32 = 12; +pub const LZIP_V1_FOOTER_SIZE: u32 = 20; +pub const LZIP_LC: u32 = 3; +pub const LZIP_LP: u32 = 0; +pub const LZIP_PB: u32 = 2; unsafe extern "C" fn lzip_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -176,9 +176,9 @@ unsafe extern "C" fn lzip_decode( (*coder).options.dict_size = (1u32 << b2log).wrapping_sub(fracnum << b2log.wrapping_sub(4)); (*coder).options.preset_dict = ::core::ptr::null::(); - (*coder).options.lc = LZIP_LC as u32; - (*coder).options.lp = LZIP_LP as u32; - (*coder).options.pb = LZIP_PB as u32; + (*coder).options.lc = LZIP_LC; + (*coder).options.lp = LZIP_LP; + (*coder).options.pb = LZIP_PB; (*coder).memusage = lzma_lzma_decoder_memusage_nocheck(&raw mut (*coder).options as *const c_void) .wrapping_add(LZMA_MEMUSAGE_BASE); diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index 291158cd..bd4b3f7d 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_ulong, c_void}; +use core::ffi::{c_ulong, c_void}; extern "C" { fn lzma_bufcpy( in_0: *const u8, @@ -12,7 +12,7 @@ extern "C" { } pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const LZMA_THREADS_MAX: c_int = 16384; +pub const LZMA_THREADS_MAX: u32 = 16384; #[inline] extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { return (core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; @@ -22,7 +22,7 @@ pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { let limit: u64 = (UINT64_MAX) .wrapping_div((2 * 16384) as u64) .wrapping_div(2); - if threads > LZMA_THREADS_MAX as u32 || buf_size_max > limit { + if threads > LZMA_THREADS_MAX || buf_size_max > limit { return UINT64_MAX; } return ((2u32).wrapping_mul(threads) as u64) @@ -87,7 +87,7 @@ pub unsafe extern "C" fn lzma_outq_init( allocator: *const lzma_allocator, threads: u32, ) -> lzma_ret { - if threads > LZMA_THREADS_MAX as u32 { + if threads > LZMA_THREADS_MAX { return LZMA_OPTIONS_ERROR; } let bufs_limit: u32 = (2u32).wrapping_mul(threads); diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 1729b9f5..5eb904e2 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_int; #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], @@ -36,8 +35,8 @@ extern "C" { ) -> lzma_ret; } pub type lzma_index = lzma_index_s; -pub const INDEX_BOUND: c_int = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3 & !(3); -pub const HEADERS_BOUND: c_int = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; +pub const INDEX_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3 & !(3); +pub const HEADERS_BOUND: u32 = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; #[no_mangle] pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { let block_bound: size_t = unsafe { lzma_block_buffer_bound(uncompressed_size) } as size_t; diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 30486383..b02c8787 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -404,7 +404,7 @@ extern "C" fn mythread_condtime_set( } } } -pub const LZMA_THREADS_MAX: c_int = 16384; +pub const LZMA_THREADS_MAX: u32 = 16384; pub const INDEX_INDICATOR: u8 = 0; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { @@ -606,12 +606,12 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons } mythread_i_502 = 1; } - i = i.wrapping_add(1); + i += 1; } let mut i_0: u32 = 0; while i_0 < (*coder).threads_initialized { mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); - i_0 = i_0.wrapping_add(1); + i_0 += 1; } lzma_free((*coder).threads as *mut c_void, allocator); (*coder).threads_initialized = 0; @@ -639,7 +639,7 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder) { } mythread_i_538 = 1; } - i = i.wrapping_add(1); + i += 1; } } unsafe extern "C" fn initialize_new_thread( @@ -1704,7 +1704,7 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( } mythread_i_1867 = 1; } - i = i.wrapping_add(1); + i += 1; } mythread_j_1862 = 1; } @@ -1717,7 +1717,7 @@ unsafe extern "C" fn stream_decoder_mt_init( options: *const lzma_mt, ) -> lzma_ret { let mut coder: *mut lzma_stream_coder = core::ptr::null_mut(); - if (*options).threads == 0 || (*options).threads > LZMA_THREADS_MAX as u32 { + if (*options).threads == 0 || (*options).threads > LZMA_THREADS_MAX { return LZMA_OPTIONS_ERROR; } if (*options).flags & !(LZMA_SUPPORTED_FLAGS as u32) != 0 { diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 96f2bedd..e0e8a7ca 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -374,7 +374,7 @@ extern "C" fn mythread_condtime_set( } } } -pub const LZMA_THREADS_MAX: c_int = 16384; +pub const LZMA_THREADS_MAX: u32 = 16384; #[inline] extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { return unsafe { (*outq).bufs_in_use < (*outq).bufs_limit }; @@ -689,7 +689,7 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_thread } mythread_i_449 = 1; } - i = i.wrapping_add(1); + i += 1; } if !wait_for_threads { return; @@ -717,7 +717,7 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_thread } mythread_i_460 = 1; } - i_0 = i_0.wrapping_add(1); + i_0 += 1; } } unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) { @@ -740,12 +740,12 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons } mythread_i_477 = 1; } - i = i.wrapping_add(1); + i += 1; } let mut i_0: u32 = 0; while i_0 < (*coder).threads_initialized { let _ret: c_int = mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); - i_0 = i_0.wrapping_add(1); + i_0 += 1; } lzma_free((*coder).threads as *mut c_void, allocator); } @@ -1270,10 +1270,7 @@ unsafe extern "C" fn get_options( if options.is_null() { return LZMA_PROG_ERROR; } - if (*options).flags != 0 - || (*options).threads == 0 - || (*options).threads > LZMA_THREADS_MAX as u32 - { + if (*options).flags != 0 || (*options).threads == 0 || (*options).threads > LZMA_THREADS_MAX { return LZMA_OPTIONS_ERROR; } if !(*options).filters.is_null() { @@ -1338,7 +1335,7 @@ unsafe extern "C" fn get_progress( } mythread_i_1015 = 1; } - i = i.wrapping_add(1); + i += 1; } mythread_j_1010 = 1; } diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index fd5d1475..de279fc3 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; static lzma_header_magic: [u8; 6]; @@ -15,7 +15,7 @@ extern "C" fn read32le(buf: *const u8) -> u32 { num }; } -pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2; +pub const LZMA_STREAM_FLAGS_SIZE: u32 = 2; extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> bool { return unsafe { if *in_0.offset(0) != 0 || *in_0.offset(1) & 0xf0 != 0 { diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 0fdba749..91f044be 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; static lzma_header_magic: [u8; 6]; @@ -14,7 +14,7 @@ extern "C" fn write32le(buf: *mut u8, num: u32) { *buf.offset(3) = (num >> 24) as u8; } } -pub const LZMA_STREAM_FLAGS_SIZE: c_int = 2; +pub const LZMA_STREAM_FLAGS_SIZE: u32 = 2; #[inline] extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { return unsafe { diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 00d8528d..8d26d291 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -63,13 +63,13 @@ pub const LZMA_STR_ENCODER: c_uint = 0x10; pub const LZMA_STR_DECODER: c_uint = 0x20; pub const LZMA_STR_GETOPT_LONG: c_uint = 0x40; pub const LZMA_STR_NO_SPACES: c_uint = 0x80; -pub const LZMA_DELTA_DIST_MIN: c_int = 1; +pub const LZMA_DELTA_DIST_MIN: u32 = 1; pub const LZMA_DICT_SIZE_DEFAULT: c_uint = 1u32 << 23; -pub const LZMA_LCLP_MIN: c_int = 0; -pub const LZMA_PB_MIN: c_int = 0; +pub const LZMA_LCLP_MIN: u32 = 0; +pub const LZMA_PB_MIN: u32 = 0; pub const LZMA_PRESET_DEFAULT: c_uint = 6; pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; -pub const STR_ALLOC_SIZE: c_int = 800; +pub const STR_ALLOC_SIZE: u32 = 800; unsafe extern "C" fn str_init(str: *mut lzma_str, allocator: *const lzma_allocator) -> lzma_ret { (*str).buf = lzma_alloc(STR_ALLOC_SIZE as size_t, allocator) as *mut c_char; if (*str).buf.is_null() { @@ -130,14 +130,14 @@ unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suf .wrapping_sub(1 as usize) { v >>= 10; - suf = suf.wrapping_add(1); + suf += 1; } } let mut buf: [c_char; 16] = ::core::mem::transmute::<[u8; 16], [c_char; 16]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); let mut pos: size_t = (core::mem::size_of::<[c_char; 16]>()).wrapping_sub(1); loop { - pos = pos.wrapping_sub(1); + pos -= 1; buf[pos as usize] = ('0' as i32 as u32).wrapping_add(v.wrapping_rem(10)) as c_char; v = v.wrapping_div(10); if !(v != 0) { @@ -152,7 +152,7 @@ unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suf ); }; } -pub const NAME_LEN_MAX: c_int = 11; +pub const NAME_LEN_MAX: u32 = 11; pub const OPTMAP_USE_NAME_VALUE_MAP: u8 = 0x1; pub const OPTMAP_USE_BYTE_SUFFIX: u8 = 0x2; pub const OPTMAP_NO_STRFY_ZERO: u8 = 0x4; @@ -194,8 +194,8 @@ static mut delta_optmap: [option_map; 1] = unsafe { offset: 4, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: LZMA_DELTA_DIST_MIN as u32, - max: LZMA_DELTA_DIST_MAX as u32, + min: LZMA_DELTA_DIST_MIN, + max: LZMA_DELTA_DIST_MAX, }, }, }] @@ -208,7 +208,7 @@ extern "C" fn parse_delta( return unsafe { let opts: *mut lzma_options_delta = filter_options as *mut lzma_options_delta; (*opts).type_0 = LZMA_DELTA_TYPE_BYTE; - (*opts).dist = LZMA_DELTA_DIST_MIN as u32; + (*opts).dist = LZMA_DELTA_DIST_MIN; parse_options( str, str_end, @@ -332,7 +332,7 @@ unsafe extern "C" fn parse_lzma12( if !errmsg.is_null() { return errmsg; } - if (*opts).lc.wrapping_add((*opts).lp) > LZMA_LCLP_MAX as u32 { + if (*opts).lc.wrapping_add((*opts).lp) > LZMA_LCLP_MAX { return b"The sum of lc and lp must not exceed 4\0" as *const u8 as *const c_char; } return ::core::ptr::null::(); @@ -572,7 +572,7 @@ unsafe extern "C" fn parse_options( { break; } - i = i.wrapping_add(1); + i += 1; } *str = equals_sign.offset(1); let value_len: size_t = name_eq_value_end.offset_from(*str) as size_t; @@ -608,7 +608,7 @@ unsafe extern "C" fn parse_options( v = (*map.offset(j as isize)).value; break; } else { - j = j.wrapping_add(1); + j += 1; } } } else if (**str as u8) < b'0' || **str as u8 > b'9' { @@ -758,7 +758,7 @@ unsafe extern "C" fn parse_filter( (*filter).options = options; return ::core::ptr::null::(); } - i = i.wrapping_add(1); + i += 1; } return b"Unknown filter name\0" as *const u8 as *const c_char; } @@ -793,7 +793,7 @@ unsafe extern "C" fn str_to_filters( if *str_end.offset(i as isize) as u8 != b' ' { return b"Unsupported preset\0" as *const u8 as *const c_char; } - i = i.wrapping_add(1); + i += 1; } } else { str_end = (*str).offset(str_len as isize); @@ -814,11 +814,9 @@ unsafe extern "C" fn str_to_filters( return b"Unsupported preset\0" as *const u8 as *const c_char; } (*filters.offset(0)).id = LZMA_FILTER_LZMA2; - let ref mut fresh0 = (*filters.offset(0)).options; - *fresh0 = opts as *mut c_void; + (*filters.offset(0)).options = opts as *mut c_void; (*filters.offset(1)).id = LZMA_VLI_UNKNOWN; - let ref mut fresh1 = (*filters.offset(1)).options; - *fresh1 = core::ptr::null_mut(); + (*filters.offset(1)).options = core::ptr::null_mut(); return ::core::ptr::null::(); } let only_xz: bool = flags & LZMA_STR_ALL_FILTERS as u32 == 0; @@ -865,7 +863,7 @@ unsafe extern "C" fn str_to_filters( while **str as u8 == b' ' { *str = (*str).offset(1); } - i_0 = i_0.wrapping_add(1); + i_0 += 1; if !(**str != 0) { current_block = 15090052786889560393; break; @@ -994,7 +992,7 @@ unsafe extern "C" fn strfy_filter( ); break; } else { - j = j.wrapping_add(1); + j += 1; } } } else { @@ -1006,7 +1004,7 @@ unsafe extern "C" fn strfy_filter( } } } - i = i.wrapping_add(1); + i += 1; } } #[no_mangle] @@ -1101,10 +1099,10 @@ pub unsafe extern "C" fn lzma_str_from_filters( break; } } else { - j = j.wrapping_add(1); + j += 1; } } - i = i.wrapping_add(1); + i += 1; } return str_finish(output_str, &raw mut dest, allocator); } @@ -1204,7 +1202,7 @@ pub unsafe extern "C" fn lzma_str_list_filters( &raw mut dest, &raw const (*m.offset(k as isize)).name as *const c_char, ); - k = k.wrapping_add(1); + k += 1; } } else { let use_byte_suffix: bool = @@ -1222,12 +1220,12 @@ pub unsafe extern "C" fn lzma_str_list_filters( ); } str_append_str(&raw mut dest, b">\0" as *const u8 as *const c_char); - j = j.wrapping_add(1); + j += 1; } } } } - i = i.wrapping_add(1); + i += 1; } if !first_filter_printed { str_free(&raw mut dest, allocator); @@ -1265,8 +1263,8 @@ unsafe extern "C" fn run_static_initializers() { offset: 20, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: LZMA_LCLP_MIN as u32, - max: LZMA_LCLP_MAX as u32, + min: LZMA_LCLP_MIN, + max: LZMA_LCLP_MAX, }, }, }, @@ -1277,8 +1275,8 @@ unsafe extern "C" fn run_static_initializers() { offset: 24, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: LZMA_LCLP_MIN as u32, - max: LZMA_LCLP_MAX as u32, + min: LZMA_LCLP_MIN, + max: LZMA_LCLP_MAX, }, }, }, @@ -1289,8 +1287,8 @@ unsafe extern "C" fn run_static_initializers() { offset: 28, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { - min: LZMA_PB_MIN as u32, - max: LZMA_PB_MAX as u32, + min: LZMA_PB_MIN, + max: LZMA_PB_MAX, }, }, }, diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index 3751ca7a..9f4ec17f 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -7,7 +7,7 @@ pub extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { let mut i: u32 = 0; loop { vli >>= 7; - i = i.wrapping_add(1); + i += 1; if !(vli != 0) { break; } diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index 49d2ebee..f0d22c95 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -8,7 +8,7 @@ extern "C" { ) -> lzma_ret; fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); } -pub const LZMA_DELTA_DIST_MIN: c_int = 1; +pub const LZMA_DELTA_DIST_MIN: u32 = 1; unsafe extern "C" fn delta_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; lzma_next_end(&raw mut (*coder).next, allocator); @@ -58,8 +58,8 @@ pub unsafe extern "C" fn lzma_delta_coder_memusage(options: *const c_void) -> u6 let opt: *const lzma_options_delta = options as *const lzma_options_delta; if opt.is_null() || (*opt).type_0 != LZMA_DELTA_TYPE_BYTE - || (*opt).dist < LZMA_DELTA_DIST_MIN as u32 - || (*opt).dist > LZMA_DELTA_DIST_MAX as u32 + || (*opt).dist < LZMA_DELTA_DIST_MIN + || (*opt).dist > LZMA_DELTA_DIST_MAX { return UINT64_MAX; } diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 822a0b50..044ce952 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -11,15 +11,13 @@ unsafe extern "C" fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8 let distance: size_t = (*coder).distance; let mut i: size_t = 0; while i < size { - let ref mut fresh0 = *buffer.offset(i as isize); - *fresh0 = (*fresh0).wrapping_add( - (*coder).history - [(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize], + *buffer.offset(i as isize) = (*buffer.offset(i as isize)).wrapping_add( + (*coder).history[(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize], ); let fresh1 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); (*coder).history[(fresh1 & 0xff) as usize] = *buffer.offset(i as isize); - i = i.wrapping_add(1); + i += 1; } } unsafe extern "C" fn delta_decode( diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index adffe88e..b9fee97c 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_next_filter_update( next: *mut lzma_next_coder, @@ -13,7 +13,7 @@ extern "C" { filters: *const lzma_filter_info, ) -> lzma_ret; } -pub const LZMA_DELTA_DIST_MIN: c_int = 1; +pub const LZMA_DELTA_DIST_MIN: u32 = 1; unsafe extern "C" fn copy_and_encode( coder: *mut lzma_delta_coder, in_0: *const u8, @@ -23,27 +23,26 @@ unsafe extern "C" fn copy_and_encode( let distance: size_t = (*coder).distance; let mut i: size_t = 0; while i < size { - let tmp: u8 = (*coder).history - [(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize]; + let tmp: u8 = + (*coder).history[(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize]; let fresh2 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); (*coder).history[(fresh2 & 0xff) as usize] = *in_0.offset(i as isize); *out.offset(i as isize) = (*in_0.offset(i as isize)).wrapping_sub(tmp); - i = i.wrapping_add(1); + i += 1; } } unsafe extern "C" fn encode_in_place(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { let distance: size_t = (*coder).distance; let mut i: size_t = 0; while i < size { - let tmp: u8 = (*coder).history - [(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize]; + let tmp: u8 = + (*coder).history[(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize]; let fresh0 = (*coder).pos; (*coder).pos = (*coder).pos.wrapping_sub(1); (*coder).history[(fresh0 & 0xff) as usize] = *buffer.offset(i as isize); - let ref mut fresh1 = *buffer.offset(i as isize); - *fresh1 = (*fresh1).wrapping_sub(tmp); - i = i.wrapping_add(1); + *buffer.offset(i as isize) = (*buffer.offset(i as isize)).wrapping_sub(tmp); + i += 1; } } unsafe extern "C" fn delta_encode( @@ -160,6 +159,6 @@ pub unsafe extern "C" fn lzma_delta_props_encode(options: *const c_void, out: *m return LZMA_PROG_ERROR; } let opt: *const lzma_options_delta = options as *const lzma_options_delta; - *out.offset(0) = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN as u32) as u8; + *out.offset(0) = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN) as u8; return LZMA_OK; } diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 183247b1..1a2ab73e 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_ulong, c_void}; +use core::ffi::{c_ulong, c_void}; extern "C" { fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -34,10 +34,10 @@ pub struct C2RustUnnamed { } pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const LZMA_BUFFER_SIZE: c_int = 4096; -pub const LZ_DICT_EXTRA: c_int = 0; -pub const LZ_DICT_REPEAT_MAX: c_int = 288; -pub const LZ_DICT_INIT_POS: c_int = 2 * LZ_DICT_REPEAT_MAX; +pub const LZMA_BUFFER_SIZE: u32 = 4096; +pub const LZ_DICT_EXTRA: u32 = 0; +pub const LZ_DICT_REPEAT_MAX: u32 = 288; +pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { coder: core::ptr::null_mut(), code: None, diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index dd9d6cba..7d48052e 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -57,7 +57,7 @@ extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { } pub const HASH_2_SIZE: c_uint = 1u32 << 10; pub const HASH_3_SIZE: c_uint = 1u32 << 16; -pub const LZMA_MEMCMPLEN_EXTRA: c_int = 0; +pub const LZMA_MEMCMPLEN_EXTRA: u32 = 0; unsafe extern "C" fn move_window(mf: *mut lzma_mf) { let move_offset: u32 = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) & !(15); let move_size: size_t = (*mf).write_pos.wrapping_sub(move_offset) as size_t; @@ -274,7 +274,7 @@ unsafe extern "C" fn lz_encoder_prepare( } } (*mf).hash_mask = hs; - hs = hs.wrapping_add(1); + hs += 1; if hash_bytes > 2 { hs = hs.wrapping_add(HASH_2_SIZE); } @@ -311,7 +311,7 @@ unsafe extern "C" fn lz_encoder_init( ) -> bool { if (*mf).buffer.is_null() { (*mf).buffer = lzma_alloc( - (*mf).size.wrapping_add(LZMA_MEMCMPLEN_EXTRA as u32) as size_t, + (*mf).size.wrapping_add(LZMA_MEMCMPLEN_EXTRA) as size_t, allocator, ) as *mut u8; if (*mf).buffer.is_null() { diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 0eb6aed4..093e6dcf 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint}; +use core::ffi::c_uint; extern "C" { static lzma_crc32_table: [[u32; 256]; 8]; } @@ -25,7 +25,7 @@ unsafe extern "C" fn lzma_memcmplen( limit: u32, ) -> u32 { while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { - len = len.wrapping_add(1); + len += 1; } return len; } @@ -55,29 +55,29 @@ pub unsafe extern "C" fn lzma_mf_find( (*mf).read_ahead = (*mf).read_ahead.wrapping_add(1); return len_best; } -pub const EMPTY_HASH_VALUE: c_int = 0; +pub const EMPTY_HASH_VALUE: u32 = 0; pub const MUST_NORMALIZE_POS: c_uint = UINT32_MAX; unsafe extern "C" fn normalize(mf: *mut lzma_mf) { - let subvalue: u32 = (MUST_NORMALIZE_POS as u32).wrapping_sub((*mf).cyclic_size); + let subvalue: u32 = MUST_NORMALIZE_POS.wrapping_sub((*mf).cyclic_size); let mut i: u32 = 0; while i < (*mf).hash_count { if *(*mf).hash.offset(i as isize) <= subvalue { - *(*mf).hash.offset(i as isize) = EMPTY_HASH_VALUE as u32; + *(*mf).hash.offset(i as isize) = EMPTY_HASH_VALUE; } else { - let ref mut fresh0 = *(*mf).hash.offset(i as isize); - *fresh0 = (*fresh0).wrapping_sub(subvalue); + *(*mf).hash.offset(i as isize) = + (*(*mf).hash.offset(i as isize)).wrapping_sub(subvalue); } - i = i.wrapping_add(1); + i += 1; } let mut i_0: u32 = 0; while i_0 < (*mf).sons_count { if *(*mf).son.offset(i_0 as isize) <= subvalue { - *(*mf).son.offset(i_0 as isize) = EMPTY_HASH_VALUE as u32; + *(*mf).son.offset(i_0 as isize) = EMPTY_HASH_VALUE; } else { - let ref mut fresh1 = *(*mf).son.offset(i_0 as isize); - *fresh1 = (*fresh1).wrapping_sub(subvalue); + *(*mf).son.offset(i_0 as isize) = + (*(*mf).son.offset(i_0 as isize)).wrapping_sub(subvalue); } - i_0 = i_0.wrapping_add(1); + i_0 += 1; } (*mf).offset = (*mf).offset.wrapping_sub(subvalue); } @@ -210,7 +210,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); } - amount = amount.wrapping_sub(1); + amount -= 1; if !(amount != 0) { break; } @@ -260,7 +260,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) == *cur { len_best = 3; let fresh3 = matches_count; - matches_count = matches_count.wrapping_add(1); + matches_count += 1; (*matches.offset(fresh3 as isize)).dist = delta3.wrapping_sub(1); delta2 = delta3; } @@ -320,7 +320,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); } - amount = amount.wrapping_sub(1); + amount -= 1; if !(amount != 0) { break; } @@ -347,8 +347,8 @@ unsafe extern "C" fn bt_find_func( let fresh4 = depth; depth = depth.wrapping_sub(1); if fresh4 == 0 || delta >= cyclic_size { - *ptr0 = EMPTY_HASH_VALUE as u32; - *ptr1 = EMPTY_HASH_VALUE as u32; + *ptr0 = EMPTY_HASH_VALUE; + *ptr1 = EMPTY_HASH_VALUE; return matches; } let pair: *mut u32 = son.offset( @@ -405,8 +405,8 @@ unsafe extern "C" fn bt_skip_func( let fresh5 = depth; depth = depth.wrapping_sub(1); if fresh5 == 0 || delta >= cyclic_size { - *ptr0 = EMPTY_HASH_VALUE as u32; - *ptr1 = EMPTY_HASH_VALUE as u32; + *ptr0 = EMPTY_HASH_VALUE; + *ptr1 = EMPTY_HASH_VALUE; return; } let pair: *mut u32 = son.offset( @@ -504,7 +504,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { } _ => {} } - amount = amount.wrapping_sub(1); + amount -= 1; if !(amount != 0) { break; } @@ -613,7 +613,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { } _ => {} } - amount = amount.wrapping_sub(1); + amount -= 1; if !(amount != 0) { break; } @@ -663,7 +663,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) == *cur { len_best = 3; let fresh6 = matches_count; - matches_count = matches_count.wrapping_add(1); + matches_count += 1; (*matches.offset(fresh6 as isize)).dist = delta3.wrapping_sub(1); delta2 = delta3; } @@ -754,7 +754,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { } _ => {} } - amount = amount.wrapping_sub(1); + amount -= 1; if !(amount != 0) { break; } diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index 635b2f38..3f0185fa 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_bufcpy( in_0: *const u8, @@ -60,8 +60,8 @@ pub const SEQ_COMPRESSED_0: sequence = 3; pub const SEQ_UNCOMPRESSED_2: sequence = 2; pub const SEQ_UNCOMPRESSED_1: sequence = 1; pub const SEQ_CONTROL: sequence = 0; -pub const LZ_DICT_REPEAT_MAX: c_int = 288; -pub const LZ_DICT_INIT_POS: c_int = 2 * LZ_DICT_REPEAT_MAX; +pub const LZ_DICT_REPEAT_MAX: u32 = 288; +pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { coder: core::ptr::null_mut(), code: None, diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index ff650869..86e54d0b 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; #[repr(C)] pub struct lzma_lzma1_encoder_s { _opaque: [u8; 0], @@ -112,7 +112,7 @@ unsafe extern "C" fn mf_read( *out_pos = (*out_pos).wrapping_add(copy_size); *left = (*left).wrapping_sub(copy_size); } -pub const FASTPOS_BITS: c_int = 13; +pub const FASTPOS_BITS: u32 = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { @@ -127,8 +127,8 @@ unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { } pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; pub const LZMA2_UNCOMPRESSED_MAX: c_uint = 1u32 << 21; -pub const LZMA2_HEADER_MAX: c_int = 6; -pub const LZMA2_HEADER_UNCOMPRESSED: c_int = 3; +pub const LZMA2_HEADER_MAX: u32 = 6; +pub const LZMA2_HEADER_UNCOMPRESSED: u32 = 3; unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { let mut pos: size_t = 0; if (*coder).need_properties { @@ -149,21 +149,21 @@ unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { (*coder).buf_pos = pos; let mut size: size_t = (*coder).uncompressed_size.wrapping_sub(1); let fresh1 = pos; - pos = pos.wrapping_add(1); + pos += 1; (*coder).buf[fresh1 as usize] = ((*coder).buf[fresh1 as usize] as size_t).wrapping_add(size >> 16) as u8; let fresh2 = pos; - pos = pos.wrapping_add(1); + pos += 1; (*coder).buf[fresh2 as usize] = (size >> 8 & 0xff) as u8; let fresh3 = pos; - pos = pos.wrapping_add(1); + pos += 1; (*coder).buf[fresh3 as usize] = (size & 0xff) as u8; size = (*coder).compressed_size.wrapping_sub(1); let fresh4 = pos; - pos = pos.wrapping_add(1); + pos += 1; (*coder).buf[fresh4 as usize] = (size >> 8) as u8; let fresh5 = pos; - pos = pos.wrapping_add(1); + pos += 1; (*coder).buf[fresh5 as usize] = (size & 0xff) as u8; if (*coder).need_properties { lzma_lzma_lclppb_encode( @@ -357,10 +357,10 @@ unsafe extern "C" fn lzma2_encoder_options_update( || (*coder).opt_cur.lp != (*opt).lp || (*coder).opt_cur.pb != (*opt).pb { - if (*opt).lc > LZMA_LCLP_MAX as u32 - || (*opt).lp > LZMA_LCLP_MAX as u32 - || (*opt).lc.wrapping_add((*opt).lp) > LZMA_LCLP_MAX as u32 - || (*opt).pb > LZMA_PB_MAX as u32 + if (*opt).lc > LZMA_LCLP_MAX + || (*opt).lp > LZMA_LCLP_MAX + || (*opt).lc.wrapping_add((*opt).lp) > LZMA_LCLP_MAX + || (*opt).pb > LZMA_PB_MAX { return LZMA_OPTIONS_ERROR; } @@ -487,7 +487,7 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *m } else { 4096 }; - d = d.wrapping_sub(1); + d -= 1; d |= d >> 2; d |= d >> 3; d |= d >> 4; diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index b3fa4b2f..3b1f3376 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_long, c_uint, c_void}; +use core::ffi::{c_long, c_uint, c_void}; extern "C" { fn lzma_lz_decoder_init( next: *mut lzma_next_coder, @@ -108,8 +108,8 @@ extern "C" fn read32le(buf: *const u8) -> u32 { }; } pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; -pub const LZ_DICT_REPEAT_MAX: c_int = 288; -pub const LZ_DICT_INIT_POS: c_int = 2 * LZ_DICT_REPEAT_MAX; +pub const LZ_DICT_REPEAT_MAX: u32 = 288; +pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; #[inline] unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { return *(*dict).buf.offset( @@ -148,11 +148,11 @@ unsafe extern "C" fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut if distance < left { loop { let fresh0 = back; - back = back.wrapping_add(1); + back += 1; let fresh1 = (*dict).pos; (*dict).pos = (*dict).pos.wrapping_add(1); *(*dict).buf.offset(fresh1 as isize) = *(*dict).buf.offset(fresh0 as isize); - left = left.wrapping_sub(1); + left -= 1; if !(left > 0) { break; } @@ -187,21 +187,21 @@ unsafe extern "C" fn dict_put_safe(dict: *mut lzma_dict, byte: u8) -> bool { dict_put(dict, byte); return false; } -pub const RC_SHIFT_BITS: c_int = 8; -pub const RC_TOP_BITS: c_int = 24; +pub const RC_SHIFT_BITS: u32 = 8; +pub const RC_TOP_BITS: u32 = 24; pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; -pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11; +pub const RC_BIT_MODEL_TOTAL_BITS: u32 = 11; pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_BITS: c_int = 5; +pub const RC_MOVE_BITS: u32 = 5; #[inline] unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { - return (*options).lc <= LZMA_LCLP_MAX as u32 - && (*options).lp <= LZMA_LCLP_MAX as u32 - && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as u32 - && (*options).pb <= LZMA_PB_MAX as u32; + return (*options).lc <= LZMA_LCLP_MAX + && (*options).lp <= LZMA_LCLP_MAX + && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX + && (*options).pb <= LZMA_PB_MAX; } -pub const STATES: c_int = 12; -pub const LIT_STATES: c_int = 7; +pub const STATES: u32 = 12; +pub const LIT_STATES: u32 = 7; pub const LITERAL_CODER_SIZE: c_uint = 0x300; #[inline] unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { @@ -209,25 +209,25 @@ unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { let mut i: size_t = 0; while i < coders { *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; - i = i.wrapping_add(1); + i += 1; } } -pub const MATCH_LEN_MIN: c_int = 2; -pub const LEN_LOW_BITS: c_int = 3; -pub const LEN_LOW_SYMBOLS: c_int = (1) << LEN_LOW_BITS; -pub const LEN_MID_BITS: c_int = 3; -pub const LEN_MID_SYMBOLS: c_int = (1) << LEN_MID_BITS; -pub const LEN_HIGH_BITS: c_int = 8; -pub const LEN_HIGH_SYMBOLS: c_int = (1) << LEN_HIGH_BITS; -pub const DIST_STATES: c_int = 4; -pub const DIST_SLOT_BITS: c_int = 6; -pub const DIST_SLOTS: c_int = (1) << DIST_SLOT_BITS; -pub const DIST_MODEL_START: c_int = 4; -pub const DIST_MODEL_END: c_int = 14; -pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2; -pub const FULL_DISTANCES: c_int = (1) << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: c_int = 4; -pub const ALIGN_SIZE: c_int = (1) << ALIGN_BITS; +pub const MATCH_LEN_MIN: u32 = 2; +pub const LEN_LOW_BITS: u32 = 3; +pub const LEN_LOW_SYMBOLS: u32 = (1) << LEN_LOW_BITS; +pub const LEN_MID_BITS: u32 = 3; +pub const LEN_MID_SYMBOLS: u32 = (1) << LEN_MID_BITS; +pub const LEN_HIGH_BITS: u32 = 8; +pub const LEN_HIGH_SYMBOLS: u32 = (1) << LEN_HIGH_BITS; +pub const DIST_STATES: u32 = 4; +pub const DIST_SLOT_BITS: u32 = 6; +pub const DIST_SLOTS: u32 = (1) << DIST_SLOT_BITS; +pub const DIST_MODEL_START: u32 = 4; +pub const DIST_MODEL_END: u32 = 14; +pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; +pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: u32 = 4; +pub const ALIGN_SIZE: u32 = (1) << ALIGN_BITS; #[inline] unsafe extern "C" fn rc_read_init( rc: *mut lzma_range_decoder, @@ -397,8 +397,8 @@ unsafe extern "C" fn lzma_decode( probs = &raw mut *(&raw mut (*coder).rep_len_decoder.low as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; - limit = LEN_LOW_SYMBOLS as u32; - len = MATCH_LEN_MIN as u32; + limit = LEN_LOW_SYMBOLS; + len = MATCH_LEN_MIN; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); @@ -519,7 +519,7 @@ unsafe extern "C" fn lzma_decode( as u32, ) >> RC_MOVE_BITS, ) as probability; - state = (if state < LIT_STATES as u32 { + state = (if state < LIT_STATES { STATE_LIT_SHORTREP } else { STATE_NONLIT_REP @@ -592,7 +592,7 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).is_rep[state as usize] as u32) >> RC_MOVE_BITS, ) as probability; - state = (if state < LIT_STATES as u32 { + state = (if state < LIT_STATES { STATE_LIT_MATCH } else { STATE_NONLIT_MATCH @@ -671,7 +671,7 @@ unsafe extern "C" fn lzma_decode( symbol = symbol.wrapping_add(offset); } offset <<= 1; - if offset < ALIGN_SIZE as u32 { + if offset < ALIGN_SIZE { current_block = 10510472849010538284; continue; } @@ -700,7 +700,7 @@ unsafe extern "C" fn lzma_decode( rc_bound = 0u32.wrapping_sub(rc.code >> 31); rc.code = rc.code.wrapping_add(rc.range & rc_bound); rep0 = (rep0 << 1).wrapping_add(rc_bound.wrapping_add(1)); - limit = limit.wrapping_sub(1); + limit -= 1; if limit > 0 { current_block = 15418612220330286504; continue; @@ -728,21 +728,21 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh133 = *probs.offset(symbol as isize); - *fresh133 = (*fresh133 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh134 = *probs.offset(symbol as isize); - *fresh134 = *fresh134 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); rep0 = (rep0 as u32).wrapping_add(1u32 << offset) as u32; } - offset = offset.wrapping_add(1); + offset += 1; if offset < limit { current_block = 617447976488552541; continue; @@ -766,30 +766,30 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh130 = *probs.offset(symbol as isize); - *fresh130 = (*fresh130 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh131 = *probs.offset(symbol as isize); - *fresh131 = *fresh131 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } - if symbol < DIST_SLOTS as u32 { + if symbol < DIST_SLOTS { current_block = 4174862988780014241; continue; } - symbol = symbol.wrapping_sub(DIST_SLOTS as u32); - if symbol < DIST_MODEL_START as u32 { + symbol = symbol.wrapping_sub(DIST_SLOTS); + if symbol < DIST_MODEL_START { rep0 = symbol; } else { limit = (symbol >> 1).wrapping_sub(1); rep0 = (2u32).wrapping_add(symbol & 1); - if symbol < DIST_MODEL_END as u32 { + if symbol < DIST_MODEL_END { rep0 <<= limit; probs = (&raw mut (*coder).pos_special as *mut probability) .offset(rep0 as isize) @@ -800,7 +800,7 @@ unsafe extern "C" fn lzma_decode( current_block = 617447976488552541; continue; } else { - limit = limit.wrapping_sub(ALIGN_BITS as u32); + limit = limit.wrapping_sub(ALIGN_BITS); current_block = 15418612220330286504; continue; } @@ -824,17 +824,17 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh127 = *probs.offset(symbol as isize); - *fresh127 = (*fresh127 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh128 = *probs.offset(symbol as isize); - *fresh128 = *fresh128 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if symbol < limit { @@ -844,7 +844,7 @@ unsafe extern "C" fn lzma_decode( len = len.wrapping_add(symbol.wrapping_sub(limit)); probs = &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]).offset( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN as u32) + len.wrapping_sub(MATCH_LEN_MIN) } else { (DIST_STATES - 1) as u32 }) as isize, @@ -879,7 +879,7 @@ unsafe extern "C" fn lzma_decode( probs = &raw mut *(&raw mut (*coder).match_len_decoder.mid as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; - limit = LEN_MID_SYMBOLS as u32; + limit = LEN_MID_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -887,7 +887,7 @@ unsafe extern "C" fn lzma_decode( (*coder).match_len_decoder.choice2 = (*coder).match_len_decoder.choice2 - ((*coder).match_len_decoder.choice2 >> RC_MOVE_BITS); probs = &raw mut (*coder).match_len_decoder.high as *mut probability; - limit = LEN_HIGH_SYMBOLS as u32; + limit = LEN_HIGH_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32; } current_block = 8485842003490715114; @@ -918,8 +918,8 @@ unsafe extern "C" fn lzma_decode( probs = &raw mut *(&raw mut (*coder).match_len_decoder.low as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; - limit = LEN_LOW_SYMBOLS as u32; - len = MATCH_LEN_MIN as u32; + limit = LEN_LOW_SYMBOLS; + len = MATCH_LEN_MIN; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); @@ -958,20 +958,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh121 = *probs.offset(subcoder_index as isize); - *fresh121 = (*fresh121 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(subcoder_index as isize) = + (*probs.offset(subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(subcoder_index as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; offset &= !match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh122 = *probs.offset(subcoder_index as isize); - *fresh122 = - *fresh122 - (*probs.offset(subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(subcoder_index as isize) -= + *probs.offset(subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); offset &= match_bit; } @@ -1044,16 +1043,16 @@ unsafe extern "C" fn lzma_decode( ) as isize, ); symbol = 1; - if state < LIT_STATES as u32 { - state = if state <= STATE_SHORTREP_LIT_LIT as u32 { - STATE_LIT_LIT as u32 + if state < LIT_STATES { + state = if state <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT } else { state.wrapping_sub(3) }; current_block = 13844743919235296534; continue; } else { - state = if state <= STATE_LIT_SHORTREP as u32 { + state = if state <= STATE_LIT_SHORTREP { state.wrapping_sub(3) } else { state.wrapping_sub(6) @@ -1090,17 +1089,17 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh118 = *probs.offset(symbol as isize); - *fresh118 = (*fresh118 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh119 = *probs.offset(symbol as isize); - *fresh119 = *fresh119 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if symbol < ((1) << 8) as u32 { @@ -1128,17 +1127,17 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh145 = *probs.offset(symbol as isize); - *fresh145 = (*fresh145 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh146 = *probs.offset(symbol as isize); - *fresh146 = *fresh146 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if symbol < limit { @@ -1184,7 +1183,7 @@ unsafe extern "C" fn lzma_decode( probs = &raw mut *(&raw mut (*coder).rep_len_decoder.mid as *mut [probability; 8]) .offset(pos_state as isize) as *mut probability; - limit = LEN_MID_SYMBOLS as u32; + limit = LEN_MID_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -1192,7 +1191,7 @@ unsafe extern "C" fn lzma_decode( (*coder).rep_len_decoder.choice2 = (*coder).rep_len_decoder.choice2 - ((*coder).rep_len_decoder.choice2 >> RC_MOVE_BITS); probs = &raw mut (*coder).rep_len_decoder.high as *mut probability; - limit = LEN_HIGH_SYMBOLS as u32; + limit = LEN_HIGH_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32; } current_block = 16690975975023747857; @@ -1241,9 +1240,9 @@ unsafe extern "C" fn lzma_decode( << literal_context_bits, ) as isize, ); - if state < LIT_STATES as u32 { - state = if state <= STATE_SHORTREP_LIT_LIT as u32 { - STATE_LIT_LIT as u32 + if state < LIT_STATES { + state = if state <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT } else { state.wrapping_sub(3) }; @@ -1258,18 +1257,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh5 = *probs.offset(symbol as isize); - *fresh5 = (*fresh5 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh6 = *probs.offset(symbol as isize); - *fresh6 = *fresh6 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1282,18 +1281,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh8 = *probs.offset(symbol as isize); - *fresh8 = (*fresh8 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh9 = *probs.offset(symbol as isize); - *fresh9 = *fresh9 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1306,18 +1305,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh11 = *probs.offset(symbol as isize); - *fresh11 = (*fresh11 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh12 = *probs.offset(symbol as isize); - *fresh12 = *fresh12 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1330,18 +1329,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh14 = *probs.offset(symbol as isize); - *fresh14 = (*fresh14 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh15 = *probs.offset(symbol as isize); - *fresh15 = *fresh15 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1354,18 +1353,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh17 = *probs.offset(symbol as isize); - *fresh17 = (*fresh17 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh18 = *probs.offset(symbol as isize); - *fresh18 = *fresh18 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1378,18 +1377,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh20 = *probs.offset(symbol as isize); - *fresh20 = (*fresh20 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh21 = *probs.offset(symbol as isize); - *fresh21 = *fresh21 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1402,18 +1401,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh23 = *probs.offset(symbol as isize); - *fresh23 = (*fresh23 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh24 = *probs.offset(symbol as isize); - *fresh24 = *fresh24 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -1426,23 +1425,22 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh26 = *probs.offset(symbol as isize); - *fresh26 = (*fresh26 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh27 = *probs.offset(symbol as isize); - *fresh27 = *fresh27 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } - } else { - state = if state <= STATE_LIT_SHORTREP as u32 { + state = if state <= STATE_LIT_SHORTREP { state.wrapping_sub(3) } else { state.wrapping_sub(6) @@ -1465,20 +1463,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh29 = *probs.offset(t_subcoder_index as isize); - *fresh29 = (*fresh29 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(t_subcoder_index as isize) = + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as u32, + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh30 = *probs.offset(t_subcoder_index as isize); - *fresh30 = *fresh30 - - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(t_subcoder_index as isize) -= + *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1495,20 +1492,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh32 = *probs.offset(t_subcoder_index as isize); - *fresh32 = (*fresh32 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(t_subcoder_index as isize) = + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as u32, + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh33 = *probs.offset(t_subcoder_index as isize); - *fresh33 = *fresh33 - - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(t_subcoder_index as isize) -= + *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1525,20 +1521,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh35 = *probs.offset(t_subcoder_index as isize); - *fresh35 = (*fresh35 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(t_subcoder_index as isize) = + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as u32, + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh36 = *probs.offset(t_subcoder_index as isize); - *fresh36 = *fresh36 - - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(t_subcoder_index as isize) -= + *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1555,20 +1550,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh38 = *probs.offset(t_subcoder_index as isize); - *fresh38 = (*fresh38 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(t_subcoder_index as isize) = + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as u32, + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh39 = *probs.offset(t_subcoder_index as isize); - *fresh39 = *fresh39 - - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(t_subcoder_index as isize) -= + *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1585,20 +1579,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh41 = *probs.offset(t_subcoder_index as isize); - *fresh41 = (*fresh41 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(t_subcoder_index as isize) = + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as u32, + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh42 = *probs.offset(t_subcoder_index as isize); - *fresh42 = *fresh42 - - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(t_subcoder_index as isize) -= + *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1615,20 +1608,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh44 = *probs.offset(t_subcoder_index as isize); - *fresh44 = (*fresh44 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(t_subcoder_index as isize) = + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as u32, + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh45 = *probs.offset(t_subcoder_index as isize); - *fresh45 = *fresh45 - - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(t_subcoder_index as isize) -= + *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1645,20 +1637,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh47 = *probs.offset(t_subcoder_index as isize); - *fresh47 = (*fresh47 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(t_subcoder_index as isize) = + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as u32, + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh48 = *probs.offset(t_subcoder_index as isize); - *fresh48 = *fresh48 - - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(t_subcoder_index as isize) -= + *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1675,20 +1666,19 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh50 = *probs.offset(t_subcoder_index as isize); - *fresh50 = (*fresh50 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(t_subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(t_subcoder_index as isize) = + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(t_subcoder_index as isize) as u32, + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh51 = *probs.offset(t_subcoder_index as isize); - *fresh51 = *fresh51 - - (*probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS); + *probs.offset(t_subcoder_index as isize) -= + *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } @@ -1716,7 +1706,7 @@ unsafe extern "C" fn lzma_decode( .wrapping_sub((*coder).is_rep[state as usize] as u32) >> RC_MOVE_BITS, ) as probability; - state = (if state < LIT_STATES as u32 { + state = (if state < LIT_STATES { STATE_LIT_MATCH } else { STATE_NONLIT_MATCH @@ -2257,7 +2247,7 @@ unsafe extern "C" fn lzma_decode( probs = &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) .offset( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN as u32) + len.wrapping_sub(MATCH_LEN_MIN) } else { (DIST_STATES - 1) as u32 }) as isize, @@ -2273,18 +2263,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh70 = *probs.offset(symbol as isize); - *fresh70 = (*fresh70 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh71 = *probs.offset(symbol as isize); - *fresh71 = *fresh71 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2297,18 +2287,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh73 = *probs.offset(symbol as isize); - *fresh73 = (*fresh73 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh74 = *probs.offset(symbol as isize); - *fresh74 = *fresh74 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2321,18 +2311,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh76 = *probs.offset(symbol as isize); - *fresh76 = (*fresh76 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh77 = *probs.offset(symbol as isize); - *fresh77 = *fresh77 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2345,18 +2335,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh79 = *probs.offset(symbol as isize); - *fresh79 = (*fresh79 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh80 = *probs.offset(symbol as isize); - *fresh80 = *fresh80 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2369,18 +2359,18 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh82 = *probs.offset(symbol as isize); - *fresh82 = (*fresh82 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh83 = *probs.offset(symbol as isize); - *fresh83 = *fresh83 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { @@ -2393,27 +2383,27 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh85 = *probs.offset(symbol as isize); - *fresh85 = (*fresh85 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh86 = *probs.offset(symbol as isize); - *fresh86 = *fresh86 - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add(-((1_i32) << 6) as u32); - if symbol < DIST_MODEL_START as u32 { + if symbol < DIST_MODEL_START { rep0 = symbol; } else { limit = (symbol >> 1).wrapping_sub(1); rep0 = (2u32).wrapping_add(symbol & 1); - if symbol < DIST_MODEL_END as u32 { + if symbol < DIST_MODEL_END { rep0 <<= limit; probs = (&raw mut (*coder).pos_special as *mut probability) .offset(rep0 as isize) @@ -2432,32 +2422,30 @@ unsafe extern "C" fn lzma_decode( .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - let ref mut fresh88 = *probs.offset(symbol as isize); - *fresh88 = (*fresh88 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) - as probability - as probability; + *probs.offset(symbol as isize) = + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + *probs.offset(symbol as isize) as u32, + ) >> RC_MOVE_BITS, + ) + as probability; symbol <<= 1; } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); - let ref mut fresh89 = *probs.offset(symbol as isize); - *fresh89 = *fresh89 - - (*probs.offset(symbol as isize) >> RC_MOVE_BITS); + *probs.offset(symbol as isize) -= + *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); rep0 = rep0.wrapping_add(offset); } offset <<= 1; - limit = limit.wrapping_sub(1); + limit -= 1; if !(limit > 0) { break; } } } else { - limit = limit.wrapping_sub(ALIGN_BITS as u32); + limit = limit.wrapping_sub(ALIGN_BITS); loop { rep0 = (rep0 << 1).wrapping_add(1); if rc.range < RC_TOP_VALUE as u32 { @@ -2471,7 +2459,7 @@ unsafe extern "C" fn lzma_decode( rc_bound = 0u32.wrapping_sub(rc.code >> 31); rep0 = rep0.wrapping_add(rc_bound); rc.code = rc.code.wrapping_add(rc.range & rc_bound); - limit = limit.wrapping_sub(1); + limit -= 1; if !(limit > 0) { break; } @@ -2508,7 +2496,7 @@ unsafe extern "C" fn lzma_decode( (*coder).pos_align[symbol.wrapping_add(1) as usize] - ((*coder).pos_align[symbol.wrapping_add(1) as usize] >> RC_MOVE_BITS); - symbol = symbol.wrapping_add(1); + symbol += 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2667,7 +2655,7 @@ unsafe extern "C" fn lzma_decode( ) >> RC_MOVE_BITS, ) as probability as probability; - state = (if state < LIT_STATES as u32 { + state = (if state < LIT_STATES { STATE_LIT_SHORTREP } else { STATE_NONLIT_REP @@ -2750,7 +2738,7 @@ unsafe extern "C" fn lzma_decode( } } } - state = (if state < LIT_STATES as u32 { + state = (if state < LIT_STATES { STATE_LIT_LONGREP } else { STATE_NONLIT_REP @@ -3324,7 +3312,7 @@ unsafe extern "C" fn lzma_decode( continue; } 15498320742470848828 => { - state = (if state < LIT_STATES as u32 { + state = (if state < LIT_STATES { STATE_LIT_LONGREP } else { STATE_NONLIT_REP @@ -3399,8 +3387,7 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo (*options).lp, ); (*coder).literal_context_bits = (*options).lc; - (*coder).literal_mask = - (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); + (*coder).literal_mask = (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); (*coder).state = STATE_LIT_LIT; (*coder).rep0 = 0; (*coder).rep1 = 0; @@ -3411,39 +3398,39 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo (*coder).rc.code = 0; (*coder).rc.init_bytes_left = 5; let mut i: u32 = 0; - while i < STATES as u32 { + while i < STATES { let mut j: u32 = 0; while j <= (*coder).pos_mask { (*coder).is_match[i as usize][j as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep0_long[i as usize][j as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - j = j.wrapping_add(1); + j += 1; } (*coder).is_rep[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep0[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep1[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep2[i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - i = i.wrapping_add(1); + i += 1; } let mut i_0: u32 = 0; - while i_0 < DIST_STATES as u32 { + while i_0 < DIST_STATES { let mut bt_i: u32 = 0; while bt_i < ((1) << 6) as u32 { (*coder).dist_slot[i_0 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i = bt_i.wrapping_add(1); + bt_i += 1; } - i_0 = i_0.wrapping_add(1); + i_0 += 1; } let mut i_1: u32 = 0; while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as u32 { (*coder).pos_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - i_1 = i_1.wrapping_add(1); + i_1 += 1; } let mut bt_i_0: u32 = 0; while bt_i_0 < ((1) << 4) as u32 { (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_0 = bt_i_0.wrapping_add(1); + bt_i_0 += 1; } let num_pos_states: u32 = (1) << (*options).pb; (*coder).match_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; @@ -3456,37 +3443,37 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo while bt_i_1 < ((1) << 3) as u32 { (*coder).match_len_decoder.low[pos_state as usize][bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_1 = bt_i_1.wrapping_add(1); + bt_i_1 += 1; } let mut bt_i_2: u32 = 0; while bt_i_2 < ((1) << 3) as u32 { (*coder).match_len_decoder.mid[pos_state as usize][bt_i_2 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_2 = bt_i_2.wrapping_add(1); + bt_i_2 += 1; } let mut bt_i_3: u32 = 0; while bt_i_3 < ((1) << 3) as u32 { (*coder).rep_len_decoder.low[pos_state as usize][bt_i_3 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_3 = bt_i_3.wrapping_add(1); + bt_i_3 += 1; } let mut bt_i_4: u32 = 0; while bt_i_4 < ((1) << 3) as u32 { (*coder).rep_len_decoder.mid[pos_state as usize][bt_i_4 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_4 = bt_i_4.wrapping_add(1); + bt_i_4 += 1; } - pos_state = pos_state.wrapping_add(1); + pos_state += 1; } let mut bt_i_5: u32 = 0; while bt_i_5 < ((1) << 8) as u32 { (*coder).match_len_decoder.high[bt_i_5 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_5 = bt_i_5.wrapping_add(1); + bt_i_5 += 1; } let mut bt_i_6: u32 = 0; while bt_i_6 < ((1) << 8) as u32 { (*coder).rep_len_decoder.high[bt_i_6 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_6 = bt_i_6.wrapping_add(1); + bt_i_6 += 1; } (*coder).sequence = SEQ_IS_MATCH; (*coder).probs = core::ptr::null_mut(); @@ -3608,7 +3595,7 @@ pub unsafe extern "C" fn lzma_lzma_lclppb_decode( byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9u32).wrapping_mul(5)) as u8; (*options).lp = (byte / 9) as u32; (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9)); - return (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX as u32; + return (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX; } #[no_mangle] pub extern "C" fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64 { diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 7a5d8970..c438628d 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_long, c_uint, c_void}; +use core::ffi::{c_long, c_uint, c_void}; extern "C" { fn lzma_lz_encoder_init( next: *mut lzma_next_coder, @@ -153,13 +153,13 @@ unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const RC_SHIFT_BITS: c_int = 8; -pub const RC_TOP_BITS: c_int = 24; +pub const RC_SHIFT_BITS: u32 = 8; +pub const RC_TOP_BITS: u32 = 24; pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; -pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11; +pub const RC_BIT_MODEL_TOTAL_BITS: u32 = 11; pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_BITS: c_int = 5; -pub const RC_MOVE_REDUCING_BITS: c_int = 4; +pub const RC_MOVE_BITS: u32 = 5; +pub const RC_MOVE_REDUCING_BITS: u32 = 4; #[inline] extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { return unsafe { @@ -227,7 +227,7 @@ unsafe extern "C" fn rc_bittree( ) { let mut model_index: u32 = 1; loop { - bit_count = bit_count.wrapping_sub(1); + bit_count -= 1; let bit: u32 = symbol >> bit_count & 1; rc_bit( rc, @@ -257,7 +257,7 @@ unsafe extern "C" fn rc_bittree_reverse( bit, ); model_index = (model_index << 1).wrapping_add(bit); - bit_count = bit_count.wrapping_sub(1); + bit_count -= 1; if !(bit_count != 0) { break; } @@ -266,7 +266,7 @@ unsafe extern "C" fn rc_bittree_reverse( #[inline] unsafe extern "C" fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) { loop { - bit_count = bit_count.wrapping_sub(1); + bit_count -= 1; let fresh0 = (*rc).count; (*rc).count = (*rc).count.wrapping_add(1); (*rc).symbols[fresh0 as usize] = @@ -283,7 +283,7 @@ unsafe extern "C" fn rc_flush(rc: *mut lzma_range_encoder) { let fresh1 = (*rc).count; (*rc).count = (*rc).count.wrapping_add(1); (*rc).symbols[fresh1 as usize] = RC_FLUSH; - i = i.wrapping_add(1); + i += 1; } } #[inline] @@ -444,7 +444,7 @@ unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u } 4 | _ => {} } - pos = pos.wrapping_add(1); + pos += 1; } pos = 0; while pos < 5 { @@ -457,7 +457,7 @@ unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u ) { return true; } - pos = pos.wrapping_add(1); + pos += 1; } return false; } @@ -467,13 +467,13 @@ unsafe extern "C" fn rc_pending(rc: *const lzma_range_encoder) -> u64 { } #[inline] unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { - return (*options).lc <= LZMA_LCLP_MAX as u32 - && (*options).lp <= LZMA_LCLP_MAX as u32 - && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX as u32 - && (*options).pb <= LZMA_PB_MAX as u32; + return (*options).lc <= LZMA_LCLP_MAX + && (*options).lp <= LZMA_LCLP_MAX + && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX + && (*options).pb <= LZMA_PB_MAX; } -pub const STATES: c_int = 12; -pub const LIT_STATES: c_int = 7; +pub const STATES: u32 = 12; +pub const LIT_STATES: u32 = 7; pub const LITERAL_CODER_SIZE: c_uint = 0x300; #[inline] unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { @@ -481,30 +481,30 @@ unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { let mut i: size_t = 0; while i < coders { *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; - i = i.wrapping_add(1); + i += 1; } } -pub const MATCH_LEN_MIN: c_int = 2; -pub const LEN_LOW_BITS: c_int = 3; -pub const LEN_LOW_SYMBOLS: c_int = (1) << LEN_LOW_BITS; -pub const LEN_MID_BITS: c_int = 3; -pub const LEN_MID_SYMBOLS: c_int = (1) << LEN_MID_BITS; -pub const LEN_HIGH_BITS: c_int = 8; -pub const LEN_HIGH_SYMBOLS: c_int = (1) << LEN_HIGH_BITS; -pub const LEN_SYMBOLS: c_int = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS; -pub const MATCH_LEN_MAX: c_int = MATCH_LEN_MIN + LEN_SYMBOLS - 1; -pub const DIST_STATES: c_int = 4; -pub const DIST_SLOT_BITS: c_int = 6; -pub const DIST_MODEL_START: c_int = 4; -pub const DIST_MODEL_END: c_int = 14; -pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2; -pub const FULL_DISTANCES: c_int = (1) << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: c_int = 4; -pub const ALIGN_SIZE: c_int = (1) << ALIGN_BITS; -pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1; -pub const REPS: c_int = 4; -pub const OPTS: c_int = (1) << 12; -pub const FASTPOS_BITS: c_int = 13; +pub const MATCH_LEN_MIN: u32 = 2; +pub const LEN_LOW_BITS: u32 = 3; +pub const LEN_LOW_SYMBOLS: u32 = (1) << LEN_LOW_BITS; +pub const LEN_MID_BITS: u32 = 3; +pub const LEN_MID_SYMBOLS: u32 = (1) << LEN_MID_BITS; +pub const LEN_HIGH_BITS: u32 = 8; +pub const LEN_HIGH_SYMBOLS: u32 = (1) << LEN_HIGH_BITS; +pub const LEN_SYMBOLS: u32 = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS; +pub const MATCH_LEN_MAX: u32 = MATCH_LEN_MIN + LEN_SYMBOLS - 1; +pub const DIST_STATES: u32 = 4; +pub const DIST_SLOT_BITS: u32 = 6; +pub const DIST_MODEL_START: u32 = 4; +pub const DIST_MODEL_END: u32 = 14; +pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; +pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: u32 = 4; +pub const ALIGN_SIZE: u32 = (1) << ALIGN_BITS; +pub const ALIGN_MASK: u32 = ALIGN_SIZE - 1; +pub const REPS: u32 = 4; +pub const OPTS: u32 = (1) << 12; +pub const FASTPOS_BITS: u32 = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { @@ -561,7 +561,7 @@ unsafe extern "C" fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, p << (*coder).literal_context_bits, ) as isize, ); - if ((*coder).state as u32) < LIT_STATES as u32 { + if ((*coder).state as u32) < LIT_STATES { (*coder).state = (if (*coder).state <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT } else { @@ -600,32 +600,32 @@ unsafe extern "C" fn length_update_prices(lc: *mut lzma_length_encoder, pos_stat &raw mut *(&raw mut (*lc).prices as *mut [u32; 272]).offset(pos_state as isize) as *mut u32; let mut i: u32 = 0; i = 0; - while i < table_size && i < LEN_LOW_SYMBOLS as u32 { + while i < table_size && i < LEN_LOW_SYMBOLS { *prices.offset(i as isize) = a0.wrapping_add(rc_bittree_price( &raw mut *(&raw mut (*lc).low as *mut [probability; 8]).offset(pos_state as isize) as *mut probability, - LEN_LOW_BITS as u32, + LEN_LOW_BITS, i, )); - i = i.wrapping_add(1); + i += 1; } while i < table_size && i < (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32 { *prices.offset(i as isize) = b0.wrapping_add(rc_bittree_price( &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]).offset(pos_state as isize) as *mut probability, - LEN_MID_BITS as u32, - i.wrapping_sub(LEN_LOW_SYMBOLS as u32), + LEN_MID_BITS, + i.wrapping_sub(LEN_LOW_SYMBOLS), )); - i = i.wrapping_add(1); + i += 1; } while i < table_size { *prices.offset(i as isize) = b1.wrapping_add(rc_bittree_price( &raw mut (*lc).high as *mut probability, - LEN_HIGH_BITS as u32, - i.wrapping_sub(LEN_LOW_SYMBOLS as u32) - .wrapping_sub(LEN_MID_SYMBOLS as u32), + LEN_HIGH_BITS, + i.wrapping_sub(LEN_LOW_SYMBOLS) + .wrapping_sub(LEN_MID_SYMBOLS), )); - i = i.wrapping_add(1); + i += 1; } } #[inline] @@ -636,35 +636,35 @@ unsafe extern "C" fn length( mut len: u32, fast_mode: bool, ) { - len = len.wrapping_sub(MATCH_LEN_MIN as u32); - if len < LEN_LOW_SYMBOLS as u32 { + len = len.wrapping_sub(MATCH_LEN_MIN); + if len < LEN_LOW_SYMBOLS { rc_bit(rc, &raw mut (*lc).choice, 0); rc_bittree( rc, &raw mut *(&raw mut (*lc).low as *mut [probability; 8]).offset(pos_state as isize) as *mut probability, - LEN_LOW_BITS as u32, + LEN_LOW_BITS, len, ); } else { rc_bit(rc, &raw mut (*lc).choice, 1); - len = len.wrapping_sub(LEN_LOW_SYMBOLS as u32); - if len < LEN_MID_SYMBOLS as u32 { + len = len.wrapping_sub(LEN_LOW_SYMBOLS); + if len < LEN_MID_SYMBOLS { rc_bit(rc, &raw mut (*lc).choice2, 0); rc_bittree( rc, &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]).offset(pos_state as isize) as *mut probability, - LEN_MID_BITS as u32, + LEN_MID_BITS, len, ); } else { rc_bit(rc, &raw mut (*lc).choice2, 1); - len = len.wrapping_sub(LEN_MID_SYMBOLS as u32); + len = len.wrapping_sub(LEN_MID_SYMBOLS); rc_bittree( rc, &raw mut (*lc).high as *mut probability, - LEN_HIGH_BITS as u32, + LEN_HIGH_BITS, len, ); } @@ -683,7 +683,7 @@ unsafe extern "C" fn match_0( distance: u32, len: u32, ) { - (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { + (*coder).state = (if ((*coder).state as u32) < LIT_STATES { STATE_LIT_MATCH } else { STATE_NONLIT_MATCH @@ -697,7 +697,7 @@ unsafe extern "C" fn match_0( ); let dist_slot: u32 = get_dist_slot(distance) as u32; let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN as u32) + len.wrapping_sub(MATCH_LEN_MIN) } else { (DIST_STATES - 1) as u32 }; @@ -705,14 +705,14 @@ unsafe extern "C" fn match_0( &raw mut (*coder).rc, &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) .offset(dist_state as isize) as *mut probability, - DIST_SLOT_BITS as u32, + DIST_SLOT_BITS, dist_slot, ); - if dist_slot >= DIST_MODEL_START as u32 { + if dist_slot >= DIST_MODEL_START { let footer_bits: u32 = (dist_slot >> 1).wrapping_sub(1); let base: u32 = (2 | dist_slot & 1) << footer_bits; let dist_reduced: u32 = distance.wrapping_sub(base); - if dist_slot < DIST_MODEL_END as u32 { + if dist_slot < DIST_MODEL_END { rc_bittree_reverse( &raw mut (*coder).rc, (&raw mut (*coder).dist_special as *mut probability) @@ -726,13 +726,13 @@ unsafe extern "C" fn match_0( rc_direct( &raw mut (*coder).rc, dist_reduced >> ALIGN_BITS, - footer_bits.wrapping_sub(ALIGN_BITS as u32), + footer_bits.wrapping_sub(ALIGN_BITS), ); rc_bittree_reverse( &raw mut (*coder).rc, &raw mut (*coder).dist_align as *mut probability, - ALIGN_BITS as u32, - dist_reduced & ALIGN_MASK as u32, + ALIGN_BITS, + dist_reduced & ALIGN_MASK, ); (*coder).align_price_count = (*coder).align_price_count.wrapping_add(1); } @@ -796,7 +796,7 @@ unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, r (*coder).reps[0] = distance; } if len == 1 { - (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { + (*coder).state = (if ((*coder).state as u32) < LIT_STATES { STATE_LIT_SHORTREP } else { STATE_NONLIT_REP @@ -809,7 +809,7 @@ unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, r len, (*coder).fast_mode, ); - (*coder).state = (if ((*coder).state as u32) < LIT_STATES as u32 { + (*coder).state = (if ((*coder).state as u32) < LIT_STATES { STATE_LIT_LONGREP } else { STATE_NONLIT_REP @@ -841,7 +841,7 @@ unsafe extern "C" fn encode_symbol( .offset(pos_state as isize) as *mut probability, 1, ); - if back < REPS as u32 { + if back < REPS { rc_bit( &raw mut (*coder).rc, (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) @@ -856,7 +856,7 @@ unsafe extern "C" fn encode_symbol( as *mut probability, 0, ); - match_0(coder, pos_state, back.wrapping_sub(REPS as u32), len); + match_0(coder, pos_state, back.wrapping_sub(REPS), len); } } (*mf).read_ahead = (*mf).read_ahead.wrapping_sub(len); @@ -902,9 +902,9 @@ unsafe extern "C" fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) as *mut probability, 0, ); - match_0(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN as u32); + match_0(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN); } -pub const LOOP_INPUT_MAX: c_int = OPTS + 1; +pub const LOOP_INPUT_MAX: u32 = OPTS + 1; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encode( coder: *mut lzma_lzma1_encoder, @@ -926,7 +926,7 @@ pub unsafe extern "C" fn lzma_lzma_encode( while !(limit != UINT32_MAX && ((*mf).read_pos.wrapping_sub((*mf).read_ahead) >= limit || (*out_pos as u64).wrapping_add(rc_pending(&raw mut (*coder).rc)) - >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX as u32) as u64)) + >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX) as u64)) { if (*mf).read_pos >= (*mf).read_limit { if (*mf).action == LZMA_RUN { @@ -1009,8 +1009,8 @@ unsafe extern "C" fn lzma_lzma_set_out_limit( extern "C" fn is_options_valid(options: *const lzma_options_lzma) -> bool { return unsafe { is_lclppb_valid(options) - && (*options).nice_len >= MATCH_LEN_MIN as u32 - && (*options).nice_len <= MATCH_LEN_MAX as u32 + && (*options).nice_len >= MATCH_LEN_MIN + && (*options).nice_len <= MATCH_LEN_MAX && ((*options).mode == LZMA_MODE_FAST || (*options).mode == LZMA_MODE_NORMAL) }; } @@ -1044,26 +1044,26 @@ unsafe extern "C" fn length_encoder_reset( while bt_i < ((1) << 3) as u32 { (*lencoder).low[pos_state as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i = bt_i.wrapping_add(1); + bt_i += 1; } let mut bt_i_0: u32 = 0; while bt_i_0 < ((1) << 3) as u32 { (*lencoder).mid[pos_state as usize][bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_0 = bt_i_0.wrapping_add(1); + bt_i_0 += 1; } - pos_state = pos_state.wrapping_add(1); + pos_state += 1; } let mut bt_i_1: u32 = 0; while bt_i_1 < ((1) << 8) as u32 { (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_1 = bt_i_1.wrapping_add(1); + bt_i_1 += 1; } if !fast_mode { let mut pos_state_0: u32 = 0; while pos_state_0 < num_pos_states { length_update_prices(lencoder, pos_state_0); - pos_state_0 = pos_state_0.wrapping_add(1); + pos_state_0 += 1; } } } @@ -1077,14 +1077,13 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( } (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; (*coder).literal_context_bits = (*options).lc; - (*coder).literal_mask = - (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); + (*coder).literal_mask = (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); rc_reset(&raw mut (*coder).rc); (*coder).state = STATE_LIT_LIT; let mut i: size_t = 0; while i < REPS as size_t { (*coder).reps[i as usize] = 0; - i = i.wrapping_add(1); + i += 1; } literal_init( &raw mut (*coder).literal as *mut probability, @@ -1098,18 +1097,18 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( (*coder).is_match[i_0 as usize][j as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep0_long[i_0 as usize][j as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - j = j.wrapping_add(1); + j += 1; } (*coder).is_rep[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep0[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep1[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).is_rep2[i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - i_0 = i_0.wrapping_add(1); + i_0 += 1; } let mut i_1: size_t = 0; while i_1 < (FULL_DISTANCES - DIST_MODEL_END) as size_t { (*coder).dist_special[i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - i_1 = i_1.wrapping_add(1); + i_1 += 1; } let mut i_2: size_t = 0; while i_2 < DIST_STATES as size_t { @@ -1117,14 +1116,14 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( while bt_i < ((1) << 6) as u32 { (*coder).dist_slot[i_2 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i = bt_i.wrapping_add(1); + bt_i += 1; } - i_2 = i_2.wrapping_add(1); + i_2 += 1; } let mut bt_i_0: u32 = 0; while bt_i_0 < ((1) << 4) as u32 { (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; - bt_i_0 = bt_i_0.wrapping_add(1); + bt_i_0 += 1; } length_encoder_reset( &raw mut (*coder).match_len_encoder, @@ -1168,7 +1167,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( } let mut log_size: u32 = 0; while (1) << log_size < (*options).dict_size { - log_size = log_size.wrapping_add(1); + log_size += 1; } (*coder).dist_table_size = log_size.wrapping_mul(2); let nice_len: u32 = if mf_get_hash_bytes((*options).mf) > (*options).nice_len { @@ -1176,12 +1175,10 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( } else { (*options).nice_len }; - (*coder).match_len_encoder.table_size = nice_len - .wrapping_add(1u32) - .wrapping_sub(MATCH_LEN_MIN as u32); - (*coder).rep_len_encoder.table_size = nice_len - .wrapping_add(1u32) - .wrapping_sub(MATCH_LEN_MIN as u32); + (*coder).match_len_encoder.table_size = + nice_len.wrapping_add(1u32).wrapping_sub(MATCH_LEN_MIN); + (*coder).rep_len_encoder.table_size = + nice_len.wrapping_add(1u32).wrapping_sub(MATCH_LEN_MIN); } _ => return LZMA_OPTIONS_ERROR, } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 766ae556..e197939f 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; } @@ -63,7 +63,7 @@ pub struct lzma_lzma1_encoder_s { pub opts_current_index: u32, pub opts: [lzma_optimal; OPTS as usize], } -pub const OPTS: c_int = (1) << 12; +pub const OPTS: u32 = (1) << 12; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { @@ -105,7 +105,7 @@ unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const REPS: c_int = 4; +pub const REPS: u32 = 4; #[inline(always)] unsafe extern "C" fn lzma_memcmplen( buf1: *const u8, @@ -114,7 +114,7 @@ unsafe extern "C" fn lzma_memcmplen( limit: u32, ) -> u32 { while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { - len = len.wrapping_add(1); + len += 1; } return len; } @@ -153,7 +153,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( let mut rep_len: u32 = 0; let mut rep_index: u32 = 0; let mut i: u32 = 0; - while i < REPS as u32 { + while i < REPS { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); if !(*buf.offset(0) != *buf_back.offset(0) || *buf.offset(1) != *buf_back.offset(1)) { let len: u32 = lzma_memcmplen(buf, buf_back, 2, buf_avail) as u32; @@ -168,12 +168,12 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( rep_len = len; } } - i = i.wrapping_add(1); + i += 1; } if len_main >= nice_len { *back_res = (*coder).matches[matches_count.wrapping_sub(1) as usize] .dist - .wrapping_add(REPS as u32); + .wrapping_add(REPS); *len_res = len_main; mf_skip(mf, len_main.wrapping_sub(1)); return; @@ -190,7 +190,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( if !(back_main >> 7 > (*coder).matches[matches_count.wrapping_sub(2) as usize].dist) { break; } - matches_count = matches_count.wrapping_sub(1); + matches_count -= 1; len_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].len; back_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].dist; } @@ -241,7 +241,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( len_main.wrapping_sub(1) }; let mut i_0: u32 = 0; - while i_0 < REPS as u32 { + while i_0 < REPS { if memcmp( buf as *const c_void, buf.offset(-((*coder).reps[i_0 as usize] as isize)) @@ -253,9 +253,9 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( *len_res = 1; return; } - i_0 = i_0.wrapping_add(1); + i_0 += 1; } - *back_res = back_main.wrapping_add(REPS as u32); + *back_res = back_main.wrapping_add(REPS); *len_res = len_main; mf_skip(mf, len_main.wrapping_sub(2)); } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 7be6a9dd..9a25ae5b 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; static lzma_rc_prices: [u8; 128]; @@ -65,7 +65,7 @@ pub struct lzma_lzma1_encoder_s { pub opts_current_index: u32, pub opts: [lzma_optimal; OPTS as usize], } -pub const OPTS: c_int = (1) << 12; +pub const OPTS: u32 = (1) << 12; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { @@ -107,10 +107,10 @@ unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } -pub const RC_BIT_MODEL_TOTAL_BITS: c_int = 11; +pub const RC_BIT_MODEL_TOTAL_BITS: u32 = 11; pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_REDUCING_BITS: c_int = 4; -pub const RC_BIT_PRICE_SHIFT_BITS: c_int = 4; +pub const RC_MOVE_REDUCING_BITS: u32 = 4; +pub const RC_BIT_PRICE_SHIFT_BITS: u32 = 4; pub const RC_INFINITY_PRICE: c_uint = 1u32 << 30; #[inline] extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { @@ -163,7 +163,7 @@ unsafe extern "C" fn rc_bittree_reverse_price( symbol >>= 1; price = price.wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); model_index = (model_index << 1).wrapping_add(bit); - bit_levels = bit_levels.wrapping_sub(1); + bit_levels -= 1; if !(bit_levels != 0) { break; } @@ -174,19 +174,19 @@ unsafe extern "C" fn rc_bittree_reverse_price( extern "C" fn rc_direct_price(bits: u32) -> u32 { return bits << RC_BIT_PRICE_SHIFT_BITS; } -pub const LIT_STATES: c_int = 7; -pub const MATCH_LEN_MIN: c_int = 2; -pub const DIST_STATES: c_int = 4; -pub const DIST_SLOT_BITS: c_int = 6; -pub const DIST_MODEL_START: c_int = 4; -pub const DIST_MODEL_END: c_int = 14; -pub const FULL_DISTANCES_BITS: c_int = DIST_MODEL_END / 2; -pub const FULL_DISTANCES: c_int = (1) << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: c_int = 4; -pub const ALIGN_SIZE: c_int = (1) << ALIGN_BITS; -pub const ALIGN_MASK: c_int = ALIGN_SIZE - 1; -pub const REPS: c_int = 4; -pub const FASTPOS_BITS: c_int = 13; +pub const LIT_STATES: u32 = 7; +pub const MATCH_LEN_MIN: u32 = 2; +pub const DIST_STATES: u32 = 4; +pub const DIST_SLOT_BITS: u32 = 6; +pub const DIST_MODEL_START: u32 = 4; +pub const DIST_MODEL_END: u32 = 14; +pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; +pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; +pub const ALIGN_BITS: u32 = 4; +pub const ALIGN_SIZE: u32 = (1) << ALIGN_BITS; +pub const ALIGN_MASK: u32 = ALIGN_SIZE - 1; +pub const REPS: u32 = 4; +pub const FASTPOS_BITS: u32 = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { @@ -220,7 +220,7 @@ unsafe extern "C" fn lzma_memcmplen( limit: u32, ) -> u32 { while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { - len = len.wrapping_add(1); + len += 1; } return len; } @@ -262,7 +262,7 @@ unsafe extern "C" fn get_literal_price( #[inline] extern "C" fn get_len_price(lencoder: *const lzma_length_encoder, len: u32, pos_state: u32) -> u32 { return unsafe { - (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN as u32) as usize] + (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN) as usize] }; } #[inline] @@ -328,17 +328,17 @@ extern "C" fn get_dist_len_price( ) -> u32 { return unsafe { let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN as u32) + len.wrapping_sub(MATCH_LEN_MIN) } else { (DIST_STATES - 1) as u32 }; let mut price: u32 = 0; - if dist < FULL_DISTANCES as u32 { + if dist < FULL_DISTANCES { price = (*coder).dist_prices[dist_state as usize][dist as usize]; } else { let dist_slot: u32 = get_dist_slot_2(dist) as u32; price = (*coder).dist_slot_prices[dist_state as usize][dist_slot as usize] - .wrapping_add((*coder).align_prices[(dist & ALIGN_MASK as u32) as usize]); + .wrapping_add((*coder).align_prices[(dist & ALIGN_MASK) as usize]); } price = price.wrapping_add(get_len_price( &raw const (*coder).match_len_encoder, @@ -350,7 +350,7 @@ extern "C" fn get_dist_len_price( } unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { let mut dist_state: u32 = 0; - while dist_state < DIST_STATES as u32 { + while dist_state < DIST_STATES { let dist_slot_prices: *mut u32 = &raw mut *(&raw mut (*coder).dist_slot_prices as *mut [u32; 64]) .offset(dist_state as isize) as *mut u32; @@ -359,31 +359,29 @@ unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { *dist_slot_prices.offset(dist_slot as isize) = rc_bittree_price( &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) .offset(dist_state as isize) as *mut probability, - DIST_SLOT_BITS as u32, + DIST_SLOT_BITS, dist_slot, ); - dist_slot = dist_slot.wrapping_add(1); + dist_slot += 1; } - let mut dist_slot_0: u32 = DIST_MODEL_END as u32; + let mut dist_slot_0: u32 = DIST_MODEL_END; while dist_slot_0 < (*coder).dist_table_size { - let ref mut fresh1 = *dist_slot_prices.offset(dist_slot_0 as isize); - *fresh1 = (*fresh1).wrapping_add(rc_direct_price( - (dist_slot_0 >> 1) - .wrapping_sub(1) - .wrapping_sub(ALIGN_BITS as u32), - )); - dist_slot_0 = dist_slot_0.wrapping_add(1); + *dist_slot_prices.offset(dist_slot_0 as isize) = + (*dist_slot_prices.offset(dist_slot_0 as isize)).wrapping_add(rc_direct_price( + (dist_slot_0 >> 1).wrapping_sub(1).wrapping_sub(ALIGN_BITS), + )); + dist_slot_0 += 1; } let mut i: u32 = 0; - while i < DIST_MODEL_START as u32 { + while i < DIST_MODEL_START { (*coder).dist_prices[dist_state as usize][i as usize] = *dist_slot_prices.offset(i as isize); - i = i.wrapping_add(1); + i += 1; } - dist_state = dist_state.wrapping_add(1); + dist_state += 1; } - let mut i_0: u32 = DIST_MODEL_START as u32; - while i_0 < FULL_DISTANCES as u32 { + let mut i_0: u32 = DIST_MODEL_START; + while i_0 < FULL_DISTANCES { let dist_slot_1: u32 = get_dist_slot(i_0) as u32; let footer_bits: u32 = (dist_slot_1 >> 1).wrapping_sub(1); let base: u32 = (2 | dist_slot_1 & 1) << footer_bits; @@ -396,25 +394,25 @@ unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { i_0.wrapping_sub(base), ) as u32; let mut dist_state_0: u32 = 0; - while dist_state_0 < DIST_STATES as u32 { + while dist_state_0 < DIST_STATES { (*coder).dist_prices[dist_state_0 as usize][i_0 as usize] = price.wrapping_add( (*coder).dist_slot_prices[dist_state_0 as usize][dist_slot_1 as usize], ); - dist_state_0 = dist_state_0.wrapping_add(1); + dist_state_0 += 1; } - i_0 = i_0.wrapping_add(1); + i_0 += 1; } (*coder).match_price_count = 0; } unsafe extern "C" fn fill_align_prices(coder: *mut lzma_lzma1_encoder) { let mut i: u32 = 0; - while i < ALIGN_SIZE as u32 { + while i < ALIGN_SIZE { (*coder).align_prices[i as usize] = rc_bittree_reverse_price( &raw mut (*coder).dist_align as *mut probability, - ALIGN_BITS as u32, + ALIGN_BITS, i, ); - i = i.wrapping_add(1); + i += 1; } (*coder).align_price_count = 0; } @@ -503,7 +501,7 @@ unsafe extern "C" fn helper1( let mut rep_lens: [u32; 4] = [0; 4]; let mut rep_max_index: u32 = 0; let mut i: u32 = 0; - while i < REPS as u32 { + while i < REPS { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); if *buf.offset(0) != *buf_back.offset(0) || *buf.offset(1) != *buf_back.offset(1) { rep_lens[i as usize] = 0; @@ -513,7 +511,7 @@ unsafe extern "C" fn helper1( rep_max_index = i; } } - i = i.wrapping_add(1); + i += 1; } if rep_lens[rep_max_index as usize] >= nice_len { *back_res = rep_max_index; @@ -524,7 +522,7 @@ unsafe extern "C" fn helper1( if len_main >= nice_len { *back_res = (*coder).matches[matches_count.wrapping_sub(1) as usize] .dist - .wrapping_add(REPS as u32); + .wrapping_add(REPS); *len_res = len_main; mf_skip(mf, len_main.wrapping_sub(1)); return UINT32_MAX; @@ -544,7 +542,7 @@ unsafe extern "C" fn helper1( coder, position, *buf.offset(-(1) as isize) as u32, - !(((*coder).state as u32) < LIT_STATES as u32), + !(((*coder).state as u32) < LIT_STATES), match_byte as u32, current_byte as u32, )); @@ -576,20 +574,20 @@ unsafe extern "C" fn helper1( } (*coder).opts[1].pos_prev = 0; let mut i_0: u32 = 0; - while i_0 < REPS as u32 { + while i_0 < REPS { (*coder).opts[0].backs[i_0 as usize] = (*coder).reps[i_0 as usize]; - i_0 = i_0.wrapping_add(1); + i_0 += 1; } let mut len: u32 = len_end; loop { (*coder).opts[len as usize].price = RC_INFINITY_PRICE as u32; - len = len.wrapping_sub(1); + len -= 1; if !(len >= 2) { break; } } let mut i_1: u32 = 0; - while i_1 < REPS as u32 { + while i_1 < REPS { let mut rep_len: u32 = rep_lens[i_1 as usize]; if !(rep_len < 2) { let price: u32 = rep_match_price.wrapping_add(get_pure_rep_price( @@ -610,13 +608,13 @@ unsafe extern "C" fn helper1( (*coder).opts[rep_len as usize].back_prev = i_1; (*coder).opts[rep_len as usize].prev_1_is_literal = false; } - rep_len = rep_len.wrapping_sub(1); + rep_len -= 1; if !(rep_len >= 2) { break; } } } - i_1 = i_1.wrapping_add(1); + i_1 += 1; } let normal_match_price: u32 = match_price.wrapping_add(rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as u32); @@ -628,7 +626,7 @@ unsafe extern "C" fn helper1( if len <= len_main { let mut i_2: u32 = 0; while len > (*coder).matches[i_2 as usize].len { - i_2 = i_2.wrapping_add(1); + i_2 += 1; } loop { let dist: u32 = (*coder).matches[i_2 as usize].dist; @@ -637,16 +635,16 @@ unsafe extern "C" fn helper1( if cur_and_len_price_0 < (*coder).opts[len as usize].price { (*coder).opts[len as usize].price = cur_and_len_price_0; (*coder).opts[len as usize].pos_prev = 0; - (*coder).opts[len as usize].back_prev = dist.wrapping_add(REPS as u32); + (*coder).opts[len as usize].back_prev = dist.wrapping_add(REPS); (*coder).opts[len as usize].prev_1_is_literal = false; } if len == (*coder).matches[i_2 as usize].len { - i_2 = i_2.wrapping_add(1); + i_2 += 1; if i_2 == matches_count { break; } } - len = len.wrapping_add(1); + len += 1; } } return len_end; @@ -667,17 +665,17 @@ unsafe extern "C" fn helper2( let mut pos_prev: u32 = (*coder).opts[cur as usize].pos_prev; let mut state: lzma_lzma_state = STATE_LIT_LIT; if (*coder).opts[cur as usize].prev_1_is_literal { - pos_prev = pos_prev.wrapping_sub(1); + pos_prev -= 1; if (*coder).opts[cur as usize].prev_2 { state = (*coder).opts[(*coder).opts[cur as usize].pos_prev_2 as usize].state; - if (*coder).opts[cur as usize].back_prev_2 < REPS as u32 { - state = (if (state as u32) < LIT_STATES as u32 { + if (*coder).opts[cur as usize].back_prev_2 < REPS { + state = (if (state as u32) < LIT_STATES { STATE_LIT_LONGREP } else { STATE_NONLIT_REP }) as lzma_lzma_state; } else { - state = (if (state as u32) < LIT_STATES as u32 { + state = (if (state as u32) < LIT_STATES { STATE_LIT_MATCH } else { STATE_NONLIT_MATCH @@ -698,7 +696,7 @@ unsafe extern "C" fn helper2( } if pos_prev == cur.wrapping_sub(1) { if (*coder).opts[cur as usize].back_prev == 0 { - state = (if (state as u32) < LIT_STATES as u32 { + state = (if (state as u32) < LIT_STATES { STATE_LIT_SHORTREP } else { STATE_NONLIT_REP @@ -717,55 +715,55 @@ unsafe extern "C" fn helper2( if (*coder).opts[cur as usize].prev_1_is_literal && (*coder).opts[cur as usize].prev_2 { pos_prev = (*coder).opts[cur as usize].pos_prev_2; pos = (*coder).opts[cur as usize].back_prev_2; - state = (if (state as u32) < LIT_STATES as u32 { + state = (if (state as u32) < LIT_STATES { STATE_LIT_LONGREP } else { STATE_NONLIT_REP }) as lzma_lzma_state; } else { pos = (*coder).opts[cur as usize].back_prev; - if pos < REPS as u32 { - state = (if (state as u32) < LIT_STATES as u32 { + if pos < REPS { + state = (if (state as u32) < LIT_STATES { STATE_LIT_LONGREP } else { STATE_NONLIT_REP }) as lzma_lzma_state; } else { - state = (if (state as u32) < LIT_STATES as u32 { + state = (if (state as u32) < LIT_STATES { STATE_LIT_MATCH } else { STATE_NONLIT_MATCH }) as lzma_lzma_state; } } - if pos < REPS as u32 { + if pos < REPS { *reps.offset(0) = (*coder).opts[pos_prev as usize].backs[pos as usize]; let mut i: u32 = 0; i = 1; while i <= pos { *reps.offset(i as isize) = (*coder).opts[pos_prev as usize].backs[i.wrapping_sub(1) as usize]; - i = i.wrapping_add(1); + i += 1; } - while i < REPS as u32 { + while i < REPS { *reps.offset(i as isize) = (*coder).opts[pos_prev as usize].backs[i as usize]; - i = i.wrapping_add(1); + i += 1; } } else { - *reps.offset(0) = pos.wrapping_sub(REPS as u32); + *reps.offset(0) = pos.wrapping_sub(REPS); let mut i_0: u32 = 1; - while i_0 < REPS as u32 { + while i_0 < REPS { *reps.offset(i_0 as isize) = (*coder).opts[pos_prev as usize].backs[i_0.wrapping_sub(1) as usize]; - i_0 = i_0.wrapping_add(1); + i_0 += 1; } } } (*coder).opts[cur as usize].state = state; let mut i_1: u32 = 0; - while i_1 < REPS as u32 { + while i_1 < REPS { (*coder).opts[cur as usize].backs[i_1 as usize] = *reps.offset(i_1 as isize); - i_1 = i_1.wrapping_add(1); + i_1 += 1; } let cur_price: u32 = (*coder).opts[cur as usize].price; let current_byte: u8 = *buf; @@ -777,7 +775,7 @@ unsafe extern "C" fn helper2( coder, position, *buf.offset(-(1) as isize) as u32, - !((state as u32) < LIT_STATES as u32), + !((state as u32) < LIT_STATES), match_byte as u32, current_byte as u32, ) as u32); @@ -844,7 +842,7 @@ unsafe extern "C" fn helper2( .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2 as usize]) as u32); let offset: u32 = cur.wrapping_add(1u32).wrapping_add(len_test); while len_end < offset { - len_end = len_end.wrapping_add(1); + len_end += 1; (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } let cur_and_len_price: u32 = next_rep_match_price.wrapping_add(get_rep_price( @@ -865,14 +863,14 @@ unsafe extern "C" fn helper2( } let mut start_len: u32 = 2; let mut rep_index: u32 = 0; - while rep_index < REPS as u32 { + while rep_index < REPS { let buf_back_0: *const u8 = buf .offset(-(*reps.offset(rep_index as isize) as isize)) .offset(-1); if !(*buf.offset(0) != *buf_back_0.offset(0) || *buf.offset(1) != *buf_back_0.offset(1)) { let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2, buf_avail); while len_end < cur.wrapping_add(len_test_0) { - len_end = len_end.wrapping_add(1); + len_end += 1; (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } let len_test_temp: u32 = len_test_0; @@ -892,7 +890,7 @@ unsafe extern "C" fn helper2( (*coder).opts[cur.wrapping_add(len_test_0) as usize].back_prev = rep_index; (*coder).opts[cur.wrapping_add(len_test_0) as usize].prev_1_is_literal = false; } - len_test_0 = len_test_0.wrapping_sub(1); + len_test_0 -= 1; if !(len_test_0 >= 2) { break; } @@ -913,7 +911,7 @@ unsafe extern "C" fn helper2( len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1)); if len_test_2 >= 2 { let mut state_2_0: lzma_lzma_state = state; - state_2_0 = (if (state_2_0 as u32) < LIT_STATES as u32 { + state_2_0 = (if (state_2_0 as u32) < LIT_STATES { STATE_LIT_LONGREP } else { STATE_NONLIT_REP @@ -956,7 +954,7 @@ unsafe extern "C" fn helper2( .wrapping_add(1) .wrapping_add(len_test_2); while len_end < offset_0 { - len_end = len_end.wrapping_add(1); + len_end += 1; (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } let cur_and_len_price_1: u32 = next_rep_match_price_0.wrapping_add(get_rep_price( @@ -979,28 +977,28 @@ unsafe extern "C" fn helper2( } } } - rep_index = rep_index.wrapping_add(1); + rep_index += 1; } if new_len > buf_avail { new_len = buf_avail; matches_count = 0; while new_len > (*coder).matches[matches_count as usize].len { - matches_count = matches_count.wrapping_add(1); + matches_count += 1; } let fresh0 = matches_count; - matches_count = matches_count.wrapping_add(1); + matches_count += 1; (*coder).matches[fresh0 as usize].len = new_len; } if new_len >= start_len { let normal_match_price: u32 = match_price.wrapping_add(rc_bit_0_price((*coder).is_rep[state as usize]) as u32); while len_end < cur.wrapping_add(new_len) { - len_end = len_end.wrapping_add(1); + len_end += 1; (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } let mut i_2: u32 = 0; while start_len > (*coder).matches[i_2 as usize].len { - i_2 = i_2.wrapping_add(1); + i_2 += 1; } let mut len_test_1: u32 = start_len; loop { @@ -1011,7 +1009,7 @@ unsafe extern "C" fn helper2( (*coder).opts[cur.wrapping_add(len_test_1) as usize].price = cur_and_len_price_2; (*coder).opts[cur.wrapping_add(len_test_1) as usize].pos_prev = cur; (*coder).opts[cur.wrapping_add(len_test_1) as usize].back_prev = - cur_back.wrapping_add(REPS as u32); + cur_back.wrapping_add(REPS); (*coder).opts[cur.wrapping_add(len_test_1) as usize].prev_1_is_literal = false; } if len_test_1 == (*coder).matches[i_2 as usize].len { @@ -1028,7 +1026,7 @@ unsafe extern "C" fn helper2( len_test_2_0 = len_test_2_0.wrapping_sub(len_test_1.wrapping_add(1)); if len_test_2_0 >= 2 { let mut state_2_1: lzma_lzma_state = state; - state_2_1 = (if (state_2_1 as u32) < LIT_STATES as u32 { + state_2_1 = (if (state_2_1 as u32) < LIT_STATES { STATE_LIT_MATCH } else { STATE_NONLIT_MATCH @@ -1065,7 +1063,7 @@ unsafe extern "C" fn helper2( .wrapping_add(1) .wrapping_add(len_test_2_0); while len_end < offset_1 { - len_end = len_end.wrapping_add(1); + len_end += 1; (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; } cur_and_len_price_2 = next_rep_match_price_1.wrapping_add(get_rep_price( @@ -1083,16 +1081,15 @@ unsafe extern "C" fn helper2( (*coder).opts[offset_1 as usize].prev_1_is_literal = true; (*coder).opts[offset_1 as usize].prev_2 = true; (*coder).opts[offset_1 as usize].pos_prev_2 = cur; - (*coder).opts[offset_1 as usize].back_prev_2 = - cur_back.wrapping_add(REPS as u32); + (*coder).opts[offset_1 as usize].back_prev_2 = cur_back.wrapping_add(REPS); } } - i_2 = i_2.wrapping_add(1); + i_2 += 1; if i_2 == matches_count { break; } } - len_test_1 = len_test_1.wrapping_add(1); + len_test_1 += 1; } } return len_end; @@ -1117,7 +1114,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( if (*coder).match_price_count >= ((1) << 7) as u32 { fill_dist_prices(coder); } - if (*coder).align_price_count >= ALIGN_SIZE as u32 { + if (*coder).align_price_count >= ALIGN_SIZE { fill_align_prices(coder); } } @@ -1156,7 +1153,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( ((((1) << 12) - 1) as u32).wrapping_sub(cur) }, ); - cur = cur.wrapping_add(1); + cur += 1; } backward(coder, len_res, back_res, cur); } diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index b61651e3..c2c56b6d 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -1,8 +1,8 @@ use crate::types::*; -use core::ffi::{c_int, c_uint}; -pub const LZMA_LC_DEFAULT: c_int = 3; -pub const LZMA_LP_DEFAULT: c_int = 0; -pub const LZMA_PB_DEFAULT: c_int = 2; +use core::ffi::c_uint; +pub const LZMA_LC_DEFAULT: u32 = 3; +pub const LZMA_LP_DEFAULT: u32 = 0; +pub const LZMA_PB_DEFAULT: u32 = 2; pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f; pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; #[no_mangle] @@ -18,9 +18,9 @@ pub unsafe extern "C" fn lzma_lzma_preset( } (*options).preset_dict = ::core::ptr::null::(); (*options).preset_dict_size = 0; - (*options).lc = LZMA_LC_DEFAULT as u32; - (*options).lp = LZMA_LP_DEFAULT as u32; - (*options).pb = LZMA_PB_DEFAULT as u32; + (*options).lc = LZMA_LC_DEFAULT; + (*options).lp = LZMA_LP_DEFAULT; + (*options).pb = LZMA_PB_DEFAULT; static mut dict_pow2: [u8; 10] = [18, 20, 21, 22, 22, 23, 23, 24, 25, 26]; (*options).dict_size = 1u32 << dict_pow2[level as usize]; if level <= 3 { diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index b04c1563..a25022a3 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -64,8 +64,7 @@ unsafe extern "C" fn arm64_code( let dest: u32 = src_0.wrapping_add(pc); instr |= (dest & 3) << 29; instr |= (dest & 0x3fffc) << 3; - instr = - (instr | (0u32.wrapping_sub(dest & 0x20000) & 0xe00000)) as u32; + instr = (instr | (0u32.wrapping_sub(dest & 0x20000) & 0xe00000)) as u32; write32le(buffer.offset(i as isize), instr); } } diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index ae982320..57cd4d6d 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -44,11 +44,9 @@ unsafe extern "C" fn armthumb_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(4)); } dest >>= 1; - *buffer.offset(i.wrapping_add(1) as isize) = - (0xf0 | dest >> 19 & 0x7) as u8; + *buffer.offset(i.wrapping_add(1) as isize) = (0xf0 | dest >> 19 & 0x7) as u8; *buffer.offset(i as isize) = (dest >> 11) as u8; - *buffer.offset(i.wrapping_add(3) as isize) = - (0xf8 | dest >> 8 & 0x7) as u8; + *buffer.offset(i.wrapping_add(3) as isize) = (0xf8 | dest >> 8 & 0x7) as u8; *buffer.offset(i.wrapping_add(2) as isize) = dest as u8; i = i.wrapping_add(2); } diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 7d3353a3..0ac8a1d7 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -42,7 +42,7 @@ unsafe extern "C" fn ia64_code( (*buffer.offset(i.wrapping_add(j).wrapping_add(byte_pos) as isize) as u64) << (8_usize).wrapping_mul(j), ); - j = j.wrapping_add(1); + j += 1; } let mut inst_norm: u64 = instruction >> bit_res; if inst_norm >> 37 & 0xf as u64 == 0x5 as u64 && inst_norm >> 9 & 0x7 as u64 == 0 { @@ -65,11 +65,11 @@ unsafe extern "C" fn ia64_code( while j_0 < 6 { *buffer.offset(i.wrapping_add(j_0).wrapping_add(byte_pos) as isize) = (instruction >> (8_usize).wrapping_mul(j_0)) as u8; - j_0 = j_0.wrapping_add(1); + j_0 += 1; } } } - slot = slot.wrapping_add(1); + slot += 1; bit_pos = bit_pos.wrapping_add(41); } i = i.wrapping_add(16); diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index 3f6929be..5995c570 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -36,14 +36,12 @@ unsafe extern "C" fn powerpc_code( } else { dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } - *buffer.offset(i as isize) = - (0x48 | dest >> 24 & 0x3) as u8; + *buffer.offset(i as isize) = (0x48 | dest >> 24 & 0x3) as u8; *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 16) as u8; *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 8) as u8; - let ref mut fresh0 = *buffer.offset(i.wrapping_add(3) as isize); - *fresh0 = (*fresh0 & 0x3) as u8; - let ref mut fresh1 = *buffer.offset(i.wrapping_add(3) as isize); - *fresh1 = (*fresh1 as u32 | dest) as u8; + *buffer.offset(i.wrapping_add(3) as isize) &= 0x3; + *buffer.offset(i.wrapping_add(3) as isize) = + (*buffer.offset(i.wrapping_add(3) as isize) as u32 | dest) as u8; } i = i.wrapping_add(4); } diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 8dd91a4d..c2504c1d 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -79,8 +79,7 @@ unsafe extern "C" fn riscv_encode( | (b3 & 0x7f) << 4 | (b3 & 0x80) << 13; addr = addr.wrapping_add(pc); - *buffer.offset(i.wrapping_add(1) as isize) = - (b1 & 0xf | addr >> 13 & 0xf0) as u8; + *buffer.offset(i.wrapping_add(1) as isize) = (b1 & 0xf | addr >> 13 & 0xf0) as u8; *buffer.offset(i.wrapping_add(2) as isize) = (addr >> 9) as u8; *buffer.offset(i.wrapping_add(3) as isize) = (addr >> 1) as u8; i = i.wrapping_add((4 - 2) as size_t); @@ -96,8 +95,7 @@ unsafe extern "C" fn riscv_encode( current_block_22 = 12517898123489920830; } else { let mut addr_0: u32 = inst & 0xfffff000; - addr_0 = addr_0 - .wrapping_add((inst2 >> 20).wrapping_sub(inst2 >> 19 & 0x1000)); + addr_0 = addr_0.wrapping_add((inst2 >> 20).wrapping_sub(inst2 >> 19 & 0x1000)); addr_0 = addr_0.wrapping_add(now_pos.wrapping_add(i as u32)); inst = (0x17 | (2) << 7) as u32 | inst2 << 12; write32le(buffer.offset(i as isize), inst); @@ -181,11 +179,9 @@ unsafe extern "C" fn riscv_decode( let pc: u32 = now_pos.wrapping_add(i as u32); let mut addr: u32 = (b1 & 0xf0) << 13 | b2 << 9 | b3 << 1; addr = addr.wrapping_sub(pc); - *buffer.offset(i.wrapping_add(1) as isize) = - (b1 & 0xf | addr >> 8 & 0xf0) as u8; + *buffer.offset(i.wrapping_add(1) as isize) = (b1 & 0xf | addr >> 8 & 0xf0) as u8; *buffer.offset(i.wrapping_add(2) as isize) = - (addr >> 16 & 0xf | addr >> 7 & 0x10 | addr << 4 & 0xe0) - as u8; + (addr >> 16 & 0xf | addr >> 7 & 0x10 | addr << 4 & 0xe0) as u8; *buffer.offset(i.wrapping_add(3) as isize) = (addr >> 4 & 0x7f | addr >> 13 & 0x80) as u8; i = i.wrapping_add((4 - 2) as size_t); @@ -216,9 +212,7 @@ unsafe extern "C" fn riscv_decode( let mut addr_1: u32 = read32be(buffer.offset(i as isize).offset(4)); addr_1 = addr_1.wrapping_sub(now_pos.wrapping_add(i as u32)); inst2 = inst >> 12 | addr_1 << 20; - inst = 0x17 - | inst2_rs1 << 7 - | addr_1.wrapping_add(0x800) & 0xfffff000; + inst = 0x17 | inst2_rs1 << 7 | addr_1.wrapping_add(0x800) & 0xfffff000; current_block_23 = 6669252993407410313; } } diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index 3d2c88c9..59f235a4 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -40,9 +40,8 @@ unsafe extern "C" fn sparc_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } dest >>= 2; - dest = 0u32.wrapping_sub(dest >> 22 & 1) << 22 & 0x3fffffff - | dest & 0x3fffff - | 0x40000000; + dest = + 0u32.wrapping_sub(dest >> 22 & 1) << 22 & 0x3fffffff | dest & 0x3fffff | 0x40000000; *buffer.offset(i as isize) = (dest >> 24) as u8; *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 16) as u8; *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 8) as u8; diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index 77893b31..25b5dc72 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -40,7 +40,7 @@ unsafe extern "C" fn x86_code( while buffer_pos <= limit { let mut b: u8 = *buffer.offset(buffer_pos as isize); if b != 0xe8 && b != 0xe9 { - buffer_pos = buffer_pos.wrapping_add(1); + buffer_pos += 1; } else { let offset: u32 = now_pos .wrapping_add(buffer_pos as u32) @@ -53,7 +53,7 @@ unsafe extern "C" fn x86_code( while i < offset { prev_mask &= 0x77; prev_mask <<= 1; - i = i.wrapping_add(1); + i += 1; } } b = *buffer.offset(buffer_pos.wrapping_add(4) as isize); @@ -90,7 +90,7 @@ unsafe extern "C" fn x86_code( buffer_pos = buffer_pos.wrapping_add(5); prev_mask = 0; } else { - buffer_pos = buffer_pos.wrapping_add(1); + buffer_pos += 1; prev_mask |= 1; if b == 0 || b == 0xff { prev_mask |= 0x10; diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 8390f27c..b11d9c8e 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -247,8 +247,8 @@ pub const LZMA_IGNORE_CHECK: c_uint = 0x10; pub const LZMA_FAIL_FAST: c_uint = 0x20; // Stream/block size constants -pub const LZMA_STREAM_HEADER_SIZE: c_int = 12; -pub const LZMA_BLOCK_HEADER_SIZE_MAX: c_int = 1024; +pub const LZMA_STREAM_HEADER_SIZE: u32 = 12; +pub const LZMA_BLOCK_HEADER_SIZE_MAX: u32 = 1024; pub const LZMA_MEMUSAGE_BASE: u64 = 1 << 15; pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; @@ -267,20 +267,20 @@ pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; pub const STATE_NONLIT_REP: lzma_lzma_state = 11; // VLI encoding constants -pub const LZMA_VLI_BYTES_MAX: c_int = 9; +pub const LZMA_VLI_BYTES_MAX: u32 = 9; // Filter chain limit -pub const LZMA_FILTERS_MAX: c_int = 4; +pub const LZMA_FILTERS_MAX: u32 = 4; // LZMA option limits -pub const LZMA_LCLP_MAX: c_int = 4; -pub const LZMA_PB_MAX: c_int = 4; +pub const LZMA_LCLP_MAX: u32 = 4; +pub const LZMA_PB_MAX: u32 = 4; // Delta filter -pub const LZMA_DELTA_DIST_MAX: c_int = 256; +pub const LZMA_DELTA_DIST_MAX: u32 = 256; // Stream flags -pub const LZMA_BACKWARD_SIZE_MIN: c_int = 4; +pub const LZMA_BACKWARD_SIZE_MIN: u32 = 4; pub const LZMA_BACKWARD_SIZE_MAX: u64 = 1 << 34; // Decoder supported flags From ce149f7b8402a6dee4776632b0293446ace2421a Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 1 Mar 2026 21:51:54 +0900 Subject: [PATCH 09/51] simplify c2rust syntax: returns, casts, negations, pointer ops, memcpy --- liblzma-rs/src/check/check.rs | 4 +- liblzma-rs/src/check/crc32_fast.rs | 16 +- liblzma-rs/src/check/crc64_fast.rs | 16 +- liblzma-rs/src/check/sha256.rs | 38 +- liblzma-rs/src/common/alone_decoder.rs | 28 +- liblzma-rs/src/common/alone_encoder.rs | 26 +- liblzma-rs/src/common/auto_decoder.rs | 33 +- liblzma-rs/src/common/block_buffer_decoder.rs | 4 +- liblzma-rs/src/common/block_buffer_encoder.rs | 73 ++- liblzma-rs/src/common/block_decoder.rs | 28 +- liblzma-rs/src/common/block_encoder.rs | 47 +- liblzma-rs/src/common/block_header_decoder.rs | 11 +- liblzma-rs/src/common/block_header_encoder.rs | 21 +- liblzma-rs/src/common/block_util.rs | 8 +- liblzma-rs/src/common/common.rs | 93 ++-- liblzma-rs/src/common/easy_buffer_encoder.rs | 10 +- .../src/common/easy_decoder_memusage.rs | 8 +- liblzma-rs/src/common/easy_encoder.rs | 8 +- .../src/common/easy_encoder_memusage.rs | 8 +- liblzma-rs/src/common/easy_preset.rs | 2 +- liblzma-rs/src/common/file_info.rs | 49 +-- .../src/common/filter_buffer_decoder.rs | 6 +- .../src/common/filter_buffer_encoder.rs | 4 +- liblzma-rs/src/common/filter_common.rs | 42 +- liblzma-rs/src/common/filter_decoder.rs | 27 +- liblzma-rs/src/common/filter_encoder.rs | 41 +- liblzma-rs/src/common/filter_flags_decoder.rs | 2 +- liblzma-rs/src/common/filter_flags_encoder.rs | 4 +- liblzma-rs/src/common/hardware_cputhreads.rs | 2 +- liblzma-rs/src/common/hardware_physmem.rs | 2 +- liblzma-rs/src/common/index.rs | 131 +++--- liblzma-rs/src/common/index_decoder.rs | 48 +- liblzma-rs/src/common/index_encoder.rs | 47 +- liblzma-rs/src/common/index_hash.rs | 49 +-- liblzma-rs/src/common/lzip_decoder.rs | 50 +-- liblzma-rs/src/common/microlzma_decoder.rs | 24 +- liblzma-rs/src/common/microlzma_encoder.rs | 23 +- liblzma-rs/src/common/outqueue.rs | 20 +- .../src/common/stream_buffer_decoder.rs | 6 +- .../src/common/stream_buffer_encoder.rs | 4 +- liblzma-rs/src/common/stream_decoder.rs | 30 +- liblzma-rs/src/common/stream_decoder_mt.rs | 97 ++-- liblzma-rs/src/common/stream_encoder.rs | 68 +-- liblzma-rs/src/common/stream_encoder_mt.rs | 136 +++--- liblzma-rs/src/common/stream_flags_common.rs | 6 +- liblzma-rs/src/common/stream_flags_decoder.rs | 26 +- liblzma-rs/src/common/stream_flags_encoder.rs | 33 +- liblzma-rs/src/common/string_conversion.rs | 276 ++++++------ liblzma-rs/src/common/vli_decoder.rs | 6 +- liblzma-rs/src/common/vli_encoder.rs | 4 +- liblzma-rs/src/common/vli_size.rs | 4 +- liblzma-rs/src/delta/delta_common.rs | 12 +- liblzma-rs/src/delta/delta_decoder.rs | 15 +- liblzma-rs/src/delta/delta_encoder.rs | 45 +- liblzma-rs/src/lz/lz_decoder.rs | 52 +-- liblzma-rs/src/lz/lz_encoder.rs | 180 +++----- liblzma-rs/src/lz/lz_encoder_mf.rs | 90 ++-- liblzma-rs/src/lzma/lzma2_decoder.rs | 102 ++--- liblzma-rs/src/lzma/lzma2_encoder.rs | 113 ++--- liblzma-rs/src/lzma/lzma_decoder.rs | 415 +++++++----------- liblzma-rs/src/lzma/lzma_encoder.rs | 175 ++++---- .../src/lzma/lzma_encoder_optimum_fast.rs | 22 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 115 +++-- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 4 +- liblzma-rs/src/simple/arm.rs | 10 +- liblzma-rs/src/simple/arm64.rs | 20 +- liblzma-rs/src/simple/armthumb.rs | 10 +- liblzma-rs/src/simple/ia64.rs | 12 +- liblzma-rs/src/simple/powerpc.rs | 10 +- liblzma-rs/src/simple/riscv.rs | 28 +- liblzma-rs/src/simple/simple_coder.rs | 66 +-- liblzma-rs/src/simple/simple_decoder.rs | 4 +- liblzma-rs/src/simple/simple_encoder.rs | 6 +- liblzma-rs/src/simple/sparc.rs | 10 +- liblzma-rs/src/simple/x86.rs | 16 +- liblzma-rs/src/types.rs | 3 - 76 files changed, 1353 insertions(+), 1931 deletions(-) diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index 8813ef7e..95c1b066 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -29,7 +29,7 @@ pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { false as lzma_bool, false as lzma_bool, ]; - return available_checks[type_0 as usize]; + available_checks[type_0 as usize] } #[no_mangle] pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { @@ -40,7 +40,7 @@ pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { 0, 4 as u8, 4 as u8, 4 as u8, 8 as u8, 8 as u8, 8 as u8, 16 as u8, 16 as u8, 16 as u8, 32 as u8, 32 as u8, 32 as u8, 64 as u8, 64 as u8, 64 as u8, ]; - return check_sizes[type_0 as usize] as u32; + check_sizes[type_0 as usize] as u32 } #[no_mangle] pub unsafe extern "C" fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check) { diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index d7e7dae2..010504d9 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -1,7 +1,7 @@ use crate::types::*; #[inline] unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { - return *(buf as *const u32); + *(buf as *const u32) } #[no_mangle] pub static mut lzma_crc32_table: [[u32; 256]; 8] = [ @@ -322,9 +322,8 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu crc = !crc; if size > 8 { while buf as uintptr_t & 7 as uintptr_t != 0 { - let fresh0 = buf; + crc = lzma_crc32_table[0][(*buf as u32 ^ crc & 0xff) as usize] ^ crc >> 8; buf = buf.offset(1); - crc = lzma_crc32_table[0][(*fresh0 as u32 ^ crc & 0xff) as usize] ^ crc >> 8; size -= 1; } let limit: *const u8 = buf.offset((size & !(7)) as isize); @@ -346,18 +345,17 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu } } loop { - let fresh1 = size; + let old_size = size; size = size.wrapping_sub(1); - if !(fresh1 != 0) { + if old_size == 0 { break; } - let fresh2 = buf; + crc = lzma_crc32_table[0][(*buf as u32 ^ crc & 0xff) as usize] ^ crc >> 8; buf = buf.offset(1); - crc = lzma_crc32_table[0][(*fresh2 as u32 ^ crc & 0xff) as usize] ^ crc >> 8; } - return !crc; + !crc } #[no_mangle] pub unsafe extern "C" fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32 { - return lzma_crc32_generic(buf, size, crc); + lzma_crc32_generic(buf, size, crc) } diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index 3f902a12..81041c88 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1,7 +1,7 @@ use crate::types::*; #[inline] unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { - return *(buf as *const u32); + *(buf as *const u32) } #[no_mangle] pub static mut lzma_crc64_table: [[u64; 256]; 4] = [ @@ -1042,9 +1042,8 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu crc = !crc; if size > 4 { while buf as uintptr_t & 3 as uintptr_t != 0 { - let fresh0 = buf; + crc = lzma_crc64_table[0][(*buf as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; buf = buf.offset(1); - crc = lzma_crc64_table[0][(*fresh0 as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; size -= 1; } let limit: *const u8 = buf.offset((size & !(3)) as isize); @@ -1060,18 +1059,17 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu } } loop { - let fresh1 = size; + let old_size = size; size = size.wrapping_sub(1); - if !(fresh1 != 0) { + if old_size == 0 { break; } - let fresh2 = buf; + crc = lzma_crc64_table[0][(*buf as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; buf = buf.offset(1); - crc = lzma_crc64_table[0][(*fresh2 as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; } - return !crc; + !crc } #[no_mangle] pub unsafe extern "C" fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64 { - return lzma_crc64_generic(buf, size, crc); + lzma_crc64_generic(buf, size, crc) } diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index ca908320..038d4f47 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -1,8 +1,8 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; +use core::ffi::c_uint; #[inline] extern "C" fn rotr_32(num: u32, amount: c_uint) -> u32 { - return num >> amount | num << 32u32.wrapping_sub(amount); + num >> amount | num << 32u32.wrapping_sub(amount) } static mut SHA256_K: [u32; 64] = [ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, @@ -17,15 +17,11 @@ static mut SHA256_K: [u32; 64] = [ unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { let mut W: [u32; 16] = [0; 16]; let mut T: [u32; 8] = [0; 8]; - memcpy( - &raw mut T as *mut u32 as *mut c_void, - state as *const c_void, - core::mem::size_of::<[u32; 8]>(), - ); - W[0] = (*data.offset(0) & 0xff) << 24 - | (*data.offset(0) & 0xff00) << 8 - | (*data.offset(0) & 0xff0000) >> 8 - | (*data.offset(0) & 0xff000000) >> 24; + core::ptr::copy_nonoverlapping(state as *const u8, &raw mut T as *mut u8, core::mem::size_of::<[u32; 8]>()); + W[0] = (*data & 0xff) << 24 + | (*data & 0xff00) << 8 + | (*data & 0xff0000) >> 8 + | (*data & 0xff000000) >> 24; T[7] = T[7].wrapping_add( rotr_32(T[4] ^ rotr_32(T[4] ^ rotr_32(T[4], 14), 5), 6) .wrapping_add(T[6] ^ T[4] & (T[5] ^ T[6])) @@ -529,7 +525,7 @@ unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { unsafe extern "C" fn process(check: *mut lzma_check_state) { transform( &raw mut (*check).state.sha256.state as *mut u32, - &raw mut (*check).buffer.u32_0 as *mut u32 as *const u32, + &raw mut (*check).buffer.u32_0 as *const u32, ); } #[no_mangle] @@ -538,11 +534,7 @@ pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, ]; - memcpy( - &raw mut (*check).state.sha256.state as *mut u32 as *mut c_void, - &raw const s as *const u32 as *const c_void, - core::mem::size_of::<[u32; 8]>(), - ); + core::ptr::copy_nonoverlapping(&raw const s as *const u8, &raw mut (*check).state.sha256.state as *mut u8, core::mem::size_of::<[u32; 8]>()); (*check).state.sha256.size = 0; } #[no_mangle] @@ -557,11 +549,7 @@ pub unsafe extern "C" fn lzma_sha256_update( if copy_size > size { copy_size = size; } - memcpy( - (&raw mut (*check).buffer.u8_0 as *mut u8).offset(copy_start as isize) as *mut c_void, - buf as *const c_void, - copy_size, - ); + core::ptr::copy_nonoverlapping(buf as *const u8, (&raw mut (*check).buffer.u8_0 as *mut u8).offset(copy_start as isize) as *mut u8, copy_size); buf = buf.offset(copy_size as isize); size = size.wrapping_sub(copy_size); (*check).state.sha256.size = (*check).state.sha256.size.wrapping_add(copy_size as u64); @@ -573,17 +561,15 @@ pub unsafe extern "C" fn lzma_sha256_update( #[no_mangle] pub unsafe extern "C" fn lzma_sha256_finish(check: *mut lzma_check_state) { let mut pos: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; - let fresh8 = pos; + (*check).buffer.u8_0[pos as usize] = 0x80 as u8; pos += 1; - (*check).buffer.u8_0[fresh8 as usize] = 0x80 as u8; while pos != (64 - 8) as size_t { if pos == 64 { process(check); pos = 0; } - let fresh9 = pos; + (*check).buffer.u8_0[pos as usize] = 0; pos += 1; - (*check).buffer.u8_0[fresh9 as usize] = 0; } (*check).state.sha256.size = (*check).state.sha256.size.wrapping_mul(8); (*check).buffer.u64_0[7] = ((*check).state.sha256.size & 0xff as u64) << 56 diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index b76d8bbc..a959fcdb 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -96,7 +96,7 @@ unsafe extern "C" fn alone_decode( } else { if (*coder).picky && (*coder).uncompressed_size != LZMA_VLI_UNKNOWN - && (*coder).uncompressed_size >= (1) << 38 + && (*coder).uncompressed_size >= 1 << 38 { return LZMA_FORMAT_ERROR; } @@ -116,7 +116,7 @@ unsafe extern "C" fn alone_decode( current_block_42 = 14763689060501151050; } 4 => { - return (*coder).next.code.expect("non-null function pointer")( + return (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -168,7 +168,7 @@ unsafe extern "C" fn alone_decode( _ => {} } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn alone_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; @@ -190,7 +190,7 @@ unsafe extern "C" fn alone_decoder_memconfig( } (*coder).memlimit = new_memlimit; } - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_alone_decoder_init( @@ -199,7 +199,7 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( memlimit: u64, picky: bool, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -221,7 +221,7 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -261,15 +261,11 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( alone_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; - (*next).memconfig = Some( - alone_decoder_memconfig - as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; + ); + (*next).memconfig = Some(alone_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -287,12 +283,12 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( (*coder).picky = picky; (*coder).pos = 0; (*coder).options.dict_size = 0; - (*coder).options.preset_dict = ::core::ptr::null::(); + (*coder).options.preset_dict = core::ptr::null(); (*coder).options.preset_dict_size = 0; (*coder).uncompressed_size = 0; (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).memusage = LZMA_MEMUSAGE_BASE; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { @@ -312,5 +308,5 @@ pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u6 } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index 58b8c462..bc22828a 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -38,7 +38,7 @@ pub const SEQ_HEADER: C2RustUnnamed_0 = 0; #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { - *buf.offset(0) = num as u8; + *buf = num as u8; *buf.offset(1) = (num >> 8) as u8; *buf.offset(2) = (num >> 16) as u8; *buf.offset(3) = (num >> 24) as u8; @@ -74,7 +74,7 @@ unsafe extern "C" fn alone_encode( (*coder).sequence = SEQ_CODE; } 1 => { - return (*coder).next.code.expect("non-null function pointer")( + return (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -89,7 +89,7 @@ unsafe extern "C" fn alone_encode( _ => return LZMA_PROG_ERROR, } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn alone_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; @@ -101,7 +101,7 @@ unsafe extern "C" fn alone_encoder_init( allocator: *const lzma_allocator, options: *const lzma_options_lzma, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -121,7 +121,7 @@ unsafe extern "C" fn alone_encoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -159,10 +159,10 @@ unsafe extern "C" fn alone_encoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( alone_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -194,11 +194,7 @@ unsafe extern "C" fn alone_encoder_init( d += 1; } write32le((&raw mut (*coder).header as *mut u8).offset(1), d); - memset( - (&raw mut (*coder).header as *mut u8).offset(1).offset(4) as *mut c_void, - 0xff, - 8, - ); + core::ptr::write_bytes((&raw mut (*coder).header as *mut u8).offset(1).offset(4) as *mut u8, 0xff as u8, 8); let filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { id: LZMA_FILTER_LZMA1, @@ -218,11 +214,11 @@ unsafe extern "C" fn alone_encoder_init( options: core::ptr::null_mut(), }, ]; - return lzma_next_filter_init( + lzma_next_filter_init( &raw mut (*coder).next, allocator, &raw const filters as *const lzma_filter_info, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_alone_encoder( @@ -244,5 +240,5 @@ pub unsafe extern "C" fn lzma_alone_encoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 5a1c0380..a6457f37 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -87,7 +87,7 @@ unsafe extern "C" fn auto_decode( } match current_block_28 { 13935781298497728377 => { - let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -108,11 +108,11 @@ unsafe extern "C" fn auto_decode( if *in_pos < in_size { return LZMA_DATA_ERROR; } - return if action == LZMA_FINISH { + if action == LZMA_FINISH { LZMA_STREAM_END } else { LZMA_OK - }; + } } unsafe extern "C" fn auto_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; @@ -125,7 +125,7 @@ extern "C" fn auto_decoder_get_check(coder_ptr: *const c_void) -> lzma_check { (if (*coder).next.get_check.is_none() { LZMA_CHECK_NONE } else { - (*coder).next.get_check.expect("non-null function pointer")((*coder).next.coder) + (*coder).next.get_check.unwrap()((*coder).next.coder) }) as lzma_check }; } @@ -138,7 +138,7 @@ unsafe extern "C" fn auto_decoder_memconfig( let coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; let mut ret: lzma_ret = LZMA_OK; if (*coder).next.memconfig.is_some() { - ret = (*coder).next.memconfig.expect("non-null function pointer")( + ret = (*coder).next.memconfig.unwrap()( (*coder).next.coder, memusage, old_memlimit, @@ -155,7 +155,7 @@ unsafe extern "C" fn auto_decoder_memconfig( if ret == LZMA_OK && new_memlimit != 0 { (*coder).memlimit = new_memlimit; } - return ret; + ret } unsafe extern "C" fn auto_decoder_init( next: *mut lzma_next_coder, @@ -163,7 +163,7 @@ unsafe extern "C" fn auto_decoder_init( memlimit: u64, flags: u32, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, >, @@ -180,7 +180,7 @@ unsafe extern "C" fn auto_decoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, >, @@ -218,18 +218,13 @@ unsafe extern "C" fn auto_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( auto_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*next).get_check = - Some(auto_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check) - as Option lzma_check>; - (*next).memconfig = Some( - auto_decoder_memconfig - as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; + Some(auto_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check); + (*next).memconfig = Some(auto_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -246,7 +241,7 @@ unsafe extern "C" fn auto_decoder_init( (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).flags = flags; (*coder).sequence = SEQ_INIT; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_auto_decoder( @@ -270,5 +265,5 @@ pub unsafe extern "C" fn lzma_auto_decoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index 75c481f1..cb84e9f7 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -43,7 +43,7 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( if ret == LZMA_OK { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - ret = block_decoder.code.expect("non-null function pointer")( + ret = block_decoder.code.unwrap()( block_decoder.coder, allocator, in_0, @@ -69,5 +69,5 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( } } lzma_next_end(&raw mut block_decoder, allocator); - return ret; + ret } diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 841cb839..0e82c0ab 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -42,7 +42,7 @@ extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { if (COMPRESSED_SIZE_MAX as u64).wrapping_sub(overhead) < uncompressed_size { return 0; } - return uncompressed_size.wrapping_add(overhead); + uncompressed_size.wrapping_add(overhead) } #[no_mangle] pub extern "C" fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { @@ -51,12 +51,12 @@ pub extern "C" fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { return 0; } lzma2_size = lzma2_size.wrapping_add(3) & !(3); - return (HEADERS_BOUND as u64).wrapping_add(lzma2_size); + (HEADERS_BOUND as u64).wrapping_add(lzma2_size) } #[no_mangle] pub extern "C" fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t { let ret: u64 = lzma_block_buffer_bound64(uncompressed_size as u64); - return ret as size_t; + ret as size_t } unsafe extern "C" fn block_encode_uncompressed( block: *mut lzma_block, @@ -68,14 +68,14 @@ unsafe extern "C" fn block_encode_uncompressed( ) -> lzma_ret { let mut lzma2: lzma_options_lzma = lzma_options_lzma { dict_size: LZMA_DICT_SIZE_MIN as u32, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, lc: 0, lp: 0, pb: 0, - mode: 0 as lzma_mode, + mode: 0, nice_len: 0, - mf: 0 as lzma_match_finder, + mf: 0, depth: 0, ext_flags: 0, ext_size_low: 0, @@ -120,33 +120,25 @@ unsafe extern "C" fn block_encode_uncompressed( let mut in_pos: size_t = 0; let mut control: u8 = 0x1 as u8; while in_pos < in_size { - let fresh1 = *out_pos; - *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh1 as isize) = control; + *out.offset(*out_pos as isize) = control; + *out_pos += 1; control = 0x2 as u8; let copy_size: size_t = if in_size.wrapping_sub(in_pos) < (1u32 << 16) as size_t { in_size.wrapping_sub(in_pos) } else { (1u32 << 16) as size_t }; - let fresh2 = *out_pos; - *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh2 as isize) = (copy_size.wrapping_sub(1) >> 8) as u8; - let fresh3 = *out_pos; - *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh3 as isize) = (copy_size.wrapping_sub(1) & 0xff) as u8; - memcpy( - out.offset(*out_pos as isize) as *mut c_void, - in_0.offset(in_pos as isize) as *const c_void, - copy_size, - ); + *out.offset(*out_pos as isize) = (copy_size.wrapping_sub(1) >> 8) as u8; + *out_pos += 1; + *out.offset(*out_pos as isize) = (copy_size.wrapping_sub(1) & 0xff) as u8; + *out_pos += 1; + core::ptr::copy_nonoverlapping(in_0.offset(in_pos as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size); in_pos = in_pos.wrapping_add(copy_size); *out_pos = (*out_pos).wrapping_add(copy_size); } - let fresh4 = *out_pos; - *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh4 as isize) = 0; - return LZMA_OK; + *out.offset(*out_pos as isize) = 0; + *out_pos += 1; + LZMA_OK } unsafe extern "C" fn block_encode_normal( block: *mut lzma_block, @@ -185,7 +177,7 @@ unsafe extern "C" fn block_encode_normal( lzma_raw_encoder_init(&raw mut raw_encoder, allocator, (*block).filters); if ret == LZMA_OK { let mut in_pos: size_t = 0; - ret = raw_encoder.code.expect("non-null function pointer")( + ret = raw_encoder.code.unwrap()( raw_encoder.coder, allocator, in_0, @@ -212,7 +204,7 @@ unsafe extern "C" fn block_encode_normal( if ret != LZMA_OK { *out_pos = out_start; } - return ret; + ret } unsafe extern "C" fn block_buffer_encode( block: *mut lzma_block, @@ -268,9 +260,8 @@ unsafe extern "C" fn block_buffer_encode( } let mut i: size_t = (*block).compressed_size as size_t; while i & 3 != 0 { - let fresh0 = *out_pos; - *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0; + *out.offset(*out_pos as isize) = 0; + *out_pos += 1; i += 1; } if check_size > 0 { @@ -281,19 +272,11 @@ unsafe extern "C" fn block_buffer_encode( lzma_check_init(&raw mut check, (*block).check); lzma_check_update(&raw mut check, (*block).check, in_0, in_size); lzma_check_finish(&raw mut check, (*block).check); - memcpy( - &raw mut (*block).raw_check as *mut u8 as *mut c_void, - &raw mut check.buffer.u8_0 as *mut u8 as *const c_void, - check_size, - ); - memcpy( - out.offset(*out_pos as isize) as *mut c_void, - &raw mut check.buffer.u8_0 as *mut u8 as *const c_void, - check_size, - ); + core::ptr::copy_nonoverlapping(&raw mut check.buffer.u8_0 as *const u8, &raw mut (*block).raw_check as *mut u8, check_size); + core::ptr::copy_nonoverlapping(&raw mut check.buffer.u8_0 as *const u8, out.offset(*out_pos as isize) as *mut u8, check_size); *out_pos = (*out_pos).wrapping_add(check_size); } - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_encode( @@ -305,9 +288,9 @@ pub unsafe extern "C" fn lzma_block_buffer_encode( out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret { - return block_buffer_encode( + block_buffer_encode( block, allocator, in_0, in_size, out, out_pos, out_size, true, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_block_uncomp_encode( @@ -318,14 +301,14 @@ pub unsafe extern "C" fn lzma_block_uncomp_encode( out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret { - return block_buffer_encode( + block_buffer_encode( block, - ::core::ptr::null::(), + core::ptr::null(), in_0, in_size, out, out_pos, out_size, false, - ); + ) } diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 3ef30688..3fbaa3fb 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -49,7 +49,7 @@ pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; #[inline] extern "C" fn is_size_valid(size: lzma_vli, reference: lzma_vli) -> bool { - return reference == LZMA_VLI_UNKNOWN || reference == size; + reference == LZMA_VLI_UNKNOWN || reference == size } unsafe extern "C" fn block_decode( coder_ptr: *mut c_void, @@ -95,7 +95,7 @@ unsafe extern "C" fn block_decode( .wrapping_sub((*coder).uncompressed_size) }) as size_t, ); - let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -169,9 +169,9 @@ unsafe extern "C" fn block_decode( return LZMA_OK; } (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); - let fresh0 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) != 0 { + let byte = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if byte != 0 { return LZMA_DATA_ERROR; } } @@ -200,8 +200,8 @@ unsafe extern "C" fn block_decode( if !(*coder).ignore_check && lzma_check_is_supported((*(*coder).block).check) != 0 && memcmp( - &raw mut (*(*coder).block).raw_check as *mut u8 as *const c_void, - &raw mut (*coder).check.buffer.u8_0 as *mut u8 as *const c_void, + &raw mut (*(*coder).block).raw_check as *const c_void, + &raw mut (*coder).check.buffer.u8_0 as *const c_void, check_size, ) != 0 { @@ -209,7 +209,7 @@ unsafe extern "C" fn block_decode( } return LZMA_STREAM_END; } - return LZMA_PROG_ERROR; + LZMA_PROG_ERROR } unsafe extern "C" fn block_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; @@ -222,7 +222,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( allocator: *const lzma_allocator, block: *mut lzma_block, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -242,7 +242,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -286,10 +286,10 @@ pub unsafe extern "C" fn lzma_block_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( block_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -326,7 +326,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( } else { false }; - return lzma_raw_decoder_init(&raw mut (*coder).next, allocator, (*block).filters); + lzma_raw_decoder_init(&raw mut (*coder).next, allocator, (*block).filters) } #[no_mangle] pub unsafe extern "C" fn lzma_block_decoder( @@ -345,5 +345,5 @@ pub unsafe extern "C" fn lzma_block_decoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index d1a43eee..2cd6a466 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -76,7 +76,7 @@ unsafe extern "C" fn block_encode( 0 => { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -154,14 +154,10 @@ unsafe extern "C" fn block_encode( if (*coder).pos < check_size { return LZMA_OK; } - memcpy( - &raw mut (*(*coder).block).raw_check as *mut u8 as *mut c_void, - &raw mut (*coder).check.buffer.u8_0 as *mut u8 as *const c_void, - check_size, - ); + core::ptr::copy_nonoverlapping(&raw mut (*coder).check.buffer.u8_0 as *const u8, &raw mut (*(*coder).block).raw_check as *mut u8, check_size); return LZMA_STREAM_END; } - return LZMA_PROG_ERROR; + LZMA_PROG_ERROR } unsafe extern "C" fn block_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; @@ -178,7 +174,7 @@ unsafe extern "C" fn block_encoder_update( if (*coder).sequence != SEQ_CODE { return LZMA_PROG_ERROR; } - return lzma_next_filter_update(&raw mut (*coder).next, allocator, reversed_filters); + lzma_next_filter_update(&raw mut (*coder).next, allocator, reversed_filters) } #[no_mangle] pub unsafe extern "C" fn lzma_block_encoder_init( @@ -186,7 +182,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( allocator: *const lzma_allocator, block: *mut lzma_block, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -206,7 +202,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -256,27 +252,16 @@ pub unsafe extern "C" fn lzma_block_encoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( block_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; - (*next).update = Some( - block_encoder_update - as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >; + ); + (*next).update = Some(block_encoder_update as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -296,7 +281,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( (*coder).uncompressed_size = 0; (*coder).pos = 0; lzma_check_init(&raw mut (*coder).check, (*block).check); - return lzma_raw_encoder_init(&raw mut (*coder).next, allocator, (*block).filters); + lzma_raw_encoder_init(&raw mut (*coder).next, allocator, (*block).filters) } #[no_mangle] pub unsafe extern "C" fn lzma_block_encoder( @@ -316,5 +301,5 @@ pub unsafe extern "C" fn lzma_block_encoder( (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 44f3a3fc..9a8daae3 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -21,7 +21,7 @@ extern "C" { #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { - let mut num: u32 = *buf.offset(0) as u32; + let mut num: u32 = *buf as u32; num |= (*buf.offset(1) as u32) << 8; num |= (*buf.offset(2) as u32) << 16; num |= (*buf.offset(3) as u32) << 24; @@ -47,7 +47,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( (*block).version = 1; } (*block).ignore_check = false as lzma_bool; - if (*in_0.offset(0) as u32).wrapping_add(1).wrapping_mul(4) != (*block).header_size + if (*in_0 as u32).wrapping_add(1).wrapping_mul(4) != (*block).header_size || (*block).check > LZMA_CHECK_ID_MAX { return LZMA_PROG_ERROR; @@ -108,12 +108,11 @@ pub unsafe extern "C" fn lzma_block_header_decode( i_0 += 1; } while in_pos < in_size { - let fresh1 = in_pos; - in_pos += 1; - if *in_0.offset(fresh1 as isize) != 0 { + if *in_0.offset(in_pos as isize) != 0 { lzma_filters_free((*block).filters, allocator); return LZMA_OPTIONS_ERROR; } + in_pos += 1; } - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 0cc71b95..59cf4a8e 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { fn lzma_vli_encode( vli: lzma_vli, @@ -22,7 +21,7 @@ extern "C" { #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { - *buf.offset(0) = num as u8; + *buf = num as u8; *buf.offset(1) = (num >> 8) as u8; *buf.offset(2) = (num >> 16) as u8; *buf.offset(3) = (num >> 24) as u8; @@ -48,7 +47,7 @@ pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ } size = size.wrapping_add(add_0); } - if (*block).filters.is_null() || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN { + if (*block).filters.is_null() || (*(*block).filters).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; } let mut i: size_t = 0; @@ -66,7 +65,7 @@ pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ i += 1; } (*block).header_size = size.wrapping_add(3) & !(3); - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_block_header_encode( @@ -80,7 +79,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( return LZMA_PROG_ERROR; } let out_size: size_t = (*block).header_size.wrapping_sub(4) as size_t; - *out.offset(0) = out_size.wrapping_div(4) as u8; + *out = out_size.wrapping_div(4) as u8; *out.offset(1) = 0; let mut out_pos: size_t = 2; if (*block).compressed_size != LZMA_VLI_UNKNOWN { @@ -109,7 +108,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( } *out.offset(1) |= 0x80; } - if (*block).filters.is_null() || (*(*block).filters.offset(0)).id == LZMA_VLI_UNKNOWN { + if (*block).filters.is_null() || (*(*block).filters).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; } let mut filter_count: size_t = 0; @@ -127,16 +126,12 @@ pub unsafe extern "C" fn lzma_block_header_encode( return ret__1; } filter_count += 1; - if !((*(*block).filters.offset(filter_count as isize)).id != LZMA_VLI_UNKNOWN) { + if (*(*block).filters.offset(filter_count as isize)).id == LZMA_VLI_UNKNOWN { break; } } *out.offset(1) |= filter_count.wrapping_sub(1) as u8; - memset( - out.offset(out_pos as isize) as *mut c_void, - 0, - out_size.wrapping_sub(out_pos), - ); + core::ptr::write_bytes(out.offset(out_pos as isize) as *mut u8, 0 as u8, out_size.wrapping_sub(out_pos)); write32le(out.offset(out_size as isize), lzma_crc32(out, out_size, 0)); - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 20ad989b..1154f8ab 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -7,7 +7,7 @@ pub const LZMA_BLOCK_HEADER_SIZE_MIN: u32 = 8; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - return vli.wrapping_add(3) & !(3); + vli.wrapping_add(3) & !(3) } #[no_mangle] pub unsafe extern "C" fn lzma_block_compressed_size( @@ -28,7 +28,7 @@ pub unsafe extern "C" fn lzma_block_compressed_size( return LZMA_DATA_ERROR; } (*block).compressed_size = compressed_size; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli { @@ -54,7 +54,7 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> l if unpadded_size > UNPADDED_SIZE_MAX as lzma_vli { return 0; } - return unpadded_size; + unpadded_size } #[no_mangle] pub unsafe extern "C" fn lzma_block_total_size(block: *const lzma_block) -> lzma_vli { @@ -62,5 +62,5 @@ pub unsafe extern "C" fn lzma_block_total_size(block: *const lzma_block) -> lzma if unpadded_size != LZMA_VLI_UNKNOWN { unpadded_size = vli_ceil4(unpadded_size); } - return unpadded_size; + unpadded_size } diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index ebf39463..f3606f53 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -18,11 +18,11 @@ pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR) pub const LZMA_TIMED_OUT: c_uint = 101; #[no_mangle] pub extern "C" fn lzma_version_number() -> u32 { - return LZMA_VERSION as u32; + LZMA_VERSION as u32 } #[no_mangle] pub extern "C" fn lzma_version_string() -> *const c_char { - return b"5.8.2\0" as *const u8 as *const c_char; + c"5.8.2".as_ptr() } #[no_mangle] pub unsafe extern "C" fn lzma_alloc( @@ -34,11 +34,11 @@ pub unsafe extern "C" fn lzma_alloc( } let mut ptr: *mut c_void = core::ptr::null_mut(); if !allocator.is_null() && (*allocator).alloc.is_some() { - ptr = (*allocator).alloc.expect("non-null function pointer")((*allocator).opaque, 1, size); + ptr = (*allocator).alloc.unwrap()((*allocator).opaque, 1, size); } else { ptr = malloc(size); } - return ptr; + ptr } #[no_mangle] pub unsafe extern "C" fn lzma_alloc_zero( @@ -50,19 +50,19 @@ pub unsafe extern "C" fn lzma_alloc_zero( } let mut ptr: *mut c_void = core::ptr::null_mut(); if !allocator.is_null() && (*allocator).alloc.is_some() { - ptr = (*allocator).alloc.expect("non-null function pointer")((*allocator).opaque, 1, size); + ptr = (*allocator).alloc.unwrap()((*allocator).opaque, 1, size); if !ptr.is_null() { - memset(ptr, 0, size); + core::ptr::write_bytes(ptr as *mut u8, 0, size); } } else { ptr = calloc(1, size); } - return ptr; + ptr } #[no_mangle] pub unsafe extern "C" fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator) { if !allocator.is_null() && (*allocator).free.is_some() { - (*allocator).free.expect("non-null function pointer")((*allocator).opaque, ptr); + (*allocator).free.unwrap()((*allocator).opaque, ptr); } else { free(ptr); }; @@ -84,15 +84,11 @@ pub unsafe extern "C" fn lzma_bufcpy( out_avail }; if copy_size > 0 { - memcpy( - out.offset(*out_pos as isize) as *mut c_void, - in_0.offset(*in_pos as isize) as *const c_void, - copy_size, - ); + core::ptr::copy_nonoverlapping(in_0.offset(*in_pos as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size); } *in_pos = (*in_pos).wrapping_add(copy_size); *out_pos = (*out_pos).wrapping_add(copy_size); - return copy_size; + copy_size } #[no_mangle] pub unsafe extern "C" fn lzma_next_filter_init( @@ -100,21 +96,18 @@ pub unsafe extern "C" fn lzma_next_filter_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - if ::core::mem::transmute::((*filters.offset(0)).init) + if core::mem::transmute::((*filters).init) != (*next).init { lzma_next_end(next, allocator); } - (*next).init = - ::core::mem::transmute::((*filters.offset(0)).init); - (*next).id = (*filters.offset(0)).id; - return if (*filters.offset(0)).init.is_none() { + (*next).init = core::mem::transmute::((*filters).init); + (*next).id = (*filters).id; + if (*filters).init.is_none() { LZMA_OK } else { - (*filters.offset(0)) - .init - .expect("non-null function pointer")(next, allocator, filters) - }; + (*filters).init.unwrap()(next, allocator, filters) + } } #[no_mangle] pub unsafe extern "C" fn lzma_next_filter_update( @@ -122,18 +115,18 @@ pub unsafe extern "C" fn lzma_next_filter_update( allocator: *const lzma_allocator, reversed_filters: *const lzma_filter, ) -> lzma_ret { - if (*reversed_filters.offset(0)).id != (*next).id { + if (*reversed_filters).id != (*next).id { return LZMA_PROG_ERROR; } - if (*reversed_filters.offset(0)).id == LZMA_VLI_UNKNOWN { + if (*reversed_filters).id == LZMA_VLI_UNKNOWN { return LZMA_OK; } - return (*next).update.expect("non-null function pointer")( + (*next).update.unwrap()( (*next).coder, allocator, - ::core::ptr::null::(), + core::ptr::null(), reversed_filters, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_next_end( @@ -142,7 +135,7 @@ pub unsafe extern "C" fn lzma_next_end( ) { if (*next).init != 0 { if (*next).end.is_some() { - (*next).end.expect("non-null function pointer")((*next).coder, allocator); + (*next).end.unwrap()((*next).coder, allocator); } else { lzma_free((*next).coder, allocator); } @@ -184,16 +177,12 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { set_out_limit: None, }; } - memset( - &raw mut (*(*strm).internal).supported_actions as *mut bool as *mut c_void, - 0, - core::mem::size_of::<[bool; 5]>(), - ); + core::ptr::write_bytes(&raw mut (*(*strm).internal).supported_actions as *mut u8, 0 as u8, core::mem::size_of::<[bool; 5]>()); (*(*strm).internal).sequence = ISEQ_RUN; (*(*strm).internal).allow_buf_error = false; (*strm).total_in = 0; (*strm).total_out = 0; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret { @@ -259,10 +248,7 @@ pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) } let mut in_pos: size_t = 0; let mut out_pos: size_t = 0; - let mut ret: lzma_ret = (*(*strm).internal) - .next - .code - .expect("non-null function pointer")( + let mut ret: lzma_ret = (*(*strm).internal).next.code.unwrap()( (*(*strm).internal).next.coder, (*strm).allocator, (*strm).next_in, @@ -335,7 +321,7 @@ pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) } _ => {} } - return ret; + ret } #[no_mangle] pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { @@ -352,10 +338,7 @@ pub unsafe extern "C" fn lzma_get_progress( progress_out: *mut u64, ) { if (*(*strm).internal).next.get_progress.is_some() { - (*(*strm).internal) - .next - .get_progress - .expect("non-null function pointer")( + (*(*strm).internal).next.get_progress.unwrap()( (*(*strm).internal).next.coder, progress_in, progress_out, @@ -371,10 +354,7 @@ pub extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { if (*(*strm).internal).next.get_check.is_none() { return LZMA_CHECK_NONE; } - (*(*strm).internal) - .next - .get_check - .expect("non-null function pointer")((*(*strm).internal).next.coder) + (*(*strm).internal).next.get_check.unwrap()((*(*strm).internal).next.coder) }; } #[no_mangle] @@ -385,10 +365,7 @@ pub extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { if strm.is_null() || (*strm).internal.is_null() || (*(*strm).internal).next.memconfig.is_none() - || (*(*strm).internal) - .next - .memconfig - .expect("non-null function pointer")( + || (*(*strm).internal).next.memconfig.unwrap()( (*(*strm).internal).next.coder, &raw mut memusage, &raw mut old_memlimit, @@ -408,10 +385,7 @@ pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { if strm.is_null() || (*strm).internal.is_null() || (*(*strm).internal).next.memconfig.is_none() - || (*(*strm).internal) - .next - .memconfig - .expect("non-null function pointer")( + || (*(*strm).internal).next.memconfig.unwrap()( (*(*strm).internal).next.coder, &raw mut memusage, &raw mut old_memlimit, @@ -437,13 +411,10 @@ pub unsafe extern "C" fn lzma_memlimit_set( if new_memlimit == 0 { new_memlimit = 1; } - return (*(*strm).internal) - .next - .memconfig - .expect("non-null function pointer")( + (*(*strm).internal).next.memconfig.unwrap()( (*(*strm).internal).next.coder, &raw mut memusage, &raw mut old_memlimit, new_memlimit, - ); + ) } diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index cb8c98c5..8c21f841 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -30,14 +30,14 @@ pub unsafe extern "C" fn lzma_easy_buffer_encode( }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, lc: 0, lp: 0, pb: 0, - mode: 0 as lzma_mode, + mode: 0, nice_len: 0, - mf: 0 as lzma_match_finder, + mf: 0, depth: 0, ext_flags: 0, ext_size_low: 0, @@ -58,7 +58,7 @@ pub unsafe extern "C" fn lzma_easy_buffer_encode( if lzma_easy_preset(&raw mut opt_easy, preset) { return LZMA_OPTIONS_ERROR; } - return lzma_stream_buffer_encode( + lzma_stream_buffer_encode( &raw mut opt_easy.filters as *mut lzma_filter, check, allocator, @@ -67,5 +67,5 @@ pub unsafe extern "C" fn lzma_easy_buffer_encode( out, out_pos, out_size, - ); + ) } diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index aed419fe..2890e2dc 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -12,14 +12,14 @@ pub extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, lc: 0, lp: 0, pb: 0, - mode: 0 as lzma_mode, + mode: 0, nice_len: 0, - mf: 0 as lzma_match_finder, + mf: 0, depth: 0, ext_flags: 0, ext_size_low: 0, @@ -40,5 +40,5 @@ pub extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { if unsafe { lzma_easy_preset(&raw mut opt_easy, preset) } { return UINT32_MAX as u64; } - return unsafe { lzma_raw_decoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter) }; + unsafe { lzma_raw_decoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter) } } diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index f75d6746..98a2a8e0 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -20,14 +20,14 @@ pub unsafe extern "C" fn lzma_easy_encoder( }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, lc: 0, lp: 0, pb: 0, - mode: 0 as lzma_mode, + mode: 0, nice_len: 0, - mf: 0 as lzma_match_finder, + mf: 0, depth: 0, ext_flags: 0, ext_size_low: 0, @@ -48,5 +48,5 @@ pub unsafe extern "C" fn lzma_easy_encoder( if lzma_easy_preset(&raw mut opt_easy, preset) { return LZMA_OPTIONS_ERROR; } - return lzma_stream_encoder(strm, &raw mut opt_easy.filters as *mut lzma_filter, check); + lzma_stream_encoder(strm, &raw mut opt_easy.filters as *mut lzma_filter, check) } diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index 1c4705e0..47599f37 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -12,14 +12,14 @@ pub extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, lc: 0, lp: 0, pb: 0, - mode: 0 as lzma_mode, + mode: 0, nice_len: 0, - mf: 0 as lzma_match_finder, + mf: 0, depth: 0, ext_flags: 0, ext_size_low: 0, @@ -40,5 +40,5 @@ pub extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { if unsafe { lzma_easy_preset(&raw mut opt_easy, preset) } { return UINT32_MAX as u64; } - return unsafe { lzma_raw_encoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter) }; + unsafe { lzma_raw_encoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter) } } diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index be14be3c..45d15c52 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -11,5 +11,5 @@ pub unsafe extern "C" fn lzma_easy_preset(opt_easy: *mut lzma_options_easy, pres (*opt_easy).filters[0].id = LZMA_FILTER_LZMA2; (*opt_easy).filters[0].options = &raw mut (*opt_easy).opt_lzma as *mut c_void; (*opt_easy).filters[1].id = LZMA_VLI_UNKNOWN; - return false; + false } diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 696c9a96..b88b01c3 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -89,7 +89,7 @@ unsafe extern "C" fn fill_temp( &raw mut (*coder).temp_pos, (*coder).temp_size, ) as u64); - return (*coder).temp_pos < (*coder).temp_size; + (*coder).temp_pos < (*coder).temp_size } unsafe extern "C" fn seek_to_pos( coder: *mut lzma_file_info_coder, @@ -114,7 +114,7 @@ unsafe extern "C" fn seek_to_pos( *in_pos = in_size; } (*coder).file_cur_pos = target_pos; - return external_seek_needed; + external_seek_needed } unsafe extern "C" fn reverse_seek( coder: *mut lzma_file_info_coder, @@ -135,7 +135,7 @@ unsafe extern "C" fn reverse_seek( .file_target_pos .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64) as size_t; } else { - (*coder).temp_size = core::mem::size_of::<[u8; 8192]>() as usize as size_t; + (*coder).temp_size = core::mem::size_of::<[u8; 8192]>() as size_t; } if seek_to_pos( coder, @@ -148,7 +148,7 @@ unsafe extern "C" fn reverse_seek( ) { return LZMA_SEEK_NEEDED; } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn get_padding_size(buf: *const u8, mut buf_size: size_t) -> size_t { let mut padding: size_t = 0; @@ -158,13 +158,13 @@ unsafe extern "C" fn get_padding_size(buf: *const u8, mut buf_size: size_t) -> s } { padding += 1; } - return padding; + padding } extern "C" fn hide_format_error(mut ret: lzma_ret) -> lzma_ret { if ret == LZMA_FORMAT_ERROR { ret = LZMA_DATA_ERROR; } - return ret; + ret } unsafe extern "C" fn decode_index( coder: *mut lzma_file_info_coder, @@ -175,10 +175,7 @@ unsafe extern "C" fn decode_index( update_file_cur_pos: bool, ) -> lzma_ret { let in_start: size_t = *in_pos; - let ret: lzma_ret = (*coder) - .index_decoder - .code - .expect("non-null function pointer")( + let ret: lzma_ret = (*coder).index_decoder.code.unwrap()( (*coder).index_decoder.coder, allocator, in_0, @@ -197,7 +194,7 @@ unsafe extern "C" fn decode_index( .file_cur_pos .wrapping_add((*in_pos).wrapping_sub(in_start) as u64); } - return ret; + ret } unsafe extern "C" fn file_info_decode( coder_ptr: *mut c_void, @@ -533,10 +530,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( this_index_memusage = lzma_index_memused((*coder).this_index); } else if (*coder).sequence == SEQ_INDEX_DECODE { let mut dummy: u64 = 0; - if (*coder) - .index_decoder - .memconfig - .expect("non-null function pointer")( + if (*coder).index_decoder.memconfig.unwrap()( (*coder).index_decoder.coder, &raw mut this_index_memusage, &raw mut dummy, @@ -559,10 +553,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( let idec_new_memlimit: u64 = new_memlimit.wrapping_sub(combined_index_memusage); let mut dummy1: u64 = 0; let mut dummy2: u64 = 0; - if (*coder) - .index_decoder - .memconfig - .expect("non-null function pointer")( + if (*coder).index_decoder.memconfig.unwrap()( (*coder).index_decoder.coder, &raw mut dummy1, &raw mut dummy2, @@ -574,7 +565,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( } (*coder).memlimit = new_memlimit; } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn file_info_decoder_end( coder_ptr: *mut c_void, @@ -594,7 +585,7 @@ unsafe extern "C" fn lzma_file_info_decoder_init( memlimit: u64, file_size: u64, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -620,7 +611,7 @@ unsafe extern "C" fn lzma_file_info_decoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -667,15 +658,11 @@ unsafe extern "C" fn lzma_file_info_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( file_info_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; - (*next).memconfig = Some( - file_info_decoder_memconfig - as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; + ); + (*next).memconfig = Some(file_info_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); (*coder).index_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -705,7 +692,7 @@ unsafe extern "C" fn lzma_file_info_decoder_init( (*coder).memlimit = if 1 > memlimit { 1 } else { memlimit }; (*coder).temp_pos = 0; (*coder).temp_size = LZMA_STREAM_HEADER_SIZE as size_t; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_file_info_decoder( @@ -732,5 +719,5 @@ pub unsafe extern "C" fn lzma_file_info_decoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index 72c6fffc..862d6613 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -45,7 +45,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( } let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - let mut ret: lzma_ret = next.code.expect("non-null function pointer")( + let mut ret: lzma_ret = next.code.unwrap()( next.coder, allocator, in_0, @@ -67,7 +67,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( } else { let mut tmp: [u8; 1] = [0; 1]; let mut tmp_pos: size_t = 0; - next.code.expect("non-null function pointer")( + next.code.unwrap()( next.coder, allocator, in_0, @@ -89,5 +89,5 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( *out_pos = out_start; } lzma_next_end(&raw mut next, allocator); - return ret; + ret } diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index d0063176..8c6afae8 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -38,7 +38,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( } let out_start: size_t = *out_pos; let mut in_pos: size_t = 0; - let mut ret: lzma_ret = next.code.expect("non-null function pointer")( + let mut ret: lzma_ret = next.code.unwrap()( next.coder, allocator, in_0, @@ -58,5 +58,5 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( } *out_pos = out_start; } - return ret; + ret } diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 57ebe75c..8c76356d 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { fn lzma_next_filter_init( next: *mut lzma_next_coder, @@ -128,7 +127,7 @@ pub unsafe extern "C" fn lzma_filters_copy( let mut i: size_t = 0; i = 0; 's_15: loop { - if !((*src.offset(i as isize)).id != LZMA_VLI_UNKNOWN) { + if (*src.offset(i as isize)).id == LZMA_VLI_UNKNOWN { current_block = 7175849428784450219; break; } @@ -158,9 +157,9 @@ pub unsafe extern "C" fn lzma_filters_copy( current_block = 6392083060350426025; break; } else { - memcpy( - dest[i as usize].options, - (*src.offset(i as isize)).options, + core::ptr::copy_nonoverlapping( + (*src.offset(i as isize)).options as *const u8, + dest[i as usize].options as *mut u8, features[j as usize].options_size, ); } @@ -179,12 +178,8 @@ pub unsafe extern "C" fn lzma_filters_copy( _ => { dest[i as usize].id = LZMA_VLI_UNKNOWN; dest[i as usize].options = core::ptr::null_mut(); - memcpy( - real_dest as *mut c_void, - &raw mut dest as *mut lzma_filter as *const c_void, - i.wrapping_add(1) - .wrapping_mul(core::mem::size_of::()), - ); + core::ptr::copy_nonoverlapping(&raw mut dest as *const u8, real_dest as *mut u8, i.wrapping_add(1) + .wrapping_mul(core::mem::size_of::())); return LZMA_OK; } }; @@ -213,7 +208,7 @@ pub unsafe extern "C" fn lzma_validate_chain( filters: *const lzma_filter, count: *mut size_t, ) -> lzma_ret { - if filters.is_null() || (*filters.offset(0)).id == LZMA_VLI_UNKNOWN { + if filters.is_null() || (*filters).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; } let mut changes_size_count: size_t = 0; @@ -237,7 +232,7 @@ pub unsafe extern "C" fn lzma_validate_chain( changes_size_count = changes_size_count.wrapping_add(features[j as usize].changes_size as size_t); i += 1; - if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN) { + if (*filters.offset(i as isize)).id == LZMA_VLI_UNKNOWN { break; } } @@ -245,7 +240,7 @@ pub unsafe extern "C" fn lzma_validate_chain( return LZMA_OPTIONS_ERROR; } *count = i; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_raw_coder_init( @@ -270,8 +265,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( while i < count { let j: size_t = count.wrapping_sub(i).wrapping_sub(1); let fc: *const lzma_filter_coder = - coder_find.expect("non-null function pointer")((*options.offset(i as isize)).id) - as *const lzma_filter_coder; + coder_find.unwrap()((*options.offset(i as isize)).id) as *const lzma_filter_coder; if fc.is_null() || (*fc).init.is_none() { return LZMA_OPTIONS_ERROR; } @@ -284,8 +278,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( let mut i_0: size_t = 0; while i_0 < count { let fc_0: *const lzma_filter_coder = - coder_find.expect("non-null function pointer")((*options.offset(i_0 as isize)).id) - as *const lzma_filter_coder; + coder_find.unwrap()((*options.offset(i_0 as isize)).id) as *const lzma_filter_coder; if fc_0.is_null() || (*fc_0).init.is_none() { return LZMA_OPTIONS_ERROR; } @@ -302,7 +295,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( if ret != LZMA_OK { lzma_next_end(next, allocator); } - return ret; + ret } #[no_mangle] pub unsafe extern "C" fn lzma_raw_coder_memusage( @@ -317,26 +310,23 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( let mut i: size_t = 0; loop { let fc: *const lzma_filter_coder = - coder_find.expect("non-null function pointer")((*filters.offset(i as isize)).id) - as *const lzma_filter_coder; + coder_find.unwrap()((*filters.offset(i as isize)).id) as *const lzma_filter_coder; if fc.is_null() { return UINT64_MAX; } if (*fc).memusage.is_none() { total = total.wrapping_add(1024); } else { - let usage: u64 = (*fc).memusage.expect("non-null function pointer")( - (*filters.offset(i as isize)).options, - ) as u64; + let usage: u64 = (*fc).memusage.unwrap()((*filters.offset(i as isize)).options) as u64; if usage == UINT64_MAX { return UINT64_MAX; } total = total.wrapping_add(usage); } i += 1; - if !((*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN) { + if (*filters.offset(i as isize)).id == LZMA_VLI_UNKNOWN { break; } } - return total.wrapping_add(LZMA_MEMUSAGE_BASE); + total.wrapping_add(LZMA_MEMUSAGE_BASE) } diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index ccbc3b35..8c5dfaef 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -366,22 +366,22 @@ static decoders: [lzma_filter_decoder; 12] = [ extern "C" fn decoder_find(id: lzma_vli) -> *const lzma_filter_decoder { let mut i: size_t = 0; while i - < (core::mem::size_of::<[lzma_filter_decoder; 12]>() as usize) - .wrapping_div(core::mem::size_of::() as usize) + < (core::mem::size_of::<[lzma_filter_decoder; 12]>()) + .wrapping_div(core::mem::size_of::()) { if decoders[i as usize].id == id { return decoders.as_ptr().wrapping_add(i as usize); } i += 1; } - return ::core::ptr::null::(); + core::ptr::null() } extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { - return decoder_find(id) as *const lzma_filter_coder; + decoder_find(id) as *const lzma_filter_coder } #[no_mangle] pub extern "C" fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { - return !decoder_find(id).is_null() as lzma_bool; + !decoder_find(id).is_null() as lzma_bool } #[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder_init( @@ -389,13 +389,13 @@ pub unsafe extern "C" fn lzma_raw_decoder_init( allocator: *const lzma_allocator, options: *const lzma_filter, ) -> lzma_ret { - return lzma_raw_coder_init( + lzma_raw_coder_init( next, allocator, options, Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), false, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder( @@ -417,14 +417,14 @@ pub unsafe extern "C" fn lzma_raw_decoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { - return lzma_raw_coder_memusage( + lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_properties_decode( @@ -445,10 +445,5 @@ pub unsafe extern "C" fn lzma_properties_decode( LZMA_OPTIONS_ERROR }; } - return (*fd).props_decode.expect("non-null function pointer")( - &raw mut (*filter).options, - allocator, - props, - props_size, - ); + (*fd).props_decode.unwrap()(&raw mut (*filter).options, allocator, props, props_size) } diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index 869bc693..93fbaafc 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -324,22 +324,22 @@ static encoders: [lzma_filter_encoder; 12] = [ extern "C" fn encoder_find(id: lzma_vli) -> *const lzma_filter_encoder { let mut i: size_t = 0; while i - < (core::mem::size_of::<[lzma_filter_encoder; 12]>() as usize) - .wrapping_div(core::mem::size_of::() as usize) + < (core::mem::size_of::<[lzma_filter_encoder; 12]>()) + .wrapping_div(core::mem::size_of::()) { if encoders[i as usize].id == id { return encoders.as_ptr().wrapping_add(i as usize); } i += 1; } - return ::core::ptr::null::(); + core::ptr::null() } extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { - return encoder_find(id) as *const lzma_filter_coder; + encoder_find(id) as *const lzma_filter_coder } #[no_mangle] pub extern "C" fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { - return !encoder_find(id).is_null() as lzma_bool; + !encoder_find(id).is_null() as lzma_bool } #[no_mangle] pub unsafe extern "C" fn lzma_filters_update( @@ -367,15 +367,12 @@ pub unsafe extern "C" fn lzma_filters_update( i += 1; } reversed_filters[count as usize].id = LZMA_VLI_UNKNOWN; - return (*(*strm).internal) - .next - .update - .expect("non-null function pointer")( + (*(*strm).internal).next.update.unwrap()( (*(*strm).internal).next.coder, (*strm).allocator, filters, &raw mut reversed_filters as *mut lzma_filter, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_raw_encoder_init( @@ -383,13 +380,13 @@ pub unsafe extern "C" fn lzma_raw_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter, ) -> lzma_ret { - return lzma_raw_coder_init( + lzma_raw_coder_init( next, allocator, filters, Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), true, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_raw_encoder( @@ -414,14 +411,14 @@ pub unsafe extern "C" fn lzma_raw_encoder( (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_SYNC_FLUSH as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64 { - return lzma_raw_coder_memusage( + lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { @@ -437,16 +434,18 @@ pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 return UINT64_MAX; } if (*fe).block_size.is_some() { - let size: u64 = (*fe).block_size.expect("non-null function pointer")( - (*filters.offset(i as isize)).options, - ) as u64; + let size: u64 = (*fe).block_size.unwrap()((*filters.offset(i as isize)).options) as u64; if size > max { max = size; } } i += 1; } - return if max == 0 { UINT64_MAX } else { max }; + if max == 0 { + UINT64_MAX + } else { + max + } } #[no_mangle] pub unsafe extern "C" fn lzma_properties_size( @@ -465,7 +464,7 @@ pub unsafe extern "C" fn lzma_properties_size( *size = (*fe).props_size_fixed; return LZMA_OK; } - return (*fe).props_size_get.expect("non-null function pointer")(size, (*filter).options); + (*fe).props_size_get.unwrap()(size, (*filter).options) } #[no_mangle] pub unsafe extern "C" fn lzma_properties_encode( @@ -479,5 +478,5 @@ pub unsafe extern "C" fn lzma_properties_encode( if (*fe).props_encode.is_none() { return LZMA_OK; } - return (*fe).props_encode.expect("non-null function pointer")((*filter).options, props); + (*fe).props_encode.unwrap()((*filter).options, props) } diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 2f046c5d..8a35d43d 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -57,5 +57,5 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( props_size as size_t, ); *in_pos = (*in_pos as lzma_vli).wrapping_add(props_size) as size_t; - return ret; + ret } diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index ee47a8fc..a4e227a8 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -25,7 +25,7 @@ pub unsafe extern "C" fn lzma_filter_flags_size( } *size = (*size) .wrapping_add(lzma_vli_size((*filter).id).wrapping_add(lzma_vli_size(*size as lzma_vli))); - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_encode( @@ -65,5 +65,5 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( return ret__2; } *out_pos = (*out_pos).wrapping_add(props_size as size_t); - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/hardware_cputhreads.rs b/liblzma-rs/src/common/hardware_cputhreads.rs index b93c2ceb..71e3fcd4 100644 --- a/liblzma-rs/src/common/hardware_cputhreads.rs +++ b/liblzma-rs/src/common/hardware_cputhreads.rs @@ -2,5 +2,5 @@ use crate::tuklib::tuklib_cpucores::tuklib_cpucores; #[no_mangle] pub extern "C" fn lzma_cputhreads() -> u32 { - return tuklib_cpucores(); + tuklib_cpucores() } diff --git a/liblzma-rs/src/common/hardware_physmem.rs b/liblzma-rs/src/common/hardware_physmem.rs index 73e1b228..6010242c 100644 --- a/liblzma-rs/src/common/hardware_physmem.rs +++ b/liblzma-rs/src/common/hardware_physmem.rs @@ -2,5 +2,5 @@ use crate::tuklib::tuklib_physmem::tuklib_physmem; #[no_mangle] pub extern "C" fn lzma_physmem() -> u64 { - return tuklib_physmem(); + tuklib_physmem() } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index f6d1f2d1..bf8443ac 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -146,32 +146,32 @@ pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; #[inline] extern "C" fn bsr32(n: u32) -> u32 { - return n.leading_zeros() as i32 as u32 ^ 31; + n.leading_zeros() as i32 as u32 ^ 31 } #[inline] extern "C" fn ctz32(n: u32) -> u32 { - return n.trailing_zeros() as i32 as u32; + n.trailing_zeros() as i32 as u32 } pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - return vli.wrapping_add(3) & !(3); + vli.wrapping_add(3) & !(3) } #[inline] extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - return (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) + (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) .wrapping_add(index_list_size) - .wrapping_add(4); + .wrapping_add(4) } #[inline] extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - return vli_ceil4(index_size_unpadded(count, index_list_size)); + vli_ceil4(index_size_unpadded(count, index_list_size)) } pub const INDEX_GROUP_SIZE: u32 = 512; pub const PREALLOC_MAX: usize = (SIZE_MAX as usize) - .wrapping_sub(core::mem::size_of::() as usize) - .wrapping_div(core::mem::size_of::() as usize); + .wrapping_sub(core::mem::size_of::()) + .wrapping_div(core::mem::size_of::()); unsafe extern "C" fn index_tree_init(tree: *mut index_tree) { (*tree).root = core::ptr::null_mut(); (*tree).leftmost = core::ptr::null_mut(); @@ -189,7 +189,7 @@ unsafe extern "C" fn index_tree_node_end( if !(*node).right.is_null() { index_tree_node_end((*node).right, allocator, free_func); } - free_func.expect("non-null function pointer")(node as *mut c_void, allocator); + free_func.unwrap()(node as *mut c_void, allocator); } unsafe extern "C" fn index_tree_end( tree: *mut index_tree, @@ -213,13 +213,13 @@ unsafe extern "C" fn index_tree_append(tree: *mut index_tree, mut node: *mut ind } (*(*tree).rightmost).right = node; (*tree).rightmost = node; - let mut up: u32 = (*tree).count ^ (1) << bsr32((*tree).count); + let mut up: u32 = (*tree).count ^ 1 << bsr32((*tree).count); if up != 0 { up = ctz32((*tree).count).wrapping_add(2); loop { node = (*node).parent; up -= 1; - if !(up > 0) { + if up == 0 { break; } } @@ -249,10 +249,10 @@ unsafe extern "C" fn index_tree_next(mut node: *const index_tree_node) -> *mut c while !(*node).parent.is_null() && (*(*node).parent).right == node as *mut index_tree_node { node = (*node).parent; } - return (*node).parent as *mut c_void; + (*node).parent as *mut c_void } unsafe extern "C" fn index_tree_locate(tree: *const index_tree, target: lzma_vli) -> *mut c_void { - let mut result: *const index_tree_node = ::core::ptr::null::(); + let mut result: *const index_tree_node = core::ptr::null(); let mut node: *const index_tree_node = (*tree).root; while !node.is_null() { if (*node).uncompressed_base > target { @@ -262,7 +262,7 @@ unsafe extern "C" fn index_tree_locate(tree: *const index_tree, target: lzma_vli node = (*node).right; } } - return result as *mut c_void; + result as *mut c_void } unsafe extern "C" fn index_stream_init( compressed_base: lzma_vli, @@ -288,7 +288,7 @@ unsafe extern "C" fn index_stream_init( (*s).index_list_size = 0; (*s).stream_flags.version = UINT32_MAX; (*s).stream_padding = 0; - return s; + s } unsafe extern "C" fn index_stream_end(node: *mut c_void, allocator: *const lzma_allocator) { let s: *mut index_stream = node as *mut index_stream; @@ -311,7 +311,7 @@ unsafe extern "C" fn index_init_plain(allocator: *const lzma_allocator) -> *mut (*i).prealloc = INDEX_GROUP_SIZE as size_t; (*i).checks = 0; } - return i; + i } #[no_mangle] pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index { @@ -325,7 +325,7 @@ pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *m return core::ptr::null_mut(); } index_tree_append(&raw mut (*i).streams, &raw mut (*s).node); - return i; + i } #[no_mangle] pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { @@ -365,7 +365,7 @@ pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u6 let streams_mem: u64 = (streams as u64).wrapping_mul(stream_base as u64); let groups_mem: u64 = (groups as u64).wrapping_mul(group_base as u64); let index_base: u64 = - (core::mem::size_of::() as usize).wrapping_add(alloc_overhead as usize) as u64; + (core::mem::size_of::()).wrapping_add(alloc_overhead as usize) as u64; let limit: u64 = (UINT64_MAX).wrapping_sub(index_base); if streams == 0 || streams > UINT32_MAX as lzma_vli @@ -376,38 +376,38 @@ pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u6 { return UINT64_MAX; } - return index_base + index_base .wrapping_add(streams_mem) - .wrapping_add(groups_mem); + .wrapping_add(groups_mem) } #[no_mangle] pub extern "C" fn lzma_index_memused(i: *const lzma_index) -> u64 { - return unsafe { lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count) }; + unsafe { lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count) } } #[no_mangle] pub extern "C" fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli { - return unsafe { (*i).record_count }; + unsafe { (*i).record_count } } #[no_mangle] pub extern "C" fn lzma_index_stream_count(i: *const lzma_index) -> lzma_vli { - return unsafe { (*i).streams.count as lzma_vli }; + unsafe { (*i).streams.count as lzma_vli } } #[no_mangle] pub extern "C" fn lzma_index_size(i: *const lzma_index) -> lzma_vli { - return unsafe { index_size((*i).record_count, (*i).index_list_size) }; + unsafe { index_size((*i).record_count, (*i).index_list_size) } } #[no_mangle] pub extern "C" fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { - return unsafe { (*i).total_size }; + unsafe { (*i).total_size } } #[no_mangle] pub extern "C" fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { - return unsafe { + unsafe { (LZMA_STREAM_HEADER_SIZE as lzma_vli) .wrapping_add((*i).total_size) .wrapping_add(index_size((*i).record_count, (*i).index_list_size)) .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) - }; + } } unsafe extern "C" fn index_file_size( compressed_base: lzma_vli, @@ -427,13 +427,13 @@ unsafe extern "C" fn index_file_size( if file_size > LZMA_VLI_MAX { return LZMA_VLI_UNKNOWN; } - return file_size; + file_size } #[no_mangle] pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli { let s: *const index_stream = (*i).streams.rightmost as *const index_stream; let g: *const index_group = (*s).groups.rightmost as *const index_group; - return index_file_size( + index_file_size( (*s).node.compressed_base, if g.is_null() { 0 @@ -444,11 +444,11 @@ pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli (*s).record_count, (*s).index_list_size, (*s).stream_padding, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { - return (*i).uncompressed_size; + (*i).uncompressed_size } #[no_mangle] pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { @@ -457,12 +457,11 @@ pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { if (*s).stream_flags.version != UINT32_MAX { checks = (checks | 1u32 << (*s).stream_flags.check) as u32; } - return checks; + checks } #[no_mangle] pub unsafe extern "C" fn lzma_index_padding_size(i: *const lzma_index) -> u32 { - return ((4_u64).wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) & 3) - as u32; + ((4_u64).wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) & 3) as u32 } #[no_mangle] pub unsafe extern "C" fn lzma_index_stream_flags( @@ -478,7 +477,7 @@ pub unsafe extern "C" fn lzma_index_stream_flags( } let s: *mut index_stream = (*i).streams.rightmost as *mut index_stream; (*s).stream_flags = *stream_flags; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_index_stream_padding( @@ -496,7 +495,7 @@ pub unsafe extern "C" fn lzma_index_stream_padding( return LZMA_DATA_ERROR; } (*s).stream_padding = stream_padding; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_index_append( @@ -588,7 +587,7 @@ pub unsafe extern "C" fn lzma_index_append( (*i).index_list_size = (*i) .index_list_size .wrapping_add(index_list_size_add as lzma_vli); - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn index_cat_helper(info: *const index_cat_info, this: *mut index_stream) { let left: *mut index_stream = (*this).node.left as *mut index_stream; @@ -653,13 +652,9 @@ pub unsafe extern "C" fn lzma_index_cat( (*newg).allocated = (*g).last.wrapping_add(1); (*newg).last = (*g).last; (*newg).number_base = (*g).number_base; - memcpy( - &raw mut (*newg).records as *mut index_record as *mut c_void, - &raw mut (*g).records as *mut index_record as *const c_void, - (*newg) - .allocated - .wrapping_mul(core::mem::size_of::()), - ); + core::ptr::copy_nonoverlapping(&raw mut (*g).records as *const u8, &raw mut (*newg).records as *mut u8, (*newg) + .allocated + .wrapping_mul(core::mem::size_of::())); if !(*g).node.parent.is_null() { (*(*g).node.parent).right = &raw mut (*newg).node; } @@ -687,7 +682,7 @@ pub unsafe extern "C" fn lzma_index_cat( (*dest).index_list_size = (*dest).index_list_size.wrapping_add((*src).index_list_size); (*dest).checks |= (*src).checks; lzma_free(src as *mut c_void, allocator); - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn index_dup_stream( src: *const index_stream, @@ -733,14 +728,10 @@ unsafe extern "C" fn index_dup_stream( let mut srcg: *const index_group = (*src).groups.leftmost as *const index_group; let mut i: size_t = 0; loop { - memcpy( - (&raw mut (*destg).records as *mut index_record).offset(i as isize) as *mut c_void, - &raw const (*srcg).records as *const index_record as *const c_void, - (*srcg) - .last - .wrapping_add(1) - .wrapping_mul(core::mem::size_of::()), - ); + core::ptr::copy_nonoverlapping(&raw const (*srcg).records as *const u8, (&raw mut (*destg).records as *mut index_record).offset(i as isize) as *mut u8, (*srcg) + .last + .wrapping_add(1) + .wrapping_mul(core::mem::size_of::())); i = i.wrapping_add((*srcg).last.wrapping_add(1)); srcg = index_tree_next(&raw const (*srcg).node) as *const index_group; if srcg.is_null() { @@ -748,7 +739,7 @@ unsafe extern "C" fn index_dup_stream( } } index_tree_append(&raw mut (*dest).groups, &raw mut (*destg).node); - return dest; + dest } #[no_mangle] pub unsafe extern "C" fn lzma_index_dup( @@ -776,7 +767,7 @@ pub unsafe extern "C" fn lzma_index_dup( break; } } - return dest; + dest } unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { let i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; @@ -795,14 +786,14 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { (*iter).internal[ITER_GROUP as usize].p = (*group).node.parent as *const c_void; } else { (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_LEFTMOST as size_t; - (*iter).internal[ITER_GROUP as usize].p = ::core::ptr::null::(); + (*iter).internal[ITER_GROUP as usize].p = core::ptr::null(); } (*iter).stream.number = (*stream).number as lzma_vli; (*iter).stream.block_count = (*stream).record_count; (*iter).stream.compressed_offset = (*stream).node.compressed_base; (*iter).stream.uncompressed_offset = (*stream).node.uncompressed_base; (*iter).stream.flags = if (*stream).stream_flags.version == UINT32_MAX { - ::core::ptr::null::() + core::ptr::null() } else { &raw const (*stream).stream_flags }; @@ -878,8 +869,8 @@ pub unsafe extern "C" fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *co } #[no_mangle] pub unsafe extern "C" fn lzma_index_iter_rewind(iter: *mut lzma_index_iter) { - (*iter).internal[ITER_STREAM as usize].p = ::core::ptr::null::(); - (*iter).internal[ITER_GROUP as usize].p = ::core::ptr::null::(); + (*iter).internal[ITER_STREAM as usize].p = core::ptr::null(); + (*iter).internal[ITER_GROUP as usize].p = core::ptr::null(); (*iter).internal[ITER_RECORD as usize].s = 0; (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NORMAL as size_t; } @@ -894,7 +885,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( let i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; let mut stream: *const index_stream = (*iter).internal[ITER_STREAM as usize].p as *const index_stream; - let mut group: *const index_group = ::core::ptr::null::(); + let mut group: *const index_group = core::ptr::null(); let mut record: size_t = (*iter).internal[ITER_RECORD as usize].s; if mode != LZMA_INDEX_ITER_STREAM { match (*iter).internal[ITER_METHOD as usize].s { @@ -938,28 +929,28 @@ pub unsafe extern "C" fn lzma_index_iter_next( if stream.is_null() { return true as lzma_bool; } - if !(mode >= LZMA_INDEX_ITER_BLOCK && (*stream).groups.leftmost.is_null()) { + if mode < LZMA_INDEX_ITER_BLOCK || !(*stream).groups.leftmost.is_null() { break; } } group = (*stream).groups.leftmost as *const index_group; } } - if !(mode == LZMA_INDEX_ITER_NONEMPTY_BLOCK) { + if mode != LZMA_INDEX_ITER_NONEMPTY_BLOCK { break; } if record == 0 { - if !((*group).node.uncompressed_base - == (*(&raw const (*group).records as *const index_record).offset(0)) - .uncompressed_sum) + if (*group).node.uncompressed_base + != (*(&raw const (*group).records as *const index_record)) + .uncompressed_sum { break; } - } else if !((*(&raw const (*group).records as *const index_record) + } else if (*(&raw const (*group).records as *const index_record) .offset(record.wrapping_sub(1) as isize)) .uncompressed_sum - == (*(&raw const (*group).records as *const index_record).offset(record as isize)) - .uncompressed_sum) + != (*(&raw const (*group).records as *const index_record).offset(record as isize)) + .uncompressed_sum { break; } @@ -968,7 +959,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( (*iter).internal[ITER_GROUP as usize].p = group as *const c_void; (*iter).internal[ITER_RECORD as usize].s = record; iter_set_info(iter); - return false as lzma_bool; + false as lzma_bool } #[no_mangle] pub unsafe extern "C" fn lzma_index_iter_locate( @@ -1001,5 +992,5 @@ pub unsafe extern "C" fn lzma_index_iter_locate( (*iter).internal[ITER_GROUP as usize].p = group as *const c_void; (*iter).internal[ITER_RECORD as usize].s = left; iter_set_info(iter); - return false as lzma_bool; + false as lzma_bool } diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index bb43452b..09c854c2 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -72,9 +72,9 @@ unsafe extern "C" fn index_decode( while *in_pos < in_size { match (*coder).sequence { 0 => { - let fresh0 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) != INDEX_INDICATOR { + let byte = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if byte != INDEX_INDICATOR { return LZMA_DATA_ERROR; } (*coder).sequence = SEQ_COUNT; @@ -153,9 +153,9 @@ unsafe extern "C" fn index_decode( 8340016495055110192 => { if (*coder).pos > 0 { (*coder).pos = (*coder).pos.wrapping_sub(1); - let fresh1 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh1 as isize) != 0 { + let byte = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if byte != 0 { return LZMA_DATA_ERROR; } continue; @@ -189,15 +189,13 @@ unsafe extern "C" fn index_decode( if *in_pos == in_size { return LZMA_OK; } - let fresh2 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - if (*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff - != *in_0.offset(fresh2 as isize) as u32 - { + let val = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if (*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff != val as u32 { return LZMA_DATA_ERROR; } (*coder).pos = (*coder).pos.wrapping_add(1); - if !((*coder).pos < 4) { + if (*coder).pos >= 4 { break; } } @@ -209,7 +207,7 @@ unsafe extern "C" fn index_decode( if in_used > 0 { (*coder).crc32 = lzma_crc32(in_0.offset(in_start as isize), in_used, (*coder).crc32); } - return ret; + ret } unsafe extern "C" fn index_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; @@ -231,7 +229,7 @@ unsafe extern "C" fn index_decoder_memconfig( } (*coder).memlimit = new_memlimit; } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn index_decoder_reset( coder: *mut lzma_index_coder, @@ -250,7 +248,7 @@ unsafe extern "C" fn index_decoder_reset( (*coder).count = 0; (*coder).pos = 0; (*coder).crc32 = 0; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_index_decoder_init( @@ -259,7 +257,7 @@ pub unsafe extern "C" fn lzma_index_decoder_init( i: *mut *mut lzma_index, memlimit: u64, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -281,7 +279,7 @@ pub unsafe extern "C" fn lzma_index_decoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -324,20 +322,16 @@ pub unsafe extern "C" fn lzma_index_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( index_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; - (*next).memconfig = Some( - index_decoder_memconfig - as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; + ); + (*next).memconfig = Some(index_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); (*coder).index = core::ptr::null_mut(); } else { lzma_index_end((*coder).index, allocator); } - return index_decoder_reset(coder, allocator, i, memlimit); + index_decoder_reset(coder, allocator, i, memlimit) } #[no_mangle] pub unsafe extern "C" fn lzma_index_decoder( @@ -364,7 +358,7 @@ pub unsafe extern "C" fn lzma_index_decoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_index_buffer_decode( @@ -420,5 +414,5 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( *memlimit = lzma_index_memusage(1, coder.count); } } - return ret; + ret } diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index ecde36a8..10dafaab 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -150,9 +150,8 @@ unsafe extern "C" fn index_encode( 5 => { if (*coder).pos > 0 { (*coder).pos = (*coder).pos.wrapping_sub(1); - let fresh0 = *out_pos; - *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0; + *out.offset(*out_pos as isize) = 0; + *out_pos += 1; continue; } else { (*coder).crc32 = lzma_crc32( @@ -193,7 +192,7 @@ unsafe extern "C" fn index_encode( ((*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff) as u8; *out_pos = (*out_pos).wrapping_add(1); (*coder).pos = (*coder).pos.wrapping_add(1); - if !((*coder).pos < 4) { + if (*coder).pos >= 4 { break; } } @@ -205,7 +204,7 @@ unsafe extern "C" fn index_encode( if out_used > 0 { (*coder).crc32 = lzma_crc32(out.offset(out_start as isize), out_used, (*coder).crc32); } - return ret; + ret } unsafe extern "C" fn index_encoder_end(coder: *mut c_void, allocator: *const lzma_allocator) { lzma_free(coder, allocator); @@ -223,7 +222,7 @@ pub unsafe extern "C" fn lzma_index_encoder_init( allocator: *const lzma_allocator, i: *const lzma_index, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -243,7 +242,7 @@ pub unsafe extern "C" fn lzma_index_encoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -281,13 +280,13 @@ pub unsafe extern "C" fn lzma_index_encoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( index_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); } index_encoder_reset((*next).coder as *mut lzma_index_coder, i); - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_index_encoder( @@ -306,7 +305,7 @@ pub unsafe extern "C" fn lzma_index_encoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_index_buffer_encode( @@ -323,13 +322,13 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( } let mut coder: lzma_index_coder = lzma_index_coder { sequence: SEQ_INDICATOR, - index: ::core::ptr::null::(), + index: core::ptr::null(), iter: lzma_index_iter { stream: C2RustUnnamed_2 { - flags: ::core::ptr::null::(), - reserved_ptr1: ::core::ptr::null::(), - reserved_ptr2: ::core::ptr::null::(), - reserved_ptr3: ::core::ptr::null::(), + flags: core::ptr::null(), + reserved_ptr1: core::ptr::null(), + reserved_ptr2: core::ptr::null(), + reserved_ptr3: core::ptr::null(), number: 0, block_count: 0, compressed_offset: 0, @@ -356,13 +355,13 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( reserved_vli2: 0, reserved_vli3: 0, reserved_vli4: 0, - reserved_ptr1: ::core::ptr::null::(), - reserved_ptr2: ::core::ptr::null::(), - reserved_ptr3: ::core::ptr::null::(), - reserved_ptr4: ::core::ptr::null::(), + reserved_ptr1: core::ptr::null(), + reserved_ptr2: core::ptr::null(), + reserved_ptr3: core::ptr::null(), + reserved_ptr4: core::ptr::null(), }, internal: [C2RustUnnamed_0 { - p: ::core::ptr::null::(), + p: core::ptr::null(), }; 6], }, pos: 0, @@ -372,8 +371,8 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( let out_start: size_t = *out_pos; let mut ret: lzma_ret = index_encode( &raw mut coder as *mut c_void, - ::core::ptr::null::(), - ::core::ptr::null::(), + core::ptr::null(), + core::ptr::null(), core::ptr::null_mut(), 0, out, @@ -387,5 +386,5 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( *out_pos = out_start; ret = LZMA_PROG_ERROR; } - return ret; + ret } diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index f8b31c24..b3495094 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -55,17 +55,17 @@ pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; pub const INDEX_INDICATOR: u8 = 0; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - return vli.wrapping_add(3) & !(3); + vli.wrapping_add(3) & !(3) } #[inline] extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - return (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) + (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) .wrapping_add(index_list_size) - .wrapping_add(4); + .wrapping_add(4) } #[inline] extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - return vli_ceil4(index_size_unpadded(count, index_list_size)); + vli_ceil4(index_size_unpadded(count, index_list_size)) } #[inline] extern "C" fn index_stream_size( @@ -73,10 +73,10 @@ extern "C" fn index_stream_size( count: lzma_vli, index_list_size: lzma_vli, ) -> lzma_vli { - return (LZMA_STREAM_HEADER_SIZE as lzma_vli) + (LZMA_STREAM_HEADER_SIZE as lzma_vli) .wrapping_add(blocks_size) .wrapping_add(index_size(count, index_list_size)) - .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli); + .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) } #[no_mangle] pub unsafe extern "C" fn lzma_index_hash_init( @@ -105,7 +105,7 @@ pub unsafe extern "C" fn lzma_index_hash_init( (*index_hash).crc32 = 0; lzma_check_init(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); lzma_check_init(&raw mut (*index_hash).records.check, LZMA_CHECK_SHA256); - return index_hash; + index_hash } #[no_mangle] pub unsafe extern "C" fn lzma_index_hash_end( @@ -116,12 +116,12 @@ pub unsafe extern "C" fn lzma_index_hash_end( } #[no_mangle] pub extern "C" fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { - return unsafe { + unsafe { index_size( (*index_hash).blocks.count, (*index_hash).blocks.index_list_size, ) - }; + } } unsafe extern "C" fn hash_append( info: *mut lzma_index_hash_info, @@ -175,7 +175,7 @@ pub unsafe extern "C" fn lzma_index_hash_append( { return LZMA_DATA_ERROR; } - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_index_hash_decode( @@ -193,9 +193,9 @@ pub unsafe extern "C" fn lzma_index_hash_decode( while *in_pos < in_size { match (*index_hash).sequence { 0 => { - let fresh0 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh0 as isize) != INDEX_INDICATOR { + let byte = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if byte != INDEX_INDICATOR { return LZMA_DATA_ERROR; } (*index_hash).sequence = SEQ_COUNT; @@ -286,9 +286,9 @@ pub unsafe extern "C" fn lzma_index_hash_decode( 12753679906265593574 => { if (*index_hash).pos > 0 { (*index_hash).pos = (*index_hash).pos.wrapping_sub(1); - let fresh1 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - if *in_0.offset(fresh1 as isize) != 0 { + let byte = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if byte != 0 { return LZMA_DATA_ERROR; } continue; @@ -304,9 +304,8 @@ pub unsafe extern "C" fn lzma_index_hash_decode( lzma_check_finish(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); lzma_check_finish(&raw mut (*index_hash).records.check, LZMA_CHECK_SHA256); if memcmp( - &raw mut (*index_hash).blocks.check.buffer.u8_0 as *mut u8 as *const c_void, - &raw mut (*index_hash).records.check.buffer.u8_0 as *mut u8 - as *const c_void, + &raw mut (*index_hash).blocks.check.buffer.u8_0 as *const c_void, + &raw mut (*index_hash).records.check.buffer.u8_0 as *const c_void, lzma_check_size(LZMA_CHECK_SHA256) as size_t, ) != 0 { @@ -326,15 +325,13 @@ pub unsafe extern "C" fn lzma_index_hash_decode( if *in_pos == in_size { return LZMA_OK; } - let fresh2 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8) & 0xff - != *in_0.offset(fresh2 as isize) as u32 - { + let val = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8) & 0xff != val as u32 { return LZMA_DATA_ERROR; } (*index_hash).pos = (*index_hash).pos.wrapping_add(1); - if !((*index_hash).pos < 4) { + if (*index_hash).pos >= 4 { break; } } @@ -345,5 +342,5 @@ pub unsafe extern "C" fn lzma_index_hash_decode( (*index_hash).crc32 = lzma_crc32(in_0.offset(in_start as isize), in_used, (*index_hash).crc32); } - return ret; + ret } diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index b8da4c7e..413f5c11 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -54,7 +54,7 @@ pub const SEQ_ID_STRING: C2RustUnnamed_0 = 0; #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { - let mut num: u32 = *buf.offset(0) as u32; + let mut num: u32 = *buf as u32; num |= (*buf.offset(1) as u32) << 8; num |= (*buf.offset(2) as u32) << 16; num |= (*buf.offset(3) as u32) << 24; @@ -64,7 +64,7 @@ extern "C" fn read32le(buf: *const u8) -> u32 { #[inline] extern "C" fn read64le(buf: *const u8) -> u64 { return unsafe { - let mut num: u64 = *buf.offset(0) as u64; + let mut num: u64 = *buf as u64; num |= (*buf.offset(1) as u64) << 8; num |= (*buf.offset(2) as u64) << 16; num |= (*buf.offset(3) as u64) << 24; @@ -97,7 +97,7 @@ unsafe extern "C" fn lzip_decode( match (*coder).sequence { 0 => { let lzip_id_string: [u8; 4] = [0x4c as u8, 0x5a as u8, 0x49 as u8, 0x50 as u8]; - while (*coder).pos < core::mem::size_of::<[u8; 4]>() as usize { + while (*coder).pos < core::mem::size_of::<[u8; 4]>() { if *in_pos >= in_size { return if !(*coder).first_member && action == LZMA_FINISH { LZMA_STREAM_END @@ -144,9 +144,8 @@ unsafe extern "C" fn lzip_decode( if *in_pos >= in_size { return LZMA_OK; } - let fresh0 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - (*coder).version = *in_0.offset(fresh0 as isize) as u32; + (*coder).version = *in_0.offset(*in_pos as isize) as u32; + *in_pos += 1; if (*coder).version > 1 { return LZMA_OPTIONS_ERROR; } @@ -164,9 +163,8 @@ unsafe extern "C" fn lzip_decode( if *in_pos >= in_size { return LZMA_OK; } - let fresh1 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - let ds: u32 = *in_0.offset(fresh1 as isize) as u32; + let ds: u32 = *in_0.offset(*in_pos as isize) as u32; + *in_pos += 1; (*coder).member_size = (*coder).member_size.wrapping_add(1); let b2log: u32 = ds & 0x1f; let fracnum: u32 = ds >> 5; @@ -175,7 +173,7 @@ unsafe extern "C" fn lzip_decode( } (*coder).options.dict_size = (1u32 << b2log).wrapping_sub(fracnum << b2log.wrapping_sub(4)); - (*coder).options.preset_dict = ::core::ptr::null::(); + (*coder).options.preset_dict = core::ptr::null(); (*coder).options.lc = LZIP_LC; (*coder).options.lp = LZIP_LP; (*coder).options.pb = LZIP_PB; @@ -230,10 +228,7 @@ unsafe extern "C" fn lzip_decode( 13394712405657322686 => { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - let ret: lzma_ret = (*coder) - .lzma_decoder - .code - .expect("non-null function pointer")( + let ret: lzma_ret = (*coder).lzma_decoder.code.unwrap()( (*coder).lzma_decoder.coder, allocator, in_0, @@ -281,7 +276,7 @@ unsafe extern "C" fn lzip_decode( (*coder).member_size = (*coder).member_size.wrapping_add(footer_size as u64); if !(*coder).ignore_check && (*coder).crc32 - != read32le((&raw mut (*coder).buffer as *mut u8).offset(0) as *mut u8) + != read32le((&raw mut (*coder).buffer as *mut u8) as *mut u8) { return LZMA_DATA_ERROR; } @@ -310,7 +305,7 @@ unsafe extern "C" fn lzip_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_free(coder as *mut c_void, allocator); } extern "C" fn lzip_decoder_get_check(_coder_ptr: *const c_void) -> lzma_check { - return LZMA_CHECK_CRC32; + LZMA_CHECK_CRC32 } unsafe extern "C" fn lzip_decoder_memconfig( coder_ptr: *mut c_void, @@ -327,7 +322,7 @@ unsafe extern "C" fn lzip_decoder_memconfig( } (*coder).memlimit = new_memlimit; } - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_lzip_decoder_init( @@ -336,7 +331,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( memlimit: u64, flags: u32, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, >, @@ -353,7 +348,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, >, @@ -391,18 +386,13 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( lzip_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*next).get_check = - Some(lzip_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check) - as Option lzma_check>; - (*next).memconfig = Some( - lzip_decoder_memconfig - as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; + Some(lzip_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check); + (*next).memconfig = Some(lzip_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); (*coder).lzma_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -424,7 +414,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0; (*coder).first_member = true; (*coder).pos = 0; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_lzip_decoder( @@ -448,5 +438,5 @@ pub unsafe extern "C" fn lzma_lzip_decoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index 01567844..629fdf45 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -54,14 +54,14 @@ unsafe extern "C" fn microlzma_decode( } let mut options: lzma_options_lzma = lzma_options_lzma { dict_size: (*coder).dict_size, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, lc: 0, lp: 0, pb: 0, - mode: 0 as lzma_mode, + mode: 0, nice_len: 0, - mf: 0 as lzma_match_finder, + mf: 0, depth: 0, ext_flags: 0, ext_size_low: UINT32_MAX, @@ -115,7 +115,7 @@ unsafe extern "C" fn microlzma_decode( } let dummy_in: u8 = 0; let mut dummy_in_pos: size_t = 0; - if (*coder).lzma.code.expect("non-null function pointer")( + if (*coder).lzma.code.unwrap()( (*coder).lzma.coder, allocator, &raw const dummy_in, @@ -131,7 +131,7 @@ unsafe extern "C" fn microlzma_decode( } (*coder).props_decoded = true; } - let mut ret: lzma_ret = (*coder).lzma.code.expect("non-null function pointer")( + let mut ret: lzma_ret = (*coder).lzma.code.unwrap()( (*coder).lzma.coder, allocator, in_0, @@ -159,7 +159,7 @@ unsafe extern "C" fn microlzma_decode( ret = LZMA_STREAM_END; } } - return ret; + ret } unsafe extern "C" fn microlzma_decoder_end( coder_ptr: *mut c_void, @@ -177,7 +177,7 @@ unsafe extern "C" fn microlzma_decoder_init( uncomp_size_is_exact: bool, dict_size: u32, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -203,7 +203,7 @@ unsafe extern "C" fn microlzma_decoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -247,10 +247,10 @@ unsafe extern "C" fn microlzma_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( microlzma_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*coder).lzma = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -272,7 +272,7 @@ unsafe extern "C" fn microlzma_decoder_init( (*coder).uncomp_size_is_exact = uncomp_size_is_exact; (*coder).dict_size = dict_size; (*coder).props_decoded = false; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_microlzma_decoder( @@ -300,5 +300,5 @@ pub unsafe extern "C" fn lzma_microlzma_decoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index e2e105c2..d5b3d0ca 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -37,10 +37,7 @@ unsafe extern "C" fn microlzma_encode( let out_start: size_t = *out_pos; let in_start: size_t = *in_pos; let mut uncomp_size: u64 = 0; - if (*coder) - .lzma - .set_out_limit - .expect("non-null function pointer")( + if (*coder).lzma.set_out_limit.unwrap()( (*coder).lzma.coder, &raw mut uncomp_size, out_size.wrapping_sub(*out_pos) as u64, @@ -48,7 +45,7 @@ unsafe extern "C" fn microlzma_encode( { return LZMA_PROG_ERROR; } - let ret: lzma_ret = (*coder).lzma.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).lzma.code.unwrap()( (*coder).lzma.coder, allocator, in_0, @@ -67,7 +64,7 @@ unsafe extern "C" fn microlzma_encode( } *out.offset(out_start as isize) = !(*coder).props; *in_pos = in_start.wrapping_add(uncomp_size as size_t); - return ret; + ret } unsafe extern "C" fn microlzma_encoder_end( coder_ptr: *mut c_void, @@ -82,7 +79,7 @@ unsafe extern "C" fn microlzma_encoder_init( allocator: *const lzma_allocator, options: *const lzma_options_lzma, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -102,7 +99,7 @@ unsafe extern "C" fn microlzma_encoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -140,10 +137,10 @@ unsafe extern "C" fn microlzma_encoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( microlzma_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*coder).lzma = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -179,11 +176,11 @@ unsafe extern "C" fn microlzma_encoder_init( options: core::ptr::null_mut(), }, ]; - return lzma_next_filter_init( + lzma_next_filter_init( &raw mut (*coder).lzma, allocator, &raw const filters as *const lzma_filter_info, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_microlzma_encoder( @@ -204,5 +201,5 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( return ret__0; } (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index bd4b3f7d..d3cc8f51 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -15,7 +15,7 @@ pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const LZMA_THREADS_MAX: u32 = 16384; #[inline] extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { - return (core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; + (core::mem::size_of::()).wrapping_add(buf_size as usize) as u64 } #[no_mangle] pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { @@ -25,8 +25,8 @@ pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { if threads > LZMA_THREADS_MAX || buf_size_max > limit { return UINT64_MAX; } - return ((2u32).wrapping_mul(threads) as u64) - .wrapping_mul(lzma_outq_outbuf_memusage(buf_size_max as size_t)); + ((2u32).wrapping_mul(threads) as u64) + .wrapping_mul(lzma_outq_outbuf_memusage(buf_size_max as size_t)) } unsafe extern "C" fn move_head_to_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator) { let buf: *mut lzma_outbuf = (*outq).head; @@ -99,7 +99,7 @@ pub unsafe extern "C" fn lzma_outq_init( } (*outq).bufs_limit = bufs_limit; (*outq).read_pos = 0; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator) { @@ -117,7 +117,7 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( if !(*outq).cache.is_null() && (*(*outq).cache).allocated == size { return LZMA_OK; } - if size > (SIZE_MAX as usize).wrapping_sub(core::mem::size_of::() as usize) { + if size > (SIZE_MAX as usize).wrapping_sub(core::mem::size_of::()) { return LZMA_MEM_ERROR; } let alloc_size: size_t = lzma_outq_outbuf_memusage(size) as size_t; @@ -130,7 +130,7 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( (*(*outq).cache).allocated = size; (*outq).bufs_allocated = (*outq).bufs_allocated.wrapping_add(1); (*outq).mem_allocated = (*outq).mem_allocated.wrapping_add(alloc_size as u64); - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_outq_get_buf( @@ -157,14 +157,14 @@ pub unsafe extern "C" fn lzma_outq_get_buf( (*outq).mem_in_use = (*outq) .mem_in_use .wrapping_add(lzma_outq_outbuf_memusage((*buf).allocated)); - return buf; + buf } #[no_mangle] pub unsafe extern "C" fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool { if (*outq).head.is_null() { return false; } - return (*outq).read_pos < (*(*outq).head).pos || (*(*outq).head).finished; + (*outq).read_pos < (*(*outq).head).pos || (*(*outq).head).finished } #[no_mangle] pub unsafe extern "C" fn lzma_outq_read( @@ -200,7 +200,7 @@ pub unsafe extern "C" fn lzma_outq_read( let finish_ret: lzma_ret = (*buf).finish_ret; move_head_to_cache(outq, allocator); (*outq).read_pos = 0; - return finish_ret; + finish_ret } #[no_mangle] pub unsafe extern "C" fn lzma_outq_enable_partial_output( @@ -208,7 +208,7 @@ pub unsafe extern "C" fn lzma_outq_enable_partial_output( enable_partial_output: Option ()>, ) { if !(*outq).head.is_null() && !(*(*outq).head).finished && !(*(*outq).head).worker.is_null() { - enable_partial_output.expect("non-null function pointer")((*(*outq).head).worker); + enable_partial_output.unwrap()((*(*outq).head).worker); (*(*outq).head).worker = core::ptr::null_mut(); } } diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index cff292b0..4b8ff342 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -51,7 +51,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( if ret == LZMA_OK { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - ret = stream_decoder.code.expect("non-null function pointer")( + ret = stream_decoder.code.unwrap()( stream_decoder.coder, allocator, in_0, @@ -75,7 +75,7 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( } } else if ret == LZMA_MEMLIMIT_ERROR { let mut memusage: u64 = 0; - stream_decoder.memconfig.expect("non-null function pointer")( + stream_decoder.memconfig.unwrap()( stream_decoder.coder, memlimit, &raw mut memusage, @@ -85,5 +85,5 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( } } lzma_next_end(&raw mut stream_decoder, allocator); - return ret; + ret } diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 5eb904e2..2d5c890a 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -49,7 +49,7 @@ pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t if stream_bound_max.wrapping_sub(block_bound) < HEADERS_BOUND as size_t { return 0; } - return block_bound.wrapping_add(HEADERS_BOUND as size_t); + block_bound.wrapping_add(HEADERS_BOUND as size_t) } #[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_encode( @@ -174,5 +174,5 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( } out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); *out_pos_ptr = out_pos; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index d6318b6c..edff061b 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -93,7 +93,7 @@ unsafe extern "C" fn stream_decoder_reset( } (*coder).sequence = SEQ_STREAM_HEADER; (*coder).pos = 0; - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn stream_decode( coder_ptr: *mut c_void, @@ -353,10 +353,7 @@ unsafe extern "C" fn stream_decode( } match current_block_100 { 721385680381463314 => { - let ret_1: lzma_ret = (*coder) - .block_decoder - .code - .expect("non-null function pointer")( + let ret_1: lzma_ret = (*coder).block_decoder.code.unwrap()( (*coder).block_decoder.coder, allocator, in_0, @@ -411,7 +408,7 @@ unsafe extern "C" fn stream_decoder_memconfig( } (*coder).memlimit = new_memlimit; } - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder_init( @@ -420,7 +417,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( memlimit: u64, flags: u32, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, >, @@ -437,7 +434,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn(*mut lzma_next_coder, *const lzma_allocator, u64, u32) -> lzma_ret, >, @@ -475,18 +472,13 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( stream_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*next).get_check = - Some(stream_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check) - as Option lzma_check>; - (*next).memconfig = Some( - stream_decoder_memconfig - as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; + Some(stream_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check); + (*next).memconfig = Some(stream_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); (*coder).block_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -509,7 +501,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( (*coder).ignore_check = flags & LZMA_IGNORE_CHECK as u32 != 0; (*coder).concatenated = flags & LZMA_CONCATENATED as u32 != 0; (*coder).first_stream = true; - return stream_decoder_reset(coder, allocator); + stream_decoder_reset(coder, allocator) } #[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder( @@ -533,5 +525,5 @@ pub unsafe extern "C" fn lzma_stream_decoder( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index b02c8787..5439ad91 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -311,26 +311,26 @@ extern "C" fn mythread_create( let ret: c_int = unsafe { pthread_create( thread as *mut pthread_t, - ::core::ptr::null::(), + core::ptr::null(), func as Option *mut c_void>, arg as *mut c_void, ) }; mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); - return ret; + ret } #[inline] extern "C" fn mythread_join(thread: mythread) -> c_int { - return unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) }; + unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) } } #[inline] extern "C" fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { - return unsafe { + unsafe { pthread_mutex_init( mutex as *mut pthread_mutex_t, - ::core::ptr::null::(), + core::ptr::null(), ) - }; + } } #[inline] extern "C" fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { @@ -350,7 +350,7 @@ extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { (*mycond).clk_id = _CLOCK_REALTIME; pthread_cond_init( &raw mut (*mycond).cond, - ::core::ptr::null::(), + core::ptr::null(), ) }; } @@ -380,7 +380,7 @@ extern "C" fn mythread_cond_timedwait( condtime as *const timespec, ) }; - return ret; + ret } #[inline] extern "C" fn mythread_condtime_set( @@ -408,19 +408,19 @@ pub const LZMA_THREADS_MAX: u32 = 16384; pub const INDEX_INDICATOR: u8 = 0; #[inline] extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - return vli.wrapping_add(3) & !(3); + vli.wrapping_add(3) & !(3) } #[inline] extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { - return unsafe { (*outq).bufs_in_use < (*outq).bufs_limit }; + unsafe { (*outq).bufs_in_use < (*outq).bufs_limit } } #[inline] extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { - return unsafe { (*outq).bufs_in_use == 0 }; + unsafe { (*outq).bufs_in_use == 0 } } #[inline] extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { - return (core::mem::size_of::() as usize).wrapping_add(buf_size as usize) as u64; + (core::mem::size_of::()).wrapping_add(buf_size as usize) as u64 } unsafe extern "C" fn worker_enable_partial_update(thr_ptr: *mut c_void) { let thr: *mut worker_thread = thr_ptr as *mut worker_thread; @@ -465,8 +465,8 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { (*thr).progress_out = (*thr).out_pos; in_filled = (*thr).in_filled; partial_update_enabled = (*thr).partial_update_enabled; - if !(in_filled == (*thr).in_pos - && !(partial_update_enabled && !(*thr).partial_update_started)) + if in_filled != (*thr).in_pos + || (partial_update_enabled && !(*thr).partial_update_started) { break; } @@ -478,10 +478,7 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { if in_filled.wrapping_sub((*thr).in_pos) > chunk_size { in_filled = (*thr).in_pos.wrapping_add(chunk_size); } - ret = (*thr) - .block_decoder - .code - .expect("non-null function pointer")( + ret = (*thr).block_decoder.code.unwrap()( (*thr).block_decoder.coder, (*thr).allocator, (*thr).in_0, @@ -659,8 +656,8 @@ unsafe extern "C" fn initialize_new_thread( .threads .offset((*coder).threads_initialized as isize) as *mut worker_thread; - if !(mythread_mutex_init(&raw mut (*thr).mutex) != 0) { - if !(mythread_cond_init(&raw mut (*thr).cond) != 0) { + if mythread_mutex_init(&raw mut (*thr).mutex) == 0 { + if mythread_cond_init(&raw mut (*thr).cond) == 0 { (*thr).state = THR_IDLE; (*thr).in_0 = core::ptr::null_mut(); (*thr).in_size = 0; @@ -695,7 +692,7 @@ unsafe extern "C" fn initialize_new_thread( } mythread_mutex_destroy(&raw mut (*thr).mutex); } - return LZMA_MEM_ERROR; + LZMA_MEM_ERROR } unsafe extern "C" fn get_thread( coder: *mut lzma_stream_coder, @@ -736,7 +733,7 @@ unsafe extern "C" fn get_thread( (*(*coder).thr).progress_out = 0; (*(*coder).thr).partial_update_enabled = false; (*(*coder).thr).partial_update_started = false; - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn read_output_and_wait( coder: *mut lzma_stream_coder, @@ -782,7 +779,7 @@ unsafe extern "C" fn read_output_and_wait( ), ); } - if !(ret == LZMA_STREAM_END) { + if ret != LZMA_STREAM_END { break; } } @@ -848,7 +845,7 @@ unsafe extern "C" fn read_output_and_wait( } else { mythread_cond_wait(&raw mut (*coder).cond, &raw mut (*coder).mutex); } - if !(ret == LZMA_OK) { + if ret != LZMA_OK { break; } } @@ -860,7 +857,7 @@ unsafe extern "C" fn read_output_and_wait( if ret != LZMA_OK && ret != LZMA_RET_INTERNAL1 { threads_stop(coder); } - return ret; + ret } unsafe extern "C" fn decode_block_header( coder: *mut lzma_stream_coder, @@ -903,17 +900,17 @@ unsafe extern "C" fn decode_block_header( return ret_; } (*coder).block_options.ignore_check = (*coder).ignore_check as lzma_bool; - return LZMA_STREAM_END; + LZMA_STREAM_END } extern "C" fn comp_blk_size(coder: *const lzma_stream_coder) -> size_t { - return unsafe { + unsafe { vli_ceil4((*coder).block_options.compressed_size) .wrapping_add(lzma_check_size((*coder).stream_flags.check) as lzma_vli) as size_t - }; + } } extern "C" fn is_direct_mode_needed(size: lzma_vli) -> bool { - return size == LZMA_VLI_UNKNOWN || size > SIZE_MAX.wrapping_div(3 as c_ulong) as lzma_vli; + size == LZMA_VLI_UNKNOWN || size > SIZE_MAX.wrapping_div(3 as c_ulong) as lzma_vli } unsafe extern "C" fn stream_decoder_reset( coder: *mut lzma_stream_coder, @@ -925,7 +922,7 @@ unsafe extern "C" fn stream_decoder_reset( } (*coder).sequence = SEQ_STREAM_HEADER; (*coder).pos = 0; - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn stream_decode_mt( coder_ptr: *mut c_void, @@ -1101,10 +1098,7 @@ unsafe extern "C" fn stream_decode_mt( 7173345243791314703 => { let in_old_1: size_t = *in_pos; let out_old: size_t = *out_pos; - let ret_4: lzma_ret = (*coder) - .block_decoder - .code - .expect("non-null function pointer")( + let ret_4: lzma_ret = (*coder).block_decoder.code.unwrap()( (*coder).block_decoder.coder, allocator, in_0, @@ -1660,7 +1654,7 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( } (*coder).memlimit_stop = new_memlimit; } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn stream_decoder_mt_get_progress( coder_ptr: *mut c_void, @@ -1723,7 +1717,7 @@ unsafe extern "C" fn stream_decoder_mt_init( if (*options).flags & !(LZMA_SUPPORTED_FLAGS as u32) != 0 { return LZMA_OPTIONS_ERROR; } - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -1743,7 +1737,7 @@ unsafe extern "C" fn stream_decoder_mt_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -1790,29 +1784,16 @@ unsafe extern "C" fn stream_decoder_mt_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( stream_decoder_mt_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*next).get_check = - Some(stream_decoder_mt_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check) - as Option lzma_check>; - (*next).memconfig = Some( - stream_decoder_mt_memconfig - as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; - (*next).get_progress = Some( - stream_decoder_mt_get_progress - as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> (), - ) - as Option ()>; + Some(stream_decoder_mt_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check); + (*next).memconfig = Some(stream_decoder_mt_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); + (*next).get_progress = Some(stream_decoder_mt_get_progress as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> ()); (*coder).filters[0].id = LZMA_VLI_UNKNOWN; - memset( - &raw mut (*coder).outq as *mut c_void, - 0, - core::mem::size_of::(), - ); + core::ptr::write_bytes(&raw mut (*coder).outq as *mut u8, 0 as u8, core::mem::size_of::()); (*coder).block_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -1870,7 +1851,7 @@ unsafe extern "C" fn stream_decoder_mt_init( if ret_ != LZMA_OK { return ret_; } - return stream_decoder_reset(coder, allocator); + stream_decoder_reset(coder, allocator) } #[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder_mt( @@ -1892,5 +1873,5 @@ pub unsafe extern "C" fn lzma_stream_decoder_mt( } (*(*strm).internal).supported_actions[LZMA_RUN as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 5a1b0ed8..6b41f468 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -79,11 +79,11 @@ unsafe extern "C" fn block_encoder_init( if ret_ != LZMA_OK { return ret_; } - return lzma_block_encoder_init( + lzma_block_encoder_init( &raw mut (*coder).block_encoder, allocator, &raw mut (*coder).block_options, - ); + ) } unsafe extern "C" fn stream_encode( coder_ptr: *mut c_void, @@ -162,10 +162,7 @@ unsafe extern "C" fn stream_encode( LZMA_FINISH, LZMA_FINISH, ]; - let ret: lzma_ret = (*coder) - .block_encoder - .code - .expect("non-null function pointer")( + let ret: lzma_ret = (*coder).block_encoder.code.unwrap()( (*coder).block_encoder.coder, allocator, in_0, @@ -193,13 +190,10 @@ unsafe extern "C" fn stream_encode( (*coder).sequence = SEQ_BLOCK_INIT; } 4 => { - let ret_0: lzma_ret = (*coder) - .index_encoder - .code - .expect("non-null function pointer")( + let ret_0: lzma_ret = (*coder).index_encoder.code.unwrap()( (*coder).index_encoder.coder, allocator, - ::core::ptr::null::(), + core::ptr::null(), core::ptr::null_mut(), 0, out, @@ -242,7 +236,7 @@ unsafe extern "C" fn stream_encode( _ => return LZMA_PROG_ERROR, } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn stream_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; @@ -281,10 +275,7 @@ unsafe extern "C" fn stream_encoder_update( current_block = 8236137900636309791; } } else if (*coder).sequence <= SEQ_BLOCK_ENCODE { - ret = (*coder) - .block_encoder - .update - .expect("non-null function pointer")( + ret = (*coder).block_encoder.update.unwrap()( (*coder).block_encoder.coder, allocator, filters, @@ -306,11 +297,7 @@ unsafe extern "C" fn stream_encoder_update( } _ => { lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); - memcpy( - &raw mut (*coder).filters as *mut lzma_filter as *mut c_void, - &raw mut temp as *mut lzma_filter as *const c_void, - core::mem::size_of::<[lzma_filter; 5]>(), - ); + core::ptr::copy_nonoverlapping(&raw mut temp as *const u8, &raw mut (*coder).filters as *mut u8, core::mem::size_of::<[lzma_filter; 5]>()); return LZMA_OK; } }; @@ -321,7 +308,7 @@ unsafe extern "C" fn stream_encoder_init( filters: *const lzma_filter, check: lzma_check, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -343,7 +330,7 @@ unsafe extern "C" fn stream_encoder_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -386,27 +373,16 @@ unsafe extern "C" fn stream_encoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( stream_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; - (*next).update = Some( - stream_encoder_update - as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >; + ); + (*next).update = Some(stream_encoder_update as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret); (*coder).filters[0].id = LZMA_VLI_UNKNOWN; (*coder).block_encoder = lzma_next_coder_s { coder: core::ptr::null_mut(), @@ -468,12 +444,12 @@ unsafe extern "C" fn stream_encoder_init( } (*coder).buffer_pos = 0; (*coder).buffer_size = LZMA_STREAM_HEADER_SIZE as size_t; - return stream_encoder_update( + stream_encoder_update( coder as *mut c_void, allocator, filters, - ::core::ptr::null::(), - ); + core::ptr::null(), + ) } #[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder( @@ -500,5 +476,5 @@ pub unsafe extern "C" fn lzma_stream_encoder( (*(*strm).internal).supported_actions[LZMA_FULL_FLUSH as usize] = true; (*(*strm).internal).supported_actions[LZMA_FULL_BARRIER as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index e0e8a7ca..b182ed7e 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -281,26 +281,26 @@ extern "C" fn mythread_create( let ret: c_int = unsafe { pthread_create( thread as *mut pthread_t, - ::core::ptr::null::(), + core::ptr::null(), func as Option *mut c_void>, arg as *mut c_void, ) }; mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); - return ret; + ret } #[inline] extern "C" fn mythread_join(thread: mythread) -> c_int { - return unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) }; + unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) } } #[inline] extern "C" fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { - return unsafe { + unsafe { pthread_mutex_init( mutex as *mut pthread_mutex_t, - ::core::ptr::null::(), + core::ptr::null(), ) - }; + } } #[inline] extern "C" fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { @@ -320,7 +320,7 @@ extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { (*mycond).clk_id = _CLOCK_REALTIME; pthread_cond_init( &raw mut (*mycond).cond, - ::core::ptr::null::(), + core::ptr::null(), ) }; } @@ -350,7 +350,7 @@ extern "C" fn mythread_cond_timedwait( condtime as *const timespec, ) }; - return ret; + ret } #[inline] extern "C" fn mythread_condtime_set( @@ -377,11 +377,11 @@ extern "C" fn mythread_condtime_set( pub const LZMA_THREADS_MAX: u32 = 16384; #[inline] extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { - return unsafe { (*outq).bufs_in_use < (*outq).bufs_limit }; + unsafe { (*outq).bufs_in_use < (*outq).bufs_limit } } #[inline] extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { - return unsafe { (*outq).bufs_in_use == 0 }; + unsafe { (*outq).bufs_in_use == 0 } } pub const BLOCK_SIZE_MAX: c_ulonglong = UINT64_MAX.wrapping_div(LZMA_THREADS_MAX as u64); unsafe extern "C" fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { @@ -497,10 +497,7 @@ unsafe extern "C" fn worker_encode( in_limit = in_pos.wrapping_add(in_chunk_max); action = LZMA_RUN; } - ret = (*thr) - .block_encoder - .code - .expect("non-null function pointer")( + ret = (*thr).block_encoder.code.unwrap()( (*thr).block_encoder.coder, (*thr).allocator, (*thr).in_0, @@ -511,7 +508,7 @@ unsafe extern "C" fn worker_encode( out_size, action, ); - if !(ret == LZMA_OK && *out_pos < out_size) { + if ret != LZMA_OK || *out_pos >= out_size { break; } } @@ -571,7 +568,7 @@ unsafe extern "C" fn worker_encode( } (*(*thr).outbuf).unpadded_size = lzma_block_unpadded_size(&raw mut (*thr).block_options); (*(*thr).outbuf).uncompressed_size = (*thr).block_options.uncompressed_size; - return THR_FINISH; + THR_FINISH } unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { let thr: *mut worker_thread = thr_ptr as *mut worker_thread; @@ -667,7 +664,7 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { mythread_cond_destroy(&raw mut (*thr).cond); lzma_next_end(&raw mut (*thr).block_encoder, (*thr).allocator); lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); - return MYTHREAD_RET_VALUE; + MYTHREAD_RET_VALUE } unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_threads: bool) { let mut i: u32 = 0; @@ -761,8 +758,8 @@ unsafe extern "C" fn initialize_new_thread( if (*thr).in_0.is_null() { return LZMA_MEM_ERROR; } - if !(mythread_mutex_init(&raw mut (*thr).mutex) != 0) { - if !(mythread_cond_init(&raw mut (*thr).cond) != 0) { + if mythread_mutex_init(&raw mut (*thr).mutex) == 0 { + if mythread_cond_init(&raw mut (*thr).cond) == 0 { (*thr).state = THR_IDLE; (*thr).allocator = allocator; (*thr).coder = coder; @@ -797,7 +794,7 @@ unsafe extern "C" fn initialize_new_thread( mythread_mutex_destroy(&raw mut (*thr).mutex); } lzma_free((*thr).in_0 as *mut c_void, allocator); - return LZMA_MEM_ERROR; + LZMA_MEM_ERROR } unsafe extern "C" fn get_thread( coder: *mut lzma_stream_coder, @@ -871,18 +868,14 @@ unsafe extern "C" fn get_thread( &raw mut (*(*coder).thr).filters as *mut lzma_filter, allocator, ); - memcpy( - &raw mut (*(*coder).thr).filters as *mut lzma_filter as *mut c_void, - &raw mut (*coder).filters_cache as *mut lzma_filter as *const c_void, - core::mem::size_of::<[lzma_filter; 5]>(), - ); + core::ptr::copy_nonoverlapping(&raw mut (*coder).filters_cache as *const u8, &raw mut (*(*coder).thr).filters as *mut u8, core::mem::size_of::<[lzma_filter; 5]>()); (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; mythread_cond_signal(&raw mut (*(*coder).thr).cond); mythread_j_578 = 1; } mythread_i_578 = 1; } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn stream_encode_in( coder: *mut lzma_stream_coder, @@ -959,7 +952,7 @@ unsafe extern "C" fn stream_encode_in( (*coder).thr = core::ptr::null_mut(); } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn wait_for_work( coder: *mut lzma_stream_coder, @@ -1004,7 +997,7 @@ unsafe extern "C" fn wait_for_work( } mythread_i_689 = 1; } - return timed_out; + timed_out } unsafe extern "C" fn stream_encode_mt( coder_ptr: *mut c_void, @@ -1030,7 +1023,7 @@ unsafe extern "C" fn stream_encode_mt( out_pos, out_size, ); - if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() as usize { + if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() { return LZMA_OK; } (*coder).header_pos = 0; @@ -1161,13 +1154,10 @@ unsafe extern "C" fn stream_encode_mt( } match current_block_53 { 7301844830188010456 => { - let ret_0: lzma_ret = (*coder) - .index_encoder - .code - .expect("non-null function pointer")( + let ret_0: lzma_ret = (*coder).index_encoder.code.unwrap()( (*coder).index_encoder.coder, allocator, - ::core::ptr::null::(), + core::ptr::null(), core::ptr::null_mut(), 0, out, @@ -1198,13 +1188,13 @@ unsafe extern "C" fn stream_encode_mt( out_pos, out_size, ); - return if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() as usize { + return if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() { LZMA_OK } else { LZMA_STREAM_END }; } - return LZMA_PROG_ERROR; + LZMA_PROG_ERROR } unsafe extern "C" fn stream_encoder_mt_end( coder_ptr: *mut c_void, @@ -1253,12 +1243,8 @@ unsafe extern "C" fn stream_encoder_mt_update( &raw mut (*coder).filters_cache as *mut lzma_filter, allocator, ); - memcpy( - &raw mut (*coder).filters as *mut lzma_filter as *mut c_void, - &raw mut temp as *mut lzma_filter as *const c_void, - core::mem::size_of::<[lzma_filter; 5]>(), - ); - return LZMA_OK; + core::ptr::copy_nonoverlapping(&raw mut temp as *const u8, &raw mut (*coder).filters as *mut u8, core::mem::size_of::<[lzma_filter; 5]>()); + LZMA_OK } unsafe extern "C" fn get_options( options: *const lzma_mt, @@ -1293,7 +1279,7 @@ unsafe extern "C" fn get_options( if *outbuf_size_max == 0 { return LZMA_MEM_ERROR; } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn get_progress( coder_ptr: *mut c_void, @@ -1347,7 +1333,7 @@ unsafe extern "C" fn stream_encoder_mt_init( allocator: *const lzma_allocator, options: *const lzma_mt, ) -> lzma_ret { - if ::core::mem::transmute::< + if core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -1367,7 +1353,7 @@ unsafe extern "C" fn stream_encoder_mt_init( { lzma_next_end(next, allocator); } - (*next).init = ::core::mem::transmute::< + (*next).init = core::mem::transmute::< Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -1391,14 +1377,14 @@ unsafe extern "C" fn stream_encoder_mt_init( }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, lc: 0, lp: 0, pb: 0, - mode: 0 as lzma_mode, + mode: 0, nice_len: 0, - mf: 0 as lzma_match_finder, + mf: 0, depth: 0, ext_flags: 0, ext_size_low: 0, @@ -1416,7 +1402,7 @@ unsafe extern "C" fn stream_encoder_mt_init( reserved_ptr2: core::ptr::null_mut(), }, }; - let mut filters: *const lzma_filter = ::core::ptr::null::(); + let mut filters: *const lzma_filter = core::ptr::null(); let mut block_size: u64 = 0; let mut outbuf_size_max: u64 = 0; let ret_: lzma_ret = get_options( @@ -1470,30 +1456,18 @@ unsafe extern "C" fn stream_encoder_mt_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( stream_encoder_mt_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; + ); (*next).get_progress = - Some(get_progress as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> ()) - as Option ()>; - (*next).update = Some( - stream_encoder_mt_update - as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >; + Some(get_progress as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> ()); + (*next).update = Some(stream_encoder_mt_update as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret); (*coder).filters[0].id = LZMA_VLI_UNKNOWN; (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; (*coder).index_encoder = lzma_next_coder_s { @@ -1509,11 +1483,7 @@ unsafe extern "C" fn stream_encoder_mt_init( set_out_limit: None, }; (*coder).index = core::ptr::null_mut(); - memset( - &raw mut (*coder).outq as *mut c_void, - 0, - core::mem::size_of::(), - ); + core::ptr::write_bytes(&raw mut (*coder).outq as *mut u8, 0 as u8, core::mem::size_of::()); (*coder).threads = core::ptr::null_mut(); (*coder).threads_max = 0; (*coder).threads_initialized = 0; @@ -1575,7 +1545,7 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).header_pos = 0; (*coder).progress_in = 0; (*coder).progress_out = LZMA_STREAM_HEADER_SIZE as u64; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder_mt( @@ -1599,7 +1569,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( (*(*strm).internal).supported_actions[LZMA_FULL_FLUSH as usize] = true; (*(*strm).internal).supported_actions[LZMA_FULL_BARRIER as usize] = true; (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64 { @@ -1610,14 +1580,14 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt }; 5], opt_lzma: lzma_options_lzma { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, lc: 0, lp: 0, pb: 0, - mode: 0 as lzma_mode, + mode: 0, nice_len: 0, - mf: 0 as lzma_match_finder, + mf: 0, depth: 0, ext_flags: 0, ext_size_low: 0, @@ -1635,7 +1605,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt reserved_ptr2: core::ptr::null_mut(), }, }; - let mut filters: *const lzma_filter = ::core::ptr::null::(); + let mut filters: *const lzma_filter = core::ptr::null(); let mut block_size: u64 = 0; let mut outbuf_size_max: u64 = 0; if get_options( @@ -1662,7 +1632,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt .wrapping_add(core::mem::size_of::() as u64) .wrapping_add( ((*options).threads as usize) - .wrapping_mul(core::mem::size_of::() as usize) as u64, + .wrapping_mul(core::mem::size_of::()) as u64, ); if (UINT64_MAX).wrapping_sub(total_memusage) < inbuf_memusage { return UINT64_MAX; @@ -1675,5 +1645,5 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt if (UINT64_MAX).wrapping_sub(total_memusage) < outq_memusage { return UINT64_MAX; } - return total_memusage.wrapping_add(outq_memusage); + total_memusage.wrapping_add(outq_memusage) } diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index 8f8244b2..ab63b13f 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -1,11 +1,11 @@ use crate::types::*; #[inline] extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { - return unsafe { + unsafe { (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli && (*options).backward_size & 3 == 0 - }; + } } #[no_mangle] pub static mut lzma_header_magic: [u8; 6] = [ @@ -35,5 +35,5 @@ pub unsafe extern "C" fn lzma_stream_flags_compare( return LZMA_DATA_ERROR; } } - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index de279fc3..4c0372ee 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -8,7 +8,7 @@ extern "C" { #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { - let mut num: u32 = *buf.offset(0) as u32; + let mut num: u32 = *buf as u32; num |= (*buf.offset(1) as u32) << 8; num |= (*buf.offset(2) as u32) << 16; num |= (*buf.offset(3) as u32) << 24; @@ -18,7 +18,7 @@ extern "C" fn read32le(buf: *const u8) -> u32 { pub const LZMA_STREAM_FLAGS_SIZE: u32 = 2; extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> bool { return unsafe { - if *in_0.offset(0) != 0 || *in_0.offset(1) & 0xf0 != 0 { + if *in_0 != 0 || *in_0.offset(1) & 0xf0 != 0 { return true; } (*options).version = 0; @@ -33,20 +33,20 @@ pub unsafe extern "C" fn lzma_stream_header_decode( ) -> lzma_ret { if memcmp( in_0 as *const c_void, - &raw const lzma_header_magic as *const u8 as *const c_void, + &raw const lzma_header_magic as *const c_void, core::mem::size_of::<[u8; 6]>(), ) != 0 { return LZMA_FORMAT_ERROR; } let crc: u32 = lzma_crc32( - in_0.offset(core::mem::size_of::<[u8; 6]>() as usize as isize), + in_0.offset(core::mem::size_of::<[u8; 6]>() as isize), LZMA_STREAM_FLAGS_SIZE as size_t, 0, ) as u32; if crc != read32le( - in_0.offset(core::mem::size_of::<[u8; 6]>() as usize as isize) + in_0.offset(core::mem::size_of::<[u8; 6]>() as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize), ) { @@ -54,12 +54,12 @@ pub unsafe extern "C" fn lzma_stream_header_decode( } if stream_flags_decode( options, - in_0.offset(core::mem::size_of::<[u8; 6]>() as usize as isize), + in_0.offset(core::mem::size_of::<[u8; 6]>() as isize), ) { return LZMA_OPTIONS_ERROR; } (*options).backward_size = LZMA_VLI_UNKNOWN; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_stream_footer_decode( @@ -67,16 +67,16 @@ pub unsafe extern "C" fn lzma_stream_footer_decode( in_0: *const u8, ) -> lzma_ret { if memcmp( - in_0.offset((core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize) + in_0.offset((core::mem::size_of::()).wrapping_mul(2) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *const c_void, - &raw const lzma_footer_magic as *const u8 as *const c_void, + &raw const lzma_footer_magic as *const c_void, core::mem::size_of::<[u8; 2]>(), ) != 0 { return LZMA_FORMAT_ERROR; } let crc: u32 = lzma_crc32( - in_0.offset(core::mem::size_of::() as usize as isize), + in_0.offset(core::mem::size_of::() as isize), (core::mem::size_of::()).wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), 0, ) as u32; @@ -85,12 +85,12 @@ pub unsafe extern "C" fn lzma_stream_footer_decode( } if stream_flags_decode( options, - in_0.offset((core::mem::size_of::() as usize).wrapping_mul(2 as usize) as isize), + in_0.offset((core::mem::size_of::()).wrapping_mul(2) as isize), ) { return LZMA_OPTIONS_ERROR; } (*options).backward_size = - read32le(in_0.offset(core::mem::size_of::() as usize as isize)) as lzma_vli; + read32le(in_0.offset(core::mem::size_of::() as isize)) as lzma_vli; (*options).backward_size = (*options).backward_size.wrapping_add(1).wrapping_mul(4); - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 91f044be..634d1aa1 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; static lzma_header_magic: [u8; 6]; @@ -8,7 +7,7 @@ extern "C" { #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { - *buf.offset(0) = num as u8; + *buf = num as u8; *buf.offset(1) = (num >> 8) as u8; *buf.offset(2) = (num >> 16) as u8; *buf.offset(3) = (num >> 24) as u8; @@ -17,18 +16,18 @@ extern "C" fn write32le(buf: *mut u8, num: u32) { pub const LZMA_STREAM_FLAGS_SIZE: u32 = 2; #[inline] extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { - return unsafe { + unsafe { (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli && (*options).backward_size & 3 == 0 - }; + } } extern "C" fn stream_flags_encode(options: *const lzma_stream_flags, out: *mut u8) -> bool { return unsafe { if (*options).check > LZMA_CHECK_ID_MAX { return true; } - *out.offset(0) = 0; + *out = 0; *out.offset(1) = (*options).check as u8; false }; @@ -41,28 +40,24 @@ pub unsafe extern "C" fn lzma_stream_header_encode( if (*options).version != 0 { return LZMA_OPTIONS_ERROR; } - memcpy( - out as *mut c_void, - &raw const lzma_header_magic as *const u8 as *const c_void, - core::mem::size_of::<[u8; 6]>(), - ); + core::ptr::copy_nonoverlapping(&raw const lzma_header_magic as *const u8, out as *mut u8, core::mem::size_of::<[u8; 6]>()); if stream_flags_encode( options, - out.offset(core::mem::size_of::<[u8; 6]>() as usize as isize), + out.offset(core::mem::size_of::<[u8; 6]>() as isize), ) { return LZMA_PROG_ERROR; } let crc: u32 = lzma_crc32( - out.offset(core::mem::size_of::<[u8; 6]>() as usize as isize), + out.offset(core::mem::size_of::<[u8; 6]>() as isize), LZMA_STREAM_FLAGS_SIZE as size_t, 0, ) as u32; write32le( - out.offset(core::mem::size_of::<[u8; 6]>() as usize as isize) + out.offset(core::mem::size_of::<[u8; 6]>() as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize), crc, ); - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_stream_footer_encode( @@ -84,11 +79,7 @@ pub unsafe extern "C" fn lzma_stream_footer_encode( } let crc: u32 = lzma_crc32(out.offset(4), (4 + LZMA_STREAM_FLAGS_SIZE) as size_t, 0) as u32; write32le(out, crc); - memcpy( - out.offset((2 * 4) as isize) - .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut c_void, - &raw const lzma_footer_magic as *const u8 as *const c_void, - core::mem::size_of::<[u8; 2]>(), - ); - return LZMA_OK; + core::ptr::copy_nonoverlapping(&raw const lzma_footer_magic as *const u8, out.offset((2 * 4) as isize) + .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut u8, core::mem::size_of::<[u8; 2]>()); + LZMA_OK } diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 8d26d291..f286e121 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -76,13 +76,13 @@ unsafe extern "C" fn str_init(str: *mut lzma_str, allocator: *const lzma_allocat return LZMA_MEM_ERROR; } (*str).pos = 0; - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn str_free(str: *mut lzma_str, allocator: *const lzma_allocator) { lzma_free((*str).buf as *mut c_void, allocator); } unsafe extern "C" fn str_is_full(str: *const lzma_str) -> bool { - return (*str).pos == (STR_ALLOC_SIZE - 1) as size_t; + (*str).pos == (STR_ALLOC_SIZE - 1) as size_t } unsafe extern "C" fn str_finish( dest: *mut *mut c_char, @@ -96,51 +96,47 @@ unsafe extern "C" fn str_finish( } *(*str).buf.offset((*str).pos as isize) = '\0' as i32 as c_char; *dest = (*str).buf; - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn str_append_str(str: *mut lzma_str, s: *const c_char) { let len: size_t = strlen(s) as size_t; let limit: size_t = ((STR_ALLOC_SIZE - 1) as size_t).wrapping_sub((*str).pos); let copy_size: size_t = if len < limit { len } else { limit }; - memcpy( - (*str).buf.offset((*str).pos as isize) as *mut c_void, - s as *const c_void, - copy_size, - ); + core::ptr::copy_nonoverlapping(s as *const u8, (*str).buf.offset((*str).pos as isize) as *mut u8, copy_size); (*str).pos = (*str).pos.wrapping_add(copy_size); } unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) { if v == 0 { - str_append_str(str, b"0\0" as *const u8 as *const c_char); + str_append_str(str, c"0".as_ptr()); } else { static mut suffixes: [[c_char; 4]; 4] = unsafe { [ - ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"\0\0\0\0"), - ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"KiB\0"), - ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"MiB\0"), - ::core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"GiB\0"), + core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"\0\0\0\0"), + core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"KiB\0"), + core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"MiB\0"), + core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"GiB\0"), ] }; let mut suf: size_t = 0; if use_byte_suffix { while v & 1023 == 0 && suf - < (core::mem::size_of::<[[c_char; 4]; 4]>() as usize) - .wrapping_div(core::mem::size_of::<[c_char; 4]>() as usize) - .wrapping_sub(1 as usize) + < (core::mem::size_of::<[[c_char; 4]; 4]>()) + .wrapping_div(core::mem::size_of::<[c_char; 4]>()) + .wrapping_sub(1) { v >>= 10; suf += 1; } } let mut buf: [c_char; 16] = - ::core::mem::transmute::<[u8; 16], [c_char; 16]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); + core::mem::transmute::<[u8; 16], [c_char; 16]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); let mut pos: size_t = (core::mem::size_of::<[c_char; 16]>()).wrapping_sub(1); loop { pos -= 1; buf[pos as usize] = ('0' as i32 as u32).wrapping_add(v.wrapping_rem(10)) as c_char; v = v.wrapping_div(10); - if !(v != 0) { + if v == 0 { break; } } @@ -158,7 +154,7 @@ pub const OPTMAP_USE_BYTE_SUFFIX: u8 = 0x2; pub const OPTMAP_NO_STRFY_ZERO: u8 = 0x4; static mut bcj_optmap: [option_map; 1] = unsafe { [option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"start\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"start\0\0\0\0\0\0\0"), type_0: 0, flags: (OPTMAP_NO_STRFY_ZERO | OPTMAP_USE_BYTE_SUFFIX) as u8, offset: 0, @@ -188,7 +184,7 @@ extern "C" fn parse_bcj( } static mut delta_optmap: [option_map; 1] = unsafe { [option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dist\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dist\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, offset: 4, @@ -220,19 +216,19 @@ extern "C" fn parse_delta( }; } pub const LZMA12_PRESET_STR: [c_char; 7] = - unsafe { ::core::mem::transmute::<[u8; 7], [c_char; 7]>(*b"0-9[e]\0") }; + unsafe { core::mem::transmute::<[u8; 7], [c_char; 7]>(*b"0-9[e]\0") }; unsafe extern "C" fn parse_lzma12_preset( str: *mut *const c_char, str_end: *const c_char, preset: *mut u32, ) -> *const c_char { - if !(**str as u8 >= b'0' && **str as u8 <= b'9') { - return b"Unsupported preset\0" as *const u8 as *const c_char; + if (**str as u8) < b'0' || (**str as u8) > b'9' { + return c"Unsupported preset".as_ptr(); } *preset = (**str as u8 - b'0') as u32; loop { *str = (*str).offset(1); - if !(*str < str_end) { + if *str >= str_end { break; } match **str { @@ -240,11 +236,11 @@ unsafe extern "C" fn parse_lzma12_preset( *preset = (*preset | LZMA_PRESET_EXTREME) as u32; } _ => { - return b"Unsupported flag in the preset\0" as *const u8 as *const c_char; + return c"Unsupported flag in the preset".as_ptr(); } } } - return ::core::ptr::null::(); + core::ptr::null() } unsafe extern "C" fn set_lzma12_preset( str: *mut *const c_char, @@ -258,22 +254,22 @@ unsafe extern "C" fn set_lzma12_preset( } let opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; if lzma_lzma_preset(opts, preset) != 0 { - return b"Unsupported preset\0" as *const u8 as *const c_char; + return c"Unsupported preset".as_ptr(); } - return ::core::ptr::null::(); + core::ptr::null() } static lzma12_mode_map: [name_value_map; 3] = unsafe { [ name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"fast\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"fast\0\0\0\0\0\0\0\0"), value: LZMA_MODE_FAST as u32, }, name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"normal\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"normal\0\0\0\0\0\0"), value: LZMA_MODE_NORMAL as u32, }, name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), value: 0, }, ] @@ -281,27 +277,27 @@ static lzma12_mode_map: [name_value_map; 3] = unsafe { static lzma12_mf_map: [name_value_map; 6] = unsafe { [ name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"hc3\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"hc3\0\0\0\0\0\0\0\0\0"), value: LZMA_MF_HC3 as u32, }, name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"hc4\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"hc4\0\0\0\0\0\0\0\0\0"), value: LZMA_MF_HC4 as u32, }, name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt2\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt2\0\0\0\0\0\0\0\0\0"), value: LZMA_MF_BT2 as u32, }, name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt3\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt3\0\0\0\0\0\0\0\0\0"), value: LZMA_MF_BT3 as u32, }, name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt4\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"bt4\0\0\0\0\0\0\0\0\0"), value: LZMA_MF_BT4 as u32, }, name_value_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0"), value: 0, }, ] @@ -312,7 +308,7 @@ static mut lzma12_optmap: [option_map; 9] = [option_map { flags: 0, offset: 0, u: C2RustUnnamed_0 { - map: ::core::ptr::null::(), + map: core::ptr::null(), }, }; 9]; unsafe extern "C" fn parse_lzma12( @@ -333,14 +329,14 @@ unsafe extern "C" fn parse_lzma12( return errmsg; } if (*opts).lc.wrapping_add((*opts).lp) > LZMA_LCLP_MAX { - return b"The sum of lc and lp must not exceed 4\0" as *const u8 as *const c_char; + return c"The sum of lc and lp must not exceed 4".as_ptr(); } - return ::core::ptr::null::(); + core::ptr::null() } static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { [ C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma1\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma1\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_LZMA1, parse: Some( @@ -357,7 +353,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: false, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma2\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma2\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_LZMA2, parse: Some( @@ -374,7 +370,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: false, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"x86\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"x86\0\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_X86, parse: Some( @@ -391,7 +387,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: true, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm\0\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARM, parse: Some( @@ -408,7 +404,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: true, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"armthumb\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"armthumb\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARMTHUMB, parse: Some( @@ -425,7 +421,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: true, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm64\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm64\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARM64, parse: Some( @@ -442,7 +438,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: true, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"riscv\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"riscv\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_RISCV, parse: Some( @@ -459,7 +455,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: true, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"powerpc\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"powerpc\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_POWERPC, parse: Some( @@ -476,7 +472,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: true, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"ia64\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"ia64\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_IA64, parse: Some( @@ -493,7 +489,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: true, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"sparc\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"sparc\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_SPARC, parse: Some( @@ -510,7 +506,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { allow_null: true, }, C2RustUnnamed { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"delta\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"delta\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_DELTA, parse: Some( @@ -556,16 +552,16 @@ unsafe extern "C" fn parse_options( } let name_len: size_t = equals_sign.offset_from(*str) as size_t; if name_len > NAME_LEN_MAX as size_t { - return b"Unknown option name\0" as *const u8 as *const c_char; + return c"Unknown option name".as_ptr(); } let mut i: size_t = 0; loop { if i == optmap_size { - return b"Unknown option name\0" as *const u8 as *const c_char; + return c"Unknown option name".as_ptr(); } if memcmp( *str as *const c_void, - &raw const (*optmap.offset(i as isize)).name as *const c_char as *const c_void, + &raw const (*optmap.offset(i as isize)).name as *const c_void, name_len, ) == 0 && (*optmap.offset(i as isize)).name[name_len as usize] == 0 @@ -577,7 +573,7 @@ unsafe extern "C" fn parse_options( *str = equals_sign.offset(1); let value_len: size_t = name_eq_value_end.offset_from(*str) as size_t; if value_len == 0 { - return b"Option value cannot be empty\0" as *const u8 as *const c_char; + return c"Option value cannot be empty".as_ptr(); } if (*optmap.offset(i as isize)).type_0 == OPTMAP_TYPE_LZMA_PRESET { let errmsg: *const c_char = @@ -589,18 +585,17 @@ unsafe extern "C" fn parse_options( let mut v: u32 = 0; if (*optmap.offset(i as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP != 0 { if value_len > NAME_LEN_MAX as size_t { - return b"Invalid option value\0" as *const u8 as *const c_char; + return c"Invalid option value".as_ptr(); } let map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0; loop { if (*map.offset(j as isize)).name[0] == 0 { - return b"Invalid option value\0" as *const u8 as *const c_char; + return c"Invalid option value".as_ptr(); } if memcmp( *str as *const c_void, - &raw const (*map.offset(j as isize)).name as *const c_char - as *const c_void, + &raw const (*map.offset(j as isize)).name as *const c_void, value_len, ) == 0 && (*map.offset(j as isize)).name[value_len as usize] == 0 @@ -619,16 +614,16 @@ unsafe extern "C" fn parse_options( v = 0; loop { if v > (UINT32_MAX).wrapping_div(10) { - return b"Value out of range\0" as *const u8 as *const c_char; + return c"Value out of range".as_ptr(); } v = v.wrapping_mul(10); let add: u32 = (*p as u8 - b'0') as u32; if (UINT32_MAX).wrapping_sub(add) < v { - return b"Value out of range\0" as *const u8 as *const c_char; + return c"Value out of range".as_ptr(); } v = v.wrapping_add(add); p = p.offset(1); - if !(p < name_eq_value_end && *p as u8 >= b'0' && *p as u8 <= b'9') { + if p >= name_eq_value_end || (*p as u8) < b'0' || (*p as u8) > b'9' { break; } } @@ -670,14 +665,14 @@ unsafe extern "C" fn parse_options( as *const c_char; } if v > UINT32_MAX >> shift { - return b"Value out of range\0" as *const u8 as *const c_char; + return c"Value out of range".as_ptr(); } v <<= shift; } if v < (*optmap.offset(i as isize)).u.range.min || v > (*optmap.offset(i as isize)).u.range.max { - return b"Value out of range\0" as *const u8 as *const c_char; + return c"Value out of range".as_ptr(); } } let ptr: *mut c_void = (filter_options as *mut c_char) @@ -698,7 +693,7 @@ unsafe extern "C" fn parse_options( } } } - return ::core::ptr::null::(); + core::ptr::null() } unsafe extern "C" fn parse_filter( str: *mut *const c_char, @@ -721,17 +716,17 @@ unsafe extern "C" fn parse_filter( } let name_len: size_t = name_end.offset_from(*str) as size_t; if name_len > NAME_LEN_MAX as size_t { - return b"Unknown filter name\0" as *const u8 as *const c_char; + return c"Unknown filter name".as_ptr(); } let mut i: size_t = 0; while i - < (core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) - .wrapping_div(core::mem::size_of::() as usize) + < (core::mem::size_of::<[C2RustUnnamed; 11]>()) + .wrapping_div(core::mem::size_of::()) { if memcmp( *str as *const c_void, &raw const (*(&raw const filter_name_map as *const C2RustUnnamed).offset(i as isize)) - .name as *const c_char as *const c_void, + .name as *const c_void, name_len, ) == 0 && filter_name_map[i as usize].name[name_len as usize] == 0 @@ -743,24 +738,22 @@ unsafe extern "C" fn parse_filter( let options: *mut c_void = lzma_alloc_zero(filter_name_map[i as usize].opts_size as size_t, allocator); if options.is_null() { - return b"Memory allocation failed\0" as *const u8 as *const c_char; + return c"Memory allocation failed".as_ptr(); } *str = opts_start; let errmsg: *const c_char = - filter_name_map[i as usize] - .parse - .expect("non-null function pointer")(str, str_end, options); + filter_name_map[i as usize].parse.unwrap()(str, str_end, options); if !errmsg.is_null() { lzma_free(options, allocator); return errmsg; } (*filter).id = filter_name_map[i as usize].id; (*filter).options = options; - return ::core::ptr::null::(); + return core::ptr::null(); } i += 1; } - return b"Unknown filter name\0" as *const u8 as *const c_char; + c"Unknown filter name".as_ptr() } unsafe extern "C" fn str_to_filters( str: *mut *const c_char, @@ -769,7 +762,7 @@ unsafe extern "C" fn str_to_filters( allocator: *const lzma_allocator, ) -> *const c_char { let mut current_block: u64; - let mut errmsg: *const c_char = ::core::ptr::null::(); + let mut errmsg: *const c_char = core::ptr::null(); while **str as u8 == b' ' { *str = (*str).offset(1); } @@ -791,7 +784,7 @@ unsafe extern "C" fn str_to_filters( let mut i: size_t = 1; while *str_end.offset(i as isize) != 0 { if *str_end.offset(i as isize) as u8 != b' ' { - return b"Unsupported preset\0" as *const u8 as *const c_char; + return c"Unsupported preset".as_ptr(); } i += 1; } @@ -807,17 +800,17 @@ unsafe extern "C" fn str_to_filters( lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_options_lzma; if opts.is_null() { - return b"Memory allocation failed\0" as *const u8 as *const c_char; + return c"Memory allocation failed".as_ptr(); } if lzma_lzma_preset(opts, preset) != 0 { lzma_free(opts as *mut c_void, allocator); - return b"Unsupported preset\0" as *const u8 as *const c_char; + return c"Unsupported preset".as_ptr(); } - (*filters.offset(0)).id = LZMA_FILTER_LZMA2; - (*filters.offset(0)).options = opts as *mut c_void; + (*filters).id = LZMA_FILTER_LZMA2; + (*filters).options = opts as *mut c_void; (*filters.offset(1)).id = LZMA_VLI_UNKNOWN; (*filters.offset(1)).options = core::ptr::null_mut(); - return ::core::ptr::null::(); + return core::ptr::null(); } let only_xz: bool = flags & LZMA_STR_ALL_FILTERS as u32 == 0; let mut temp_filters: [lzma_filter; 5] = [lzma_filter { @@ -827,24 +820,24 @@ unsafe extern "C" fn str_to_filters( let mut i_0: size_t = 0; loop { if i_0 == LZMA_FILTERS_MAX as size_t { - errmsg = b"The maximum number of filters is four\0" as *const u8 as *const c_char; + errmsg = c"The maximum number of filters is four".as_ptr(); current_block = 6100283484465977373; break; } else { - if *(*str).offset(0) as u8 == b'-' && *(*str).offset(1) as u8 == b'-' { + if *(*str) as u8 == b'-' && *(*str).offset(1) as u8 == b'-' { *str = (*str).offset(2); } let mut filter_end: *const c_char = *str; - while *filter_end.offset(0) != 0 { - if *filter_end.offset(0) as u8 == b'-' && *filter_end.offset(1) as u8 == b'-' - || *filter_end.offset(0) as u8 == b' ' + while *filter_end != 0 { + if *filter_end as u8 == b'-' && *filter_end.offset(1) as u8 == b'-' + || *filter_end as u8 == b' ' { break; } filter_end = filter_end.offset(1); } if filter_end == *str { - errmsg = b"Filter name is missing\0" as *const u8 as *const c_char; + errmsg = c"Filter name is missing".as_ptr(); current_block = 6100283484465977373; break; } else { @@ -864,7 +857,7 @@ unsafe extern "C" fn str_to_filters( *str = (*str).offset(1); } i_0 += 1; - if !(**str != 0) { + if **str == 0 { current_block = 15090052786889560393; break; } @@ -892,27 +885,23 @@ unsafe extern "C" fn str_to_filters( match current_block { 6100283484465977373 => {} _ => { - memcpy( - filters as *mut c_void, - &raw mut temp_filters as *mut lzma_filter as *const c_void, - i_0.wrapping_add(1) - .wrapping_mul(core::mem::size_of::()), - ); - return ::core::ptr::null::(); + core::ptr::copy_nonoverlapping(&raw mut temp_filters as *const u8, filters as *mut u8, i_0.wrapping_add(1) + .wrapping_mul(core::mem::size_of::())); + return core::ptr::null(); } } } _ => {} } loop { - let fresh2 = i_0; + let old_i = i_0; i_0 = i_0.wrapping_sub(1); - if !(fresh2 > 0) { + if old_i == 0 { break; } lzma_free(temp_filters[i_0 as usize].options, allocator); } - return errmsg; + errmsg } #[no_mangle] pub unsafe extern "C" fn lzma_str_to_filters( @@ -931,7 +920,7 @@ pub unsafe extern "C" fn lzma_str_to_filters( } let supported_flags: u32 = LZMA_STR_ALL_FILTERS as u32 | LZMA_STR_NO_VALIDATION as u32; if flags & !supported_flags != 0 { - return b"Unsupported flags to lzma_str_to_filters()\0" as *const u8 as *const c_char; + return c"Unsupported flags to lzma_str_to_filters()".as_ptr(); } let mut used: *const c_char = str; let errmsg: *const c_char = str_to_filters(&raw mut used, filters, flags, allocator); @@ -943,7 +932,7 @@ pub unsafe extern "C" fn lzma_str_to_filters( n as c_int }; } - return errmsg; + errmsg } unsafe extern "C" fn strfy_filter( dest: *mut lzma_str, @@ -954,7 +943,7 @@ unsafe extern "C" fn strfy_filter( ) { let mut i: size_t = 0; while i < optmap_count { - if !((*optmap.offset(i as isize)).type_0 == OPTMAP_TYPE_LZMA_PRESET) { + if (*optmap.offset(i as isize)).type_0 != OPTMAP_TYPE_LZMA_PRESET { let mut v: u32 = 0; let ptr: *const c_void = (filter_options as *const c_char) .offset((*optmap.offset(i as isize)).offset as isize) @@ -970,20 +959,20 @@ unsafe extern "C" fn strfy_filter( v = *(ptr as *const u32); } } - if !(v == 0 && (*optmap.offset(i as isize)).flags & OPTMAP_NO_STRFY_ZERO != 0) { + if v != 0 || (*optmap.offset(i as isize)).flags & OPTMAP_NO_STRFY_ZERO == 0 { str_append_str(dest, delimiter); - delimiter = b",\0" as *const u8 as *const c_char; + delimiter = c",".as_ptr(); str_append_str( dest, &raw const (*optmap.offset(i as isize)).name as *const c_char, ); - str_append_str(dest, b"=\0" as *const u8 as *const c_char); + str_append_str(dest, c"=".as_ptr()); if (*optmap.offset(i as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP != 0 { let map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0; loop { if (*map.offset(j as isize)).name[0] == 0 { - str_append_str(dest, b"UNKNOWN\0" as *const u8 as *const c_char); + str_append_str(dest, c"UNKNOWN".as_ptr()); break; } else if (*map.offset(j as isize)).value == v { str_append_str( @@ -1028,7 +1017,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( if flags & !supported_flags != 0 { return LZMA_OPTIONS_ERROR; } - if (*filters.offset(0)).id == LZMA_VLI_UNKNOWN { + if (*filters).id == LZMA_VLI_UNKNOWN { return LZMA_OPTIONS_ERROR; } let mut dest: lzma_str = lzma_str { @@ -1041,9 +1030,9 @@ pub unsafe extern "C" fn lzma_str_from_filters( } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; let opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { - b"=\0" as *const u8 as *const c_char + c"=".as_ptr() } else { - b":\0" as *const u8 as *const c_char + c":".as_ptr() }; let mut i: size_t = 0; while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN { @@ -1052,17 +1041,17 @@ pub unsafe extern "C" fn lzma_str_from_filters( return LZMA_OPTIONS_ERROR; } if i > 0 && flags & LZMA_STR_NO_SPACES as u32 == 0 { - str_append_str(&raw mut dest, b" \0" as *const u8 as *const c_char); + str_append_str(&raw mut dest, c" ".as_ptr()); } if flags & LZMA_STR_GETOPT_LONG as u32 != 0 || i > 0 && flags & LZMA_STR_NO_SPACES as u32 != 0 { - str_append_str(&raw mut dest, b"--\0" as *const u8 as *const c_char); + str_append_str(&raw mut dest, c"--".as_ptr()); } let mut j: size_t = 0; loop { - if j == (core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) - .wrapping_div(core::mem::size_of::() as usize) + if j == (core::mem::size_of::<[C2RustUnnamed; 11]>()) + .wrapping_div(core::mem::size_of::()) { str_free(&raw mut dest, allocator); return LZMA_OPTIONS_ERROR; @@ -1104,7 +1093,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( } i += 1; } - return str_finish(output_str, &raw mut dest, allocator); + str_finish(output_str, &raw mut dest, allocator) } #[no_mangle] pub unsafe extern "C" fn lzma_str_list_filters( @@ -1134,32 +1123,32 @@ pub unsafe extern "C" fn lzma_str_list_filters( } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; let filter_delim: *const c_char = if show_opts { - b"\n\0" as *const u8 as *const c_char + c"\n".as_ptr() } else { - b" \0" as *const u8 as *const c_char + c" ".as_ptr() }; let opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { - b"=\0" as *const u8 as *const c_char + c"=".as_ptr() } else { - b":\0" as *const u8 as *const c_char + c":".as_ptr() }; let mut first_filter_printed: bool = false; let mut i: size_t = 0; while i - < (core::mem::size_of::<[C2RustUnnamed; 11]>() as usize) - .wrapping_div(core::mem::size_of::() as usize) + < (core::mem::size_of::<[C2RustUnnamed; 11]>()) + .wrapping_div(core::mem::size_of::()) { - if !(filter_id != LZMA_VLI_UNKNOWN && filter_id != filter_name_map[i as usize].id) { - if !(filter_name_map[i as usize].id >= LZMA_FILTER_RESERVED_START - && flags & LZMA_STR_ALL_FILTERS as u32 == 0 - && filter_id == LZMA_VLI_UNKNOWN) + if filter_id == LZMA_VLI_UNKNOWN || filter_id == filter_name_map[i as usize].id { + if filter_name_map[i as usize].id < LZMA_FILTER_RESERVED_START + || flags & LZMA_STR_ALL_FILTERS as u32 != 0 + || filter_id != LZMA_VLI_UNKNOWN { if first_filter_printed { str_append_str(&raw mut dest, filter_delim); } first_filter_printed = true; if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { - str_append_str(&raw mut dest, b"--\0" as *const u8 as *const c_char); + str_append_str(&raw mut dest, c"--".as_ptr()); } str_append_str( &raw mut dest, @@ -1178,12 +1167,12 @@ pub unsafe extern "C" fn lzma_str_list_filters( let mut j: size_t = 0; while j < end { str_append_str(&raw mut dest, d); - d = b",\0" as *const u8 as *const c_char; + d = c",".as_ptr(); str_append_str( &raw mut dest, &raw const (*optmap.offset(j as isize)).name as *const c_char, ); - str_append_str(&raw mut dest, b"=<\0" as *const u8 as *const c_char); + str_append_str(&raw mut dest, c"=<".as_ptr()); if (*optmap.offset(j as isize)).type_0 == OPTMAP_TYPE_LZMA_PRESET { str_append_str(&raw mut dest, LZMA12_PRESET_STR.as_ptr()); } else if (*optmap.offset(j as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP @@ -1193,10 +1182,7 @@ pub unsafe extern "C" fn lzma_str_list_filters( let mut k: size_t = 0; while (*m.offset(k as isize)).name[0] != 0 { if k > 0 { - str_append_str( - &raw mut dest, - b"|\0" as *const u8 as *const c_char, - ); + str_append_str(&raw mut dest, c"|".as_ptr()); } str_append_str( &raw mut dest, @@ -1212,14 +1198,14 @@ pub unsafe extern "C" fn lzma_str_list_filters( (*optmap.offset(j as isize)).u.range.min, use_byte_suffix, ); - str_append_str(&raw mut dest, b"-\0" as *const u8 as *const c_char); + str_append_str(&raw mut dest, c"-".as_ptr()); str_append_u32( &raw mut dest, (*optmap.offset(j as isize)).u.range.max, use_byte_suffix, ); } - str_append_str(&raw mut dest, b">\0" as *const u8 as *const c_char); + str_append_str(&raw mut dest, c">".as_ptr()); j += 1; } } @@ -1231,33 +1217,33 @@ pub unsafe extern "C" fn lzma_str_list_filters( str_free(&raw mut dest, allocator); return LZMA_OPTIONS_ERROR; } - return str_finish(output_str, &raw mut dest, allocator); + str_finish(output_str, &raw mut dest, allocator) } unsafe extern "C" fn run_static_initializers() { lzma12_optmap = [ option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"preset\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"preset\0\0\0\0\0\0"), type_0: OPTMAP_TYPE_LZMA_PRESET, flags: 0, offset: 0, u: C2RustUnnamed_0 { - map: ::core::ptr::null::(), + map: core::ptr::null(), }, }, option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dict\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"dict\0\0\0\0\0\0\0\0"), type_0: 0, flags: OPTMAP_USE_BYTE_SUFFIX, offset: 0, u: C2RustUnnamed_0 { range: C2RustUnnamed_1 { min: LZMA_DICT_SIZE_MIN as u32, - max: (1u32 << 30).wrapping_add((1) << 29), + max: (1u32 << 30).wrapping_add(1 << 29), }, }, }, option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lc\0\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lc\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, offset: 20, @@ -1269,7 +1255,7 @@ unsafe extern "C" fn run_static_initializers() { }, }, option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lp\0\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lp\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, offset: 24, @@ -1281,7 +1267,7 @@ unsafe extern "C" fn run_static_initializers() { }, }, option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"pb\0\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"pb\0\0\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, offset: 28, @@ -1293,7 +1279,7 @@ unsafe extern "C" fn run_static_initializers() { }, }, option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mode\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mode\0\0\0\0\0\0\0\0"), type_0: OPTMAP_TYPE_LZMA_MODE, flags: OPTMAP_USE_NAME_VALUE_MAP, offset: 32, @@ -1302,7 +1288,7 @@ unsafe extern "C" fn run_static_initializers() { }, }, option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"nice\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"nice\0\0\0\0\0\0\0\0"), type_0: 0, flags: 0, offset: 36, @@ -1311,7 +1297,7 @@ unsafe extern "C" fn run_static_initializers() { }, }, option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mf\0\0\0\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"mf\0\0\0\0\0\0\0\0\0\0"), type_0: OPTMAP_TYPE_LZMA_MATCH_FINDER, flags: OPTMAP_USE_NAME_VALUE_MAP, offset: 40, @@ -1320,7 +1306,7 @@ unsafe extern "C" fn run_static_initializers() { }, }, option_map { - name: ::core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"depth\0\0\0\0\0\0\0"), + name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"depth\0\0\0\0\0\0\0"), type_0: 0, flags: 0, offset: 44, diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index beacd6c3..b956a795 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -43,13 +43,13 @@ pub unsafe extern "C" fn lzma_vli_decode( if *vli_pos == LZMA_VLI_BYTES_MAX as size_t { return LZMA_DATA_ERROR; } - if !(*in_pos < in_size) { + if *in_pos >= in_size { break; } } - return if vli_pos == &raw mut vli_pos_internal { + if vli_pos == &raw mut vli_pos_internal { LZMA_DATA_ERROR } else { LZMA_OK - }; + } } diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index 4b8e996c..6055bc00 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -36,9 +36,9 @@ pub unsafe extern "C" fn lzma_vli_encode( *out.offset(*out_pos as isize) = vli as u8; *out_pos = (*out_pos).wrapping_add(1); *vli_pos = (*vli_pos).wrapping_add(1); - return if vli_pos == &raw mut vli_pos_internal { + if vli_pos == &raw mut vli_pos_internal { LZMA_OK } else { LZMA_STREAM_END - }; + } } diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index 9f4ec17f..43036f7c 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -8,9 +8,9 @@ pub extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { loop { vli >>= 7; i += 1; - if !(vli != 0) { + if vli == 0 { break; } } - return i; + i } diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index f0d22c95..e1c6c0a8 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -30,7 +30,7 @@ pub unsafe extern "C" fn lzma_delta_coder_init( (*next).coder = coder as *mut c_void; (*next).end = Some(delta_coder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) - as lzma_end_function; + ; (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -44,14 +44,14 @@ pub unsafe extern "C" fn lzma_delta_coder_init( set_out_limit: None, }; } - if lzma_delta_coder_memusage((*filters.offset(0)).options) == UINT64_MAX { + if lzma_delta_coder_memusage((*filters).options) == UINT64_MAX { return LZMA_OPTIONS_ERROR; } - let opt: *const lzma_options_delta = (*filters.offset(0)).options as *const lzma_options_delta; + let opt: *const lzma_options_delta = (*filters).options as *const lzma_options_delta; (*coder).distance = (*opt).dist as size_t; (*coder).pos = 0; - memset(&raw mut (*coder).history as *mut u8 as *mut c_void, 0, 256); - return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); + core::ptr::write_bytes(&raw mut (*coder).history as *mut u8, 0 as u8, 256); + lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) } #[no_mangle] pub unsafe extern "C" fn lzma_delta_coder_memusage(options: *const c_void) -> u64 { @@ -63,5 +63,5 @@ pub unsafe extern "C" fn lzma_delta_coder_memusage(options: *const c_void) -> u6 { return UINT64_MAX; } - return core::mem::size_of::() as u64; + core::mem::size_of::() as u64 } diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 044ce952..20d087d6 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -14,9 +14,8 @@ unsafe extern "C" fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8 *buffer.offset(i as isize) = (*buffer.offset(i as isize)).wrapping_add( (*coder).history[(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize], ); - let fresh1 = (*coder).pos; + (*coder).history[((*coder).pos & 0xff) as usize] = *buffer.offset(i as isize); (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder).history[(fresh1 & 0xff) as usize] = *buffer.offset(i as isize); i += 1; } } @@ -33,7 +32,7 @@ unsafe extern "C" fn delta_decode( ) -> lzma_ret { let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; let out_start: size_t = *out_pos; - let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -48,7 +47,7 @@ unsafe extern "C" fn delta_decode( if size > 0 { decode_buffer(coder, out.offset(out_start as isize), size); } - return ret; + ret } #[no_mangle] pub unsafe extern "C" fn lzma_delta_decoder_init( @@ -69,8 +68,8 @@ pub unsafe extern "C" fn lzma_delta_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; - return lzma_delta_coder_init(next, allocator, filters); + ); + lzma_delta_coder_init(next, allocator, filters) } #[no_mangle] pub unsafe extern "C" fn lzma_delta_props_decode( @@ -89,7 +88,7 @@ pub unsafe extern "C" fn lzma_delta_props_decode( return LZMA_MEM_ERROR; } (*opt).type_0 = LZMA_DELTA_TYPE_BYTE; - (*opt).dist = u32::from(*props.offset(0)).wrapping_add(1); + (*opt).dist = u32::from(*props).wrapping_add(1); *options = opt as *mut c_void; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index b9fee97c..7f7a7509 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -25,9 +25,8 @@ unsafe extern "C" fn copy_and_encode( while i < size { let tmp: u8 = (*coder).history[(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize]; - let fresh2 = (*coder).pos; + (*coder).history[((*coder).pos & 0xff) as usize] = *in_0.offset(i as isize); (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder).history[(fresh2 & 0xff) as usize] = *in_0.offset(i as isize); *out.offset(i as isize) = (*in_0.offset(i as isize)).wrapping_sub(tmp); i += 1; } @@ -38,9 +37,8 @@ unsafe extern "C" fn encode_in_place(coder: *mut lzma_delta_coder, buffer: *mut while i < size { let tmp: u8 = (*coder).history[(distance.wrapping_add((*coder).pos as size_t) & 0xff) as usize]; - let fresh0 = (*coder).pos; + (*coder).history[((*coder).pos & 0xff) as usize] = *buffer.offset(i as isize); (*coder).pos = (*coder).pos.wrapping_sub(1); - (*coder).history[(fresh0 & 0xff) as usize] = *buffer.offset(i as isize); *buffer.offset(i as isize) = (*buffer.offset(i as isize)).wrapping_sub(tmp); i += 1; } @@ -83,7 +81,7 @@ unsafe extern "C" fn delta_encode( }; } else { let out_start: size_t = *out_pos; - ret = (*coder).next.code.expect("non-null function pointer")( + ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -99,7 +97,7 @@ unsafe extern "C" fn delta_encode( encode_in_place(coder, out.offset(out_start as isize), size_0); } } - return ret; + ret } unsafe extern "C" fn delta_encoder_update( coder_ptr: *mut c_void, @@ -108,11 +106,11 @@ unsafe extern "C" fn delta_encoder_update( reversed_filters: *const lzma_filter, ) -> lzma_ret { let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; - return lzma_next_filter_update( + lzma_next_filter_update( &raw mut (*coder).next, allocator, reversed_filters.offset(1), - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_delta_encoder_init( @@ -133,25 +131,14 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; - (*next).update = Some( - delta_encoder_update - as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >; - return lzma_delta_coder_init(next, allocator, filters); + ); + (*next).update = Some(delta_encoder_update as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret); + lzma_delta_coder_init(next, allocator, filters) } #[no_mangle] pub unsafe extern "C" fn lzma_delta_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { @@ -159,6 +146,6 @@ pub unsafe extern "C" fn lzma_delta_props_encode(options: *const c_void, out: *m return LZMA_PROG_ERROR; } let opt: *const lzma_options_delta = options as *const lzma_options_delta; - *out.offset(0) = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN) as u8; - return LZMA_OK; + *out = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN) as u8; + LZMA_OK } diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 1a2ab73e..e623e099 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -65,15 +65,11 @@ unsafe extern "C" fn decode_buffer( if (*coder).dict.pos == (*coder).dict.size { (*coder).dict.pos = LZ_DICT_REPEAT_MAX as size_t; (*coder).dict.has_wrapped = true; - memcpy( - (*coder).dict.buf as *mut c_void, - (*coder) - .dict - .buf - .offset((*coder).dict.size as isize) - .offset(-(LZ_DICT_REPEAT_MAX as isize)) as *const c_void, - LZ_DICT_REPEAT_MAX as size_t, - ); + core::ptr::copy_nonoverlapping((*coder) + .dict + .buf + .offset((*coder).dict.size as isize) + .offset(-(LZ_DICT_REPEAT_MAX as isize)) as *const u8, (*coder).dict.buf as *mut u8, LZ_DICT_REPEAT_MAX as size_t); } let dict_start: size_t = (*coder).dict.pos; (*coder).dict.limit = (*coder).dict.pos.wrapping_add( @@ -84,7 +80,7 @@ unsafe extern "C" fn decode_buffer( (*coder).dict.size.wrapping_sub((*coder).dict.pos) }, ); - let ret: lzma_ret = (*coder).lz.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).lz.code.unwrap()( (*coder).lz.coder, &raw mut (*coder).dict, in_0, @@ -93,11 +89,7 @@ unsafe extern "C" fn decode_buffer( ); let copy_size: size_t = (*coder).dict.pos.wrapping_sub(dict_start); if copy_size > 0 { - memcpy( - out.offset(*out_pos as isize) as *mut c_void, - (*coder).dict.buf.offset(dict_start as isize) as *const c_void, - copy_size, - ); + core::ptr::copy_nonoverlapping((*coder).dict.buf.offset(dict_start as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size); } *out_pos = (*out_pos).wrapping_add(copy_size); if (*coder).dict.need_reset { @@ -129,7 +121,7 @@ unsafe extern "C" fn lz_decode( if !(*coder).next_finished && (*coder).temp.pos == (*coder).temp.size { (*coder).temp.pos = 0; (*coder).temp.size = 0; - let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -172,14 +164,14 @@ unsafe extern "C" fn lz_decode( return LZMA_DATA_ERROR; } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn lz_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; lzma_next_end(&raw mut (*coder).next, allocator); lzma_free((*coder).dict.buf as *mut c_void, allocator); if (*coder).lz.end.is_some() { - (*coder).lz.end.expect("non-null function pointer")((*coder).lz.coder, allocator); + (*coder).lz.end.unwrap()((*coder).lz.coder, allocator); } else { lzma_free((*coder).lz.coder, allocator); } @@ -220,10 +212,10 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some(lz_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) - as lzma_end_function; + ; (*coder).dict.buf = core::ptr::null_mut(); (*coder).dict.size = 0; (*coder).lz = LZMA_LZ_DECODER_INIT; @@ -242,14 +234,14 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( } let mut lz_options: lzma_lz_options = lzma_lz_options { dict_size: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, }; - let ret_: lzma_ret = lz_init.expect("non-null function pointer")( + let ret_: lzma_ret = lz_init.unwrap()( &raw mut (*coder).lz, allocator, - (*filters.offset(0)).id, - (*filters.offset(0)).options, + (*filters).id, + (*filters).options, &raw mut lz_options, ); if ret_ != LZMA_OK { @@ -287,11 +279,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( lz_options.dict_size }; let offset: size_t = lz_options.preset_dict_size.wrapping_sub(copy_size); - memcpy( - (*coder).dict.buf.offset((*coder).dict.pos as isize) as *mut c_void, - lz_options.preset_dict.offset(offset as isize) as *const c_void, - copy_size, - ); + core::ptr::copy_nonoverlapping(lz_options.preset_dict.offset(offset as isize) as *const u8, (*coder).dict.buf.offset((*coder).dict.pos as isize) as *mut u8, copy_size); (*coder).dict.pos = (*coder).dict.pos.wrapping_add(copy_size); (*coder).dict.full = copy_size; } @@ -299,12 +287,12 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( (*coder).this_finished = false; (*coder).temp.pos = 0; (*coder).temp.size = 0; - return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); + lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) } #[no_mangle] pub extern "C" fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64 { - return (core::mem::size_of::() as u64) + (core::mem::size_of::() as u64) .wrapping_add(dictionary_size as u64) .wrapping_add((2 * LZ_DICT_REPEAT_MAX) as u64) - .wrapping_add(LZ_DICT_EXTRA as u64); + .wrapping_add(LZ_DICT_EXTRA as u64) } diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 7d48052e..75fa909f 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -53,7 +53,7 @@ pub struct lzma_coder { } #[inline] extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { - return match_finder as u32 & 0xf; + match_finder as u32 & 0xf } pub const HASH_2_SIZE: c_uint = 1u32 << 10; pub const HASH_3_SIZE: c_uint = 1u32 << 16; @@ -61,11 +61,7 @@ pub const LZMA_MEMCMPLEN_EXTRA: u32 = 0; unsafe extern "C" fn move_window(mf: *mut lzma_mf) { let move_offset: u32 = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) & !(15); let move_size: size_t = (*mf).write_pos.wrapping_sub(move_offset) as size_t; - memmove( - (*mf).buffer as *mut c_void, - (*mf).buffer.offset(move_offset as isize) as *const c_void, - move_size, - ); + core::ptr::copy((*mf).buffer.offset(move_offset as isize) as *const u8, (*mf).buffer as *mut u8, move_size); (*mf).offset = (*mf).offset.wrapping_add(move_offset); (*mf).read_pos = (*mf).read_pos.wrapping_sub(move_offset); (*mf).read_limit = (*mf).read_limit.wrapping_sub(move_offset); @@ -99,7 +95,7 @@ unsafe extern "C" fn fill_window( LZMA_OK }; } else { - ret = (*coder).next.code.expect("non-null function pointer")( + ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -112,11 +108,7 @@ unsafe extern "C" fn fill_window( ); } (*coder).mf.write_pos = write_pos as u32; - memset( - (*coder).mf.buffer.offset(write_pos as isize) as *mut c_void, - 0, - 0, - ); + core::ptr::write_bytes((*coder).mf.buffer.offset(write_pos as isize) as *mut u8, 0 as u8, 0); if ret == LZMA_STREAM_END { ret = LZMA_OK; (*coder).mf.action = action; @@ -131,9 +123,9 @@ unsafe extern "C" fn fill_window( let pending: u32 = (*coder).mf.pending; (*coder).mf.pending = 0; (*coder).mf.read_pos = (*coder).mf.read_pos.wrapping_sub(pending); - (*coder).mf.skip.expect("non-null function pointer")(&raw mut (*coder).mf, pending); + (*coder).mf.skip.unwrap()(&raw mut (*coder).mf, pending); } - return ret; + ret } unsafe extern "C" fn lz_encode( coder_ptr: *mut c_void, @@ -154,7 +146,7 @@ unsafe extern "C" fn lz_encode( return ret_; } } - let ret: lzma_ret = (*coder).lz.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).lz.code.unwrap()( (*coder).lz.coder, &raw mut (*coder).mf, out, @@ -166,15 +158,15 @@ unsafe extern "C" fn lz_encode( return ret; } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn lz_encoder_prepare( mf: *mut lzma_mf, allocator: *const lzma_allocator, lz_options: *const lzma_lz_options, ) -> bool { - if !((*lz_options).dict_size >= LZMA_DICT_SIZE_MIN as size_t - && (*lz_options).dict_size <= (1u32 << 30).wrapping_add(1u32 << 29) as size_t) + if (*lz_options).dict_size < LZMA_DICT_SIZE_MIN as size_t + || (*lz_options).dict_size > (1u32 << 30).wrapping_add(1u32 << 29) as size_t || (*lz_options).nice_len > (*lz_options).match_len_max { return true; @@ -186,7 +178,7 @@ unsafe extern "C" fn lz_encoder_prepare( .after_size .wrapping_add((*lz_options).match_len_max) as u32; let mut reserve: u32 = (*lz_options).dict_size.wrapping_div(2) as u32; - if reserve > (1) << 30 { + if reserve > 1 << 30 { reserve = reserve.wrapping_div(2); } reserve = (reserve as size_t).wrapping_add( @@ -211,44 +203,24 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1) as u32; match (*lz_options).match_finder { 3 => { - (*mf).find = Some( - lzma_mf_hc3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, - ) - as Option u32>; - (*mf).skip = Some(lzma_mf_hc3_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) - as Option ()>; + (*mf).find = Some(lzma_mf_hc3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).skip = Some(lzma_mf_hc3_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } 4 => { - (*mf).find = Some( - lzma_mf_hc4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, - ) - as Option u32>; - (*mf).skip = Some(lzma_mf_hc4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) - as Option ()>; + (*mf).find = Some(lzma_mf_hc4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).skip = Some(lzma_mf_hc4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } 18 => { - (*mf).find = Some( - lzma_mf_bt2_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, - ) - as Option u32>; - (*mf).skip = Some(lzma_mf_bt2_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) - as Option ()>; + (*mf).find = Some(lzma_mf_bt2_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).skip = Some(lzma_mf_bt2_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } 19 => { - (*mf).find = Some( - lzma_mf_bt3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, - ) - as Option u32>; - (*mf).skip = Some(lzma_mf_bt3_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) - as Option ()>; + (*mf).find = Some(lzma_mf_bt3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).skip = Some(lzma_mf_bt3_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } 20 => { - (*mf).find = Some( - lzma_mf_bt4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, - ) - as Option u32>; - (*mf).skip = Some(lzma_mf_bt4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()) - as Option ()>; + (*mf).find = Some(lzma_mf_bt4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).skip = Some(lzma_mf_bt4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } _ => return true, } @@ -265,7 +237,7 @@ unsafe extern "C" fn lz_encoder_prepare( hs |= hs >> 8; hs >>= 1; hs |= 0xffff; - if hs > (1) << 24 { + if hs > 1 << 24 { if hash_bytes == 3 { hs = (1u32 << 24).wrapping_sub(1) as u32; } else { @@ -302,7 +274,7 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).depth = (4u32).wrapping_add((*mf).nice_len.wrapping_div(4)); } } - return false; + false } unsafe extern "C" fn lz_encoder_init( mf: *mut lzma_mf, @@ -317,11 +289,7 @@ unsafe extern "C" fn lz_encoder_init( if (*mf).buffer.is_null() { return true; } - memset( - (*mf).buffer.offset((*mf).size as isize) as *mut c_void, - 0, - 0, - ); + core::ptr::write_bytes((*mf).buffer.offset((*mf).size as isize) as *mut u8, 0 as u8, 0); } (*mf).offset = (*mf).cyclic_size; (*mf).read_pos = 0; @@ -346,11 +314,7 @@ unsafe extern "C" fn lz_encoder_init( return true; } } else { - memset( - (*mf).hash as *mut c_void, - 0, - ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::()), - ); + core::ptr::write_bytes((*mf).hash as *mut u8, 0 as u8, ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::())); } (*mf).cyclic_pos = 0; if !(*lz_options).preset_dict.is_null() && (*lz_options).preset_dict_size > 0 { @@ -359,19 +323,15 @@ unsafe extern "C" fn lz_encoder_init( } else { (*mf).size }; - memcpy( - (*mf).buffer as *mut c_void, - (*lz_options) - .preset_dict - .offset((*lz_options).preset_dict_size as isize) - .offset(-((*mf).write_pos as isize)) as *const c_void, - (*mf).write_pos as size_t, - ); + core::ptr::copy_nonoverlapping((*lz_options) + .preset_dict + .offset((*lz_options).preset_dict_size as isize) + .offset(-((*mf).write_pos as isize)) as *const u8, (*mf).buffer as *mut u8, (*mf).write_pos as size_t); (*mf).action = LZMA_SYNC_FLUSH; - (*mf).skip.expect("non-null function pointer")(mf, (*mf).write_pos); + (*mf).skip.unwrap()(mf, (*mf).write_pos); } (*mf).action = LZMA_RUN; - return false; + false } #[no_mangle] pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> u64 { @@ -400,20 +360,14 @@ pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) - hash_count: 0, sons_count: 0, }; - if unsafe { - lz_encoder_prepare( - &raw mut mf, - ::core::ptr::null::(), - lz_options, - ) - } { + if unsafe { lz_encoder_prepare(&raw mut mf, core::ptr::null(), lz_options) } { return UINT64_MAX; } - return (mf.hash_count as u64) + (mf.hash_count as u64) .wrapping_add(mf.sons_count as u64) .wrapping_mul(core::mem::size_of::() as u64) .wrapping_add(mf.size as u64) - .wrapping_add(core::mem::size_of::() as u64); + .wrapping_add(core::mem::size_of::() as u64) } unsafe extern "C" fn lz_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; @@ -422,7 +376,7 @@ unsafe extern "C" fn lz_encoder_end(coder_ptr: *mut c_void, allocator: *const lz lzma_free((*coder).mf.hash as *mut c_void, allocator); lzma_free((*coder).mf.buffer as *mut c_void, allocator); if (*coder).lz.end.is_some() { - (*coder).lz.end.expect("non-null function pointer")((*coder).lz.coder, allocator); + (*coder).lz.end.unwrap()((*coder).lz.coder, allocator); } else { lzma_free((*coder).lz.coder, allocator); } @@ -438,19 +392,15 @@ unsafe extern "C" fn lz_encoder_update( if (*coder).lz.options_update.is_none() { return LZMA_PROG_ERROR; } - let ret_: lzma_ret = - (*coder) - .lz - .options_update - .expect("non-null function pointer")((*coder).lz.coder, reversed_filters); + let ret_: lzma_ret = (*coder).lz.options_update.unwrap()((*coder).lz.coder, reversed_filters); if ret_ != LZMA_OK { return ret_; } - return lzma_next_filter_update( + lzma_next_filter_update( &raw mut (*coder).next, allocator, reversed_filters.offset(1), - ); + ) } unsafe extern "C" fn lz_encoder_set_out_limit( coder_ptr: *mut c_void, @@ -459,14 +409,9 @@ unsafe extern "C" fn lz_encoder_set_out_limit( ) -> lzma_ret { let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; if (*coder).next.code.is_none() && (*coder).lz.set_out_limit.is_some() { - return (*coder) - .lz - .set_out_limit - .expect("non-null function pointer")( - (*coder).lz.coder, uncomp_size, out_limit - ); + return (*coder).lz.set_out_limit.unwrap()((*coder).lz.coder, uncomp_size, out_limit); } - return LZMA_OPTIONS_ERROR; + LZMA_OPTIONS_ERROR } #[no_mangle] pub unsafe extern "C" fn lzma_lz_encoder_init( @@ -503,32 +448,17 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some(lz_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) - as lzma_end_function; - (*next).update = Some( - lz_encoder_update - as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >; - (*next).set_out_limit = Some( - lz_encoder_set_out_limit - as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; + ; + (*next).update = Some(lz_encoder_update as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret); + (*next).set_out_limit = Some(lz_encoder_set_out_limit as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret); (*coder).lz.coder = core::ptr::null_mut(); (*coder).lz.code = None; (*coder).lz.end = None; @@ -559,16 +489,16 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( after_size: 0, match_len_max: 0, nice_len: 0, - match_finder: 0 as lzma_match_finder, + match_finder: 0, depth: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, }; - let ret_: lzma_ret = lz_init.expect("non-null function pointer")( + let ret_: lzma_ret = lz_init.unwrap()( &raw mut (*coder).lz, allocator, - (*filters.offset(0)).id, - (*filters.offset(0)).options, + (*filters).id, + (*filters).options, &raw mut lz_options, ); if ret_ != LZMA_OK { @@ -580,7 +510,7 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( if lz_encoder_init(&raw mut (*coder).mf, allocator, &raw mut lz_options) { return LZMA_MEM_ERROR; } - return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); + lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) } #[no_mangle] pub extern "C" fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 093e6dcf..83181c6f 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -5,11 +5,11 @@ extern "C" { } #[inline] unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { - return (*mf).buffer.offset((*mf).read_pos as isize); + (*mf).buffer.offset((*mf).read_pos as isize) } #[inline] unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { - return (*mf).write_pos.wrapping_sub((*mf).read_pos); + (*mf).write_pos.wrapping_sub((*mf).read_pos) } pub const HASH_2_SIZE: c_uint = 1u32 << 10; pub const HASH_3_SIZE: c_uint = 1u32 << 16; @@ -27,7 +27,7 @@ unsafe extern "C" fn lzma_memcmplen( while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { len += 1; } - return len; + len } #[no_mangle] pub unsafe extern "C" fn lzma_mf_find( @@ -35,7 +35,7 @@ pub unsafe extern "C" fn lzma_mf_find( count_ptr: *mut u32, matches: *mut lzma_match, ) -> u32 { - let count: u32 = (*mf).find.expect("non-null function pointer")(mf, matches) as u32; + let count: u32 = (*mf).find.unwrap()(mf, matches) as u32; let mut len_best: u32 = 0; if count > 0 { len_best = (*matches.offset(count.wrapping_sub(1) as isize)).len; @@ -53,7 +53,7 @@ pub unsafe extern "C" fn lzma_mf_find( } *count_ptr = count; (*mf).read_ahead = (*mf).read_ahead.wrapping_add(1); - return len_best; + len_best } pub const EMPTY_HASH_VALUE: u32 = 0; pub const MUST_NORMALIZE_POS: c_uint = UINT32_MAX; @@ -110,9 +110,9 @@ unsafe extern "C" fn hc_find_func( *son.offset(cyclic_pos as isize) = cur_match; loop { let delta: u32 = pos.wrapping_sub(cur_match); - let fresh2 = depth; + let old_depth = depth; depth = depth.wrapping_sub(1); - if fresh2 == 0 || delta >= cyclic_size { + if old_depth == 0 || delta >= cyclic_size { return matches; } let pb: *const u8 = cur.offset(-(delta as isize)); @@ -123,7 +123,7 @@ unsafe extern "C" fn hc_find_func( as isize, ); if *pb.offset(len_best as isize) == *cur.offset(len_best as isize) - && *pb.offset(0) == *cur.offset(0) + && *pb == *cur { let len: u32 = lzma_memcmplen(pb, cur, 1, len_limit); if len_best < len { @@ -150,7 +150,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0; - let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); @@ -164,8 +164,8 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_best: u32 = 2; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); - (*matches.offset(0)).len = len_best; - (*matches.offset(0)).dist = delta2.wrapping_sub(1); + (*matches).len = len_best; + (*matches).dist = delta2.wrapping_sub(1); matches_count = 1; if len_best == len_limit { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; @@ -187,7 +187,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m ) .offset_from(matches) as u32; move_pos(mf); - return matches_count; + matches_count } #[no_mangle] pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { @@ -197,7 +197,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { } else { let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let cur_match: u32 = *(*mf) @@ -211,7 +211,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { move_pos(mf); } amount -= 1; - if !(amount != 0) { + if amount == 0 { break; } } @@ -228,7 +228,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0; - let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; let hash_value: u32 = @@ -253,15 +253,14 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_best: u32 = 1; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = 2; - (*matches.offset(0)).len = 2; - (*matches.offset(0)).dist = delta2.wrapping_sub(1); + (*matches).len = 2; + (*matches).dist = delta2.wrapping_sub(1); matches_count = 1; } if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) == *cur { len_best = 3; - let fresh3 = matches_count; + (*matches.offset(matches_count as isize)).dist = delta3.wrapping_sub(1); matches_count += 1; - (*matches.offset(fresh3 as isize)).dist = delta3.wrapping_sub(1); delta2 = delta3; } if matches_count != 0 { @@ -290,7 +289,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m ) .offset_from(matches) as u32; move_pos(mf); - return matches_count; + matches_count } #[no_mangle] pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { @@ -300,7 +299,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { } else { let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; let hash_value: u32 = (temp @@ -321,7 +320,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { move_pos(mf); } amount -= 1; - if !(amount != 0) { + if amount == 0 { break; } } @@ -344,9 +343,9 @@ unsafe extern "C" fn bt_find_func( let mut len1: u32 = 0; loop { let delta: u32 = pos.wrapping_sub(cur_match); - let fresh4 = depth; + let old_depth = depth; depth = depth.wrapping_sub(1); - if fresh4 == 0 || delta >= cyclic_size { + if old_depth == 0 || delta >= cyclic_size { *ptr0 = EMPTY_HASH_VALUE; *ptr1 = EMPTY_HASH_VALUE; return matches; @@ -367,7 +366,7 @@ unsafe extern "C" fn bt_find_func( (*matches).dist = delta.wrapping_sub(1); matches = matches.offset(1); if len == len_limit { - *ptr1 = *pair.offset(0); + *ptr1 = *pair; *ptr0 = *pair.offset(1); return matches; } @@ -402,9 +401,9 @@ unsafe extern "C" fn bt_skip_func( let mut len1: u32 = 0; loop { let delta: u32 = pos.wrapping_sub(cur_match); - let fresh5 = depth; + let old_depth = depth; depth = depth.wrapping_sub(1); - if fresh5 == 0 || delta >= cyclic_size { + if old_depth == 0 || delta >= cyclic_size { *ptr0 = EMPTY_HASH_VALUE; *ptr1 = EMPTY_HASH_VALUE; return; @@ -420,7 +419,7 @@ unsafe extern "C" fn bt_skip_func( if *pb.offset(len as isize) == *cur.offset(len as isize) { len = lzma_memcmplen(pb, cur, len.wrapping_add(1), len_limit); if len == len_limit { - *ptr1 = *pair.offset(0); + *ptr1 = *pair; *ptr0 = *pair.offset(1); return; } @@ -450,7 +449,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_m let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0; - let hash_value: u32 = *cur.offset(0) as u32 | (*cur.offset(1) as u32) << 8; + let hash_value: u32 = *cur as u32 | (*cur.offset(1) as u32) << 8; let cur_match: u32 = *(*mf).hash.offset(hash_value as isize); *(*mf).hash.offset(hash_value as isize) = pos; matches_count = bt_find_func( @@ -467,7 +466,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_m ) .offset_from(matches) as u32; move_pos(mf); - return matches_count; + matches_count } #[no_mangle] pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { @@ -487,7 +486,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { 11875828834189669668 => { let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let hash_value: u32 = *cur.offset(0) as u32 | (*cur.offset(1) as u32) << 8; + let hash_value: u32 = *cur as u32 | (*cur.offset(1) as u32) << 8; let cur_match: u32 = *(*mf).hash.offset(hash_value as isize); *(*mf).hash.offset(hash_value as isize) = pos; bt_skip_func( @@ -505,7 +504,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { _ => {} } amount -= 1; - if !(amount != 0) { + if amount == 0 { break; } } @@ -522,7 +521,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0; - let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); @@ -536,8 +535,8 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_best: u32 = 2; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); - (*matches.offset(0)).len = len_best; - (*matches.offset(0)).dist = delta2.wrapping_sub(1); + (*matches).len = len_best; + (*matches).dist = delta2.wrapping_sub(1); matches_count = 1; if len_best == len_limit { bt_skip_func( @@ -568,7 +567,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m ) .offset_from(matches) as u32; move_pos(mf); - return matches_count; + matches_count } #[no_mangle] pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { @@ -589,7 +588,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let temp: u32 = - lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; + lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let cur_match: u32 = *(*mf) @@ -614,7 +613,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { _ => {} } amount -= 1; - if !(amount != 0) { + if amount == 0 { break; } } @@ -631,7 +630,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let mut matches_count: u32 = 0; - let temp: u32 = lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; let hash_value: u32 = @@ -656,15 +655,14 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m let mut len_best: u32 = 1; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = 2; - (*matches.offset(0)).len = 2; - (*matches.offset(0)).dist = delta2.wrapping_sub(1); + (*matches).len = 2; + (*matches).dist = delta2.wrapping_sub(1); matches_count = 1; } if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) == *cur { len_best = 3; - let fresh6 = matches_count; + (*matches.offset(matches_count as isize)).dist = delta3.wrapping_sub(1); matches_count += 1; - (*matches.offset(fresh6 as isize)).dist = delta3.wrapping_sub(1); delta2 = delta3; } if matches_count != 0 { @@ -702,7 +700,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m ) .offset_from(matches) as u32; move_pos(mf); - return matches_count; + matches_count } #[no_mangle] pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { @@ -723,7 +721,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); let temp: u32 = - lzma_crc32_table[0][*cur.offset(0) as usize] ^ *cur.offset(1) as u32; + lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; let hash_value: u32 = (temp @@ -755,7 +753,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { _ => {} } amount -= 1; - if !(amount != 0) { + if amount == 0 { break; } } diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index 3f0185fa..efe1a5ef 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -129,7 +129,7 @@ unsafe extern "C" fn lzma2_decode( } else { (*coder).next_sequence = SEQ_LZMA; if control >= 0xa0 { - (*coder).lzma.reset.expect("non-null function pointer")( + (*coder).lzma.reset.unwrap()( (*coder).lzma.coder, &raw mut (*coder).options as *const c_void, ); @@ -149,51 +149,43 @@ unsafe extern "C" fn lzma2_decode( } } 1 => { - let fresh0 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); (*coder).uncompressed_size = (*coder) .uncompressed_size - .wrapping_add(((*in_0.offset(fresh0 as isize) as u32) << 8) as size_t); + .wrapping_add(((*in_0.offset(*in_pos as isize) as u32) << 8) as size_t); + *in_pos += 1; (*coder).sequence = SEQ_UNCOMPRESSED_2; } 2 => { - let fresh1 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); (*coder).uncompressed_size = (*coder).uncompressed_size.wrapping_add( - u32::from(*in_0.offset(fresh1 as isize)).wrapping_add(1) as size_t, + u32::from(*in_0.offset(*in_pos as isize)).wrapping_add(1) as size_t, ); + *in_pos += 1; (*coder).sequence = SEQ_COMPRESSED_0; - (*coder) - .lzma - .set_uncompressed - .expect("non-null function pointer")( + (*coder).lzma.set_uncompressed.unwrap()( (*coder).lzma.coder, (*coder).uncompressed_size as lzma_vli, false, ); } 3 => { - let fresh2 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - (*coder).compressed_size = ((*in_0.offset(fresh2 as isize) as u32) << 8) as size_t; + (*coder).compressed_size = ((*in_0.offset(*in_pos as isize) as u32) << 8) as size_t; + *in_pos += 1; (*coder).sequence = SEQ_COMPRESSED_1; } 4 => { - let fresh3 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); (*coder).compressed_size = (*coder).compressed_size.wrapping_add( - u32::from(*in_0.offset(fresh3 as isize)).wrapping_add(1) as size_t, + u32::from(*in_0.offset(*in_pos as isize)).wrapping_add(1) as size_t, ); + *in_pos += 1; (*coder).sequence = (*coder).next_sequence as sequence; } 5 => { - let fresh4 = *in_pos; - *in_pos = (*in_pos).wrapping_add(1); - if lzma_lzma_lclppb_decode(&raw mut (*coder).options, *in_0.offset(fresh4 as isize)) - { + let prop_byte = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if lzma_lzma_lclppb_decode(&raw mut (*coder).options, prop_byte) { return LZMA_DATA_ERROR; } - (*coder).lzma.reset.expect("non-null function pointer")( + (*coder).lzma.reset.unwrap()( (*coder).lzma.coder, &raw mut (*coder).options as *const c_void, ); @@ -201,13 +193,8 @@ unsafe extern "C" fn lzma2_decode( } 6 => { let in_start: size_t = *in_pos; - let ret: lzma_ret = (*coder).lzma.code.expect("non-null function pointer")( - (*coder).lzma.coder, - dict, - in_0, - in_pos, - in_size, - ); + let ret: lzma_ret = + (*coder).lzma.code.unwrap()((*coder).lzma.coder, dict, in_0, in_pos, in_size); let in_used: size_t = (*in_pos).wrapping_sub(in_start); if in_used > (*coder).compressed_size { return LZMA_DATA_ERROR; @@ -237,7 +224,7 @@ unsafe extern "C" fn lzma2_decode( _ => return LZMA_PROG_ERROR, } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn lzma2_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; @@ -259,29 +246,14 @@ unsafe extern "C" fn lzma2_decoder_init( return LZMA_MEM_ERROR; } (*lz).coder = coder as *mut c_void; - (*lz).code = Some( - lzma2_decode - as unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret, - >; - (*lz).end = Some( - lzma2_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) - as Option ()>; + (*lz).code = Some(lzma2_decode as unsafe extern "C" fn( + *mut c_void, + *mut lzma_dict, + *const u8, + *mut size_t, + size_t, + ) -> lzma_ret); + (*lz).end = Some(lzma2_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()); (*coder).lzma = LZMA_LZ_DECODER_INIT; } let options: *const lzma_options_lzma = opt as *const lzma_options_lzma; @@ -289,7 +261,7 @@ unsafe extern "C" fn lzma2_decoder_init( (*coder).need_properties = true; (*coder).need_dictionary_reset = (*options).preset_dict.is_null() || (*options).preset_dict_size == 0; - return lzma_lzma_decoder_create(&raw mut (*coder).lzma, allocator, options, lz_options); + lzma_lzma_decoder_create(&raw mut (*coder).lzma, allocator, options, lz_options) } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_decoder_init( @@ -297,7 +269,7 @@ pub unsafe extern "C" fn lzma_lzma2_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return lzma_lz_decoder_init( + lzma_lz_decoder_init( next, allocator, filters, @@ -311,12 +283,12 @@ pub unsafe extern "C" fn lzma_lzma2_decoder_init( *mut lzma_lz_options, ) -> lzma_ret, ), - ); + ) } #[no_mangle] pub extern "C" fn lzma_lzma2_decoder_memusage(options: *const c_void) -> u64 { - return (core::mem::size_of::() as u64) - .wrapping_add(unsafe { lzma_lzma_decoder_memusage_nocheck(options) }); + (core::mem::size_of::() as u64) + .wrapping_add(unsafe { lzma_lzma_decoder_memusage_nocheck(options) }) } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_props_decode( @@ -328,10 +300,10 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if props_size != 1 { return LZMA_OPTIONS_ERROR; } - if *props.offset(0) & 0xc0 != 0 { + if *props & 0xc0 != 0 { return LZMA_OPTIONS_ERROR; } - if *props.offset(0) > 40 { + if *props > 40 { return LZMA_OPTIONS_ERROR; } let opt: *mut lzma_options_lzma = @@ -339,14 +311,14 @@ pub unsafe extern "C" fn lzma_lzma2_props_decode( if opt.is_null() { return LZMA_MEM_ERROR; } - if *props.offset(0) == 40 { + if *props == 40 { (*opt).dict_size = UINT32_MAX; } else { - (*opt).dict_size = 2u32 | (u32::from(*props.offset(0)) & 1); - (*opt).dict_size <<= u32::from(*props.offset(0)).wrapping_div(2).wrapping_add(11); + (*opt).dict_size = 2u32 | (u32::from(*props) & 1); + (*opt).dict_size <<= u32::from(*props).wrapping_div(2).wrapping_add(11); } - (*opt).preset_dict = ::core::ptr::null::(); + (*opt).preset_dict = core::ptr::null(); (*opt).preset_dict_size = 0; *options = opt as *mut c_void; - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 86e54d0b..0fd4ab12 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -86,10 +86,10 @@ pub const SEQ_LZMA_ENCODE: C2RustUnnamed = 1; pub const SEQ_INIT: C2RustUnnamed = 0; #[inline] unsafe extern "C" fn mf_unencoded(mf: *const lzma_mf) -> u32 { - return (*mf) + (*mf) .write_pos .wrapping_sub((*mf).read_pos) - .wrapping_add((*mf).read_ahead); + .wrapping_add((*mf).read_ahead) } #[inline] unsafe extern "C" fn mf_read( @@ -101,29 +101,25 @@ unsafe extern "C" fn mf_read( ) { let out_avail: size_t = out_size.wrapping_sub(*out_pos); let copy_size: size_t = if out_avail < *left { out_avail } else { *left }; - memcpy( - out.offset(*out_pos as isize) as *mut c_void, - (*mf) - .buffer - .offset((*mf).read_pos as isize) - .offset(-(*left as isize)) as *const c_void, - copy_size, - ); + core::ptr::copy_nonoverlapping((*mf) + .buffer + .offset((*mf).read_pos as isize) + .offset(-(*left as isize)) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size); *out_pos = (*out_pos).wrapping_add(copy_size); *left = (*left).wrapping_sub(copy_size); } pub const FASTPOS_BITS: u32 = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { + if dist < 1 << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1) << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { + if dist < 1 << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); } - return (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32); + (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) } pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; pub const LZMA2_UNCOMPRESSED_MAX: c_uint = 1u32 << 21; @@ -141,30 +137,25 @@ unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { } else { pos = 1; if (*coder).need_state_reset { - (*coder).buf[pos as usize] = (0x80 + ((1) << 5)) as u8; + (*coder).buf[pos as usize] = (0x80 + (1 << 5)) as u8; } else { (*coder).buf[pos as usize] = 0x80 as u8; } } (*coder).buf_pos = pos; let mut size: size_t = (*coder).uncompressed_size.wrapping_sub(1); - let fresh1 = pos; + (*coder).buf[pos as usize] = + ((*coder).buf[pos as usize] as size_t).wrapping_add(size >> 16) as u8; pos += 1; - (*coder).buf[fresh1 as usize] = - ((*coder).buf[fresh1 as usize] as size_t).wrapping_add(size >> 16) as u8; - let fresh2 = pos; + (*coder).buf[pos as usize] = (size >> 8 & 0xff) as u8; pos += 1; - (*coder).buf[fresh2 as usize] = (size >> 8 & 0xff) as u8; - let fresh3 = pos; + (*coder).buf[pos as usize] = (size & 0xff) as u8; pos += 1; - (*coder).buf[fresh3 as usize] = (size & 0xff) as u8; size = (*coder).compressed_size.wrapping_sub(1); - let fresh4 = pos; + (*coder).buf[pos as usize] = (size >> 8) as u8; pos += 1; - (*coder).buf[fresh4 as usize] = (size >> 8) as u8; - let fresh5 = pos; + (*coder).buf[pos as usize] = (size & 0xff) as u8; pos += 1; - (*coder).buf[fresh5 as usize] = (size & 0xff) as u8; if (*coder).need_properties { lzma_lzma_lclppb_encode( &raw mut (*coder).opt_cur, @@ -203,9 +194,8 @@ unsafe extern "C" fn lzma2_encode( 0 => { if mf_unencoded(mf) == 0 { if (*mf).action == LZMA_FINISH { - let fresh0 = *out_pos; - *out_pos = (*out_pos).wrapping_add(1); - *out.offset(fresh0 as isize) = 0; + *out.offset(*out_pos as isize) = 0; + *out_pos += 1; } return if (*mf).action == LZMA_RUN { LZMA_OK @@ -337,7 +327,7 @@ unsafe extern "C" fn lzma2_encode( _ => {} } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn lzma2_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; @@ -370,7 +360,7 @@ unsafe extern "C" fn lzma2_encoder_options_update( (*coder).need_properties = true; (*coder).need_state_reset = true; } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn lzma2_encoder_init( lz: *mut lzma_lz_encoder, @@ -390,34 +380,15 @@ unsafe extern "C" fn lzma2_encoder_init( return LZMA_MEM_ERROR; } (*lz).coder = coder as *mut c_void; - (*lz).code = Some( - lzma2_encode - as unsafe extern "C" fn( - *mut c_void, - *mut lzma_mf, - *mut u8, - *mut size_t, - size_t, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *mut lzma_mf, - *mut u8, - *mut size_t, - size_t, - ) -> lzma_ret, - >; - (*lz).end = Some( - lzma2_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) - as Option ()>; - (*lz).options_update = Some( - lzma2_encoder_options_update - as unsafe extern "C" fn(*mut c_void, *const lzma_filter) -> lzma_ret, - ) - as Option lzma_ret>; + (*lz).code = Some(lzma2_encode as unsafe extern "C" fn( + *mut c_void, + *mut lzma_mf, + *mut u8, + *mut size_t, + size_t, + ) -> lzma_ret); + (*lz).end = Some(lzma2_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()); + (*lz).options_update = Some(lzma2_encoder_options_update as unsafe extern "C" fn(*mut c_void, *const lzma_filter) -> lzma_ret); (*coder).lzma = core::ptr::null_mut(); } (*coder).opt_cur = *(options as *const lzma_options_lzma); @@ -444,7 +415,7 @@ unsafe extern "C" fn lzma2_encoder_init( (*lz_options).before_size = (LZMA2_CHUNK_MAX as size_t).wrapping_sub((*lz_options).dict_size); } - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_encoder_init( @@ -452,7 +423,7 @@ pub unsafe extern "C" fn lzma_lzma2_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return lzma_lz_encoder_init( + lzma_lz_encoder_init( next, allocator, filters, @@ -466,7 +437,7 @@ pub unsafe extern "C" fn lzma_lzma2_encoder_init( *mut lzma_lz_options, ) -> lzma_ret, ), - ); + ) } #[no_mangle] pub extern "C" fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64 { @@ -474,7 +445,7 @@ pub extern "C" fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64 { if lzma_mem == UINT64_MAX { return UINT64_MAX; } - return (core::mem::size_of::() as u64).wrapping_add(lzma_mem); + (core::mem::size_of::() as u64).wrapping_add(lzma_mem) } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { @@ -494,23 +465,23 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *m d |= d >> 8; d |= d >> 16; if d == UINT32_MAX { - *out.offset(0) = 40; + *out = 40; } else { - *out.offset(0) = get_dist_slot(d.wrapping_add(1)).wrapping_sub(24) as u8; + *out = get_dist_slot(d.wrapping_add(1)).wrapping_sub(24) as u8; } - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_block_size(options: *const c_void) -> u64 { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; - if !((*opt).dict_size >= LZMA_DICT_SIZE_MIN as u32 - && (*opt).dict_size <= (1u32 << 30).wrapping_add((1) << 29)) + if (*opt).dict_size < LZMA_DICT_SIZE_MIN as u32 + || (*opt).dict_size > (1u32 << 30).wrapping_add(1 << 29) { return UINT64_MAX; } - return if ((*opt).dict_size as u64).wrapping_mul(3) > (1) << 20 { + if ((*opt).dict_size as u64).wrapping_mul(3) > 1 << 20 { ((*opt).dict_size as u64).wrapping_mul(3) } else { - (1) << 20 - }; + 1 << 20 + } } diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 3b1f3376..07fabd21 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_long, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_lz_decoder_init( next: *mut lzma_next_coder, @@ -100,7 +100,7 @@ pub struct lzma_length_decoder { #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { - let mut num: u32 = *buf.offset(0) as u32; + let mut num: u32 = *buf as u32; num |= (*buf.offset(1) as u32) << 8; num |= (*buf.offset(2) as u32) << 16; num |= (*buf.offset(3) as u32) << 24; @@ -112,7 +112,7 @@ pub const LZ_DICT_REPEAT_MAX: u32 = 288; pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; #[inline] unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { - return *(*dict).buf.offset( + *(*dict).buf.offset( (*dict) .pos .wrapping_sub(distance as size_t) @@ -122,15 +122,15 @@ unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { } else { (*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t) }) as isize, - ); + ) } #[inline] unsafe extern "C" fn dict_get0(dict: *const lzma_dict) -> u8 { - return *(*dict).buf.offset((*dict).pos.wrapping_sub(1) as isize); + *(*dict).buf.offset((*dict).pos.wrapping_sub(1) as isize) } #[inline] unsafe extern "C" fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bool { - return (*dict).full > distance; + (*dict).full > distance } #[inline] unsafe extern "C" fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut u32) -> bool { @@ -147,45 +147,38 @@ unsafe extern "C" fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut } if distance < left { loop { - let fresh0 = back; + *(*dict).buf.offset((*dict).pos as isize) = *(*dict).buf.offset(back as isize); back += 1; - let fresh1 = (*dict).pos; (*dict).pos = (*dict).pos.wrapping_add(1); - *(*dict).buf.offset(fresh1 as isize) = *(*dict).buf.offset(fresh0 as isize); left -= 1; - if !(left > 0) { + if left == 0 { break; } } } else { - memcpy( - (*dict).buf.offset((*dict).pos as isize) as *mut c_void, - (*dict).buf.offset(back as isize) as *const c_void, - left as size_t, - ); + core::ptr::copy_nonoverlapping((*dict).buf.offset(back as isize) as *const u8, (*dict).buf.offset((*dict).pos as isize) as *mut u8, left as size_t); (*dict).pos = (*dict).pos.wrapping_add(left as size_t); } if !(*dict).has_wrapped { (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); } - return *len != 0; + *len != 0 } #[inline] unsafe extern "C" fn dict_put(dict: *mut lzma_dict, byte: u8) { - let fresh2 = (*dict).pos; + *(*dict).buf.offset((*dict).pos as isize) = byte; (*dict).pos = (*dict).pos.wrapping_add(1); - *(*dict).buf.offset(fresh2 as isize) = byte; if !(*dict).has_wrapped { (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); } } #[inline] unsafe extern "C" fn dict_put_safe(dict: *mut lzma_dict, byte: u8) -> bool { - if ((*dict).pos == (*dict).limit) as c_long != 0 { + if (*dict).pos == (*dict).limit { return true; } dict_put(dict, byte); - return false; + false } pub const RC_SHIFT_BITS: u32 = 8; pub const RC_TOP_BITS: u32 = 24; @@ -195,10 +188,10 @@ pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; pub const RC_MOVE_BITS: u32 = 5; #[inline] unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { - return (*options).lc <= LZMA_LCLP_MAX + (*options).lc <= LZMA_LCLP_MAX && (*options).lp <= LZMA_LCLP_MAX && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX - && (*options).pb <= LZMA_PB_MAX; + && (*options).pb <= LZMA_PB_MAX } pub const STATES: u32 = 12; pub const LIT_STATES: u32 = 7; @@ -214,20 +207,20 @@ unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { } pub const MATCH_LEN_MIN: u32 = 2; pub const LEN_LOW_BITS: u32 = 3; -pub const LEN_LOW_SYMBOLS: u32 = (1) << LEN_LOW_BITS; +pub const LEN_LOW_SYMBOLS: u32 = 1 << LEN_LOW_BITS; pub const LEN_MID_BITS: u32 = 3; -pub const LEN_MID_SYMBOLS: u32 = (1) << LEN_MID_BITS; +pub const LEN_MID_SYMBOLS: u32 = 1 << LEN_MID_BITS; pub const LEN_HIGH_BITS: u32 = 8; -pub const LEN_HIGH_SYMBOLS: u32 = (1) << LEN_HIGH_BITS; +pub const LEN_HIGH_SYMBOLS: u32 = 1 << LEN_HIGH_BITS; pub const DIST_STATES: u32 = 4; pub const DIST_SLOT_BITS: u32 = 6; -pub const DIST_SLOTS: u32 = (1) << DIST_SLOT_BITS; +pub const DIST_SLOTS: u32 = 1 << DIST_SLOT_BITS; pub const DIST_MODEL_START: u32 = 4; pub const DIST_MODEL_END: u32 = 14; pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; pub const ALIGN_BITS: u32 = 4; -pub const ALIGN_SIZE: u32 = (1) << ALIGN_BITS; +pub const ALIGN_SIZE: u32 = 1 << ALIGN_BITS; #[inline] unsafe extern "C" fn rc_read_init( rc: *mut lzma_range_decoder, @@ -246,7 +239,7 @@ unsafe extern "C" fn rc_read_init( *in_pos = (*in_pos).wrapping_add(1); (*rc).init_bytes_left = (*rc).init_bytes_left.wrapping_sub(1); } - return LZMA_STREAM_END; + LZMA_STREAM_END } unsafe extern "C" fn lzma_decode( coder_ptr: *mut c_void, @@ -266,7 +259,7 @@ unsafe extern "C" fn lzma_decode( let mut rc: lzma_range_decoder = (*coder).rc; let mut rc_in_ptr: *const u8 = in_0.offset(*in_pos as isize); let rc_in_end: *const u8 = in_0.offset(in_size as isize); - let rc_in_fast_end: *const u8 = if rc_in_end.offset_from(rc_in_ptr) as c_long <= 20 as c_long { + let rc_in_fast_end: *const u8 = if rc_in_end.offset_from(rc_in_ptr) <= 20 { rc_in_ptr } else { rc_in_end.offset(-20) @@ -380,9 +373,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh142 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh142 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -417,9 +409,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh141 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh141 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -457,9 +448,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh140 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh140 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -502,9 +492,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh139 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh139 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -544,9 +533,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh138 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh138 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -578,9 +566,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh123 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh123 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -607,7 +594,7 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); - if !(!dict_is_distance_valid(&raw mut dict, 0)) { + if dict_is_distance_valid(&raw mut dict, 0) { current_block = 4420799852307653083; continue; } @@ -624,9 +611,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh137 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh137 as u32; } } ret_0 = if rc.code == 0 { @@ -645,9 +631,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh136 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh136 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -690,9 +675,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh135 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh135 as u32; } } rc.range >>= 1; @@ -719,9 +703,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh132 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh132 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -757,9 +740,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh129 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh129 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -815,9 +797,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh126 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh126 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -861,9 +842,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh125 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh125 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -900,9 +880,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh124 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh124 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -949,9 +928,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh120 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh120 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -975,7 +953,7 @@ unsafe extern "C" fn lzma_decode( offset &= match_bit; } len <<= 1; - if symbol < ((1) << 8) as u32 { + if symbol < (1 << 8) as u32 { current_block = 18125716024132132232; continue; } else { @@ -984,7 +962,7 @@ unsafe extern "C" fn lzma_decode( } } 5979571030476392895 => { - if (might_finish_without_eopm && dict.pos == dict.limit) as c_long != 0 { + if might_finish_without_eopm && dict.pos == dict.limit { if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_NORMALIZE; @@ -992,9 +970,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh115 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh115 as u32; } } if rc.code == 0 { @@ -1016,9 +993,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh116 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh116 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -1080,9 +1056,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh117 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh117 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -1102,7 +1077,7 @@ unsafe extern "C" fn lzma_decode( *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } - if symbol < ((1) << 8) as u32 { + if symbol < (1 << 8) as u32 { current_block = 13844743919235296534; continue; } else { @@ -1118,9 +1093,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh144 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh144 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -1149,7 +1123,7 @@ unsafe extern "C" fn lzma_decode( continue; } 17340485688450593529 => { - if dict_repeat(&raw mut dict, rep0, &raw mut len) as c_long != 0 { + if dict_repeat(&raw mut dict, rep0, &raw mut len) { (*coder).sequence = SEQ_COPY; current_block = 4609795085482299213; continue; @@ -1165,9 +1139,8 @@ unsafe extern "C" fn lzma_decode( continue; } else { rc.range <<= RC_SHIFT_BITS; - let fresh143 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh143 as u32; } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) @@ -1199,7 +1172,7 @@ unsafe extern "C" fn lzma_decode( } match current_block { 13383302701878543647 => { - if !(!dict_is_distance_valid(&raw mut dict, rep0 as size_t)) { + if dict_is_distance_valid(&raw mut dict, rep0 as size_t) { current_block = 17340485688450593529; continue; } @@ -1209,15 +1182,14 @@ unsafe extern "C" fn lzma_decode( } 4956146061682418353 => loop { pos_state = (dict.pos & pos_mask as size_t) as u32; - if !(rc_in_ptr < rc_in_fast_end) || dict.pos == dict.limit { + if rc_in_ptr >= rc_in_fast_end || dict.pos == dict.limit { current_block = 5979571030476392895; continue 'c_9380; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh3 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh3 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); @@ -1249,9 +1221,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh4 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh4 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -1273,9 +1244,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh7 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh7 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -1297,9 +1267,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh10 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh10 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -1321,9 +1290,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh13 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh13 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -1345,9 +1313,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh16 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh16 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -1369,9 +1336,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh19 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh19 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -1393,9 +1359,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh22 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh22 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -1417,9 +1382,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh25 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh25 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -1455,9 +1419,8 @@ unsafe extern "C" fn lzma_decode( t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh28 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh28 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); @@ -1484,9 +1447,8 @@ unsafe extern "C" fn lzma_decode( t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh31 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh31 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); @@ -1513,9 +1475,8 @@ unsafe extern "C" fn lzma_decode( t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh34 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh34 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); @@ -1542,9 +1503,8 @@ unsafe extern "C" fn lzma_decode( t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh37 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh37 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); @@ -1571,9 +1531,8 @@ unsafe extern "C" fn lzma_decode( t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh40 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh40 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); @@ -1600,9 +1559,8 @@ unsafe extern "C" fn lzma_decode( t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh43 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh43 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); @@ -1629,9 +1587,8 @@ unsafe extern "C" fn lzma_decode( t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh46 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh46 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); @@ -1658,9 +1615,8 @@ unsafe extern "C" fn lzma_decode( t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh49 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh49 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); @@ -1692,9 +1648,8 @@ unsafe extern "C" fn lzma_decode( - ((*coder).is_match[state as usize][pos_state as usize] >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh52 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh52 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).is_rep[state as usize] as u32); @@ -1717,9 +1672,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh53 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh53 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).match_len_decoder.choice as u32); @@ -1734,9 +1688,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh54 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh54 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] @@ -1771,9 +1724,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh55 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh55 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] @@ -1808,9 +1760,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh56 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh56 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] @@ -1843,7 +1794,7 @@ unsafe extern "C" fn lzma_decode( >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add((-((1_i32) << 3) + 2) as u32); + symbol = symbol.wrapping_add((-(1_i32 << 3) + 2) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -1852,9 +1803,8 @@ unsafe extern "C" fn lzma_decode( - ((*coder).match_len_decoder.choice >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh57 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh57 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).match_len_decoder.choice2 as u32); @@ -1870,9 +1820,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh58 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh58 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.mid[pos_state as usize] @@ -1910,9 +1859,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh59 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh59 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.mid[pos_state as usize] @@ -1950,9 +1898,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh60 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh60 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.mid[pos_state as usize] @@ -1989,7 +1936,7 @@ unsafe extern "C" fn lzma_decode( symbol = (symbol << 1).wrapping_add(1); } symbol = - symbol.wrapping_add((-((1_i32) << 3) + 2 + ((1) << 3)) as u32); + symbol.wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2000,9 +1947,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh61 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh61 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.high[symbol as usize] as u32, @@ -2030,9 +1976,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh62 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh62 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.high[symbol as usize] as u32, @@ -2060,9 +2005,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh63 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh63 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.high[symbol as usize] as u32, @@ -2090,9 +2034,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh64 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh64 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.high[symbol as usize] as u32, @@ -2120,9 +2063,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh65 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh65 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.high[symbol as usize] as u32, @@ -2150,9 +2092,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh66 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh66 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.high[symbol as usize] as u32, @@ -2180,9 +2121,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh67 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh67 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.high[symbol as usize] as u32, @@ -2210,9 +2150,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh68 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh68 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.high[symbol as usize] as u32, @@ -2239,7 +2178,7 @@ unsafe extern "C" fn lzma_decode( symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add( - (-((1_i32) << 8) + 2 + ((1) << 3) + ((1) << 3)) as u32, + (-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32, ); len = symbol; } @@ -2255,9 +2194,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh69 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh69 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -2279,9 +2217,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh72 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh72 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -2303,9 +2240,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh75 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh75 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -2327,9 +2263,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh78 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh78 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -2351,9 +2286,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh81 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh81 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -2375,9 +2309,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh84 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh84 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -2397,7 +2330,7 @@ unsafe extern "C" fn lzma_decode( *probs.offset(symbol as isize) >> RC_MOVE_BITS; symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add(-((1_i32) << 6) as u32); + symbol = symbol.wrapping_add(-(1_i32 << 6) as u32); if symbol < DIST_MODEL_START { rep0 = symbol; } else { @@ -2414,9 +2347,8 @@ unsafe extern "C" fn lzma_decode( loop { if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh87 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh87 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul(*probs.offset(symbol as isize) as u32); @@ -2440,7 +2372,7 @@ unsafe extern "C" fn lzma_decode( } offset <<= 1; limit -= 1; - if !(limit > 0) { + if limit == 0 { break; } } @@ -2450,9 +2382,8 @@ unsafe extern "C" fn lzma_decode( rep0 = (rep0 << 1).wrapping_add(1); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh90 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh90 as u32; } rc.range >>= 1; rc.code = rc.code.wrapping_sub(rc.range); @@ -2460,7 +2391,7 @@ unsafe extern "C" fn lzma_decode( rep0 = rep0.wrapping_add(rc_bound); rc.code = rc.code.wrapping_add(rc.range & rc_bound); limit -= 1; - if !(limit > 0) { + if limit == 0 { break; } } @@ -2468,9 +2399,8 @@ unsafe extern "C" fn lzma_decode( symbol = 0; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh91 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh91 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).pos_align[symbol.wrapping_add(1) as usize] as u32, @@ -2500,9 +2430,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh92 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh92 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).pos_align[symbol.wrapping_add(2) as usize] as u32, @@ -2532,9 +2461,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh93 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh93 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).pos_align[symbol.wrapping_add(4) as usize] as u32, @@ -2564,9 +2492,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh94 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh94 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).pos_align[symbol.wrapping_add(8) as usize] as u32, @@ -2600,7 +2527,7 @@ unsafe extern "C" fn lzma_decode( } } } - if !dict_is_distance_valid(&raw mut dict, rep0 as size_t) as c_long != 0 { + if !dict_is_distance_valid(&raw mut dict, rep0 as size_t) { ret_0 = LZMA_DATA_ERROR; current_block = 4609795085482299213; continue 'c_9380; @@ -2617,9 +2544,8 @@ unsafe extern "C" fn lzma_decode( } else { if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh95 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh95 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).is_rep0[state as usize] as u32); @@ -2634,9 +2560,8 @@ unsafe extern "C" fn lzma_decode( as probability; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh96 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh96 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).is_rep0_long[state as usize][pos_state as usize] @@ -2678,9 +2603,8 @@ unsafe extern "C" fn lzma_decode( - ((*coder).is_rep0[state as usize] >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh97 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh97 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).is_rep1[state as usize] as u32); @@ -2704,9 +2628,8 @@ unsafe extern "C" fn lzma_decode( - ((*coder).is_rep1[state as usize] >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh98 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh98 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).is_rep2[state as usize] as u32); @@ -2746,9 +2669,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh99 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh99 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).rep_len_decoder.choice as u32); @@ -2764,9 +2686,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh100 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh100 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.low[pos_state as usize] @@ -2803,9 +2724,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh101 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh101 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.low[pos_state as usize] @@ -2842,9 +2762,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh102 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh102 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.low[pos_state as usize] @@ -2879,7 +2798,7 @@ unsafe extern "C" fn lzma_decode( >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add((-((1_i32) << 3) + 2) as u32); + symbol = symbol.wrapping_add((-(1_i32 << 3) + 2) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2888,9 +2807,8 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.choice >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh103 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh103 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) .wrapping_mul((*coder).rep_len_decoder.choice2 as u32); @@ -2906,9 +2824,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh104 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh104 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.mid[pos_state as usize] @@ -2946,9 +2863,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh105 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh105 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.mid[pos_state as usize] @@ -2986,9 +2902,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh106 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh106 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.mid[pos_state as usize] @@ -3025,7 +2940,7 @@ unsafe extern "C" fn lzma_decode( symbol = (symbol << 1).wrapping_add(1); } symbol = symbol - .wrapping_add((-((1_i32) << 3) + 2 + ((1) << 3)) as u32); + .wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3036,9 +2951,8 @@ unsafe extern "C" fn lzma_decode( symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh107 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh107 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.high[symbol as usize] as u32, @@ -3068,9 +2982,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh108 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh108 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.high[symbol as usize] as u32, @@ -3100,9 +3013,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh109 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh109 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.high[symbol as usize] as u32, @@ -3132,9 +3044,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh110 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh110 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.high[symbol as usize] as u32, @@ -3164,9 +3075,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh111 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh111 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.high[symbol as usize] as u32, @@ -3196,9 +3106,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh112 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh112 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.high[symbol as usize] as u32, @@ -3228,9 +3137,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh113 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh113 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.high[symbol as usize] as u32, @@ -3260,9 +3168,8 @@ unsafe extern "C" fn lzma_decode( } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; - let fresh114 = rc_in_ptr; + rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); - rc.code = rc.code << RC_SHIFT_BITS | *fresh114 as u32; } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.high[symbol as usize] as u32, @@ -3291,14 +3198,14 @@ unsafe extern "C" fn lzma_decode( symbol = (symbol << 1).wrapping_add(1); } symbol = symbol.wrapping_add( - (-((1_i32) << 8) + 2 + ((1) << 3) + ((1) << 3)) as u32, + (-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32, ); len = symbol; } } } } - if !(dict_repeat(&raw mut dict, rep0, &raw mut len) as c_long != 0) { + if !dict_repeat(&raw mut dict, rep0, &raw mut len) { continue; } (*coder).sequence = SEQ_COPY; @@ -3366,7 +3273,7 @@ unsafe extern "C" fn lzma_decode( (*coder).rc.init_bytes_left = 5; (*coder).sequence = SEQ_IS_MATCH; } - return ret_0; + ret_0 } unsafe extern "C" fn lzma_decoder_uncompressed( coder_ptr: *mut c_void, @@ -3415,7 +3322,7 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo let mut i_0: u32 = 0; while i_0 < DIST_STATES { let mut bt_i: u32 = 0; - while bt_i < ((1) << 6) as u32 { + while bt_i < (1 << 6) as u32 { (*coder).dist_slot[i_0 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i += 1; @@ -3428,11 +3335,11 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo i_1 += 1; } let mut bt_i_0: u32 = 0; - while bt_i_0 < ((1) << 4) as u32 { + while bt_i_0 < (1 << 4) as u32 { (*coder).pos_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 += 1; } - let num_pos_states: u32 = (1) << (*options).pb; + let num_pos_states: u32 = 1 << (*options).pb; (*coder).match_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).match_len_decoder.choice2 = (RC_BIT_MODEL_TOTAL >> 1) as probability; (*coder).rep_len_decoder.choice = (RC_BIT_MODEL_TOTAL >> 1) as probability; @@ -3440,25 +3347,25 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo let mut pos_state: u32 = 0; while pos_state < num_pos_states { let mut bt_i_1: u32 = 0; - while bt_i_1 < ((1) << 3) as u32 { + while bt_i_1 < (1 << 3) as u32 { (*coder).match_len_decoder.low[pos_state as usize][bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_1 += 1; } let mut bt_i_2: u32 = 0; - while bt_i_2 < ((1) << 3) as u32 { + while bt_i_2 < (1 << 3) as u32 { (*coder).match_len_decoder.mid[pos_state as usize][bt_i_2 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_2 += 1; } let mut bt_i_3: u32 = 0; - while bt_i_3 < ((1) << 3) as u32 { + while bt_i_3 < (1 << 3) as u32 { (*coder).rep_len_decoder.low[pos_state as usize][bt_i_3 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_3 += 1; } let mut bt_i_4: u32 = 0; - while bt_i_4 < ((1) << 3) as u32 { + while bt_i_4 < (1 << 3) as u32 { (*coder).rep_len_decoder.mid[pos_state as usize][bt_i_4 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_4 += 1; @@ -3466,12 +3373,12 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo pos_state += 1; } let mut bt_i_5: u32 = 0; - while bt_i_5 < ((1) << 8) as u32 { + while bt_i_5 < (1 << 8) as u32 { (*coder).match_len_decoder.high[bt_i_5 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_5 += 1; } let mut bt_i_6: u32 = 0; - while bt_i_6 < ((1) << 8) as u32 { + while bt_i_6 < (1 << 8) as u32 { (*coder).rep_len_decoder.high[bt_i_6 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_6 += 1; } @@ -3494,37 +3401,21 @@ pub unsafe extern "C" fn lzma_lzma_decoder_create( if (*lz).coder.is_null() { return LZMA_MEM_ERROR; } - (*lz).code = Some( - lzma_decode - as unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret, - >; + (*lz).code = Some(lzma_decode as unsafe extern "C" fn( + *mut c_void, + *mut lzma_dict, + *const u8, + *mut size_t, + size_t, + ) -> lzma_ret); (*lz).reset = - Some(lzma_decoder_reset as unsafe extern "C" fn(*mut c_void, *const c_void) -> ()) - as Option ()>; - (*lz).set_uncompressed = Some( - lzma_decoder_uncompressed as unsafe extern "C" fn(*mut c_void, lzma_vli, bool) -> (), - ) - as Option ()>; + Some(lzma_decoder_reset as unsafe extern "C" fn(*mut c_void, *const c_void) -> ()); + (*lz).set_uncompressed = Some(lzma_decoder_uncompressed as unsafe extern "C" fn(*mut c_void, lzma_vli, bool) -> ()); } (*lz_options).dict_size = (*options).dict_size as size_t; (*lz_options).preset_dict = (*options).preset_dict; (*lz_options).preset_dict_size = (*options).preset_dict_size as size_t; - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn lzma_decoder_init( lz: *mut lzma_lz_decoder, @@ -3559,7 +3450,7 @@ unsafe extern "C" fn lzma_decoder_init( } lzma_decoder_reset((*lz).coder, options); lzma_decoder_uncompressed((*lz).coder, uncomp_size, allow_eopm); - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_decoder_init( @@ -3567,7 +3458,7 @@ pub unsafe extern "C" fn lzma_lzma_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return lzma_lz_decoder_init( + lzma_lz_decoder_init( next, allocator, filters, @@ -3581,7 +3472,7 @@ pub unsafe extern "C" fn lzma_lzma_decoder_init( *mut lzma_lz_options, ) -> lzma_ret, ), - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_lclppb_decode( @@ -3595,7 +3486,7 @@ pub unsafe extern "C" fn lzma_lzma_lclppb_decode( byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9u32).wrapping_mul(5)) as u8; (*options).lp = (byte / 9) as u32; (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9)); - return (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX; + (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX } #[no_mangle] pub extern "C" fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64 { @@ -3610,7 +3501,7 @@ pub extern "C" fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64 { if !unsafe { is_lclppb_valid(options as *const lzma_options_lzma) } { return UINT64_MAX; } - return lzma_lzma_decoder_memusage_nocheck(options); + lzma_lzma_decoder_memusage_nocheck(options) } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_props_decode( @@ -3627,12 +3518,12 @@ pub unsafe extern "C" fn lzma_lzma_props_decode( if opt.is_null() { return LZMA_MEM_ERROR; } - if lzma_lzma_lclppb_decode(opt, *props.offset(0)) { + if lzma_lzma_lclppb_decode(opt, *props) { lzma_free(opt as *mut c_void, allocator); return LZMA_OPTIONS_ERROR; } else { (*opt).dict_size = read32le(props.offset(1)); - (*opt).preset_dict = ::core::ptr::null::(); + (*opt).preset_dict = core::ptr::null(); (*opt).preset_dict_size = 0; *options = opt as *mut c_void; return LZMA_OK; diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index c438628d..a3e4d4d3 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_long, c_uint, c_void}; +use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_lz_encoder_init( next: *mut lzma_next_coder, @@ -134,7 +134,7 @@ pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { - *buf.offset(0) = num as u8; + *buf = num as u8; *buf.offset(1) = (num >> 8) as u8; *buf.offset(2) = (num >> 16) as u8; *buf.offset(3) = (num >> 24) as u8; @@ -144,12 +144,12 @@ pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; #[inline] extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { - return match_finder as u32 & 0xf; + match_finder as u32 & 0xf } #[inline] unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { if amount != 0 { - (*mf).skip.expect("non-null function pointer")(mf, amount); + (*mf).skip.unwrap()(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } @@ -162,23 +162,23 @@ pub const RC_MOVE_BITS: u32 = 5; pub const RC_MOVE_REDUCING_BITS: u32 = 4; #[inline] extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { - return unsafe { + unsafe { lzma_rc_prices[((prob as u32 ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] as u32 - }; + } } #[inline] extern "C" fn rc_bit_0_price(prob: probability) -> u32 { - return unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 }; + unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 } } #[inline] extern "C" fn rc_bit_1_price(prob: probability) -> u32 { - return unsafe { + unsafe { lzma_rc_prices [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] as u32 - }; + } } #[inline] unsafe extern "C" fn rc_bittree_price( @@ -192,11 +192,11 @@ unsafe extern "C" fn rc_bittree_price( let bit: u32 = symbol & 1; symbol >>= 1; price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); - if !(symbol != 1) { + if symbol == 1 { break; } } - return price; + price } #[inline] unsafe extern "C" fn rc_reset(rc: *mut lzma_range_encoder) { @@ -235,7 +235,7 @@ unsafe extern "C" fn rc_bittree( bit, ); model_index = (model_index << 1).wrapping_add(bit); - if !(bit_count != 0) { + if bit_count == 0 { break; } } @@ -258,7 +258,7 @@ unsafe extern "C" fn rc_bittree_reverse( ); model_index = (model_index << 1).wrapping_add(bit); bit_count -= 1; - if !(bit_count != 0) { + if bit_count == 0 { break; } } @@ -267,11 +267,10 @@ unsafe extern "C" fn rc_bittree_reverse( unsafe extern "C" fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) { loop { bit_count -= 1; - let fresh0 = (*rc).count; - (*rc).count = (*rc).count.wrapping_add(1); - (*rc).symbols[fresh0 as usize] = + (*rc).symbols[(*rc).count as usize] = (RC_DIRECT_0 as u32).wrapping_add(value >> bit_count & 1) as C2RustUnnamed; - if !(bit_count != 0) { + (*rc).count += 1; + if bit_count == 0 { break; } } @@ -280,9 +279,8 @@ unsafe extern "C" fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_ unsafe extern "C" fn rc_flush(rc: *mut lzma_range_encoder) { let mut i: size_t = 0; while i < 5 { - let fresh1 = (*rc).count; - (*rc).count = (*rc).count.wrapping_add(1); - (*rc).symbols[fresh1 as usize] = RC_FLUSH; + (*rc).symbols[(*rc).count as usize] = RC_FLUSH; + (*rc).count += 1; i += 1; } } @@ -303,7 +301,7 @@ unsafe extern "C" fn rc_shift_low( (*rc).out_total = (*rc).out_total.wrapping_add(1); (*rc).cache = 0xff; (*rc).cache_size = (*rc).cache_size.wrapping_sub(1); - if !((*rc).cache_size != 0) { + if (*rc).cache_size == 0 { break; } } @@ -311,7 +309,7 @@ unsafe extern "C" fn rc_shift_low( } (*rc).cache_size = (*rc).cache_size.wrapping_add(1); (*rc).low = ((*rc).low & 0xffffff as u64) << RC_SHIFT_BITS; - return false; + false } #[inline] unsafe extern "C" fn rc_shift_low_dummy( @@ -329,7 +327,7 @@ unsafe extern "C" fn rc_shift_low_dummy( *out_pos = (*out_pos).wrapping_add(1); *cache = 0xff; *cache_size = (*cache_size).wrapping_sub(1); - if !(*cache_size != 0) { + if *cache_size == 0 { break; } } @@ -337,7 +335,7 @@ unsafe extern "C" fn rc_shift_low_dummy( } *cache_size = (*cache_size).wrapping_add(1); *low = (*low & 0xffffff as u64) << RC_SHIFT_BITS; - return false; + false } #[inline] unsafe extern "C" fn rc_encode( @@ -385,7 +383,7 @@ unsafe extern "C" fn rc_encode( return true; } (*rc).pos = (*rc).pos.wrapping_add(1); - if !((*rc).pos < (*rc).count) { + if (*rc).pos >= (*rc).count { break; } } @@ -398,7 +396,7 @@ unsafe extern "C" fn rc_encode( } (*rc).count = 0; (*rc).pos = 0; - return false; + false } #[inline] unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u64) -> bool { @@ -459,18 +457,18 @@ unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u } pos += 1; } - return false; + false } #[inline] unsafe extern "C" fn rc_pending(rc: *const lzma_range_encoder) -> u64 { - return (*rc).cache_size.wrapping_add(5).wrapping_sub(1); + (*rc).cache_size.wrapping_add(5).wrapping_sub(1) } #[inline] unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { - return (*options).lc <= LZMA_LCLP_MAX + (*options).lc <= LZMA_LCLP_MAX && (*options).lp <= LZMA_LCLP_MAX && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX - && (*options).pb <= LZMA_PB_MAX; + && (*options).pb <= LZMA_PB_MAX } pub const STATES: u32 = 12; pub const LIT_STATES: u32 = 7; @@ -486,11 +484,11 @@ unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { } pub const MATCH_LEN_MIN: u32 = 2; pub const LEN_LOW_BITS: u32 = 3; -pub const LEN_LOW_SYMBOLS: u32 = (1) << LEN_LOW_BITS; +pub const LEN_LOW_SYMBOLS: u32 = 1 << LEN_LOW_BITS; pub const LEN_MID_BITS: u32 = 3; -pub const LEN_MID_SYMBOLS: u32 = (1) << LEN_MID_BITS; +pub const LEN_MID_SYMBOLS: u32 = 1 << LEN_MID_BITS; pub const LEN_HIGH_BITS: u32 = 8; -pub const LEN_HIGH_SYMBOLS: u32 = (1) << LEN_HIGH_BITS; +pub const LEN_HIGH_SYMBOLS: u32 = 1 << LEN_HIGH_BITS; pub const LEN_SYMBOLS: u32 = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS; pub const MATCH_LEN_MAX: u32 = MATCH_LEN_MIN + LEN_SYMBOLS - 1; pub const DIST_STATES: u32 = 4; @@ -500,22 +498,22 @@ pub const DIST_MODEL_END: u32 = 14; pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; pub const ALIGN_BITS: u32 = 4; -pub const ALIGN_SIZE: u32 = (1) << ALIGN_BITS; +pub const ALIGN_SIZE: u32 = 1 << ALIGN_BITS; pub const ALIGN_MASK: u32 = ALIGN_SIZE - 1; pub const REPS: u32 = 4; -pub const OPTS: u32 = (1) << 12; +pub const OPTS: u32 = 1 << 12; pub const FASTPOS_BITS: u32 = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { + if dist < 1 << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1) << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { + if dist < 1 << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); } - return (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32); + (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) } #[inline] unsafe extern "C" fn literal_matched( @@ -538,7 +536,7 @@ unsafe extern "C" fn literal_matched( ); symbol <<= 1; offset &= !(match_byte ^ symbol); - if !(symbol < (1) << 16) { + if symbol >= 1 << 16 { break; } } @@ -871,21 +869,21 @@ unsafe extern "C" fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_m (*mf).read_ahead = 0; rc_bit( &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]).offset(0) + (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) as *mut probability) - .offset(0) as *mut probability, + as *mut probability, 0, ); rc_bittree( &raw mut (*coder).rc, - (&raw mut (*coder).literal as *mut probability).offset(0), + &raw mut (*coder).literal as *mut probability , 8, - *(*mf).buffer.offset(0) as u32, + *(*mf).buffer as u32, ); (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(1); } (*coder).is_initialized = true; - return true; + true } unsafe extern "C" fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) { let pos_state: u32 = position & (*coder).pos_mask; @@ -971,7 +969,7 @@ pub unsafe extern "C" fn lzma_lzma_encode( (*coder).is_flushed = true; return LZMA_OK; } - return LZMA_STREAM_END; + LZMA_STREAM_END } unsafe extern "C" fn lzma_encode( coder: *mut c_void, @@ -980,17 +978,17 @@ unsafe extern "C" fn lzma_encode( out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret { - if ((*mf).action == LZMA_SYNC_FLUSH) as c_long != 0 { + if (*mf).action == LZMA_SYNC_FLUSH { return LZMA_OPTIONS_ERROR; } - return lzma_lzma_encode( + lzma_lzma_encode( coder as *mut lzma_lzma1_encoder, mf, out, out_pos, out_size, UINT32_MAX, - ); + ) } unsafe extern "C" fn lzma_lzma_set_out_limit( coder_ptr: *mut c_void, @@ -1004,15 +1002,15 @@ unsafe extern "C" fn lzma_lzma_set_out_limit( (*coder).out_limit = out_limit; (*coder).uncomp_size_ptr = uncomp_size; (*coder).use_eopm = false; - return LZMA_OK; + LZMA_OK } extern "C" fn is_options_valid(options: *const lzma_options_lzma) -> bool { - return unsafe { + unsafe { is_lclppb_valid(options) && (*options).nice_len >= MATCH_LEN_MIN && (*options).nice_len <= MATCH_LEN_MAX && ((*options).mode == LZMA_MODE_FAST || (*options).mode == LZMA_MODE_NORMAL) - }; + } } extern "C" fn set_lz_options(lz_options: *mut lzma_lz_options, options: *const lzma_options_lzma) { unsafe { @@ -1041,13 +1039,13 @@ unsafe extern "C" fn length_encoder_reset( let mut pos_state: size_t = 0; while pos_state < num_pos_states as size_t { let mut bt_i: u32 = 0; - while bt_i < ((1) << 3) as u32 { + while bt_i < (1 << 3) as u32 { (*lencoder).low[pos_state as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i += 1; } let mut bt_i_0: u32 = 0; - while bt_i_0 < ((1) << 3) as u32 { + while bt_i_0 < (1 << 3) as u32 { (*lencoder).mid[pos_state as usize][bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 += 1; @@ -1055,7 +1053,7 @@ unsafe extern "C" fn length_encoder_reset( pos_state += 1; } let mut bt_i_1: u32 = 0; - while bt_i_1 < ((1) << 8) as u32 { + while bt_i_1 < (1 << 8) as u32 { (*lencoder).high[bt_i_1 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_1 += 1; } @@ -1113,7 +1111,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( let mut i_2: size_t = 0; while i_2 < DIST_STATES as size_t { let mut bt_i: u32 = 0; - while bt_i < ((1) << 6) as u32 { + while bt_i < (1 << 6) as u32 { (*coder).dist_slot[i_2 as usize][bt_i as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i += 1; @@ -1121,25 +1119,25 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( i_2 += 1; } let mut bt_i_0: u32 = 0; - while bt_i_0 < ((1) << 4) as u32 { + while bt_i_0 < (1 << 4) as u32 { (*coder).dist_align[bt_i_0 as usize] = (RC_BIT_MODEL_TOTAL >> 1) as probability; bt_i_0 += 1; } length_encoder_reset( &raw mut (*coder).match_len_encoder, - (1) << (*options).pb, + 1 << (*options).pb, (*coder).fast_mode, ); length_encoder_reset( &raw mut (*coder).rep_len_encoder, - (1) << (*options).pb, + 1 << (*options).pb, (*coder).fast_mode, ); (*coder).match_price_count = UINT32_MAX.wrapping_div(2) as u32; (*coder).align_price_count = UINT32_MAX.wrapping_div(2) as u32; (*coder).opts_end_index = 0; (*coder).opts_current_index = 0; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_create( @@ -1162,11 +1160,11 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( } 2 => { (*coder).fast_mode = false; - if (*options).dict_size > (1u32 << 30).wrapping_add((1) << 29) { + if (*options).dict_size > (1u32 << 30).wrapping_add(1 << 29) { return LZMA_OPTIONS_ERROR; } let mut log_size: u32 = 0; - while (1) << log_size < (*options).dict_size { + while 1 << log_size < (*options).dict_size { log_size += 1; } (*coder).dist_table_size = log_size.wrapping_mul(2); @@ -1195,7 +1193,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( (*coder).use_eopm = (*options).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0; } set_lz_options(lz_options, options); - return lzma_lzma_encoder_reset(coder, options); + lzma_lzma_encoder_reset(coder, options) } unsafe extern "C" fn lzma_encoder_init( lz: *mut lzma_lz_encoder, @@ -1207,36 +1205,21 @@ unsafe extern "C" fn lzma_encoder_init( if options.is_null() { return LZMA_PROG_ERROR; } - (*lz).code = Some( - lzma_encode - as unsafe extern "C" fn( - *mut c_void, - *mut lzma_mf, - *mut u8, - *mut size_t, - size_t, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *mut lzma_mf, - *mut u8, - *mut size_t, - size_t, - ) -> lzma_ret, - >; - (*lz).set_out_limit = Some( - lzma_lzma_set_out_limit as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret, - ) - as Option lzma_ret>; - return lzma_lzma_encoder_create( + (*lz).code = Some(lzma_encode as unsafe extern "C" fn( + *mut c_void, + *mut lzma_mf, + *mut u8, + *mut size_t, + size_t, + ) -> lzma_ret); + (*lz).set_out_limit = Some(lzma_lzma_set_out_limit as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret); + lzma_lzma_encoder_create( &raw mut (*lz).coder, allocator, id, options as *const lzma_options_lzma, lz_options, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_init( @@ -1244,7 +1227,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return lzma_lz_encoder_init( + lzma_lz_encoder_init( next, allocator, filters, @@ -1258,7 +1241,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_init( *mut lzma_lz_options, ) -> lzma_ret, ), - ); + ) } #[no_mangle] pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { @@ -1271,9 +1254,9 @@ pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { after_size: 0, match_len_max: 0, nice_len: 0, - match_finder: 0 as lzma_match_finder, + match_finder: 0, depth: 0, - preset_dict: ::core::ptr::null::(), + preset_dict: core::ptr::null(), preset_dict_size: 0, }; set_lz_options(&raw mut lz_options, options as *const lzma_options_lzma); @@ -1281,7 +1264,7 @@ pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { if lz_memusage == UINT64_MAX { return UINT64_MAX; } - return (core::mem::size_of::() as u64).wrapping_add(lz_memusage); + (core::mem::size_of::() as u64).wrapping_add(lz_memusage) } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_lclppb_encode( @@ -1297,7 +1280,7 @@ pub unsafe extern "C" fn lzma_lzma_lclppb_encode( .wrapping_add((*options).lp) .wrapping_mul(9) .wrapping_add((*options).lc) as u8; - return false; + false } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { @@ -1309,9 +1292,9 @@ pub unsafe extern "C" fn lzma_lzma_props_encode(options: *const c_void, out: *mu return LZMA_PROG_ERROR; } write32le(out.offset(1), (*opt).dict_size); - return LZMA_OK; + LZMA_OK } #[no_mangle] pub extern "C" fn lzma_mode_is_supported(mode: lzma_mode) -> lzma_bool { - return (mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL) as lzma_bool; + (mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL) as lzma_bool } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index e197939f..d8094b49 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -63,7 +63,7 @@ pub struct lzma_lzma1_encoder_s { pub opts_current_index: u32, pub opts: [lzma_optimal; OPTS as usize], } -pub const OPTS: u32 = (1) << 12; +pub const OPTS: u32 = 1 << 12; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { @@ -92,16 +92,16 @@ pub struct lzma_length_encoder { pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; #[inline] unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { - return (*mf).buffer.offset((*mf).read_pos as isize); + (*mf).buffer.offset((*mf).read_pos as isize) } #[inline] unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { - return (*mf).write_pos.wrapping_sub((*mf).read_pos); + (*mf).write_pos.wrapping_sub((*mf).read_pos) } #[inline] unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { if amount != 0 { - (*mf).skip.expect("non-null function pointer")(mf, amount); + (*mf).skip.unwrap()(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } @@ -116,7 +116,7 @@ unsafe extern "C" fn lzma_memcmplen( while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { len += 1; } - return len; + len } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_optimum_fast( @@ -140,10 +140,10 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( } let mut buf: *const u8 = mf_ptr(mf).offset(-1); let buf_avail: u32 = - if mf_avail(mf).wrapping_add(1) < (2 + (((1) << 3) + ((1) << 3) + ((1) << 8)) - 1) as u32 { + if mf_avail(mf).wrapping_add(1) < (2 + ((1 << 3) + (1 << 3) + (1 << 8)) - 1) as u32 { (mf_avail(mf) as u32).wrapping_add(1) } else { - (2 + (((1) << 3) + ((1) << 3) + ((1) << 8)) - 1) as u32 + (2 + ((1 << 3) + (1 << 3) + (1 << 8)) - 1) as u32 }; if buf_avail < 2 { *back_res = UINT32_MAX; @@ -155,7 +155,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( let mut i: u32 = 0; while i < REPS { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); - if !(*buf.offset(0) != *buf_back.offset(0) || *buf.offset(1) != *buf_back.offset(1)) { + if *buf == *buf_back && *buf.offset(1) == *buf_back.offset(1) { let len: u32 = lzma_memcmplen(buf, buf_back, 2, buf_avail) as u32; if len >= nice_len { *back_res = i; @@ -187,7 +187,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( .len .wrapping_add(1) { - if !(back_main >> 7 > (*coder).matches[matches_count.wrapping_sub(2) as usize].dist) { + if back_main >> 7 <= (*coder).matches[matches_count.wrapping_sub(2) as usize].dist { break; } matches_count -= 1; @@ -200,8 +200,8 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( } if rep_len >= 2 { if rep_len.wrapping_add(1) >= len_main - || rep_len.wrapping_add(2) >= len_main && back_main > (1) << 9 - || rep_len.wrapping_add(3) >= len_main && back_main > (1) << 15 + || rep_len.wrapping_add(2) >= len_main && back_main > 1 << 9 + || rep_len.wrapping_add(3) >= len_main && back_main > 1 << 15 { *back_res = rep_index; *len_res = rep_len; diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 9a25ae5b..22827d4d 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; +use core::ffi::c_uint; extern "C" { fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; static lzma_rc_prices: [u8; 128]; @@ -65,7 +65,7 @@ pub struct lzma_lzma1_encoder_s { pub opts_current_index: u32, pub opts: [lzma_optimal; OPTS as usize], } -pub const OPTS: u32 = (1) << 12; +pub const OPTS: u32 = 1 << 12; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { @@ -94,16 +94,16 @@ pub struct lzma_length_encoder { pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; #[inline] unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { - return (*mf).buffer.offset((*mf).read_pos as isize); + (*mf).buffer.offset((*mf).read_pos as isize) } #[inline] unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { - return (*mf).write_pos.wrapping_sub((*mf).read_pos); + (*mf).write_pos.wrapping_sub((*mf).read_pos) } #[inline] unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { if amount != 0 { - (*mf).skip.expect("non-null function pointer")(mf, amount); + (*mf).skip.unwrap()(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } @@ -114,23 +114,23 @@ pub const RC_BIT_PRICE_SHIFT_BITS: u32 = 4; pub const RC_INFINITY_PRICE: c_uint = 1u32 << 30; #[inline] extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { - return unsafe { + unsafe { lzma_rc_prices[((prob as u32 ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] as u32 - }; + } } #[inline] extern "C" fn rc_bit_0_price(prob: probability) -> u32 { - return unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 }; + unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 } } #[inline] extern "C" fn rc_bit_1_price(prob: probability) -> u32 { - return unsafe { + unsafe { lzma_rc_prices [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] as u32 - }; + } } #[inline] unsafe extern "C" fn rc_bittree_price( @@ -144,11 +144,11 @@ unsafe extern "C" fn rc_bittree_price( let bit: u32 = symbol & 1; symbol >>= 1; price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); - if !(symbol != 1) { + if symbol == 1 { break; } } - return price; + price } #[inline] unsafe extern "C" fn rc_bittree_reverse_price( @@ -164,15 +164,15 @@ unsafe extern "C" fn rc_bittree_reverse_price( price = price.wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); model_index = (model_index << 1).wrapping_add(bit); bit_levels -= 1; - if !(bit_levels != 0) { + if bit_levels == 0 { break; } } - return price; + price } #[inline] extern "C" fn rc_direct_price(bits: u32) -> u32 { - return bits << RC_BIT_PRICE_SHIFT_BITS; + bits << RC_BIT_PRICE_SHIFT_BITS } pub const LIT_STATES: u32 = 7; pub const MATCH_LEN_MIN: u32 = 2; @@ -183,34 +183,34 @@ pub const DIST_MODEL_END: u32 = 14; pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; pub const ALIGN_BITS: u32 = 4; -pub const ALIGN_SIZE: u32 = (1) << ALIGN_BITS; +pub const ALIGN_SIZE: u32 = 1 << ALIGN_BITS; pub const ALIGN_MASK: u32 = ALIGN_SIZE - 1; pub const REPS: u32 = 4; pub const FASTPOS_BITS: u32 = 13; #[inline] unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < (1) << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { + if dist < 1 << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { return lzma_fastpos[dist as usize] as u32; } - if dist < (1) << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { + if dist < 1 << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); } - return (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32); + (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) } #[inline] unsafe extern "C" fn get_dist_slot_2(dist: u32) -> u32 { - if dist < (1) << FASTPOS_BITS + (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1)) { + if dist < 1 << FASTPOS_BITS + (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1)) { return (lzma_fastpos[(dist >> 14 / 2 - 1 + 0 * (FASTPOS_BITS - 1)) as usize] as u32) .wrapping_add((2 * (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1))) as u32); } - if dist < (1) << FASTPOS_BITS + (14 / 2 - 1 + 1 * (FASTPOS_BITS - 1)) { + if dist < 1 << FASTPOS_BITS + (14 / 2 - 1 + 1 * (FASTPOS_BITS - 1)) { return (lzma_fastpos[(dist >> 14 / 2 - 1 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) .wrapping_add((2 * (14 / 2 - 1 + 1 * (FASTPOS_BITS - 1))) as u32); } - return (lzma_fastpos[(dist >> 14 / 2 - 1 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (14 / 2 - 1 + 2 * (FASTPOS_BITS - 1))) as u32); + (lzma_fastpos[(dist >> 14 / 2 - 1 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (14 / 2 - 1 + 2 * (FASTPOS_BITS - 1))) as u32) } #[inline(always)] unsafe extern "C" fn lzma_memcmplen( @@ -222,7 +222,7 @@ unsafe extern "C" fn lzma_memcmplen( while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { len += 1; } - return len; + len } unsafe extern "C" fn get_literal_price( coder: *const lzma_lzma1_encoder, @@ -252,18 +252,16 @@ unsafe extern "C" fn get_literal_price( price.wrapping_add(rc_bit_price(*subcoder.offset(subcoder_index as isize), bit)); symbol <<= 1; offset &= !(match_byte ^ symbol); - if !(symbol < (1) << 16) { + if symbol >= 1 << 16 { break; } } } - return price; + price } #[inline] extern "C" fn get_len_price(lencoder: *const lzma_length_encoder, len: u32, pos_state: u32) -> u32 { - return unsafe { - (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN) as usize] - }; + unsafe { (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN) as usize] } } #[inline] extern "C" fn get_short_rep_price( @@ -271,11 +269,11 @@ extern "C" fn get_short_rep_price( state: lzma_lzma_state, pos_state: u32, ) -> u32 { - return unsafe { + unsafe { rc_bit_0_price((*coder).is_rep0[state as usize]).wrapping_add(rc_bit_0_price( (*coder).is_rep0_long[state as usize][pos_state as usize], )) - }; + } } #[inline] extern "C" fn get_pure_rep_price( @@ -314,10 +312,10 @@ extern "C" fn get_rep_price( state: lzma_lzma_state, pos_state: u32, ) -> u32 { - return unsafe { + unsafe { get_len_price(&raw const (*coder).rep_len_encoder, len, pos_state) .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state)) - }; + } } #[inline] extern "C" fn get_dist_len_price( @@ -457,7 +455,7 @@ unsafe extern "C" fn backward( (*coder).opts[pos_prev as usize].back_prev = back_cur; (*coder).opts[pos_prev as usize].pos_prev = cur; cur = pos_prev; - if !(cur != 0) { + if cur == 0 { break; } } @@ -487,10 +485,10 @@ unsafe extern "C" fn helper1( matches_count = (*coder).matches_count; } let buf_avail: u32 = - if mf_avail(mf).wrapping_add(1) < (2 + (((1) << 3) + ((1) << 3) + ((1) << 8)) - 1) as u32 { + if mf_avail(mf).wrapping_add(1) < (2 + ((1 << 3) + (1 << 3) + (1 << 8)) - 1) as u32 { (mf_avail(mf) as u32).wrapping_add(1) } else { - (2 + (((1) << 3) + ((1) << 3) + ((1) << 8)) - 1) as u32 + (2 + ((1 << 3) + (1 << 3) + (1 << 8)) - 1) as u32 }; if buf_avail < 2 { *back_res = UINT32_MAX; @@ -503,7 +501,7 @@ unsafe extern "C" fn helper1( let mut i: u32 = 0; while i < REPS { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); - if *buf.offset(0) != *buf_back.offset(0) || *buf.offset(1) != *buf_back.offset(1) { + if *buf != *buf_back || *buf.offset(1) != *buf_back.offset(1) { rep_lens[i as usize] = 0; } else { rep_lens[i as usize] = lzma_memcmplen(buf, buf_back, 2, buf_avail); @@ -541,7 +539,7 @@ unsafe extern "C" fn helper1( .wrapping_add(get_literal_price( coder, position, - *buf.offset(-(1) as isize) as u32, + *buf.offset(-1) as u32, !(((*coder).state as u32) < LIT_STATES), match_byte as u32, current_byte as u32, @@ -582,14 +580,14 @@ unsafe extern "C" fn helper1( loop { (*coder).opts[len as usize].price = RC_INFINITY_PRICE as u32; len -= 1; - if !(len >= 2) { + if len < 2 { break; } } let mut i_1: u32 = 0; while i_1 < REPS { let mut rep_len: u32 = rep_lens[i_1 as usize]; - if !(rep_len < 2) { + if rep_len >= 2 { let price: u32 = rep_match_price.wrapping_add(get_pure_rep_price( coder, i_1, @@ -609,7 +607,7 @@ unsafe extern "C" fn helper1( (*coder).opts[rep_len as usize].prev_1_is_literal = false; } rep_len -= 1; - if !(rep_len >= 2) { + if rep_len < 2 { break; } } @@ -647,7 +645,7 @@ unsafe extern "C" fn helper1( len += 1; } } - return len_end; + len_end } #[inline] unsafe extern "C" fn helper2( @@ -737,7 +735,7 @@ unsafe extern "C" fn helper2( } } if pos < REPS { - *reps.offset(0) = (*coder).opts[pos_prev as usize].backs[pos as usize]; + *reps = (*coder).opts[pos_prev as usize].backs[pos as usize]; let mut i: u32 = 0; i = 1; while i <= pos { @@ -750,7 +748,7 @@ unsafe extern "C" fn helper2( i += 1; } } else { - *reps.offset(0) = pos.wrapping_sub(REPS); + *reps = pos.wrapping_sub(REPS); let mut i_0: u32 = 1; while i_0 < REPS { *reps.offset(i_0 as isize) = @@ -767,14 +765,14 @@ unsafe extern "C" fn helper2( } let cur_price: u32 = (*coder).opts[cur as usize].price; let current_byte: u8 = *buf; - let match_byte: u8 = *buf.offset(-(*reps.offset(0) as isize)).offset(-1); + let match_byte: u8 = *buf.offset(-(*reps as isize)).offset(-1); let pos_state: u32 = position & (*coder).pos_mask; let cur_and_1_price: u32 = cur_price .wrapping_add(rc_bit_0_price((*coder).is_match[state as usize][pos_state as usize]) as u32) .wrapping_add(get_literal_price( coder, position, - *buf.offset(-(1) as isize) as u32, + *buf.offset(-1) as u32, !((state as u32) < LIT_STATES), match_byte as u32, current_byte as u32, @@ -818,7 +816,7 @@ unsafe extern "C" fn helper2( nice_len }; if !next_is_literal && match_byte != current_byte { - let buf_back: *const u8 = buf.offset(-(*reps.offset(0) as isize)).offset(-1); + let buf_back: *const u8 = buf.offset(-(*reps as isize)).offset(-1); let limit: u32 = if buf_avail_full < nice_len.wrapping_add(1) { buf_avail_full } else { @@ -867,7 +865,7 @@ unsafe extern "C" fn helper2( let buf_back_0: *const u8 = buf .offset(-(*reps.offset(rep_index as isize) as isize)) .offset(-1); - if !(*buf.offset(0) != *buf_back_0.offset(0) || *buf.offset(1) != *buf_back_0.offset(1)) { + if *buf == *buf_back_0 && *buf.offset(1) == *buf_back_0.offset(1) { let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2, buf_avail); while len_end < cur.wrapping_add(len_test_0) { len_end += 1; @@ -891,7 +889,7 @@ unsafe extern "C" fn helper2( (*coder).opts[cur.wrapping_add(len_test_0) as usize].prev_1_is_literal = false; } len_test_0 -= 1; - if !(len_test_0 >= 2) { + if len_test_0 < 2 { break; } } @@ -985,9 +983,8 @@ unsafe extern "C" fn helper2( while new_len > (*coder).matches[matches_count as usize].len { matches_count += 1; } - let fresh0 = matches_count; + (*coder).matches[matches_count as usize].len = new_len; matches_count += 1; - (*coder).matches[fresh0 as usize].len = new_len; } if new_len >= start_len { let normal_match_price: u32 = @@ -1092,7 +1089,7 @@ unsafe extern "C" fn helper2( len_test_1 += 1; } } - return len_end; + len_end } #[no_mangle] pub unsafe extern "C" fn lzma_lzma_optimum_normal( @@ -1111,7 +1108,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( return; } if (*mf).read_ahead == 0 { - if (*coder).match_price_count >= ((1) << 7) as u32 { + if (*coder).match_price_count >= (1 << 7) as u32 { fill_dist_prices(coder); } if (*coder).align_price_count >= ALIGN_SIZE { @@ -1123,11 +1120,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( return; } let mut reps: [u32; 4] = [0; 4]; - memcpy( - &raw mut reps as *mut u32 as *mut c_void, - &raw mut (*coder).reps as *mut u32 as *const c_void, - core::mem::size_of::<[u32; 4]>(), - ); + core::ptr::copy_nonoverlapping(&raw mut (*coder).reps as *const u8, &raw mut reps as *mut u8, core::mem::size_of::<[u32; 4]>()); let mut cur: u32 = 0; cur = 1; while cur < len_end { @@ -1147,10 +1140,10 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( position.wrapping_add(cur), cur, (*mf).nice_len, - if mf_avail(mf).wrapping_add(1) < ((((1) << 12) - 1) as u32).wrapping_sub(cur) { + if mf_avail(mf).wrapping_add(1) < (((1 << 12) - 1) as u32).wrapping_sub(cur) { mf_avail(mf).wrapping_add(1) } else { - ((((1) << 12) - 1) as u32).wrapping_sub(cur) + (((1 << 12) - 1) as u32).wrapping_sub(cur) }, ); cur += 1; diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index c2c56b6d..607c400e 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -16,7 +16,7 @@ pub unsafe extern "C" fn lzma_lzma_preset( if level > 9 || flags & !supported_flags != 0 { return true as lzma_bool; } - (*options).preset_dict = ::core::ptr::null::(); + (*options).preset_dict = core::ptr::null(); (*options).preset_dict_size = 0; (*options).lc = LZMA_LC_DEFAULT; (*options).lp = LZMA_LP_DEFAULT; @@ -52,5 +52,5 @@ pub unsafe extern "C" fn lzma_lzma_preset( (*options).depth = 512; } } - return false as lzma_bool; + false as lzma_bool } diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index 2feccb57..433b085c 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -44,7 +44,7 @@ unsafe extern "C" fn arm_code( } i = i.wrapping_add(4); } - return i; + i } extern "C" fn arm_coder_init( next: *mut lzma_next_coder, @@ -52,7 +52,7 @@ extern "C" fn arm_coder_init( filters: *const lzma_filter_info, is_encoder: bool, ) -> lzma_ret { - return unsafe { + unsafe { lzma_simple_coder_init( next, allocator, @@ -65,7 +65,7 @@ extern "C" fn arm_coder_init( 4, is_encoder, ) - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_simple_arm_encoder_init( @@ -73,7 +73,7 @@ pub unsafe extern "C" fn lzma_simple_arm_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return arm_coder_init(next, allocator, filters, true); + arm_coder_init(next, allocator, filters, true) } #[no_mangle] pub unsafe extern "C" fn lzma_simple_arm_decoder_init( @@ -81,5 +81,5 @@ pub unsafe extern "C" fn lzma_simple_arm_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return arm_coder_init(next, allocator, filters, false); + arm_coder_init(next, allocator, filters, false) } diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index a25022a3..503d0cab 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -15,7 +15,7 @@ extern "C" { #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { - let mut num: u32 = *buf.offset(0) as u32; + let mut num: u32 = *buf as u32; num |= (*buf.offset(1) as u32) << 8; num |= (*buf.offset(2) as u32) << 16; num |= (*buf.offset(3) as u32) << 24; @@ -25,7 +25,7 @@ extern "C" fn read32le(buf: *const u8) -> u32 { #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { - *buf.offset(0) = num as u8; + *buf = num as u8; *buf.offset(1) = (num >> 8) as u8; *buf.offset(2) = (num >> 16) as u8; *buf.offset(3) = (num >> 24) as u8; @@ -55,7 +55,7 @@ unsafe extern "C" fn arm64_code( write32le(buffer.offset(i as isize), instr); } else if instr & 0x9f000000 == 0x90000000 { let src_0: u32 = instr >> 29 & 3 | instr >> 3 & 0x1ffffc; - if !(src_0.wrapping_add(0x20000) & 0x1c0000 != 0) { + if src_0.wrapping_add(0x20000) & 0x1c0000 == 0 { instr = (instr & 0x9000001f) as u32; pc >>= 12; if !is_encoder { @@ -70,7 +70,7 @@ unsafe extern "C" fn arm64_code( } i = i.wrapping_add(4); } - return i; + i } extern "C" fn arm64_coder_init( next: *mut lzma_next_coder, @@ -78,7 +78,7 @@ extern "C" fn arm64_coder_init( filters: *const lzma_filter_info, is_encoder: bool, ) -> lzma_ret { - return unsafe { + unsafe { lzma_simple_coder_init( next, allocator, @@ -92,7 +92,7 @@ extern "C" fn arm64_coder_init( 4, is_encoder, ) - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( @@ -100,7 +100,7 @@ pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return arm64_coder_init(next, allocator, filters, true); + arm64_coder_init(next, allocator, filters, true) } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_arm64_encode( @@ -109,7 +109,7 @@ pub unsafe extern "C" fn lzma_bcj_arm64_encode( size: size_t, ) -> size_t { start_offset = (start_offset & !3u32) as u32; - return arm64_code(core::ptr::null_mut(), start_offset, true, buf, size); + arm64_code(core::ptr::null_mut(), start_offset, true, buf, size) } #[no_mangle] pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( @@ -117,7 +117,7 @@ pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return arm64_coder_init(next, allocator, filters, false); + arm64_coder_init(next, allocator, filters, false) } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_arm64_decode( @@ -126,5 +126,5 @@ pub unsafe extern "C" fn lzma_bcj_arm64_decode( size: size_t, ) -> size_t { start_offset = (start_offset & !3u32) as u32; - return arm64_code(core::ptr::null_mut(), start_offset, false, buf, size); + arm64_code(core::ptr::null_mut(), start_offset, false, buf, size) } diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index 57cd4d6d..2991d556 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -52,7 +52,7 @@ unsafe extern "C" fn armthumb_code( } i = i.wrapping_add(2); } - return i; + i } extern "C" fn armthumb_coder_init( next: *mut lzma_next_coder, @@ -60,7 +60,7 @@ extern "C" fn armthumb_coder_init( filters: *const lzma_filter_info, is_encoder: bool, ) -> lzma_ret { - return unsafe { + unsafe { lzma_simple_coder_init( next, allocator, @@ -74,7 +74,7 @@ extern "C" fn armthumb_coder_init( 2, is_encoder, ) - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_simple_armthumb_encoder_init( @@ -82,7 +82,7 @@ pub unsafe extern "C" fn lzma_simple_armthumb_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return armthumb_coder_init(next, allocator, filters, true); + armthumb_coder_init(next, allocator, filters, true) } #[no_mangle] pub unsafe extern "C" fn lzma_simple_armthumb_decoder_init( @@ -90,5 +90,5 @@ pub unsafe extern "C" fn lzma_simple_armthumb_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return armthumb_coder_init(next, allocator, filters, false); + armthumb_coder_init(next, allocator, filters, false) } diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 0ac8a1d7..6d45a88a 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -32,7 +32,7 @@ unsafe extern "C" fn ia64_code( let mut bit_pos: u32 = 5; let mut slot: size_t = 0; while slot < 3 { - if !(mask >> slot & 1 == 0) { + if mask >> slot & 1 != 0 { let byte_pos: size_t = (bit_pos >> 3) as size_t; let bit_res: u32 = bit_pos & 0x7; let mut instruction: u64 = 0; @@ -74,7 +74,7 @@ unsafe extern "C" fn ia64_code( } i = i.wrapping_add(16); } - return i; + i } extern "C" fn ia64_coder_init( next: *mut lzma_next_coder, @@ -82,7 +82,7 @@ extern "C" fn ia64_coder_init( filters: *const lzma_filter_info, is_encoder: bool, ) -> lzma_ret { - return unsafe { + unsafe { lzma_simple_coder_init( next, allocator, @@ -96,7 +96,7 @@ extern "C" fn ia64_coder_init( 16, is_encoder, ) - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_simple_ia64_encoder_init( @@ -104,7 +104,7 @@ pub unsafe extern "C" fn lzma_simple_ia64_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return ia64_coder_init(next, allocator, filters, true); + ia64_coder_init(next, allocator, filters, true) } #[no_mangle] pub unsafe extern "C" fn lzma_simple_ia64_decoder_init( @@ -112,5 +112,5 @@ pub unsafe extern "C" fn lzma_simple_ia64_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return ia64_coder_init(next, allocator, filters, false); + ia64_coder_init(next, allocator, filters, false) } diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index 5995c570..cbb1fd5b 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -45,7 +45,7 @@ unsafe extern "C" fn powerpc_code( } i = i.wrapping_add(4); } - return i; + i } extern "C" fn powerpc_coder_init( next: *mut lzma_next_coder, @@ -53,7 +53,7 @@ extern "C" fn powerpc_coder_init( filters: *const lzma_filter_info, is_encoder: bool, ) -> lzma_ret { - return unsafe { + unsafe { lzma_simple_coder_init( next, allocator, @@ -67,7 +67,7 @@ extern "C" fn powerpc_coder_init( 4, is_encoder, ) - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_simple_powerpc_encoder_init( @@ -75,7 +75,7 @@ pub unsafe extern "C" fn lzma_simple_powerpc_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return powerpc_coder_init(next, allocator, filters, true); + powerpc_coder_init(next, allocator, filters, true) } #[no_mangle] pub unsafe extern "C" fn lzma_simple_powerpc_decoder_init( @@ -83,5 +83,5 @@ pub unsafe extern "C" fn lzma_simple_powerpc_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return powerpc_coder_init(next, allocator, filters, false); + powerpc_coder_init(next, allocator, filters, false) } diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index c2504c1d..f96544a9 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -15,7 +15,7 @@ extern "C" { #[inline] extern "C" fn read32be(buf: *const u8) -> u32 { return unsafe { - let mut num: u32 = (*buf.offset(0) as u32) << 24; + let mut num: u32 = (*buf as u32) << 24; num |= (*buf.offset(1) as u32) << 16; num |= (*buf.offset(2) as u32) << 8; num |= *buf.offset(3) as u32; @@ -25,7 +25,7 @@ extern "C" fn read32be(buf: *const u8) -> u32 { #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { - let mut num: u32 = *buf.offset(0) as u32; + let mut num: u32 = *buf as u32; num |= (*buf.offset(1) as u32) << 8; num |= (*buf.offset(2) as u32) << 16; num |= (*buf.offset(3) as u32) << 24; @@ -35,7 +35,7 @@ extern "C" fn read32le(buf: *const u8) -> u32 { #[inline] extern "C" fn write32be(buf: *mut u8, num: u32) { unsafe { - *buf.offset(0) = (num >> 24) as u8; + *buf = (num >> 24) as u8; *buf.offset(1) = (num >> 16) as u8; *buf.offset(2) = (num >> 8) as u8; *buf.offset(3) = num as u8; @@ -44,7 +44,7 @@ extern "C" fn write32be(buf: *mut u8, num: u32) { #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { - *buf.offset(0) = num as u8; + *buf = num as u8; *buf.offset(1) = (num >> 8) as u8; *buf.offset(2) = (num >> 16) as u8; *buf.offset(3) = (num >> 24) as u8; @@ -68,7 +68,7 @@ unsafe extern "C" fn riscv_encode( let mut inst: u32 = *buffer.offset(i as isize) as u32; if inst == 0xef { let b1: u32 = *buffer.offset(i.wrapping_add(1) as isize) as u32; - if !(b1 & 0xd != 0) { + if b1 & 0xd == 0 { let b2: u32 = *buffer.offset(i.wrapping_add(2) as isize) as u32; let b3: u32 = *buffer.offset(i.wrapping_add(3) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); @@ -125,7 +125,7 @@ unsafe extern "C" fn riscv_encode( } i = i.wrapping_add(2); } - return i; + i } #[no_mangle] pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( @@ -133,7 +133,7 @@ pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return lzma_simple_coder_init( + lzma_simple_coder_init( next, allocator, filters, @@ -144,7 +144,7 @@ pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( 8, 2, true, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_riscv_encode( @@ -153,7 +153,7 @@ pub unsafe extern "C" fn lzma_bcj_riscv_encode( size: size_t, ) -> size_t { start_offset = (start_offset & !1u32) as u32; - return riscv_encode(core::ptr::null_mut(), start_offset, true, buf, size); + riscv_encode(core::ptr::null_mut(), start_offset, true, buf, size) } unsafe extern "C" fn riscv_decode( _simple: *mut c_void, @@ -173,7 +173,7 @@ unsafe extern "C" fn riscv_decode( let mut inst: u32 = *buffer.offset(i as isize) as u32; if inst == 0xef { let b1: u32 = *buffer.offset(i.wrapping_add(1) as isize) as u32; - if !(b1 & 0xd != 0) { + if b1 & 0xd == 0 { let b2: u32 = *buffer.offset(i.wrapping_add(2) as isize) as u32; let b3: u32 = *buffer.offset(i.wrapping_add(3) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); @@ -227,7 +227,7 @@ unsafe extern "C" fn riscv_decode( } i = i.wrapping_add(2); } - return i; + i } #[no_mangle] pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( @@ -235,7 +235,7 @@ pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return lzma_simple_coder_init( + lzma_simple_coder_init( next, allocator, filters, @@ -246,7 +246,7 @@ pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( 8, 2, false, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_riscv_decode( @@ -255,5 +255,5 @@ pub unsafe extern "C" fn lzma_bcj_riscv_decode( size: size_t, ) -> size_t { start_offset = (start_offset & !1u32) as u32; - return riscv_decode(core::ptr::null_mut(), start_offset, false, buf, size); + riscv_decode(core::ptr::null_mut(), start_offset, false, buf, size) } diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 4ad660e4..eac745f0 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -38,7 +38,7 @@ unsafe extern "C" fn copy_or_code( (*coder).end_was_reached = true; } } else { - let ret: lzma_ret = (*coder).next.code.expect("non-null function pointer")( + let ret: lzma_ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -55,14 +55,14 @@ unsafe extern "C" fn copy_or_code( return ret; } } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn call_filter( coder: *mut lzma_simple_coder, buffer: *mut u8, size: size_t, ) -> size_t { - let filtered: size_t = (*coder).filter.expect("non-null function pointer")( + let filtered: size_t = (*coder).filter.unwrap()( (*coder).simple, (*coder).now_pos, (*coder).is_encoder, @@ -70,7 +70,7 @@ unsafe extern "C" fn call_filter( size, ) as size_t; (*coder).now_pos = ((*coder).now_pos as size_t).wrapping_add(filtered) as u32; - return filtered; + filtered } unsafe extern "C" fn simple_code( coder_ptr: *mut c_void, @@ -109,12 +109,7 @@ unsafe extern "C" fn simple_code( if out_avail > buf_avail || buf_avail == 0 { let out_start: size_t = *out_pos; if buf_avail > 0 { - memcpy( - out.offset(*out_pos as isize) as *mut c_void, - (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) - as *const c_void, - buf_avail, - ); + core::ptr::copy_nonoverlapping((&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, buf_avail); } *out_pos = (*out_pos).wrapping_add(buf_avail); let ret: lzma_ret = copy_or_code( @@ -136,18 +131,10 @@ unsafe extern "C" fn simple_code( (*coder).size = 0; } else if unfiltered > 0 { *out_pos = (*out_pos).wrapping_sub(unfiltered); - memcpy( - &raw mut (*coder).buffer as *mut u8 as *mut c_void, - out.offset(*out_pos as isize) as *const c_void, - unfiltered, - ); + core::ptr::copy_nonoverlapping(out.offset(*out_pos as isize) as *const u8, &raw mut (*coder).buffer as *mut u8, unfiltered); } } else if (*coder).pos > 0 { - memmove( - &raw mut (*coder).buffer as *mut u8 as *mut c_void, - (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const c_void, - buf_avail, - ); + core::ptr::copy((&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const u8, &raw mut (*coder).buffer as *mut u8, buf_avail); (*coder).size = (*coder).size.wrapping_sub((*coder).pos); (*coder).pos = 0; } @@ -182,7 +169,7 @@ unsafe extern "C" fn simple_code( if (*coder).end_was_reached && (*coder).pos == (*coder).size { return LZMA_STREAM_END; } - return LZMA_OK; + LZMA_OK } unsafe extern "C" fn simple_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; @@ -197,11 +184,11 @@ unsafe extern "C" fn simple_coder_update( reversed_filters: *const lzma_filter, ) -> lzma_ret { let coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; - return lzma_next_filter_update( + lzma_next_filter_update( &raw mut (*coder).next, allocator, reversed_filters.offset(1), - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_simple_coder_init( @@ -238,27 +225,16 @@ pub unsafe extern "C" fn lzma_simple_coder_init( size_t, lzma_action, ) -> lzma_ret, - ) as lzma_code_function; + ); (*next).end = Some( simple_coder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ) as lzma_end_function; - (*next).update = Some( - simple_coder_update - as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - ) - as Option< - unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - >; + ); + (*next).update = Some(simple_coder_update as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -282,9 +258,9 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*coder).simple = core::ptr::null_mut(); } } - if !(*filters.offset(0)).options.is_null() { + if !(*filters).options.is_null() { let simple: *const lzma_options_bcj = - (*filters.offset(0)).options as *const lzma_options_bcj; + (*filters).options as *const lzma_options_bcj; (*coder).now_pos = (*simple).start_offset; if (*coder).now_pos & alignment.wrapping_sub(1) != 0 { return LZMA_OPTIONS_ERROR; @@ -297,5 +273,5 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*coder).pos = 0; (*coder).filtered = 0; (*coder).size = 0; - return lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)); + lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) } diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs index e0bdef43..48987a85 100644 --- a/liblzma-rs/src/simple/simple_decoder.rs +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -3,7 +3,7 @@ use core::ffi::c_void; #[inline] extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { - let mut num: u32 = *buf.offset(0) as u32; + let mut num: u32 = *buf as u32; num |= (*buf.offset(1) as u32) << 8; num |= (*buf.offset(2) as u32) << 16; num |= (*buf.offset(3) as u32) << 24; @@ -34,5 +34,5 @@ pub unsafe extern "C" fn lzma_simple_props_decode( } else { *options = opt as *mut c_void; } - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index f05ec3d5..aae02e12 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -3,7 +3,7 @@ use core::ffi::c_void; #[inline] extern "C" fn write32le(buf: *mut u8, num: u32) { unsafe { - *buf.offset(0) = num as u8; + *buf = num as u8; *buf.offset(1) = (num >> 8) as u8; *buf.offset(2) = (num >> 16) as u8; *buf.offset(3) = (num >> 24) as u8; @@ -20,7 +20,7 @@ pub unsafe extern "C" fn lzma_simple_props_size( } else { 4 }) as u32; - return LZMA_OK; + LZMA_OK } #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_encode( @@ -32,5 +32,5 @@ pub unsafe extern "C" fn lzma_simple_props_encode( return LZMA_OK; } write32le(out, (*opt).start_offset); - return LZMA_OK; + LZMA_OK } diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index 59f235a4..b4d2275e 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -49,7 +49,7 @@ unsafe extern "C" fn sparc_code( } i = i.wrapping_add(4); } - return i; + i } extern "C" fn sparc_coder_init( next: *mut lzma_next_coder, @@ -57,7 +57,7 @@ extern "C" fn sparc_coder_init( filters: *const lzma_filter_info, is_encoder: bool, ) -> lzma_ret { - return unsafe { + unsafe { lzma_simple_coder_init( next, allocator, @@ -71,7 +71,7 @@ extern "C" fn sparc_coder_init( 4, is_encoder, ) - }; + } } #[no_mangle] pub unsafe extern "C" fn lzma_simple_sparc_encoder_init( @@ -79,7 +79,7 @@ pub unsafe extern "C" fn lzma_simple_sparc_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return sparc_coder_init(next, allocator, filters, true); + sparc_coder_init(next, allocator, filters, true) } #[no_mangle] pub unsafe extern "C" fn lzma_simple_sparc_decoder_init( @@ -87,5 +87,5 @@ pub unsafe extern "C" fn lzma_simple_sparc_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return sparc_coder_init(next, allocator, filters, false); + sparc_coder_init(next, allocator, filters, false) } diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index 25b5dc72..da75af77 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -76,7 +76,7 @@ unsafe extern "C" fn x86_code( } let i_0: u32 = MASK_TO_BIT_NUMBER[(prev_mask >> 1) as usize]; b = (dest >> (24u32).wrapping_sub(i_0.wrapping_mul(8))) as u8; - if !(b == 0 || b == 0xff) { + if b != 0 && b != 0xff { break; } src = @@ -100,7 +100,7 @@ unsafe extern "C" fn x86_code( } (*simple).prev_mask = prev_mask; (*simple).prev_pos = prev_pos; - return buffer_pos; + buffer_pos } extern "C" fn x86_coder_init( next: *mut lzma_next_coder, @@ -136,7 +136,7 @@ pub unsafe extern "C" fn lzma_simple_x86_encoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return x86_coder_init(next, allocator, filters, true); + x86_coder_init(next, allocator, filters, true) } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_x86_encode( @@ -148,13 +148,13 @@ pub unsafe extern "C" fn lzma_bcj_x86_encode( prev_mask: 0, prev_pos: (-5_i32) as u32, }; - return x86_code( + x86_code( &raw mut simple as *mut c_void, start_offset, true, buf, size, - ); + ) } #[no_mangle] pub unsafe extern "C" fn lzma_simple_x86_decoder_init( @@ -162,7 +162,7 @@ pub unsafe extern "C" fn lzma_simple_x86_decoder_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - return x86_coder_init(next, allocator, filters, false); + x86_coder_init(next, allocator, filters, false) } #[no_mangle] pub unsafe extern "C" fn lzma_bcj_x86_decode( @@ -174,11 +174,11 @@ pub unsafe extern "C" fn lzma_bcj_x86_decode( prev_mask: 0, prev_pos: (-5_i32) as u32, }; - return x86_code( + x86_code( &raw mut simple as *mut c_void, start_offset, false, buf, size, - ); + ) } diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index b11d9c8e..c9c56fae 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -596,9 +596,6 @@ extern "C" { pub fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; pub fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; pub fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); - pub fn memcpy(dst: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; - pub fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void; - pub fn memmove(dst: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; pub fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn strlen(s: *const c_char) -> size_t; From 719a6cefd250d82d39f0bd2f5f949f227fe3334c Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 1 Mar 2026 23:41:16 +0900 Subject: [PATCH 10/51] centralize extern declarations, constants, and helper functions into types.rs --- liblzma-rs-sys/src/lib.rs | 5 +- liblzma-rs/src/check/check.rs | 1 - liblzma-rs/src/check/crc32_fast.rs | 4 - liblzma-rs/src/check/crc64_fast.rs | 4 - liblzma-rs/src/check/sha256.rs | 18 +- liblzma-rs/src/common/alone_decoder.rs | 23 +- liblzma-rs/src/common/alone_encoder.rs | 39 +- liblzma-rs/src/common/auto_decoder.rs | 14 +- liblzma-rs/src/common/block_buffer_decoder.rs | 8 - liblzma-rs/src/common/block_buffer_encoder.rs | 47 +- liblzma-rs/src/common/block_decoder.rs | 29 - liblzma-rs/src/common/block_encoder.rs | 63 +- liblzma-rs/src/common/block_header_decoder.rs | 20 - liblzma-rs/src/common/block_header_encoder.rs | 25 +- liblzma-rs/src/common/block_util.rs | 11 +- liblzma-rs/src/common/common.rs | 16 +- liblzma-rs/src/common/easy_buffer_encoder.rs | 1 - .../src/common/easy_decoder_memusage.rs | 4 - liblzma-rs/src/common/easy_encoder.rs | 1 - .../src/common/easy_encoder_memusage.rs | 4 - liblzma-rs/src/common/easy_preset.rs | 3 - liblzma-rs/src/common/file_info.rs | 29 +- .../src/common/filter_buffer_decoder.rs | 8 - .../src/common/filter_buffer_encoder.rs | 8 - liblzma-rs/src/common/filter_common.rs | 16 +- liblzma-rs/src/common/filter_decoder.rs | 16 - liblzma-rs/src/common/filter_encoder.rs | 17 - liblzma-rs/src/common/filter_flags_decoder.rs | 7 - liblzma-rs/src/common/filter_flags_encoder.rs | 8 - liblzma-rs/src/common/index.rs | 69 +- liblzma-rs/src/common/index_decoder.rs | 40 +- liblzma-rs/src/common/index_encoder.rs | 24 - liblzma-rs/src/common/index_hash.rs | 49 +- liblzma-rs/src/common/lzip_decoder.rs | 43 +- liblzma-rs/src/common/microlzma_decoder.rs | 16 - liblzma-rs/src/common/microlzma_encoder.rs | 16 - liblzma-rs/src/common/outqueue.rs | 19 +- .../src/common/stream_buffer_decoder.rs | 11 - .../src/common/stream_buffer_encoder.rs | 18 - liblzma-rs/src/common/stream_decoder.rs | 61 +- liblzma-rs/src/common/stream_decoder_mt.rs | 349 +------- liblzma-rs/src/common/stream_encoder.rs | 76 +- liblzma-rs/src/common/stream_encoder_mt.rs | 354 +------- liblzma-rs/src/common/stream_flags_common.rs | 8 - liblzma-rs/src/common/stream_flags_decoder.rs | 12 - liblzma-rs/src/common/stream_flags_encoder.rs | 33 +- liblzma-rs/src/common/string_conversion.rs | 17 +- liblzma-rs/src/delta/delta_common.rs | 12 +- liblzma-rs/src/delta/delta_decoder.rs | 7 - liblzma-rs/src/delta/delta_encoder.rs | 29 +- liblzma-rs/src/lz/lz_decoder.rs | 43 +- liblzma-rs/src/lz/lz_encoder.rs | 106 +-- liblzma-rs/src/lz/lz_encoder_mf.rs | 32 +- liblzma-rs/src/lzma/lzma2_decoder.rs | 33 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 69 +- liblzma-rs/src/lzma/lzma_decoder.rs | 92 +-- liblzma-rs/src/lzma/lzma_encoder.rs | 243 +----- .../src/lzma/lzma_encoder_optimum_fast.rs | 120 +-- .../src/lzma/lzma_encoder_optimum_normal.rs | 191 +---- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 1 - liblzma-rs/src/simple/arm.rs | 12 - liblzma-rs/src/simple/arm64.rs | 31 - liblzma-rs/src/simple/armthumb.rs | 12 - liblzma-rs/src/simple/ia64.rs | 12 - liblzma-rs/src/simple/powerpc.rs | 12 - liblzma-rs/src/simple/riscv.rs | 31 - liblzma-rs/src/simple/simple_coder.rs | 57 +- liblzma-rs/src/simple/simple_decoder.rs | 10 - liblzma-rs/src/simple/simple_encoder.rs | 9 - liblzma-rs/src/simple/sparc.rs | 12 - liblzma-rs/src/simple/x86.rs | 12 - liblzma-rs/src/types.rs | 759 +++++++++++++++++- 72 files changed, 1176 insertions(+), 2435 deletions(-) diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs index 1388f86e..db97cf2c 100644 --- a/liblzma-rs-sys/src/lib.rs +++ b/liblzma-rs-sys/src/lib.rs @@ -36,9 +36,9 @@ pub type lzma_bool = c_uchar; pub type lzma_vli = u64; // === Canonical struct re-exports === -pub use liblzma_rs::common::index_decoder::lzma_index; pub use liblzma_rs::types::lzma_allocator; pub use liblzma_rs::types::lzma_filter; +pub use liblzma_rs::types::lzma_index; pub use liblzma_rs::types::lzma_options_lzma; pub use liblzma_rs::types::lzma_stream; pub use liblzma_rs::types::lzma_stream_flags; @@ -95,8 +95,7 @@ pub const LZMA_PRESET_DEFAULT: u32 = liblzma_rs::common::string_conversion::LZMA_PRESET_DEFAULT as u32; pub const LZMA_PRESET_LEVEL_MASK: u32 = liblzma_rs::lzma::lzma_encoder_presets::LZMA_PRESET_LEVEL_MASK as u32; -pub const LZMA_PRESET_EXTREME: u32 = - liblzma_rs::common::string_conversion::LZMA_PRESET_EXTREME as u32; +pub const LZMA_PRESET_EXTREME: u32 = liblzma_rs::types::LZMA_PRESET_EXTREME as u32; pub const LZMA_DICT_SIZE_MIN: u32 = liblzma_rs::types::LZMA_DICT_SIZE_MIN as u32; pub const LZMA_DICT_SIZE_DEFAULT: u32 = liblzma_rs::common::string_conversion::LZMA_DICT_SIZE_DEFAULT as u32; diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index 95c1b066..ca2c6609 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -1,6 +1,5 @@ use crate::types::*; extern "C" { - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64; fn lzma_sha256_init(check: *mut lzma_check_state); fn lzma_sha256_update(buf: *const u8, size: size_t, check: *mut lzma_check_state); diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index 010504d9..3af34d0b 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -1,8 +1,4 @@ use crate::types::*; -#[inline] -unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { - *(buf as *const u32) -} #[no_mangle] pub static mut lzma_crc32_table: [[u32; 256]; 8] = [ [ diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index 81041c88..f6760428 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1,8 +1,4 @@ use crate::types::*; -#[inline] -unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { - *(buf as *const u32) -} #[no_mangle] pub static mut lzma_crc64_table: [[u64; 256]; 4] = [ [ diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index 038d4f47..cc9cdbdc 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -17,7 +17,11 @@ static mut SHA256_K: [u32; 64] = [ unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { let mut W: [u32; 16] = [0; 16]; let mut T: [u32; 8] = [0; 8]; - core::ptr::copy_nonoverlapping(state as *const u8, &raw mut T as *mut u8, core::mem::size_of::<[u32; 8]>()); + core::ptr::copy_nonoverlapping( + state as *const u8, + &raw mut T as *mut u8, + core::mem::size_of::<[u32; 8]>(), + ); W[0] = (*data & 0xff) << 24 | (*data & 0xff00) << 8 | (*data & 0xff0000) >> 8 @@ -534,7 +538,11 @@ pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, ]; - core::ptr::copy_nonoverlapping(&raw const s as *const u8, &raw mut (*check).state.sha256.state as *mut u8, core::mem::size_of::<[u32; 8]>()); + core::ptr::copy_nonoverlapping( + &raw const s as *const u8, + &raw mut (*check).state.sha256.state as *mut u8, + core::mem::size_of::<[u32; 8]>(), + ); (*check).state.sha256.size = 0; } #[no_mangle] @@ -549,7 +557,11 @@ pub unsafe extern "C" fn lzma_sha256_update( if copy_size > size { copy_size = size; } - core::ptr::copy_nonoverlapping(buf as *const u8, (&raw mut (*check).buffer.u8_0 as *mut u8).offset(copy_start as isize) as *mut u8, copy_size); + core::ptr::copy_nonoverlapping( + buf as *const u8, + (&raw mut (*check).buffer.u8_0 as *mut u8).offset(copy_start as isize) as *mut u8, + copy_size, + ); buf = buf.offset(copy_size as isize); size = size.wrapping_sub(copy_size); (*check).state.sha256.size = (*check).state.sha256.size.wrapping_add(copy_size as u64); diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index a959fcdb..f121eb6b 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -1,22 +1,5 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_lzma_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; - fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_alone_coder { @@ -35,7 +18,6 @@ pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; pub const SEQ_UNCOMPRESSED_SIZE: C2RustUnnamed_0 = 2; pub const SEQ_DICTIONARY_SIZE: C2RustUnnamed_0 = 1; pub const SEQ_PROPERTIES: C2RustUnnamed_0 = 0; -pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; unsafe extern "C" fn alone_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -265,7 +247,10 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( (*next).end = Some( alone_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ); - (*next).memconfig = Some(alone_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); + (*next).memconfig = Some( + alone_decoder_memconfig + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, + ); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index bc22828a..14d1f40f 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -1,29 +1,5 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - fn lzma_lzma_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_alone_coder { @@ -35,15 +11,6 @@ pub struct lzma_alone_coder { pub type C2RustUnnamed_0 = c_uint; pub const SEQ_CODE: C2RustUnnamed_0 = 1; pub const SEQ_HEADER: C2RustUnnamed_0 = 0; -#[inline] -extern "C" fn write32le(buf: *mut u8, num: u32) { - unsafe { - *buf = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; - } -} pub const ALONE_HEADER_SIZE: u32 = 1 + 4 + 8; unsafe extern "C" fn alone_encode( coder_ptr: *mut c_void, @@ -194,7 +161,11 @@ unsafe extern "C" fn alone_encoder_init( d += 1; } write32le((&raw mut (*coder).header as *mut u8).offset(1), d); - core::ptr::write_bytes((&raw mut (*coder).header as *mut u8).offset(1).offset(4) as *mut u8, 0xff as u8, 8); + core::ptr::write_bytes( + (&raw mut (*coder).header as *mut u8).offset(1).offset(4) as *mut u8, + 0xff as u8, + 8, + ); let filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { id: LZMA_FILTER_LZMA1, diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index a6457f37..e2882a75 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -1,15 +1,6 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_stream_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - memlimit: u64, - flags: u32, - ) -> lzma_ret; fn lzma_alone_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -224,7 +215,10 @@ unsafe extern "C" fn auto_decoder_init( ); (*next).get_check = Some(auto_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check); - (*next).memconfig = Some(auto_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); + (*next).memconfig = Some( + auto_decoder_memconfig + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, + ); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index cb84e9f7..dbe12462 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -1,12 +1,4 @@ use crate::types::*; -extern "C" { - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_block_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - block: *mut lzma_block, - ) -> lzma_ret; -} #[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_decode( block: *mut lzma_block, diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 0e82c0ab..23f9f976 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -1,32 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_ulonglong, c_void}; -extern "C" { - fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_check_size(check: lzma_check) -> u32; - fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; - fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_raw_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter, - ) -> lzma_ret; - fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); - fn lzma_check_update( - check: *mut lzma_check_state, - type_0: lzma_check, - buf: *const u8, - size: size_t, - ); - fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); -} -pub const LZMA_CHECK_SIZE_MAX: u32 = 64; -pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX - .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) - .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) - & !3; -pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; -pub const LZMA2_HEADER_UNCOMPRESSED: u32 = 3; +use core::ffi::c_void; pub const HEADERS_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 + LZMA_CHECK_SIZE_MAX + 3 & !(3); extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { @@ -132,7 +105,11 @@ unsafe extern "C" fn block_encode_uncompressed( *out_pos += 1; *out.offset(*out_pos as isize) = (copy_size.wrapping_sub(1) & 0xff) as u8; *out_pos += 1; - core::ptr::copy_nonoverlapping(in_0.offset(in_pos as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size); + core::ptr::copy_nonoverlapping( + in_0.offset(in_pos as isize) as *const u8, + out.offset(*out_pos as isize) as *mut u8, + copy_size, + ); in_pos = in_pos.wrapping_add(copy_size); *out_pos = (*out_pos).wrapping_add(copy_size); } @@ -272,8 +249,16 @@ unsafe extern "C" fn block_buffer_encode( lzma_check_init(&raw mut check, (*block).check); lzma_check_update(&raw mut check, (*block).check, in_0, in_size); lzma_check_finish(&raw mut check, (*block).check); - core::ptr::copy_nonoverlapping(&raw mut check.buffer.u8_0 as *const u8, &raw mut (*block).raw_check as *mut u8, check_size); - core::ptr::copy_nonoverlapping(&raw mut check.buffer.u8_0 as *const u8, out.offset(*out_pos as isize) as *mut u8, check_size); + core::ptr::copy_nonoverlapping( + &raw mut check.buffer.u8_0 as *const u8, + &raw mut (*block).raw_check as *mut u8, + check_size, + ); + core::ptr::copy_nonoverlapping( + &raw mut check.buffer.u8_0 as *const u8, + out.offset(*out_pos as isize) as *mut u8, + check_size, + ); *out_pos = (*out_pos).wrapping_add(check_size); } LZMA_OK diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 3fbaa3fb..a9fedc5b 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -1,34 +1,5 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_check_size(check: lzma_check) -> u32; - fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - fn lzma_raw_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - options: *const lzma_filter, - ) -> lzma_ret; - fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); - fn lzma_check_update( - check: *mut lzma_check_state, - type_0: lzma_check, - buf: *const u8, - size: size_t, - ); - fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block_coder { diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 2cd6a466..36b498b2 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -1,38 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_ulonglong, c_void}; -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_check_size(check: lzma_check) -> u32; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_filter_update( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - reversed_filters: *const lzma_filter, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - fn lzma_raw_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter, - ) -> lzma_ret; - fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); - fn lzma_check_update( - check: *mut lzma_check_state, - type_0: lzma_check, - buf: *const u8, - size: size_t, - ); - fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); -} +use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block_coder { @@ -48,11 +15,6 @@ pub type C2RustUnnamed_2 = c_uint; pub const SEQ_CHECK: C2RustUnnamed_2 = 2; pub const SEQ_PADDING: C2RustUnnamed_2 = 1; pub const SEQ_CODE: C2RustUnnamed_2 = 0; -pub const LZMA_CHECK_SIZE_MAX: u32 = 64; -pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX - .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) - .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64) - & !3; unsafe extern "C" fn block_encode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -89,7 +51,7 @@ unsafe extern "C" fn block_encode( ); let in_used: size_t = (*in_pos).wrapping_sub(in_start); let out_used: size_t = (*out_pos).wrapping_sub(out_start); - if (COMPRESSED_SIZE_MAX as lzma_vli).wrapping_sub((*coder).compressed_size) + if (COMPRESSED_SIZE_MAX).wrapping_sub((*coder).compressed_size) < out_used as lzma_vli { return LZMA_DATA_ERROR; @@ -154,7 +116,11 @@ unsafe extern "C" fn block_encode( if (*coder).pos < check_size { return LZMA_OK; } - core::ptr::copy_nonoverlapping(&raw mut (*coder).check.buffer.u8_0 as *const u8, &raw mut (*(*coder).block).raw_check as *mut u8, check_size); + core::ptr::copy_nonoverlapping( + &raw mut (*coder).check.buffer.u8_0 as *const u8, + &raw mut (*(*coder).block).raw_check as *mut u8, + check_size, + ); return LZMA_STREAM_END; } LZMA_PROG_ERROR @@ -256,12 +222,15 @@ pub unsafe extern "C" fn lzma_block_encoder_init( (*next).end = Some( block_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ); - (*next).update = Some(block_encoder_update as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret); + (*next).update = Some( + block_encoder_update + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 9a8daae3..ad34c3ee 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -1,14 +1,5 @@ use crate::types::*; extern "C" { - fn lzma_vli_decode( - vli: *mut lzma_vli, - vli_pos: *mut size_t, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; - fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); fn lzma_filter_flags_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, @@ -16,17 +7,6 @@ extern "C" { in_pos: *mut size_t, in_size: size_t, ) -> lzma_ret; - fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; -} -#[inline] -extern "C" fn read32le(buf: *const u8) -> u32 { - return unsafe { - let mut num: u32 = *buf as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - num - }; } #[no_mangle] pub unsafe extern "C" fn lzma_block_header_decode( diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 59cf4a8e..b452031f 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,14 +1,5 @@ use crate::types::*; extern "C" { - fn lzma_vli_encode( - vli: lzma_vli, - vli_pos: *mut size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; - fn lzma_vli_size(vli: lzma_vli) -> u32; - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; fn lzma_filter_flags_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret; fn lzma_filter_flags_encode( filter: *const lzma_filter, @@ -16,16 +7,6 @@ extern "C" { out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; - fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; -} -#[inline] -extern "C" fn write32le(buf: *mut u8, num: u32) { - unsafe { - *buf = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; - } } #[no_mangle] pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { @@ -131,7 +112,11 @@ pub unsafe extern "C" fn lzma_block_header_encode( } } *out.offset(1) |= filter_count.wrapping_sub(1) as u8; - core::ptr::write_bytes(out.offset(out_pos as isize) as *mut u8, 0 as u8, out_size.wrapping_sub(out_pos)); + core::ptr::write_bytes( + out.offset(out_pos as isize) as *mut u8, + 0 as u8, + out_size.wrapping_sub(out_pos), + ); write32le(out.offset(out_size as isize), lzma_crc32(out, out_size, 0)); LZMA_OK } diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 1154f8ab..7cfbe476 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -1,14 +1,5 @@ use crate::types::*; -use core::ffi::c_ulonglong; -extern "C" { - fn lzma_check_size(check: lzma_check) -> u32; -} pub const LZMA_BLOCK_HEADER_SIZE_MIN: u32 = 8; -pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; -#[inline] -extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - vli.wrapping_add(3) & !(3) -} #[no_mangle] pub unsafe extern "C" fn lzma_block_compressed_size( block: *mut lzma_block, @@ -51,7 +42,7 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> l .compressed_size .wrapping_add((*block).header_size as lzma_vli) .wrapping_add(lzma_check_size((*block).check) as lzma_vli); - if unpadded_size > UNPADDED_SIZE_MAX as lzma_vli { + if unpadded_size > UNPADDED_SIZE_MAX { return 0; } unpadded_size diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index f3606f53..ece75228 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -84,7 +84,11 @@ pub unsafe extern "C" fn lzma_bufcpy( out_avail }; if copy_size > 0 { - core::ptr::copy_nonoverlapping(in_0.offset(*in_pos as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size); + core::ptr::copy_nonoverlapping( + in_0.offset(*in_pos as isize) as *const u8, + out.offset(*out_pos as isize) as *mut u8, + copy_size, + ); } *in_pos = (*in_pos).wrapping_add(copy_size); *out_pos = (*out_pos).wrapping_add(copy_size); @@ -96,9 +100,7 @@ pub unsafe extern "C" fn lzma_next_filter_init( allocator: *const lzma_allocator, filters: *const lzma_filter_info, ) -> lzma_ret { - if core::mem::transmute::((*filters).init) - != (*next).init - { + if core::mem::transmute::((*filters).init) != (*next).init { lzma_next_end(next, allocator); } (*next).init = core::mem::transmute::((*filters).init); @@ -177,7 +179,11 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { set_out_limit: None, }; } - core::ptr::write_bytes(&raw mut (*(*strm).internal).supported_actions as *mut u8, 0 as u8, core::mem::size_of::<[bool; 5]>()); + core::ptr::write_bytes( + &raw mut (*(*strm).internal).supported_actions as *mut u8, + 0 as u8, + core::mem::size_of::<[bool; 5]>(), + ); (*(*strm).internal).sequence = ISEQ_RUN; (*(*strm).internal).allow_buf_error = false; (*strm).total_in = 0; diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 8c21f841..3d1871ad 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -10,7 +10,6 @@ extern "C" { out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } #[no_mangle] pub unsafe extern "C" fn lzma_easy_buffer_encode( diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index 2890e2dc..5494145e 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -1,8 +1,4 @@ use crate::types::*; -extern "C" { - fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; -} #[no_mangle] pub extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index 98a2a8e0..e698d97d 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -5,7 +5,6 @@ extern "C" { filters: *const lzma_filter, check: lzma_check, ) -> lzma_ret; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; } #[no_mangle] pub unsafe extern "C" fn lzma_easy_encoder( diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index 47599f37..1f635250 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -1,8 +1,4 @@ use crate::types::*; -extern "C" { - fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; -} #[no_mangle] pub extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index 45d15c52..01a7447b 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -1,8 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; -} #[no_mangle] pub unsafe extern "C" fn lzma_easy_preset(opt_easy: *mut lzma_options_easy, preset: u32) -> bool { if lzma_lzma_preset(&raw mut (*opt_easy).opt_lzma, preset) != 0 { diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index b88b01c3..63e555ba 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -1,20 +1,7 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -#[repr(C)] -pub struct lzma_index_s { - _opaque: [u8; 0], -} extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_stream_header_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; - fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; - fn lzma_stream_flags_compare( - a: *const lzma_stream_flags, - b: *const lzma_stream_flags, - ) -> lzma_ret; - fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64; fn lzma_index_memused(i: *const lzma_index) -> u64; - fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); fn lzma_index_stream_flags( i: *mut lzma_index, stream_flags: *const lzma_stream_flags, @@ -26,16 +13,6 @@ extern "C" { src: *mut lzma_index, allocator: *const lzma_allocator, ) -> lzma_ret; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; fn lzma_index_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -43,7 +20,6 @@ extern "C" { memlimit: u64, ) -> lzma_ret; } -pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_file_info_coder { @@ -662,7 +638,10 @@ unsafe extern "C" fn lzma_file_info_decoder_init( (*next).end = Some( file_info_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ); - (*next).memconfig = Some(file_info_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); + (*next).memconfig = Some( + file_info_decoder_memconfig + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, + ); (*coder).index_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index 862d6613..74455faa 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -1,12 +1,4 @@ use crate::types::*; -extern "C" { - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_raw_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - options: *const lzma_filter, - ) -> lzma_ret; -} #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_decode( filters: *const lzma_filter, diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index 8c6afae8..5d04d8b4 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -1,12 +1,4 @@ use crate::types::*; -extern "C" { - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_raw_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter, - ) -> lzma_ret; -} #[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_encode( filters: *const lzma_filter, diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 8c76356d..133ca6fc 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -1,12 +1,4 @@ use crate::types::*; -extern "C" { - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); -} #[derive(Copy, Clone)] #[repr(C)] pub struct C2RustUnnamed { @@ -178,8 +170,12 @@ pub unsafe extern "C" fn lzma_filters_copy( _ => { dest[i as usize].id = LZMA_VLI_UNKNOWN; dest[i as usize].options = core::ptr::null_mut(); - core::ptr::copy_nonoverlapping(&raw mut dest as *const u8, real_dest as *mut u8, i.wrapping_add(1) - .wrapping_mul(core::mem::size_of::())); + core::ptr::copy_nonoverlapping( + &raw mut dest as *const u8, + real_dest as *mut u8, + i.wrapping_add(1) + .wrapping_mul(core::mem::size_of::()), + ); return LZMA_OK; } }; diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 8c5dfaef..717105c7 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -1,21 +1,6 @@ use crate::types::*; use core::ffi::c_void; extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_raw_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter, - coder_find_0: lzma_filter_find, - is_encoder: bool, - ) -> lzma_ret; - fn lzma_raw_coder_memusage(coder_find_0: lzma_filter_find, filters: *const lzma_filter) -> u64; - fn lzma_lzma_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64; fn lzma_lzma_props_decode( options: *mut *mut c_void, @@ -81,7 +66,6 @@ extern "C" { props: *const u8, props_size: size_t, ) -> lzma_ret; - fn lzma_delta_coder_memusage(options: *const c_void) -> u64; fn lzma_delta_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index 93fbaafc..8564f0d5 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -1,22 +1,6 @@ use crate::types::*; use core::ffi::c_void; extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_raw_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter, - coder_find_0: lzma_filter_find, - is_encoder: bool, - ) -> lzma_ret; - fn lzma_raw_coder_memusage(coder_find_0: lzma_filter_find, filters: *const lzma_filter) -> u64; - fn lzma_lzma_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64; fn lzma_lzma_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; fn lzma_lzma2_encoder_init( next: *mut lzma_next_coder, @@ -68,7 +52,6 @@ extern "C" { ) -> lzma_ret; fn lzma_simple_props_size(size: *mut u32, options: *const c_void) -> lzma_ret; fn lzma_simple_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; - fn lzma_delta_coder_memusage(options: *const c_void) -> u64; fn lzma_delta_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 8a35d43d..a458f6a7 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -1,12 +1,5 @@ use crate::types::*; extern "C" { - fn lzma_vli_decode( - vli: *mut lzma_vli, - vli_pos: *mut size_t, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; fn lzma_properties_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index a4e227a8..110c639d 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -1,13 +1,5 @@ use crate::types::*; extern "C" { - fn lzma_vli_encode( - vli: lzma_vli, - vli_pos: *mut size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; - fn lzma_vli_size(vli: lzma_vli) -> u32; fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret; fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret; } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index bf8443ac..470773a4 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -1,12 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_ulong, c_ulonglong, c_void}; -extern "C" { - fn lzma_vli_size(vli: lzma_vli) -> u32; - fn lzma_stream_flags_compare( - a: *const lzma_stream_flags, - b: *const lzma_stream_flags, - ) -> lzma_ret; -} +use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_s { @@ -91,11 +84,6 @@ pub struct C2RustUnnamed_1 { pub reserved_vli3: lzma_vli, pub reserved_vli4: lzma_vli, } -pub type lzma_index_iter_mode = c_uint; -pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; -pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; -pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; -pub const LZMA_INDEX_ITER_ANY: lzma_index_iter_mode = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct index_record { @@ -142,8 +130,6 @@ pub struct index_cat_info { } pub type C2RustUnnamed_2 = c_uint; pub type C2RustUnnamed_3 = c_uint; -pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; -pub const SIZE_MAX: c_ulong = UINTPTR_MAX; #[inline] extern "C" fn bsr32(n: u32) -> u32 { n.leading_zeros() as i32 as u32 ^ 31 @@ -152,22 +138,6 @@ extern "C" fn bsr32(n: u32) -> u32 { extern "C" fn ctz32(n: u32) -> u32 { n.trailing_zeros() as i32 as u32 } -pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; -pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; -#[inline] -extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - vli.wrapping_add(3) & !(3) -} -#[inline] -extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) - .wrapping_add(index_list_size) - .wrapping_add(4) -} -#[inline] -extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - vli_ceil4(index_size_unpadded(count, index_list_size)) -} pub const INDEX_GROUP_SIZE: u32 = 512; pub const PREALLOC_MAX: usize = (SIZE_MAX as usize) .wrapping_sub(core::mem::size_of::()) @@ -505,8 +475,8 @@ pub unsafe extern "C" fn lzma_index_append( uncompressed_size: lzma_vli, ) -> lzma_ret { if i.is_null() - || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli - || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli + || unpadded_size < UNPADDED_SIZE_MIN + || unpadded_size > UNPADDED_SIZE_MAX || uncompressed_size > LZMA_VLI_MAX { return LZMA_PROG_ERROR; @@ -530,7 +500,7 @@ pub unsafe extern "C" fn lzma_index_append( if uncompressed_base.wrapping_add(uncompressed_size) > LZMA_VLI_MAX { return LZMA_DATA_ERROR; } - if compressed_base.wrapping_add(unpadded_size) > UNPADDED_SIZE_MAX as lzma_vli { + if compressed_base.wrapping_add(unpadded_size) > UNPADDED_SIZE_MAX { return LZMA_DATA_ERROR; } if index_file_size( @@ -548,7 +518,7 @@ pub unsafe extern "C" fn lzma_index_append( (*i).record_count.wrapping_add(1), (*i).index_list_size .wrapping_add(index_list_size_add as lzma_vli), - ) > LZMA_BACKWARD_SIZE_MAX as lzma_vli + ) > LZMA_BACKWARD_SIZE_MAX { return LZMA_DATA_ERROR; } @@ -618,7 +588,7 @@ pub unsafe extern "C" fn lzma_index_cat( if dest.is_null() || src.is_null() { return LZMA_PROG_ERROR; } - let dest_file_size: lzma_vli = lzma_index_file_size(dest) as lzma_vli; + let dest_file_size: lzma_vli = lzma_index_file_size(dest); if dest_file_size.wrapping_add(lzma_index_file_size(src)) > LZMA_VLI_MAX || (*dest) .uncompressed_size @@ -631,7 +601,7 @@ pub unsafe extern "C" fn lzma_index_cat( index_size_unpadded((*dest).record_count, (*dest).index_list_size) as lzma_vli; let src_size: lzma_vli = index_size_unpadded((*src).record_count, (*src).index_list_size) as lzma_vli; - if vli_ceil4(dest_size.wrapping_add(src_size)) > LZMA_BACKWARD_SIZE_MAX as lzma_vli { + if vli_ceil4(dest_size.wrapping_add(src_size)) > LZMA_BACKWARD_SIZE_MAX { return LZMA_DATA_ERROR; } let s: *mut index_stream = (*dest).streams.rightmost as *mut index_stream; @@ -652,9 +622,13 @@ pub unsafe extern "C" fn lzma_index_cat( (*newg).allocated = (*g).last.wrapping_add(1); (*newg).last = (*g).last; (*newg).number_base = (*g).number_base; - core::ptr::copy_nonoverlapping(&raw mut (*g).records as *const u8, &raw mut (*newg).records as *mut u8, (*newg) - .allocated - .wrapping_mul(core::mem::size_of::())); + core::ptr::copy_nonoverlapping( + &raw mut (*g).records as *const u8, + &raw mut (*newg).records as *mut u8, + (*newg) + .allocated + .wrapping_mul(core::mem::size_of::()), + ); if !(*g).node.parent.is_null() { (*(*g).node.parent).right = &raw mut (*newg).node; } @@ -728,10 +702,14 @@ unsafe extern "C" fn index_dup_stream( let mut srcg: *const index_group = (*src).groups.leftmost as *const index_group; let mut i: size_t = 0; loop { - core::ptr::copy_nonoverlapping(&raw const (*srcg).records as *const u8, (&raw mut (*destg).records as *mut index_record).offset(i as isize) as *mut u8, (*srcg) - .last - .wrapping_add(1) - .wrapping_mul(core::mem::size_of::())); + core::ptr::copy_nonoverlapping( + &raw const (*srcg).records as *const u8, + (&raw mut (*destg).records as *mut index_record).offset(i as isize) as *mut u8, + (*srcg) + .last + .wrapping_add(1) + .wrapping_mul(core::mem::size_of::()), + ); i = i.wrapping_add((*srcg).last.wrapping_add(1)); srcg = index_tree_next(&raw const (*srcg).node) as *const index_group; if srcg.is_null() { @@ -941,8 +919,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( } if record == 0 { if (*group).node.uncompressed_base - != (*(&raw const (*group).records as *const index_record)) - .uncompressed_sum + != (*(&raw const (*group).records as *const index_record)).uncompressed_sum { break; } diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 09c854c2..bd169791 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -1,34 +1,8 @@ use crate::types::*; -use core::ffi::{c_uint, c_ulonglong, c_void}; -#[repr(C)] -pub struct lzma_index_s { - _opaque: [u8; 0], -} +use core::ffi::{c_uint, c_void}; extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_vli_decode( - vli: *mut lzma_vli, - vli_pos: *mut size_t, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; - fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64; - fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; - fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); - fn lzma_index_append( - i: *mut lzma_index, - allocator: *const lzma_allocator, - unpadded_size: lzma_vli, - uncompressed_size: lzma_vli, - ) -> lzma_ret; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_index_padding_size(i: *const lzma_index) -> u32; fn lzma_index_prealloc(i: *mut lzma_index, records: lzma_vli); } -pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_coder { @@ -51,9 +25,6 @@ pub const SEQ_UNPADDED: C2RustUnnamed_0 = 3; pub const SEQ_MEMUSAGE: C2RustUnnamed_0 = 2; pub const SEQ_COUNT: C2RustUnnamed_0 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; -pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; -pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; -pub const INDEX_INDICATOR: u8 = 0; unsafe extern "C" fn index_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -111,8 +82,8 @@ unsafe extern "C" fn index_decode( ret = LZMA_OK; (*coder).pos = 0; if (*coder).sequence == SEQ_UNPADDED { - if (*coder).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli - || (*coder).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli + if (*coder).unpadded_size < UNPADDED_SIZE_MIN + || (*coder).unpadded_size > UNPADDED_SIZE_MAX { return LZMA_DATA_ERROR; } @@ -326,7 +297,10 @@ pub unsafe extern "C" fn lzma_index_decoder_init( (*next).end = Some( index_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ); - (*next).memconfig = Some(index_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); + (*next).memconfig = Some( + index_decoder_memconfig + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, + ); (*coder).index = core::ptr::null_mut(); } else { lzma_index_end((*coder).index, allocator); diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index 10dafaab..377b365f 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -1,28 +1,10 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -#[repr(C)] -pub struct lzma_index_s { - _opaque: [u8; 0], -} extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_vli_encode( - vli: lzma_vli, - vli_pos: *mut size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli; - fn lzma_index_size(i: *const lzma_index) -> lzma_vli; fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index); fn lzma_index_iter_next(iter: *mut lzma_index_iter, mode: lzma_index_iter_mode) -> lzma_bool; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_index_padding_size(i: *const lzma_index) -> u32; } -pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_iter { @@ -77,11 +59,6 @@ pub struct C2RustUnnamed_2 { pub reserved_vli3: lzma_vli, pub reserved_vli4: lzma_vli, } -pub type lzma_index_iter_mode = c_uint; -pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; -pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; -pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; -pub const LZMA_INDEX_ITER_ANY: lzma_index_iter_mode = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_coder { @@ -99,7 +76,6 @@ pub const SEQ_UNCOMPRESSED: C2RustUnnamed_3 = 3; pub const SEQ_UNPADDED: C2RustUnnamed_3 = 2; pub const SEQ_COUNT: C2RustUnnamed_3 = 1; pub const SEQ_INDICATOR: C2RustUnnamed_3 = 0; -pub const INDEX_INDICATOR: u8 = 0; unsafe extern "C" fn index_encode( coder_ptr: *mut c_void, _allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index b3495094..71743a2f 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -1,25 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_ulonglong, c_void}; -extern "C" { - fn lzma_vli_decode( - vli: *mut lzma_vli, - vli_pos: *mut size_t, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; - fn lzma_vli_size(vli: lzma_vli) -> u32; - fn lzma_check_size(check: lzma_check) -> u32; - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; - fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); - fn lzma_check_update( - check: *mut lzma_check_state, - type_0: lzma_check, - buf: *const u8, - size: size_t, - ); - fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); -} +use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_hash_s { @@ -50,23 +30,6 @@ pub const SEQ_UNPADDED: C2RustUnnamed_1 = 2; pub const SEQ_COUNT: C2RustUnnamed_1 = 1; pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; pub type lzma_index_hash = lzma_index_hash_s; -pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; -pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; -pub const INDEX_INDICATOR: u8 = 0; -#[inline] -extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - vli.wrapping_add(3) & !(3) -} -#[inline] -extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) - .wrapping_add(index_list_size) - .wrapping_add(4) -} -#[inline] -extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - vli_ceil4(index_size_unpadded(count, index_list_size)) -} #[inline] extern "C" fn index_stream_size( blocks_size: lzma_vli, @@ -150,8 +113,8 @@ pub unsafe extern "C" fn lzma_index_hash_append( ) -> lzma_ret { if index_hash.is_null() || (*index_hash).sequence != SEQ_BLOCK - || unpadded_size < UNPADDED_SIZE_MIN as lzma_vli - || unpadded_size > UNPADDED_SIZE_MAX as lzma_vli + || unpadded_size < UNPADDED_SIZE_MIN + || unpadded_size > UNPADDED_SIZE_MAX || uncompressed_size > LZMA_VLI_MAX { return LZMA_PROG_ERROR; @@ -166,7 +129,7 @@ pub unsafe extern "C" fn lzma_index_hash_append( || index_size( (*index_hash).blocks.count, (*index_hash).blocks.index_list_size, - ) > LZMA_BACKWARD_SIZE_MAX as lzma_vli + ) > LZMA_BACKWARD_SIZE_MAX || index_stream_size( (*index_hash).blocks.blocks_size, (*index_hash).blocks.count, @@ -237,8 +200,8 @@ pub unsafe extern "C" fn lzma_index_hash_decode( ret = LZMA_OK; (*index_hash).pos = 0; if (*index_hash).sequence == SEQ_UNPADDED { - if (*index_hash).unpadded_size < UNPADDED_SIZE_MIN as lzma_vli - || (*index_hash).unpadded_size > UNPADDED_SIZE_MAX as lzma_vli + if (*index_hash).unpadded_size < UNPADDED_SIZE_MIN + || (*index_hash).unpadded_size > UNPADDED_SIZE_MAX { return LZMA_DATA_ERROR; } diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 413f5c11..384308f3 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -1,30 +1,5 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - fn lzma_lzma_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzip_coder { @@ -52,16 +27,6 @@ pub const SEQ_DICT_SIZE: C2RustUnnamed_0 = 2; pub const SEQ_VERSION: C2RustUnnamed_0 = 1; pub const SEQ_ID_STRING: C2RustUnnamed_0 = 0; #[inline] -extern "C" fn read32le(buf: *const u8) -> u32 { - return unsafe { - let mut num: u32 = *buf as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - num - }; -} -#[inline] extern "C" fn read64le(buf: *const u8) -> u64 { return unsafe { let mut num: u64 = *buf as u64; @@ -275,8 +240,7 @@ unsafe extern "C" fn lzip_decode( (*coder).pos = 0; (*coder).member_size = (*coder).member_size.wrapping_add(footer_size as u64); if !(*coder).ignore_check - && (*coder).crc32 - != read32le((&raw mut (*coder).buffer as *mut u8) as *mut u8) + && (*coder).crc32 != read32le((&raw mut (*coder).buffer as *mut u8) as *mut u8) { return LZMA_DATA_ERROR; } @@ -392,7 +356,10 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( ); (*next).get_check = Some(lzip_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check); - (*next).memconfig = Some(lzip_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); + (*next).memconfig = Some( + lzip_decoder_memconfig + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, + ); (*coder).lzma_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index 629fdf45..66a3455e 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -1,21 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_lzma_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_microlzma_coder { diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index d5b3d0ca..bffbd1e8 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -1,21 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_lzma_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_microlzma_coder { diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index d3cc8f51..c6cece9d 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,22 +1,5 @@ use crate::types::*; -use core::ffi::{c_ulong, c_void}; -extern "C" { - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; -} -pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; -pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const LZMA_THREADS_MAX: u32 = 16384; -#[inline] -extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { - (core::mem::size_of::()).wrapping_add(buf_size as usize) as u64 -} +use core::ffi::c_void; #[no_mangle] pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { let limit: u64 = (UINT64_MAX) diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index 4b8ff342..2595a2d9 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -1,15 +1,4 @@ use crate::types::*; -use core::ffi::c_uint; -extern "C" { - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_stream_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - memlimit: u64, - flags: u32, - ) -> lzma_ret; -} -pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; #[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_decode( memlimit: *mut u64, diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 2d5c890a..82cd10a0 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -1,13 +1,5 @@ use crate::types::*; -#[repr(C)] -pub struct lzma_index_s { - _opaque: [u8; 0], -} extern "C" { - fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; - fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; - fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t; fn lzma_block_buffer_encode( block: *mut lzma_block, @@ -18,15 +10,6 @@ extern "C" { out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; - fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; - fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); - fn lzma_index_append( - i: *mut lzma_index, - allocator: *const lzma_allocator, - unpadded_size: lzma_vli, - uncompressed_size: lzma_vli, - ) -> lzma_ret; - fn lzma_index_size(i: *const lzma_index) -> lzma_vli; fn lzma_index_buffer_encode( i: *const lzma_index, out: *mut u8, @@ -34,7 +17,6 @@ extern "C" { out_size: size_t, ) -> lzma_ret; } -pub type lzma_index = lzma_index_s; pub const INDEX_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3 & !(3); pub const HEADERS_BOUND: u32 = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; #[no_mangle] diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index edff061b..5742eeb9 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -1,59 +1,5 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -#[repr(C)] -pub struct lzma_index_hash_s { - _opaque: [u8; 0], -} -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); - fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; - fn lzma_stream_header_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; - fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; - fn lzma_stream_flags_compare( - a: *const lzma_stream_flags, - b: *const lzma_stream_flags, - ) -> lzma_ret; - fn lzma_block_header_decode( - block: *mut lzma_block, - allocator: *const lzma_allocator, - in_0: *const u8, - ) -> lzma_ret; - fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; - fn lzma_index_hash_init( - index_hash: *mut lzma_index_hash, - allocator: *const lzma_allocator, - ) -> *mut lzma_index_hash; - fn lzma_index_hash_end(index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator); - fn lzma_index_hash_append( - index_hash: *mut lzma_index_hash, - unpadded_size: lzma_vli, - uncompressed_size: lzma_vli, - ) -> lzma_ret; - fn lzma_index_hash_decode( - index_hash: *mut lzma_index_hash, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; - fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - fn lzma_block_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - block: *mut lzma_block, - ) -> lzma_ret; -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { @@ -73,7 +19,6 @@ pub struct lzma_stream_coder { pub pos: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub type lzma_index_hash = lzma_index_hash_s; pub type C2RustUnnamed_0 = c_uint; pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 6; pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; @@ -82,7 +27,6 @@ pub const SEQ_BLOCK_RUN: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub const INDEX_INDICATOR: u8 = 0; unsafe extern "C" fn stream_decoder_reset( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, @@ -478,7 +422,10 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( ); (*next).get_check = Some(stream_decoder_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check); - (*next).memconfig = Some(stream_decoder_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); + (*next).memconfig = Some( + stream_decoder_memconfig + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, + ); (*coder).block_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 5439ad91..6374a358 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -1,196 +1,17 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_long, c_uint, c_ulong, c_void}; -pub enum lzma_index_hash_s {} +use core::ffi::{c_uint, c_ulong, c_void}; extern "C" { - fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; - fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; - fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> c_int; - fn pthread_cond_signal(_: *mut pthread_cond_t) -> c_int; - fn pthread_cond_timedwait( - _: *mut pthread_cond_t, - _: *mut pthread_mutex_t, - _: *const timespec, - ) -> c_int; - fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> c_int; - fn pthread_create( - _: *mut pthread_t, - _: *const pthread_attr_t, - _: Option *mut c_void>, - _: *mut c_void, - ) -> c_int; - fn pthread_join(_: pthread_t, _: *mut *mut c_void) -> c_int; - fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> c_int; - fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> c_int; - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> c_int; - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> c_int; - fn pthread_sigmask(_: c_int, _: *const sigset_t, _: *mut sigset_t) -> c_int; - fn lzma_end(strm: *mut lzma_stream); - fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_check_size(check: lzma_check) -> u32; - fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); - fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; - fn lzma_stream_header_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; - fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; - fn lzma_stream_flags_compare( - a: *const lzma_stream_flags, - b: *const lzma_stream_flags, - ) -> lzma_ret; - fn lzma_block_header_decode( - block: *mut lzma_block, - allocator: *const lzma_allocator, - in_0: *const u8, - ) -> lzma_ret; - fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; - fn lzma_index_hash_init( - index_hash: *mut lzma_index_hash, - allocator: *const lzma_allocator, - ) -> *mut lzma_index_hash; - fn lzma_index_hash_end(index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator); - fn lzma_index_hash_append( - index_hash: *mut lzma_index_hash, - unpadded_size: lzma_vli, - uncompressed_size: lzma_vli, - ) -> lzma_ret; - fn lzma_index_hash_decode( - index_hash: *mut lzma_index_hash, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; - fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - fn lzma_block_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - block: *mut lzma_block, - ) -> lzma_ret; - fn lzma_outq_init( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - threads: u32, - ) -> lzma_ret; - fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator); fn lzma_outq_clear_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator); fn lzma_outq_clear_cache2( outq: *mut lzma_outq, allocator: *const lzma_allocator, keep_size: size_t, ); - fn lzma_outq_prealloc_buf( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - size: size_t, - ) -> lzma_ret; - fn lzma_outq_get_buf(outq: *mut lzma_outq, worker: *mut c_void) -> *mut lzma_outbuf; - fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool; - fn lzma_outq_read( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - unpadded_size: *mut lzma_vli, - uncompressed_size: *mut lzma_vli, - ) -> lzma_ret; fn lzma_outq_enable_partial_output( outq: *mut lzma_outq, enable_partial_output: Option ()>, ); } -pub type __uint32_t = u32; -pub type __darwin_time_t = c_long; -pub type __darwin_sigset_t = __uint32_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __darwin_pthread_handler_rec { - pub __routine: Option ()>, - pub __arg: *mut c_void, - pub __next: *mut __darwin_pthread_handler_rec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_attr_t { - pub __sig: c_long, - pub __opaque: [c_char; 56], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: c_long, - pub __opaque: [c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_condattr_t { - pub __sig: c_long, - pub __opaque: [c_char; 8], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: c_long, - pub __opaque: [c_char; 56], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutexattr_t { - pub __sig: c_long, - pub __opaque: [c_char; 8], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_t { - pub __sig: c_long, - pub __cleanup_stack: *mut __darwin_pthread_handler_rec, - pub __opaque: [c_char; 8176], -} -pub type __darwin_pthread_attr_t = _opaque_pthread_attr_t; -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_condattr_t = _opaque_pthread_condattr_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t; -pub type __darwin_pthread_t = *mut _opaque_pthread_t; -pub type pthread_attr_t = __darwin_pthread_attr_t; -pub type sigset_t = __darwin_sigset_t; -pub type time_t = __darwin_time_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct timespec { - pub tv_sec: __darwin_time_t, - pub tv_nsec: c_long, -} -pub type clockid_t = c_uint; -pub const _CLOCK_THREAD_CPUTIME_ID: clockid_t = 16; -pub const _CLOCK_PROCESS_CPUTIME_ID: clockid_t = 12; -pub const _CLOCK_UPTIME_RAW_APPROX: clockid_t = 9; -pub const _CLOCK_UPTIME_RAW: clockid_t = 8; -pub const _CLOCK_MONOTONIC_RAW_APPROX: clockid_t = 5; -pub const _CLOCK_MONOTONIC_RAW: clockid_t = 4; -pub const _CLOCK_MONOTONIC: clockid_t = 6; -pub const _CLOCK_REALTIME: clockid_t = 0; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_condattr_t = __darwin_pthread_condattr_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -pub type pthread_mutexattr_t = __darwin_pthread_mutexattr_t; -pub type pthread_t = __darwin_pthread_t; -pub type mythread = pthread_t; -pub type mythread_mutex = pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mythread_cond { - pub cond: pthread_cond_t, - pub clk_id: clockid_t, -} -pub type mythread_condtime = timespec; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { @@ -232,21 +53,6 @@ pub struct lzma_stream_coder { pub pos: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub type lzma_outbuf = lzma_outbuf_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_outbuf_s { - pub next: *mut lzma_outbuf, - pub worker: *mut c_void, - pub allocated: size_t, - pub pos: size_t, - pub decoder_in_pos: size_t, - pub finished: bool, - pub finish_ret: lzma_ret, - pub unpadded_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub buf: [u8; 0], -} #[derive(Copy, Clone)] #[repr(C)] pub struct worker_thread { @@ -271,11 +77,7 @@ pub struct worker_thread { pub cond: mythread_cond, pub thread_id: mythread, } -pub type worker_state = c_uint; pub const THR_EXIT: worker_state = 2; -pub const THR_RUN: worker_state = 1; -pub const THR_IDLE: worker_state = 0; -pub type lzma_index_hash = lzma_index_hash_s; pub type C2RustUnnamed_0 = c_uint; pub const SEQ_ERROR: C2RustUnnamed_0 = 11; pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 10; @@ -289,139 +91,6 @@ pub const SEQ_BLOCK_THR_INIT: C2RustUnnamed_0 = 3; pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; -pub const SIZE_MAX: c_ulong = UINTPTR_MAX; -pub const SIG_SETMASK: c_int = 3; -pub const MYTHREAD_RET_VALUE: *mut c_void = core::ptr::null_mut(); -#[inline] -extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { - let _ret: c_int = - unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; -} -#[inline] -extern "C" fn mythread_create( - thread: *mut mythread, - func: Option *mut c_void>, - arg: *mut c_void, -) -> c_int { - let mut old: sigset_t = 0; - let mut all: sigset_t = 0; - all = !(0 as sigset_t); - mythread_sigmask(SIG_SETMASK, &raw mut all, &raw mut old); - let ret: c_int = unsafe { - pthread_create( - thread as *mut pthread_t, - core::ptr::null(), - func as Option *mut c_void>, - arg as *mut c_void, - ) - }; - mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); - ret -} -#[inline] -extern "C" fn mythread_join(thread: mythread) -> c_int { - unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) } -} -#[inline] -extern "C" fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { - unsafe { - pthread_mutex_init( - mutex as *mut pthread_mutex_t, - core::ptr::null(), - ) - } -} -#[inline] -extern "C" fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { - let _ret: c_int = unsafe { pthread_mutex_destroy(mutex as *mut pthread_mutex_t) }; -} -#[inline] -extern "C" fn mythread_mutex_lock(mutex: *mut mythread_mutex) { - let _ret: c_int = unsafe { pthread_mutex_lock(mutex as *mut pthread_mutex_t) }; -} -#[inline] -extern "C" fn mythread_mutex_unlock(mutex: *mut mythread_mutex) { - let _ret: c_int = unsafe { pthread_mutex_unlock(mutex as *mut pthread_mutex_t) }; -} -#[inline] -extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { - return unsafe { - (*mycond).clk_id = _CLOCK_REALTIME; - pthread_cond_init( - &raw mut (*mycond).cond, - core::ptr::null(), - ) - }; -} -#[inline] -extern "C" fn mythread_cond_destroy(cond: *mut mythread_cond) { - let _ret: c_int = unsafe { pthread_cond_destroy(&raw mut (*cond).cond) }; -} -#[inline] -extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { - let _ret: c_int = unsafe { pthread_cond_signal(&raw mut (*cond).cond) }; -} -#[inline] -extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { - let _ret: c_int = - unsafe { pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) }; -} -#[inline] -extern "C" fn mythread_cond_timedwait( - cond: *mut mythread_cond, - mutex: *mut mythread_mutex, - condtime: *const mythread_condtime, -) -> c_int { - let ret: c_int = unsafe { - pthread_cond_timedwait( - &raw mut (*cond).cond, - mutex as *mut pthread_mutex_t, - condtime as *const timespec, - ) - }; - ret -} -#[inline] -extern "C" fn mythread_condtime_set( - condtime: *mut mythread_condtime, - cond: *const mythread_cond, - timeout_ms: u32, -) { - unsafe { - (*condtime).tv_sec = timeout_ms.wrapping_div(1000) as time_t as __darwin_time_t; - (*condtime).tv_nsec = timeout_ms.wrapping_rem(1000).wrapping_mul(1000000) as c_long; - let mut now: timespec = timespec { - tv_sec: 0, - tv_nsec: 0, - }; - let _ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); - (*condtime).tv_sec += now.tv_sec; - (*condtime).tv_nsec += now.tv_nsec; - if (*condtime).tv_nsec >= 1000000000 as c_long { - (*condtime).tv_nsec -= 1000000000 as c_long; - (*condtime).tv_sec += 1; - } - } -} -pub const LZMA_THREADS_MAX: u32 = 16384; -pub const INDEX_INDICATOR: u8 = 0; -#[inline] -extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { - vli.wrapping_add(3) & !(3) -} -#[inline] -extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { - unsafe { (*outq).bufs_in_use < (*outq).bufs_limit } -} -#[inline] -extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { - unsafe { (*outq).bufs_in_use == 0 } -} -#[inline] -extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { - (core::mem::size_of::()).wrapping_add(buf_size as usize) as u64 -} unsafe extern "C" fn worker_enable_partial_update(thr_ptr: *mut c_void) { let thr: *mut worker_thread = thr_ptr as *mut worker_thread; let mut mythread_i_325: c_uint = 0; @@ -1790,10 +1459,20 @@ unsafe extern "C" fn stream_decoder_mt_init( ); (*next).get_check = Some(stream_decoder_mt_get_check as unsafe extern "C" fn(*const c_void) -> lzma_check); - (*next).memconfig = Some(stream_decoder_mt_memconfig as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret); - (*next).get_progress = Some(stream_decoder_mt_get_progress as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> ()); + (*next).memconfig = Some( + stream_decoder_mt_memconfig + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64, u64) -> lzma_ret, + ); + (*next).get_progress = Some( + stream_decoder_mt_get_progress + as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> (), + ); (*coder).filters[0].id = LZMA_VLI_UNKNOWN; - core::ptr::write_bytes(&raw mut (*coder).outq as *mut u8, 0 as u8, core::mem::size_of::()); + core::ptr::write_bytes( + &raw mut (*coder).outq as *mut u8, + 0 as u8, + core::mem::size_of::(), + ); (*coder).block_decoder = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 6b41f468..84166c7c 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -1,52 +1,5 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -#[repr(C)] -pub struct lzma_index_s { - _opaque: [u8; 0], -} -extern "C" { - fn lzma_end(strm: *mut lzma_stream); - fn lzma_filters_copy( - src: *const lzma_filter, - dest: *mut lzma_filter, - allocator: *const lzma_allocator, - ) -> lzma_ret; - fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); - fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; - fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; - fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; - fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret; - fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; - fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; - fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); - fn lzma_index_append( - i: *mut lzma_index, - allocator: *const lzma_allocator, - unpadded_size: lzma_vli, - uncompressed_size: lzma_vli, - ) -> lzma_ret; - fn lzma_index_size(i: *const lzma_index) -> lzma_vli; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - fn lzma_block_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - block: *mut lzma_block, - ) -> lzma_ret; - fn lzma_index_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - i: *const lzma_index, - ) -> lzma_ret; -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { @@ -61,7 +14,6 @@ pub struct lzma_stream_coder { pub buffer_size: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub type lzma_index = lzma_index_s; pub type C2RustUnnamed_0 = c_uint; pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; pub const SEQ_INDEX_ENCODE: C2RustUnnamed_0 = 4; @@ -297,7 +249,11 @@ unsafe extern "C" fn stream_encoder_update( } _ => { lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); - core::ptr::copy_nonoverlapping(&raw mut temp as *const u8, &raw mut (*coder).filters as *mut u8, core::mem::size_of::<[lzma_filter; 5]>()); + core::ptr::copy_nonoverlapping( + &raw mut temp as *const u8, + &raw mut (*coder).filters as *mut u8, + core::mem::size_of::<[lzma_filter; 5]>(), + ); return LZMA_OK; } }; @@ -377,12 +333,15 @@ unsafe extern "C" fn stream_encoder_init( (*next).end = Some( stream_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ); - (*next).update = Some(stream_encoder_update as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret); + (*next).update = Some( + stream_encoder_update + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ); (*coder).filters[0].id = LZMA_VLI_UNKNOWN; (*coder).block_encoder = lzma_next_coder_s { coder: core::ptr::null_mut(), @@ -444,12 +403,7 @@ unsafe extern "C" fn stream_encoder_init( } (*coder).buffer_pos = 0; (*coder).buffer_size = LZMA_STREAM_HEADER_SIZE as size_t; - stream_encoder_update( - coder as *mut c_void, - allocator, - filters, - core::ptr::null(), - ) + stream_encoder_update(coder as *mut c_void, allocator, filters, core::ptr::null()) } #[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder( diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index b182ed7e..683ac11f 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -1,44 +1,7 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_long, c_uint, c_ulonglong, c_void}; -pub enum lzma_index_s {} +use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { - fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; - fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; - fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> c_int; - fn pthread_cond_signal(_: *mut pthread_cond_t) -> c_int; - fn pthread_cond_timedwait( - _: *mut pthread_cond_t, - _: *mut pthread_mutex_t, - _: *const timespec, - ) -> c_int; - fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> c_int; - fn pthread_create( - _: *mut pthread_t, - _: *const pthread_attr_t, - _: Option *mut c_void>, - _: *mut c_void, - ) -> c_int; - fn pthread_join(_: pthread_t, _: *mut *mut c_void) -> c_int; - fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> c_int; - fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> c_int; - fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> c_int; - fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> c_int; - fn pthread_sigmask(_: c_int, _: *const sigset_t, _: *mut sigset_t) -> c_int; - fn lzma_end(strm: *mut lzma_stream); - fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - fn lzma_filters_copy( - src: *const lzma_filter, - dest: *mut lzma_filter, - allocator: *const lzma_allocator, - ) -> lzma_ret; - fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); - fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64; fn lzma_mt_block_size(filters: *const lzma_filter) -> u64; - fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; - fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; - fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; - fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret; - fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; fn lzma_block_uncomp_encode( block: *mut lzma_block, in_0: *const u8, @@ -47,146 +10,9 @@ extern "C" { out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret; - fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; - fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); - fn lzma_index_append( - i: *mut lzma_index, - allocator: *const lzma_allocator, - unpadded_size: lzma_vli, - uncompressed_size: lzma_vli, - ) -> lzma_ret; - fn lzma_index_size(i: *const lzma_index) -> lzma_vli; - fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; - fn lzma_block_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - block: *mut lzma_block, - ) -> lzma_ret; fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64; - fn lzma_index_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - i: *const lzma_index, - ) -> lzma_ret; fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64; - fn lzma_outq_init( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - threads: u32, - ) -> lzma_ret; - fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator); - fn lzma_outq_prealloc_buf( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - size: size_t, - ) -> lzma_ret; - fn lzma_outq_get_buf(outq: *mut lzma_outq, worker: *mut c_void) -> *mut lzma_outbuf; - fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool; - fn lzma_outq_read( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - unpadded_size: *mut lzma_vli, - uncompressed_size: *mut lzma_vli, - ) -> lzma_ret; } -pub type __uint32_t = u32; -pub type __darwin_time_t = c_long; -pub type __darwin_sigset_t = __uint32_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct __darwin_pthread_handler_rec { - pub __routine: Option ()>, - pub __arg: *mut c_void, - pub __next: *mut __darwin_pthread_handler_rec, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_attr_t { - pub __sig: c_long, - pub __opaque: [c_char; 56], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_cond_t { - pub __sig: c_long, - pub __opaque: [c_char; 40], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_condattr_t { - pub __sig: c_long, - pub __opaque: [c_char; 8], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutex_t { - pub __sig: c_long, - pub __opaque: [c_char; 56], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_mutexattr_t { - pub __sig: c_long, - pub __opaque: [c_char; 8], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct _opaque_pthread_t { - pub __sig: c_long, - pub __cleanup_stack: *mut __darwin_pthread_handler_rec, - pub __opaque: [c_char; 8176], -} -pub type __darwin_pthread_attr_t = _opaque_pthread_attr_t; -pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; -pub type __darwin_pthread_condattr_t = _opaque_pthread_condattr_t; -pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t; -pub type __darwin_pthread_t = *mut _opaque_pthread_t; -pub type pthread_attr_t = __darwin_pthread_attr_t; -pub type sigset_t = __darwin_sigset_t; -pub type time_t = __darwin_time_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct timespec { - pub tv_sec: __darwin_time_t, - pub tv_nsec: c_long, -} -pub type clockid_t = c_uint; -pub const _CLOCK_THREAD_CPUTIME_ID: clockid_t = 16; -pub const _CLOCK_PROCESS_CPUTIME_ID: clockid_t = 12; -pub const _CLOCK_UPTIME_RAW_APPROX: clockid_t = 9; -pub const _CLOCK_UPTIME_RAW: clockid_t = 8; -pub const _CLOCK_MONOTONIC_RAW_APPROX: clockid_t = 5; -pub const _CLOCK_MONOTONIC_RAW: clockid_t = 4; -pub const _CLOCK_MONOTONIC: clockid_t = 6; -pub const _CLOCK_REALTIME: clockid_t = 0; -pub type pthread_cond_t = __darwin_pthread_cond_t; -pub type pthread_condattr_t = __darwin_pthread_condattr_t; -pub type pthread_mutex_t = __darwin_pthread_mutex_t; -pub type pthread_mutexattr_t = __darwin_pthread_mutexattr_t; -pub type pthread_t = __darwin_pthread_t; -pub type mythread = pthread_t; -pub type mythread_mutex = pthread_mutex_t; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct mythread_cond { - pub cond: pthread_cond_t, - pub clk_id: clockid_t, -} -pub type mythread_condtime = timespec; pub type worker_thread = worker_thread_s; #[derive(Copy, Clone)] #[repr(C)] @@ -234,155 +60,14 @@ pub struct lzma_stream_coder_s { pub mutex: mythread_mutex, pub cond: mythread_cond, } -pub type lzma_outbuf = lzma_outbuf_s; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_outbuf_s { - pub next: *mut lzma_outbuf, - pub worker: *mut c_void, - pub allocated: size_t, - pub pos: size_t, - pub decoder_in_pos: size_t, - pub finished: bool, - pub finish_ret: lzma_ret, - pub unpadded_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub buf: [u8; 0], -} -pub type lzma_index = lzma_index_s; pub type C2RustUnnamed_0 = c_uint; pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 3; pub const SEQ_INDEX: C2RustUnnamed_0 = 2; pub const SEQ_BLOCK: C2RustUnnamed_0 = 1; pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; -pub type worker_state = c_uint; pub const THR_EXIT: worker_state = 4; pub const THR_STOP: worker_state = 3; pub const THR_FINISH: worker_state = 2; -pub const THR_RUN: worker_state = 1; -pub const THR_IDLE: worker_state = 0; -pub const SIG_SETMASK: c_int = 3; -pub const MYTHREAD_RET_VALUE: *mut c_void = core::ptr::null_mut(); -#[inline] -extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { - let _ret: c_int = - unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; -} -#[inline] -extern "C" fn mythread_create( - thread: *mut mythread, - func: Option *mut c_void>, - arg: *mut c_void, -) -> c_int { - let mut old: sigset_t = 0; - let mut all: sigset_t = 0; - all = !(0 as sigset_t); - mythread_sigmask(SIG_SETMASK, &raw mut all, &raw mut old); - let ret: c_int = unsafe { - pthread_create( - thread as *mut pthread_t, - core::ptr::null(), - func as Option *mut c_void>, - arg as *mut c_void, - ) - }; - mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); - ret -} -#[inline] -extern "C" fn mythread_join(thread: mythread) -> c_int { - unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) } -} -#[inline] -extern "C" fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { - unsafe { - pthread_mutex_init( - mutex as *mut pthread_mutex_t, - core::ptr::null(), - ) - } -} -#[inline] -extern "C" fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { - let _ret: c_int = unsafe { pthread_mutex_destroy(mutex as *mut pthread_mutex_t) }; -} -#[inline] -extern "C" fn mythread_mutex_lock(mutex: *mut mythread_mutex) { - let _ret: c_int = unsafe { pthread_mutex_lock(mutex as *mut pthread_mutex_t) }; -} -#[inline] -extern "C" fn mythread_mutex_unlock(mutex: *mut mythread_mutex) { - let _ret: c_int = unsafe { pthread_mutex_unlock(mutex as *mut pthread_mutex_t) }; -} -#[inline] -extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { - return unsafe { - (*mycond).clk_id = _CLOCK_REALTIME; - pthread_cond_init( - &raw mut (*mycond).cond, - core::ptr::null(), - ) - }; -} -#[inline] -extern "C" fn mythread_cond_destroy(cond: *mut mythread_cond) { - let _ret: c_int = unsafe { pthread_cond_destroy(&raw mut (*cond).cond) }; -} -#[inline] -extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { - let _ret: c_int = unsafe { pthread_cond_signal(&raw mut (*cond).cond) }; -} -#[inline] -extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { - let _ret: c_int = - unsafe { pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) }; -} -#[inline] -extern "C" fn mythread_cond_timedwait( - cond: *mut mythread_cond, - mutex: *mut mythread_mutex, - condtime: *const mythread_condtime, -) -> c_int { - let ret: c_int = unsafe { - pthread_cond_timedwait( - &raw mut (*cond).cond, - mutex as *mut pthread_mutex_t, - condtime as *const timespec, - ) - }; - ret -} -#[inline] -extern "C" fn mythread_condtime_set( - condtime: *mut mythread_condtime, - cond: *const mythread_cond, - timeout_ms: u32, -) { - unsafe { - (*condtime).tv_sec = timeout_ms.wrapping_div(1000) as time_t as __darwin_time_t; - (*condtime).tv_nsec = timeout_ms.wrapping_rem(1000).wrapping_mul(1000000) as c_long; - let mut now: timespec = timespec { - tv_sec: 0, - tv_nsec: 0, - }; - let _ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); - (*condtime).tv_sec += now.tv_sec; - (*condtime).tv_nsec += now.tv_nsec; - if (*condtime).tv_nsec >= 1000000000 as c_long { - (*condtime).tv_nsec -= 1000000000 as c_long; - (*condtime).tv_sec += 1; - } - } -} -pub const LZMA_THREADS_MAX: u32 = 16384; -#[inline] -extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { - unsafe { (*outq).bufs_in_use < (*outq).bufs_limit } -} -#[inline] -extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { - unsafe { (*outq).bufs_in_use == 0 } -} pub const BLOCK_SIZE_MAX: c_ulonglong = UINT64_MAX.wrapping_div(LZMA_THREADS_MAX as u64); unsafe extern "C" fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { let mut mythread_i_207: c_uint = 0; @@ -868,7 +553,11 @@ unsafe extern "C" fn get_thread( &raw mut (*(*coder).thr).filters as *mut lzma_filter, allocator, ); - core::ptr::copy_nonoverlapping(&raw mut (*coder).filters_cache as *const u8, &raw mut (*(*coder).thr).filters as *mut u8, core::mem::size_of::<[lzma_filter; 5]>()); + core::ptr::copy_nonoverlapping( + &raw mut (*coder).filters_cache as *const u8, + &raw mut (*(*coder).thr).filters as *mut u8, + core::mem::size_of::<[lzma_filter; 5]>(), + ); (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; mythread_cond_signal(&raw mut (*(*coder).thr).cond); mythread_j_578 = 1; @@ -1243,7 +932,11 @@ unsafe extern "C" fn stream_encoder_mt_update( &raw mut (*coder).filters_cache as *mut lzma_filter, allocator, ); - core::ptr::copy_nonoverlapping(&raw mut temp as *const u8, &raw mut (*coder).filters as *mut u8, core::mem::size_of::<[lzma_filter; 5]>()); + core::ptr::copy_nonoverlapping( + &raw mut temp as *const u8, + &raw mut (*coder).filters as *mut u8, + core::mem::size_of::<[lzma_filter; 5]>(), + ); LZMA_OK } unsafe extern "C" fn get_options( @@ -1462,12 +1155,15 @@ unsafe extern "C" fn stream_encoder_mt_init( ); (*next).get_progress = Some(get_progress as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> ()); - (*next).update = Some(stream_encoder_mt_update as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret); + (*next).update = Some( + stream_encoder_mt_update + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ); (*coder).filters[0].id = LZMA_VLI_UNKNOWN; (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; (*coder).index_encoder = lzma_next_coder_s { @@ -1483,7 +1179,11 @@ unsafe extern "C" fn stream_encoder_mt_init( set_out_limit: None, }; (*coder).index = core::ptr::null_mut(); - core::ptr::write_bytes(&raw mut (*coder).outq as *mut u8, 0 as u8, core::mem::size_of::()); + core::ptr::write_bytes( + &raw mut (*coder).outq as *mut u8, + 0 as u8, + core::mem::size_of::(), + ); (*coder).threads = core::ptr::null_mut(); (*coder).threads_max = 0; (*coder).threads_initialized = 0; @@ -1631,8 +1331,8 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt let mut total_memusage: u64 = (LZMA_MEMUSAGE_BASE) .wrapping_add(core::mem::size_of::() as u64) .wrapping_add( - ((*options).threads as usize) - .wrapping_mul(core::mem::size_of::()) as u64, + ((*options).threads as usize).wrapping_mul(core::mem::size_of::()) + as u64, ); if (UINT64_MAX).wrapping_sub(total_memusage) < inbuf_memusage { return UINT64_MAX; diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index ab63b13f..9e8997c6 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -1,12 +1,4 @@ use crate::types::*; -#[inline] -extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { - unsafe { - (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli - && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli - && (*options).backward_size & 3 == 0 - } -} #[no_mangle] pub static mut lzma_header_magic: [u8; 6] = [ 0xfd as u8, 0x37 as u8, 0x7a as u8, 0x58 as u8, 0x5a as u8, 0, diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 4c0372ee..d51eb6b5 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -1,21 +1,9 @@ use crate::types::*; use core::ffi::c_void; extern "C" { - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; static lzma_header_magic: [u8; 6]; static lzma_footer_magic: [u8; 2]; } -#[inline] -extern "C" fn read32le(buf: *const u8) -> u32 { - return unsafe { - let mut num: u32 = *buf as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - num - }; -} -pub const LZMA_STREAM_FLAGS_SIZE: u32 = 2; extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> bool { return unsafe { if *in_0 != 0 || *in_0.offset(1) & 0xf0 != 0 { diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 634d1aa1..2ed6ac82 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -1,27 +1,8 @@ use crate::types::*; extern "C" { - fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; static lzma_header_magic: [u8; 6]; static lzma_footer_magic: [u8; 2]; } -#[inline] -extern "C" fn write32le(buf: *mut u8, num: u32) { - unsafe { - *buf = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; - } -} -pub const LZMA_STREAM_FLAGS_SIZE: u32 = 2; -#[inline] -extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { - unsafe { - (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli - && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX as lzma_vli - && (*options).backward_size & 3 == 0 - } -} extern "C" fn stream_flags_encode(options: *const lzma_stream_flags, out: *mut u8) -> bool { return unsafe { if (*options).check > LZMA_CHECK_ID_MAX { @@ -40,7 +21,11 @@ pub unsafe extern "C" fn lzma_stream_header_encode( if (*options).version != 0 { return LZMA_OPTIONS_ERROR; } - core::ptr::copy_nonoverlapping(&raw const lzma_header_magic as *const u8, out as *mut u8, core::mem::size_of::<[u8; 6]>()); + core::ptr::copy_nonoverlapping( + &raw const lzma_header_magic as *const u8, + out as *mut u8, + core::mem::size_of::<[u8; 6]>(), + ); if stream_flags_encode( options, out.offset(core::mem::size_of::<[u8; 6]>() as isize), @@ -79,7 +64,11 @@ pub unsafe extern "C" fn lzma_stream_footer_encode( } let crc: u32 = lzma_crc32(out.offset(4), (4 + LZMA_STREAM_FLAGS_SIZE) as size_t, 0) as u32; write32le(out, crc); - core::ptr::copy_nonoverlapping(&raw const lzma_footer_magic as *const u8, out.offset((2 * 4) as isize) - .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut u8, core::mem::size_of::<[u8; 2]>()); + core::ptr::copy_nonoverlapping( + &raw const lzma_footer_magic as *const u8, + out.offset((2 * 4) as isize) + .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut u8, + core::mem::size_of::<[u8; 2]>(), + ); LZMA_OK } diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index f286e121..aaa89e2a 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -1,7 +1,6 @@ use crate::types::*; use core::ffi::{c_char, c_int, c_uint, c_void}; extern "C" { - fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; fn lzma_validate_chain(filters: *const lzma_filter, count: *mut size_t) -> lzma_ret; } #[derive(Copy, Clone)] @@ -63,12 +62,10 @@ pub const LZMA_STR_ENCODER: c_uint = 0x10; pub const LZMA_STR_DECODER: c_uint = 0x20; pub const LZMA_STR_GETOPT_LONG: c_uint = 0x40; pub const LZMA_STR_NO_SPACES: c_uint = 0x80; -pub const LZMA_DELTA_DIST_MIN: u32 = 1; pub const LZMA_DICT_SIZE_DEFAULT: c_uint = 1u32 << 23; pub const LZMA_LCLP_MIN: u32 = 0; pub const LZMA_PB_MIN: u32 = 0; pub const LZMA_PRESET_DEFAULT: c_uint = 6; -pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; pub const STR_ALLOC_SIZE: u32 = 800; unsafe extern "C" fn str_init(str: *mut lzma_str, allocator: *const lzma_allocator) -> lzma_ret { (*str).buf = lzma_alloc(STR_ALLOC_SIZE as size_t, allocator) as *mut c_char; @@ -102,7 +99,11 @@ unsafe extern "C" fn str_append_str(str: *mut lzma_str, s: *const c_char) { let len: size_t = strlen(s) as size_t; let limit: size_t = ((STR_ALLOC_SIZE - 1) as size_t).wrapping_sub((*str).pos); let copy_size: size_t = if len < limit { len } else { limit }; - core::ptr::copy_nonoverlapping(s as *const u8, (*str).buf.offset((*str).pos as isize) as *mut u8, copy_size); + core::ptr::copy_nonoverlapping( + s as *const u8, + (*str).buf.offset((*str).pos as isize) as *mut u8, + copy_size, + ); (*str).pos = (*str).pos.wrapping_add(copy_size); } unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) { @@ -885,8 +886,12 @@ unsafe extern "C" fn str_to_filters( match current_block { 6100283484465977373 => {} _ => { - core::ptr::copy_nonoverlapping(&raw mut temp_filters as *const u8, filters as *mut u8, i_0.wrapping_add(1) - .wrapping_mul(core::mem::size_of::())); + core::ptr::copy_nonoverlapping( + &raw mut temp_filters as *const u8, + filters as *mut u8, + i_0.wrapping_add(1) + .wrapping_mul(core::mem::size_of::()), + ); return core::ptr::null(); } } diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index e1c6c0a8..48b2fcec 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -1,14 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); -} -pub const LZMA_DELTA_DIST_MIN: u32 = 1; unsafe extern "C" fn delta_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; lzma_next_end(&raw mut (*coder).next, allocator); @@ -29,8 +20,7 @@ pub unsafe extern "C" fn lzma_delta_coder_init( } (*next).coder = coder as *mut c_void; (*next).end = - Some(delta_coder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) - ; + Some(delta_coder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 20d087d6..8c547b6f 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -1,12 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_delta_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; -} unsafe extern "C" fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { let distance: size_t = (*coder).distance; let mut i: size_t = 0; diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index 7f7a7509..6248b1bb 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -1,19 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_next_filter_update( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - reversed_filters: *const lzma_filter, - ) -> lzma_ret; - fn lzma_delta_coder_memusage(options: *const c_void) -> u64; - fn lzma_delta_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; -} -pub const LZMA_DELTA_DIST_MIN: u32 = 1; unsafe extern "C" fn copy_and_encode( coder: *mut lzma_delta_coder, in_0: *const u8, @@ -132,12 +118,15 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( lzma_action, ) -> lzma_ret, ); - (*next).update = Some(delta_encoder_update as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret); + (*next).update = Some( + delta_encoder_update + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ); lzma_delta_coder_init(next, allocator, filters) } #[no_mangle] diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index e623e099..5d88aac0 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -1,13 +1,5 @@ use crate::types::*; -use core::ffi::{c_ulong, c_void}; -extern "C" { - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); -} +use core::ffi::c_void; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -32,12 +24,8 @@ pub struct C2RustUnnamed { pub size: size_t, pub buffer: [u8; LZMA_BUFFER_SIZE as usize], } -pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; -pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const LZMA_BUFFER_SIZE: u32 = 4096; pub const LZ_DICT_EXTRA: u32 = 0; -pub const LZ_DICT_REPEAT_MAX: u32 = 288; -pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { coder: core::ptr::null_mut(), code: None, @@ -65,11 +53,15 @@ unsafe extern "C" fn decode_buffer( if (*coder).dict.pos == (*coder).dict.size { (*coder).dict.pos = LZ_DICT_REPEAT_MAX as size_t; (*coder).dict.has_wrapped = true; - core::ptr::copy_nonoverlapping((*coder) - .dict - .buf - .offset((*coder).dict.size as isize) - .offset(-(LZ_DICT_REPEAT_MAX as isize)) as *const u8, (*coder).dict.buf as *mut u8, LZ_DICT_REPEAT_MAX as size_t); + core::ptr::copy_nonoverlapping( + (*coder) + .dict + .buf + .offset((*coder).dict.size as isize) + .offset(-(LZ_DICT_REPEAT_MAX as isize)) as *const u8, + (*coder).dict.buf as *mut u8, + LZ_DICT_REPEAT_MAX as size_t, + ); } let dict_start: size_t = (*coder).dict.pos; (*coder).dict.limit = (*coder).dict.pos.wrapping_add( @@ -89,7 +81,11 @@ unsafe extern "C" fn decode_buffer( ); let copy_size: size_t = (*coder).dict.pos.wrapping_sub(dict_start); if copy_size > 0 { - core::ptr::copy_nonoverlapping((*coder).dict.buf.offset(dict_start as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size); + core::ptr::copy_nonoverlapping( + (*coder).dict.buf.offset(dict_start as isize) as *const u8, + out.offset(*out_pos as isize) as *mut u8, + copy_size, + ); } *out_pos = (*out_pos).wrapping_add(copy_size); if (*coder).dict.need_reset { @@ -214,8 +210,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( ) -> lzma_ret, ); (*next).end = - Some(lz_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) - ; + Some(lz_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()); (*coder).dict.buf = core::ptr::null_mut(); (*coder).dict.size = 0; (*coder).lz = LZMA_LZ_DECODER_INIT; @@ -279,7 +274,11 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( lz_options.dict_size }; let offset: size_t = lz_options.preset_dict_size.wrapping_sub(copy_size); - core::ptr::copy_nonoverlapping(lz_options.preset_dict.offset(offset as isize) as *const u8, (*coder).dict.buf.offset((*coder).dict.pos as isize) as *mut u8, copy_size); + core::ptr::copy_nonoverlapping( + lz_options.preset_dict.offset(offset as isize) as *const u8, + (*coder).dict.buf.offset((*coder).dict.pos as isize) as *mut u8, + copy_size, + ); (*coder).dict.pos = (*coder).dict.pos.wrapping_add(copy_size); (*coder).dict.full = copy_size; } diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 75fa909f..177d0f2b 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -1,25 +1,6 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; +use core::ffi::c_void; extern "C" { - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_filter_update( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - reversed_filters: *const lzma_filter, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; fn lzma_mf_hc3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; fn lzma_mf_hc3_skip(dict: *mut lzma_mf, amount: u32); fn lzma_mf_hc4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; @@ -51,17 +32,15 @@ pub struct lzma_coder { pub mf: lzma_mf, pub next: lzma_next_coder, } -#[inline] -extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { - match_finder as u32 & 0xf -} -pub const HASH_2_SIZE: c_uint = 1u32 << 10; -pub const HASH_3_SIZE: c_uint = 1u32 << 16; pub const LZMA_MEMCMPLEN_EXTRA: u32 = 0; unsafe extern "C" fn move_window(mf: *mut lzma_mf) { let move_offset: u32 = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) & !(15); let move_size: size_t = (*mf).write_pos.wrapping_sub(move_offset) as size_t; - core::ptr::copy((*mf).buffer.offset(move_offset as isize) as *const u8, (*mf).buffer as *mut u8, move_size); + core::ptr::copy( + (*mf).buffer.offset(move_offset as isize) as *const u8, + (*mf).buffer as *mut u8, + move_size, + ); (*mf).offset = (*mf).offset.wrapping_add(move_offset); (*mf).read_pos = (*mf).read_pos.wrapping_sub(move_offset); (*mf).read_limit = (*mf).read_limit.wrapping_sub(move_offset); @@ -108,7 +87,11 @@ unsafe extern "C" fn fill_window( ); } (*coder).mf.write_pos = write_pos as u32; - core::ptr::write_bytes((*coder).mf.buffer.offset(write_pos as isize) as *mut u8, 0 as u8, 0); + core::ptr::write_bytes( + (*coder).mf.buffer.offset(write_pos as isize) as *mut u8, + 0 as u8, + 0, + ); if ret == LZMA_STREAM_END { ret = LZMA_OK; (*coder).mf.action = action; @@ -203,23 +186,33 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1) as u32; match (*lz_options).match_finder { 3 => { - (*mf).find = Some(lzma_mf_hc3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).find = Some( + lzma_mf_hc3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ); (*mf).skip = Some(lzma_mf_hc3_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } 4 => { - (*mf).find = Some(lzma_mf_hc4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).find = Some( + lzma_mf_hc4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ); (*mf).skip = Some(lzma_mf_hc4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } 18 => { - (*mf).find = Some(lzma_mf_bt2_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).find = Some( + lzma_mf_bt2_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ); (*mf).skip = Some(lzma_mf_bt2_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } 19 => { - (*mf).find = Some(lzma_mf_bt3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).find = Some( + lzma_mf_bt3_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ); (*mf).skip = Some(lzma_mf_bt3_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } 20 => { - (*mf).find = Some(lzma_mf_bt4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32); + (*mf).find = Some( + lzma_mf_bt4_find as unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, + ); (*mf).skip = Some(lzma_mf_bt4_skip as unsafe extern "C" fn(*mut lzma_mf, u32) -> ()); } _ => return true, @@ -289,7 +282,11 @@ unsafe extern "C" fn lz_encoder_init( if (*mf).buffer.is_null() { return true; } - core::ptr::write_bytes((*mf).buffer.offset((*mf).size as isize) as *mut u8, 0 as u8, 0); + core::ptr::write_bytes( + (*mf).buffer.offset((*mf).size as isize) as *mut u8, + 0 as u8, + 0, + ); } (*mf).offset = (*mf).cyclic_size; (*mf).read_pos = 0; @@ -314,7 +311,11 @@ unsafe extern "C" fn lz_encoder_init( return true; } } else { - core::ptr::write_bytes((*mf).hash as *mut u8, 0 as u8, ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::())); + core::ptr::write_bytes( + (*mf).hash as *mut u8, + 0 as u8, + ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::()), + ); } (*mf).cyclic_pos = 0; if !(*lz_options).preset_dict.is_null() && (*lz_options).preset_dict_size > 0 { @@ -323,10 +324,14 @@ unsafe extern "C" fn lz_encoder_init( } else { (*mf).size }; - core::ptr::copy_nonoverlapping((*lz_options) - .preset_dict - .offset((*lz_options).preset_dict_size as isize) - .offset(-((*mf).write_pos as isize)) as *const u8, (*mf).buffer as *mut u8, (*mf).write_pos as size_t); + core::ptr::copy_nonoverlapping( + (*lz_options) + .preset_dict + .offset((*lz_options).preset_dict_size as isize) + .offset(-((*mf).write_pos as isize)) as *const u8, + (*mf).buffer as *mut u8, + (*mf).write_pos as size_t, + ); (*mf).action = LZMA_SYNC_FLUSH; (*mf).skip.unwrap()(mf, (*mf).write_pos); } @@ -450,15 +455,20 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( ) -> lzma_ret, ); (*next).end = - Some(lz_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()) - ; - (*next).update = Some(lz_encoder_update as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret); - (*next).set_out_limit = Some(lz_encoder_set_out_limit as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret); + Some(lz_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()); + (*next).update = Some( + lz_encoder_update + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ); + (*next).set_out_limit = Some( + lz_encoder_set_out_limit + as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret, + ); (*coder).lz.coder = core::ptr::null_mut(); (*coder).lz.code = None; (*coder).lz.end = None; diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 83181c6f..87b45658 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -3,32 +3,10 @@ use core::ffi::c_uint; extern "C" { static lzma_crc32_table: [[u32; 256]; 8]; } -#[inline] -unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { - (*mf).buffer.offset((*mf).read_pos as isize) -} -#[inline] -unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { - (*mf).write_pos.wrapping_sub((*mf).read_pos) -} -pub const HASH_2_SIZE: c_uint = 1u32 << 10; -pub const HASH_3_SIZE: c_uint = 1u32 << 16; pub const HASH_2_MASK: c_uint = HASH_2_SIZE.wrapping_sub(1); pub const HASH_3_MASK: c_uint = HASH_3_SIZE.wrapping_sub(1); pub const FIX_3_HASH_SIZE: c_uint = 1u32 << 10; pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); -#[inline(always)] -unsafe extern "C" fn lzma_memcmplen( - buf1: *const u8, - buf2: *const u8, - mut len: u32, - limit: u32, -) -> u32 { - while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { - len += 1; - } - len -} #[no_mangle] pub unsafe extern "C" fn lzma_mf_find( mf: *mut lzma_mf, @@ -122,9 +100,7 @@ unsafe extern "C" fn hc_find_func( .wrapping_add(if delta > cyclic_pos { cyclic_size } else { 0 }) as isize, ); - if *pb.offset(len_best as isize) == *cur.offset(len_best as isize) - && *pb == *cur - { + if *pb.offset(len_best as isize) == *cur.offset(len_best as isize) && *pb == *cur { let len: u32 = lzma_memcmplen(pb, cur, 1, len_limit); if len_best < len { len_best = len; @@ -587,8 +563,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { 11875828834189669668 => { let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = - lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let cur_match: u32 = *(*mf) @@ -720,8 +695,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { 11875828834189669668 => { let cur: *const u8 = mf_ptr(mf); let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = - lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; let hash_2_value: u32 = temp & HASH_2_MASK as u32; let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; let hash_value: u32 = (temp diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index efe1a5ef..15fd866b 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -1,14 +1,6 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; extern "C" { - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; fn lzma_lz_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -23,8 +15,6 @@ extern "C" { ) -> lzma_ret, >, ) -> lzma_ret; - fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; - fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; fn lzma_lzma_decoder_create( lz: *mut lzma_lz_decoder, allocator: *const lzma_allocator, @@ -60,8 +50,6 @@ pub const SEQ_COMPRESSED_0: sequence = 3; pub const SEQ_UNCOMPRESSED_2: sequence = 2; pub const SEQ_UNCOMPRESSED_1: sequence = 1; pub const SEQ_CONTROL: sequence = 0; -pub const LZ_DICT_REPEAT_MAX: u32 = 288; -pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { coder: core::ptr::null_mut(), code: None, @@ -246,14 +234,19 @@ unsafe extern "C" fn lzma2_decoder_init( return LZMA_MEM_ERROR; } (*lz).coder = coder as *mut c_void; - (*lz).code = Some(lzma2_decode as unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret); - (*lz).end = Some(lzma2_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()); + (*lz).code = Some( + lzma2_decode + as unsafe extern "C" fn( + *mut c_void, + *mut lzma_dict, + *const u8, + *mut size_t, + size_t, + ) -> lzma_ret, + ); + (*lz).end = Some( + lzma2_decoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), + ); (*coder).lzma = LZMA_LZ_DECODER_INIT; } let options: *const lzma_options_lzma = opt as *const lzma_options_lzma; diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 0fd4ab12..89bbb95a 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -1,18 +1,6 @@ use crate::types::*; use core::ffi::{c_uint, c_void}; -#[repr(C)] -pub struct lzma_lzma1_encoder_s { - _opaque: [u8; 0], -} extern "C" { - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; fn lzma_lz_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -27,8 +15,6 @@ extern "C" { ) -> lzma_ret, >, ) -> lzma_ret; - fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64; - fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; fn lzma_lzma_encoder_create( coder_ptr: *mut *mut c_void, allocator: *const lzma_allocator, @@ -48,7 +34,6 @@ extern "C" { out_size: size_t, read_limit: u32, ) -> lzma_ret; - static lzma_fastpos: [u8; 8192]; } #[derive(Copy, Clone)] #[repr(C)] @@ -63,7 +48,6 @@ pub struct lzma_lz_options { pub preset_dict: *const u8, pub preset_dict_size: u32, } -pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma2_coder { @@ -101,30 +85,19 @@ unsafe extern "C" fn mf_read( ) { let out_avail: size_t = out_size.wrapping_sub(*out_pos); let copy_size: size_t = if out_avail < *left { out_avail } else { *left }; - core::ptr::copy_nonoverlapping((*mf) - .buffer - .offset((*mf).read_pos as isize) - .offset(-(*left as isize)) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size); + core::ptr::copy_nonoverlapping( + (*mf) + .buffer + .offset((*mf).read_pos as isize) + .offset(-(*left as isize)) as *const u8, + out.offset(*out_pos as isize) as *mut u8, + copy_size, + ); *out_pos = (*out_pos).wrapping_add(copy_size); *left = (*left).wrapping_sub(copy_size); } -pub const FASTPOS_BITS: u32 = 13; -#[inline] -unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < 1 << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { - return lzma_fastpos[dist as usize] as u32; - } - if dist < 1 << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { - return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); - } - (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) -} -pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; pub const LZMA2_UNCOMPRESSED_MAX: c_uint = 1u32 << 21; pub const LZMA2_HEADER_MAX: u32 = 6; -pub const LZMA2_HEADER_UNCOMPRESSED: u32 = 3; unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { let mut pos: size_t = 0; if (*coder).need_properties { @@ -380,15 +353,23 @@ unsafe extern "C" fn lzma2_encoder_init( return LZMA_MEM_ERROR; } (*lz).coder = coder as *mut c_void; - (*lz).code = Some(lzma2_encode as unsafe extern "C" fn( - *mut c_void, - *mut lzma_mf, - *mut u8, - *mut size_t, - size_t, - ) -> lzma_ret); - (*lz).end = Some(lzma2_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()); - (*lz).options_update = Some(lzma2_encoder_options_update as unsafe extern "C" fn(*mut c_void, *const lzma_filter) -> lzma_ret); + (*lz).code = Some( + lzma2_encode + as unsafe extern "C" fn( + *mut c_void, + *mut lzma_mf, + *mut u8, + *mut size_t, + size_t, + ) -> lzma_ret, + ); + (*lz).end = Some( + lzma2_encoder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), + ); + (*lz).options_update = Some( + lzma2_encoder_options_update + as unsafe extern "C" fn(*mut c_void, *const lzma_filter) -> lzma_ret, + ); (*coder).lzma = core::ptr::null_mut(); } (*coder).opt_cur = *(options as *const lzma_options_lzma); diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 07fabd21..577a5009 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -98,19 +98,6 @@ pub struct lzma_length_decoder { pub high: [probability; 256], } #[inline] -extern "C" fn read32le(buf: *const u8) -> u32 { - return unsafe { - let mut num: u32 = *buf as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - num - }; -} -pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; -pub const LZ_DICT_REPEAT_MAX: u32 = 288; -pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; -#[inline] unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { *(*dict).buf.offset( (*dict) @@ -156,7 +143,11 @@ unsafe extern "C" fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut } } } else { - core::ptr::copy_nonoverlapping((*dict).buf.offset(back as isize) as *const u8, (*dict).buf.offset((*dict).pos as isize) as *mut u8, left as size_t); + core::ptr::copy_nonoverlapping( + (*dict).buf.offset(back as isize) as *const u8, + (*dict).buf.offset((*dict).pos as isize) as *mut u8, + left as size_t, + ); (*dict).pos = (*dict).pos.wrapping_add(left as size_t); } if !(*dict).has_wrapped { @@ -180,47 +171,7 @@ unsafe extern "C" fn dict_put_safe(dict: *mut lzma_dict, byte: u8) -> bool { dict_put(dict, byte); false } -pub const RC_SHIFT_BITS: u32 = 8; -pub const RC_TOP_BITS: u32 = 24; -pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; -pub const RC_BIT_MODEL_TOTAL_BITS: u32 = 11; -pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_BITS: u32 = 5; -#[inline] -unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { - (*options).lc <= LZMA_LCLP_MAX - && (*options).lp <= LZMA_LCLP_MAX - && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX - && (*options).pb <= LZMA_PB_MAX -} -pub const STATES: u32 = 12; -pub const LIT_STATES: u32 = 7; -pub const LITERAL_CODER_SIZE: c_uint = 0x300; -#[inline] -unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { - let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; - let mut i: size_t = 0; - while i < coders { - *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; - i += 1; - } -} -pub const MATCH_LEN_MIN: u32 = 2; -pub const LEN_LOW_BITS: u32 = 3; -pub const LEN_LOW_SYMBOLS: u32 = 1 << LEN_LOW_BITS; -pub const LEN_MID_BITS: u32 = 3; -pub const LEN_MID_SYMBOLS: u32 = 1 << LEN_MID_BITS; -pub const LEN_HIGH_BITS: u32 = 8; -pub const LEN_HIGH_SYMBOLS: u32 = 1 << LEN_HIGH_BITS; -pub const DIST_STATES: u32 = 4; -pub const DIST_SLOT_BITS: u32 = 6; pub const DIST_SLOTS: u32 = 1 << DIST_SLOT_BITS; -pub const DIST_MODEL_START: u32 = 4; -pub const DIST_MODEL_END: u32 = 14; -pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; -pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: u32 = 4; -pub const ALIGN_SIZE: u32 = 1 << ALIGN_BITS; #[inline] unsafe extern "C" fn rc_read_init( rc: *mut lzma_range_decoder, @@ -1935,8 +1886,7 @@ unsafe extern "C" fn lzma_decode( >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = - symbol.wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); + symbol = symbol.wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -2177,9 +2127,8 @@ unsafe extern "C" fn lzma_decode( >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol.wrapping_add( - (-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32, - ); + symbol = symbol + .wrapping_add((-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32); len = symbol; } } @@ -2939,8 +2888,8 @@ unsafe extern "C" fn lzma_decode( >> RC_MOVE_BITS); symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol - .wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); + symbol = + symbol.wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); len = symbol; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3401,16 +3350,21 @@ pub unsafe extern "C" fn lzma_lzma_decoder_create( if (*lz).coder.is_null() { return LZMA_MEM_ERROR; } - (*lz).code = Some(lzma_decode as unsafe extern "C" fn( - *mut c_void, - *mut lzma_dict, - *const u8, - *mut size_t, - size_t, - ) -> lzma_ret); + (*lz).code = Some( + lzma_decode + as unsafe extern "C" fn( + *mut c_void, + *mut lzma_dict, + *const u8, + *mut size_t, + size_t, + ) -> lzma_ret, + ); (*lz).reset = Some(lzma_decoder_reset as unsafe extern "C" fn(*mut c_void, *const c_void) -> ()); - (*lz).set_uncompressed = Some(lzma_decoder_uncompressed as unsafe extern "C" fn(*mut c_void, lzma_vli, bool) -> ()); + (*lz).set_uncompressed = Some( + lzma_decoder_uncompressed as unsafe extern "C" fn(*mut c_void, lzma_vli, bool) -> (), + ); } (*lz_options).dict_size = (*options).dict_size as size_t; (*lz_options).preset_dict = (*options).preset_dict; diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index a3e4d4d3..bd144255 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; +use core::ffi::c_void; extern "C" { fn lzma_lz_encoder_init( next: *mut lzma_next_coder, @@ -16,7 +16,6 @@ extern "C" { >, ) -> lzma_ret; fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> u64; - static lzma_rc_prices: [u8; 128]; fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, @@ -30,7 +29,6 @@ extern "C" { len_res: *mut u32, position: u32, ); - static lzma_fastpos: [u8; 8192]; } #[derive(Copy, Clone)] #[repr(C)] @@ -45,159 +43,6 @@ pub struct lzma_lz_options { pub preset_dict: *const u8, pub preset_dict_size: u32, } -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_range_encoder { - pub low: u64, - pub cache_size: u64, - pub range: u32, - pub cache: u8, - pub out_total: u64, - pub count: size_t, - pub pos: size_t, - pub symbols: [C2RustUnnamed; 53], - pub probs: [*mut probability; 53], -} -pub type C2RustUnnamed = c_uint; -pub const RC_FLUSH: C2RustUnnamed = 4; -pub const RC_DIRECT_1: C2RustUnnamed = 3; -pub const RC_DIRECT_0: C2RustUnnamed = 2; -pub const RC_BIT_1: C2RustUnnamed = 1; -pub const RC_BIT_0: C2RustUnnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_lzma1_encoder_s { - pub rc: lzma_range_encoder, - pub uncomp_size: u64, - pub out_limit: u64, - pub uncomp_size_ptr: *mut u64, - pub state: lzma_lzma_state, - pub reps: [u32; 4], - pub matches: [lzma_match; 274], - pub matches_count: u32, - pub longest_match_length: u32, - pub fast_mode: bool, - pub is_initialized: bool, - pub is_flushed: bool, - pub use_eopm: bool, - pub pos_mask: u32, - pub literal_context_bits: u32, - pub literal_mask: u32, - pub literal: [probability; 12288], - pub is_match: [[probability; 16]; 12], - pub is_rep: [probability; 12], - pub is_rep0: [probability; 12], - pub is_rep1: [probability; 12], - pub is_rep2: [probability; 12], - pub is_rep0_long: [[probability; 16]; 12], - pub dist_slot: [[probability; 64]; 4], - pub dist_special: [probability; 114], - pub dist_align: [probability; 16], - pub match_len_encoder: lzma_length_encoder, - pub rep_len_encoder: lzma_length_encoder, - pub dist_slot_prices: [[u32; 64]; 4], - pub dist_prices: [[u32; 128]; 4], - pub dist_table_size: u32, - pub match_price_count: u32, - pub align_prices: [u32; 16], - pub align_price_count: u32, - pub opts_end_index: u32, - pub opts_current_index: u32, - pub opts: [lzma_optimal; OPTS as usize], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_optimal { - pub state: lzma_lzma_state, - pub prev_1_is_literal: bool, - pub prev_2: bool, - pub pos_prev_2: u32, - pub back_prev_2: u32, - pub price: u32, - pub pos_prev: u32, - pub back_prev: u32, - pub backs: [u32; 4], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_length_encoder { - pub choice: probability, - pub choice2: probability, - pub low: [[probability; 8]; 16], - pub mid: [[probability; 8]; 16], - pub high: [probability; 256], - pub prices: [[u32; 272]; 16], - pub table_size: u32, - pub counters: [u32; 16], -} -pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -#[inline] -extern "C" fn write32le(buf: *mut u8, num: u32) { - unsafe { - *buf = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; - } -} -pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; -pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; -#[inline] -extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { - match_finder as u32 & 0xf -} -#[inline] -unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { - if amount != 0 { - (*mf).skip.unwrap()(mf, amount); - (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); - } -} -pub const RC_SHIFT_BITS: u32 = 8; -pub const RC_TOP_BITS: u32 = 24; -pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; -pub const RC_BIT_MODEL_TOTAL_BITS: u32 = 11; -pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_BITS: u32 = 5; -pub const RC_MOVE_REDUCING_BITS: u32 = 4; -#[inline] -extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { - unsafe { - lzma_rc_prices[((prob as u32 - ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) - >> RC_MOVE_REDUCING_BITS) as usize] as u32 - } -} -#[inline] -extern "C" fn rc_bit_0_price(prob: probability) -> u32 { - unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 } -} -#[inline] -extern "C" fn rc_bit_1_price(prob: probability) -> u32 { - unsafe { - lzma_rc_prices - [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] - as u32 - } -} -#[inline] -unsafe extern "C" fn rc_bittree_price( - probs: *const probability, - bit_levels: u32, - mut symbol: u32, -) -> u32 { - let mut price: u32 = 0; - symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; - loop { - let bit: u32 = symbol & 1; - symbol >>= 1; - price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); - if symbol == 1 { - break; - } - } - price -} #[inline] unsafe extern "C" fn rc_reset(rc: *mut lzma_range_encoder) { (*rc).low = 0; @@ -214,7 +59,7 @@ unsafe extern "C" fn rc_forget(rc: *mut lzma_range_encoder) { } #[inline] unsafe extern "C" fn rc_bit(rc: *mut lzma_range_encoder, prob: *mut probability, bit: u32) { - (*rc).symbols[(*rc).count as usize] = bit as C2RustUnnamed; + (*rc).symbols[(*rc).count as usize] = bit as rc_symbol; (*rc).probs[(*rc).count as usize] = prob; (*rc).count = (*rc).count.wrapping_add(1); } @@ -268,7 +113,7 @@ unsafe extern "C" fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_ loop { bit_count -= 1; (*rc).symbols[(*rc).count as usize] = - (RC_DIRECT_0 as u32).wrapping_add(value >> bit_count & 1) as C2RustUnnamed; + (RC_DIRECT_0 as u32).wrapping_add(value >> bit_count & 1) as rc_symbol; (*rc).count += 1; if bit_count == 0 { break; @@ -463,58 +308,8 @@ unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u unsafe extern "C" fn rc_pending(rc: *const lzma_range_encoder) -> u64 { (*rc).cache_size.wrapping_add(5).wrapping_sub(1) } -#[inline] -unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { - (*options).lc <= LZMA_LCLP_MAX - && (*options).lp <= LZMA_LCLP_MAX - && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX - && (*options).pb <= LZMA_PB_MAX -} -pub const STATES: u32 = 12; -pub const LIT_STATES: u32 = 7; -pub const LITERAL_CODER_SIZE: c_uint = 0x300; -#[inline] -unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { - let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; - let mut i: size_t = 0; - while i < coders { - *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; - i += 1; - } -} -pub const MATCH_LEN_MIN: u32 = 2; -pub const LEN_LOW_BITS: u32 = 3; -pub const LEN_LOW_SYMBOLS: u32 = 1 << LEN_LOW_BITS; -pub const LEN_MID_BITS: u32 = 3; -pub const LEN_MID_SYMBOLS: u32 = 1 << LEN_MID_BITS; -pub const LEN_HIGH_BITS: u32 = 8; -pub const LEN_HIGH_SYMBOLS: u32 = 1 << LEN_HIGH_BITS; pub const LEN_SYMBOLS: u32 = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS; pub const MATCH_LEN_MAX: u32 = MATCH_LEN_MIN + LEN_SYMBOLS - 1; -pub const DIST_STATES: u32 = 4; -pub const DIST_SLOT_BITS: u32 = 6; -pub const DIST_MODEL_START: u32 = 4; -pub const DIST_MODEL_END: u32 = 14; -pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; -pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: u32 = 4; -pub const ALIGN_SIZE: u32 = 1 << ALIGN_BITS; -pub const ALIGN_MASK: u32 = ALIGN_SIZE - 1; -pub const REPS: u32 = 4; -pub const OPTS: u32 = 1 << 12; -pub const FASTPOS_BITS: u32 = 13; -#[inline] -unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < 1 << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { - return lzma_fastpos[dist as usize] as u32; - } - if dist < 1 << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { - return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); - } - (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) -} #[inline] unsafe extern "C" fn literal_matched( rc: *mut lzma_range_encoder, @@ -869,14 +664,13 @@ unsafe extern "C" fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_m (*mf).read_ahead = 0; rc_bit( &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) - as *mut probability) - as *mut probability, + (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) as *mut probability) + as *mut probability, 0, ); rc_bittree( &raw mut (*coder).rc, - &raw mut (*coder).literal as *mut probability , + &raw mut (*coder).literal as *mut probability, 8, *(*mf).buffer as u32, ); @@ -1133,8 +927,8 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( 1 << (*options).pb, (*coder).fast_mode, ); - (*coder).match_price_count = UINT32_MAX.wrapping_div(2) as u32; - (*coder).align_price_count = UINT32_MAX.wrapping_div(2) as u32; + (*coder).match_price_count = UINT32_MAX.wrapping_div(2); + (*coder).align_price_count = UINT32_MAX.wrapping_div(2); (*coder).opts_end_index = 0; (*coder).opts_current_index = 0; LZMA_OK @@ -1205,14 +999,19 @@ unsafe extern "C" fn lzma_encoder_init( if options.is_null() { return LZMA_PROG_ERROR; } - (*lz).code = Some(lzma_encode as unsafe extern "C" fn( - *mut c_void, - *mut lzma_mf, - *mut u8, - *mut size_t, - size_t, - ) -> lzma_ret); - (*lz).set_out_limit = Some(lzma_lzma_set_out_limit as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret); + (*lz).code = Some( + lzma_encode + as unsafe extern "C" fn( + *mut c_void, + *mut lzma_mf, + *mut u8, + *mut size_t, + size_t, + ) -> lzma_ret, + ); + (*lz).set_out_limit = Some( + lzma_lzma_set_out_limit as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret, + ); lzma_lzma_encoder_create( &raw mut (*lz).coder, allocator, diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index d8094b49..b7a289fb 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -1,123 +1,5 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; -extern "C" { - fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_range_encoder { - pub low: u64, - pub cache_size: u64, - pub range: u32, - pub cache: u8, - pub out_total: u64, - pub count: size_t, - pub pos: size_t, - pub symbols: [C2RustUnnamed; 53], - pub probs: [*mut probability; 53], -} -pub type C2RustUnnamed = c_uint; -pub const RC_FLUSH: C2RustUnnamed = 4; -pub const RC_DIRECT_1: C2RustUnnamed = 3; -pub const RC_DIRECT_0: C2RustUnnamed = 2; -pub const RC_BIT_1: C2RustUnnamed = 1; -pub const RC_BIT_0: C2RustUnnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_lzma1_encoder_s { - pub rc: lzma_range_encoder, - pub uncomp_size: u64, - pub out_limit: u64, - pub uncomp_size_ptr: *mut u64, - pub state: lzma_lzma_state, - pub reps: [u32; 4], - pub matches: [lzma_match; 274], - pub matches_count: u32, - pub longest_match_length: u32, - pub fast_mode: bool, - pub is_initialized: bool, - pub is_flushed: bool, - pub use_eopm: bool, - pub pos_mask: u32, - pub literal_context_bits: u32, - pub literal_mask: u32, - pub literal: [probability; 12288], - pub is_match: [[probability; 16]; 12], - pub is_rep: [probability; 12], - pub is_rep0: [probability; 12], - pub is_rep1: [probability; 12], - pub is_rep2: [probability; 12], - pub is_rep0_long: [[probability; 16]; 12], - pub dist_slot: [[probability; 64]; 4], - pub dist_special: [probability; 114], - pub dist_align: [probability; 16], - pub match_len_encoder: lzma_length_encoder, - pub rep_len_encoder: lzma_length_encoder, - pub dist_slot_prices: [[u32; 64]; 4], - pub dist_prices: [[u32; 128]; 4], - pub dist_table_size: u32, - pub match_price_count: u32, - pub align_prices: [u32; 16], - pub align_price_count: u32, - pub opts_end_index: u32, - pub opts_current_index: u32, - pub opts: [lzma_optimal; OPTS as usize], -} -pub const OPTS: u32 = 1 << 12; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_optimal { - pub state: lzma_lzma_state, - pub prev_1_is_literal: bool, - pub prev_2: bool, - pub pos_prev_2: u32, - pub back_prev_2: u32, - pub price: u32, - pub pos_prev: u32, - pub back_prev: u32, - pub backs: [u32; 4], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_length_encoder { - pub choice: probability, - pub choice2: probability, - pub low: [[probability; 8]; 16], - pub mid: [[probability; 8]; 16], - pub high: [probability; 256], - pub prices: [[u32; 272]; 16], - pub table_size: u32, - pub counters: [u32; 16], -} -pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -#[inline] -unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { - (*mf).buffer.offset((*mf).read_pos as isize) -} -#[inline] -unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { - (*mf).write_pos.wrapping_sub((*mf).read_pos) -} -#[inline] -unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { - if amount != 0 { - (*mf).skip.unwrap()(mf, amount); - (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); - } -} -pub const REPS: u32 = 4; -#[inline(always)] -unsafe extern "C" fn lzma_memcmplen( - buf1: *const u8, - buf2: *const u8, - mut len: u32, - limit: u32, -) -> u32 { - while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { - len += 1; - } - len -} +use core::ffi::c_void; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 22827d4d..52cd5ca9 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -1,156 +1,8 @@ use crate::types::*; use core::ffi::c_uint; -extern "C" { - fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; - static lzma_rc_prices: [u8; 128]; - static lzma_fastpos: [u8; 8192]; -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_range_encoder { - pub low: u64, - pub cache_size: u64, - pub range: u32, - pub cache: u8, - pub out_total: u64, - pub count: size_t, - pub pos: size_t, - pub symbols: [C2RustUnnamed; 53], - pub probs: [*mut probability; 53], -} -pub type C2RustUnnamed = c_uint; -pub const RC_FLUSH: C2RustUnnamed = 4; -pub const RC_DIRECT_1: C2RustUnnamed = 3; -pub const RC_DIRECT_0: C2RustUnnamed = 2; -pub const RC_BIT_1: C2RustUnnamed = 1; -pub const RC_BIT_0: C2RustUnnamed = 0; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_lzma1_encoder_s { - pub rc: lzma_range_encoder, - pub uncomp_size: u64, - pub out_limit: u64, - pub uncomp_size_ptr: *mut u64, - pub state: lzma_lzma_state, - pub reps: [u32; 4], - pub matches: [lzma_match; 274], - pub matches_count: u32, - pub longest_match_length: u32, - pub fast_mode: bool, - pub is_initialized: bool, - pub is_flushed: bool, - pub use_eopm: bool, - pub pos_mask: u32, - pub literal_context_bits: u32, - pub literal_mask: u32, - pub literal: [probability; 12288], - pub is_match: [[probability; 16]; 12], - pub is_rep: [probability; 12], - pub is_rep0: [probability; 12], - pub is_rep1: [probability; 12], - pub is_rep2: [probability; 12], - pub is_rep0_long: [[probability; 16]; 12], - pub dist_slot: [[probability; 64]; 4], - pub dist_special: [probability; 114], - pub dist_align: [probability; 16], - pub match_len_encoder: lzma_length_encoder, - pub rep_len_encoder: lzma_length_encoder, - pub dist_slot_prices: [[u32; 64]; 4], - pub dist_prices: [[u32; 128]; 4], - pub dist_table_size: u32, - pub match_price_count: u32, - pub align_prices: [u32; 16], - pub align_price_count: u32, - pub opts_end_index: u32, - pub opts_current_index: u32, - pub opts: [lzma_optimal; OPTS as usize], -} -pub const OPTS: u32 = 1 << 12; -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_optimal { - pub state: lzma_lzma_state, - pub prev_1_is_literal: bool, - pub prev_2: bool, - pub pos_prev_2: u32, - pub back_prev_2: u32, - pub price: u32, - pub pos_prev: u32, - pub back_prev: u32, - pub backs: [u32; 4], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_length_encoder { - pub choice: probability, - pub choice2: probability, - pub low: [[probability; 8]; 16], - pub mid: [[probability; 8]; 16], - pub high: [probability; 256], - pub prices: [[u32; 272]; 16], - pub table_size: u32, - pub counters: [u32; 16], -} -pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; -#[inline] -unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { - (*mf).buffer.offset((*mf).read_pos as isize) -} -#[inline] -unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { - (*mf).write_pos.wrapping_sub((*mf).read_pos) -} -#[inline] -unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { - if amount != 0 { - (*mf).skip.unwrap()(mf, amount); - (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); - } -} -pub const RC_BIT_MODEL_TOTAL_BITS: u32 = 11; -pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; -pub const RC_MOVE_REDUCING_BITS: u32 = 4; pub const RC_BIT_PRICE_SHIFT_BITS: u32 = 4; pub const RC_INFINITY_PRICE: c_uint = 1u32 << 30; #[inline] -extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { - unsafe { - lzma_rc_prices[((prob as u32 - ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) - >> RC_MOVE_REDUCING_BITS) as usize] as u32 - } -} -#[inline] -extern "C" fn rc_bit_0_price(prob: probability) -> u32 { - unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 } -} -#[inline] -extern "C" fn rc_bit_1_price(prob: probability) -> u32 { - unsafe { - lzma_rc_prices - [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] - as u32 - } -} -#[inline] -unsafe extern "C" fn rc_bittree_price( - probs: *const probability, - bit_levels: u32, - mut symbol: u32, -) -> u32 { - let mut price: u32 = 0; - symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; - loop { - let bit: u32 = symbol & 1; - symbol >>= 1; - price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); - if symbol == 1 { - break; - } - } - price -} -#[inline] unsafe extern "C" fn rc_bittree_reverse_price( probs: *const probability, mut bit_levels: u32, @@ -174,31 +26,6 @@ unsafe extern "C" fn rc_bittree_reverse_price( extern "C" fn rc_direct_price(bits: u32) -> u32 { bits << RC_BIT_PRICE_SHIFT_BITS } -pub const LIT_STATES: u32 = 7; -pub const MATCH_LEN_MIN: u32 = 2; -pub const DIST_STATES: u32 = 4; -pub const DIST_SLOT_BITS: u32 = 6; -pub const DIST_MODEL_START: u32 = 4; -pub const DIST_MODEL_END: u32 = 14; -pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; -pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; -pub const ALIGN_BITS: u32 = 4; -pub const ALIGN_SIZE: u32 = 1 << ALIGN_BITS; -pub const ALIGN_MASK: u32 = ALIGN_SIZE - 1; -pub const REPS: u32 = 4; -pub const FASTPOS_BITS: u32 = 13; -#[inline] -unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { - if dist < 1 << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { - return lzma_fastpos[dist as usize] as u32; - } - if dist < 1 << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { - return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); - } - (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) -} #[inline] unsafe extern "C" fn get_dist_slot_2(dist: u32) -> u32 { if dist < 1 << FASTPOS_BITS + (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1)) { @@ -212,18 +39,6 @@ unsafe extern "C" fn get_dist_slot_2(dist: u32) -> u32 { (lzma_fastpos[(dist >> 14 / 2 - 1 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) .wrapping_add((2 * (14 / 2 - 1 + 2 * (FASTPOS_BITS - 1))) as u32) } -#[inline(always)] -unsafe extern "C" fn lzma_memcmplen( - buf1: *const u8, - buf2: *const u8, - mut len: u32, - limit: u32, -) -> u32 { - while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { - len += 1; - } - len -} unsafe extern "C" fn get_literal_price( coder: *const lzma_lzma1_encoder, pos: u32, @@ -1120,7 +935,11 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( return; } let mut reps: [u32; 4] = [0; 4]; - core::ptr::copy_nonoverlapping(&raw mut (*coder).reps as *const u8, &raw mut reps as *mut u8, core::mem::size_of::<[u32; 4]>()); + core::ptr::copy_nonoverlapping( + &raw mut (*coder).reps as *const u8, + &raw mut reps as *mut u8, + core::mem::size_of::<[u32; 4]>(), + ); let mut cur: u32 = 0; cur = 1; while cur < len_end { diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index 607c400e..58936bd4 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -4,7 +4,6 @@ pub const LZMA_LC_DEFAULT: u32 = 3; pub const LZMA_LP_DEFAULT: u32 = 0; pub const LZMA_PB_DEFAULT: u32 = 2; pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f; -pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_preset( options: *mut lzma_options_lzma, diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index 433b085c..2d9b6e8b 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -1,17 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; -} unsafe extern "C" fn arm_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index 503d0cab..2c153360 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -1,36 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; -} -#[inline] -extern "C" fn read32le(buf: *const u8) -> u32 { - return unsafe { - let mut num: u32 = *buf as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - num - }; -} -#[inline] -extern "C" fn write32le(buf: *mut u8, num: u32) { - unsafe { - *buf = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; - } -} unsafe extern "C" fn arm64_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index 2991d556..7fd6c280 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -1,17 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; -} unsafe extern "C" fn armthumb_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 6d45a88a..a481879e 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -1,17 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; -} unsafe extern "C" fn ia64_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index cbb1fd5b..916cf2ab 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -1,17 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; -} unsafe extern "C" fn powerpc_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index f96544a9..dc5f39b7 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -1,17 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; -} #[inline] extern "C" fn read32be(buf: *const u8) -> u32 { return unsafe { @@ -23,16 +11,6 @@ extern "C" fn read32be(buf: *const u8) -> u32 { }; } #[inline] -extern "C" fn read32le(buf: *const u8) -> u32 { - return unsafe { - let mut num: u32 = *buf as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - num - }; -} -#[inline] extern "C" fn write32be(buf: *mut u8, num: u32) { unsafe { *buf = (num >> 24) as u8; @@ -41,15 +19,6 @@ extern "C" fn write32be(buf: *mut u8, num: u32) { *buf.offset(3) = num as u8; } } -#[inline] -extern "C" fn write32le(buf: *mut u8, num: u32) { - unsafe { - *buf = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; - } -} unsafe extern "C" fn riscv_encode( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index eac745f0..dd859d80 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -1,26 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_next_filter_update( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - reversed_filters: *const lzma_filter, - ) -> lzma_ret; - fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; -} unsafe extern "C" fn copy_or_code( coder: *mut lzma_simple_coder, allocator: *const lzma_allocator, @@ -109,7 +88,11 @@ unsafe extern "C" fn simple_code( if out_avail > buf_avail || buf_avail == 0 { let out_start: size_t = *out_pos; if buf_avail > 0 { - core::ptr::copy_nonoverlapping((&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, buf_avail); + core::ptr::copy_nonoverlapping( + (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const u8, + out.offset(*out_pos as isize) as *mut u8, + buf_avail, + ); } *out_pos = (*out_pos).wrapping_add(buf_avail); let ret: lzma_ret = copy_or_code( @@ -131,10 +114,18 @@ unsafe extern "C" fn simple_code( (*coder).size = 0; } else if unfiltered > 0 { *out_pos = (*out_pos).wrapping_sub(unfiltered); - core::ptr::copy_nonoverlapping(out.offset(*out_pos as isize) as *const u8, &raw mut (*coder).buffer as *mut u8, unfiltered); + core::ptr::copy_nonoverlapping( + out.offset(*out_pos as isize) as *const u8, + &raw mut (*coder).buffer as *mut u8, + unfiltered, + ); } } else if (*coder).pos > 0 { - core::ptr::copy((&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const u8, &raw mut (*coder).buffer as *mut u8, buf_avail); + core::ptr::copy( + (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const u8, + &raw mut (*coder).buffer as *mut u8, + buf_avail, + ); (*coder).size = (*coder).size.wrapping_sub((*coder).pos); (*coder).pos = 0; } @@ -229,12 +220,15 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*next).end = Some( simple_coder_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), ); - (*next).update = Some(simple_coder_update as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret); + (*next).update = Some( + simple_coder_update + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ); (*coder).next = lzma_next_coder_s { coder: core::ptr::null_mut(), id: LZMA_VLI_UNKNOWN, @@ -259,8 +253,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( } } if !(*filters).options.is_null() { - let simple: *const lzma_options_bcj = - (*filters).options as *const lzma_options_bcj; + let simple: *const lzma_options_bcj = (*filters).options as *const lzma_options_bcj; (*coder).now_pos = (*simple).start_offset; if (*coder).now_pos & alignment.wrapping_sub(1) != 0 { return LZMA_OPTIONS_ERROR; diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs index 48987a85..30dce43d 100644 --- a/liblzma-rs/src/simple/simple_decoder.rs +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -1,15 +1,5 @@ use crate::types::*; use core::ffi::c_void; -#[inline] -extern "C" fn read32le(buf: *const u8) -> u32 { - return unsafe { - let mut num: u32 = *buf as u32; - num |= (*buf.offset(1) as u32) << 8; - num |= (*buf.offset(2) as u32) << 16; - num |= (*buf.offset(3) as u32) << 24; - num - }; -} #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_decode( options: *mut *mut c_void, diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index aae02e12..8026a4d3 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -1,14 +1,5 @@ use crate::types::*; use core::ffi::c_void; -#[inline] -extern "C" fn write32le(buf: *mut u8, num: u32) { - unsafe { - *buf = num as u8; - *buf.offset(1) = (num >> 8) as u8; - *buf.offset(2) = (num >> 16) as u8; - *buf.offset(3) = (num >> 24) as u8; - } -} #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_size( size: *mut u32, diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index b4d2275e..f6b36ecf 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -1,17 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; -} unsafe extern "C" fn sparc_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index da75af77..7c5acc42 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -1,17 +1,5 @@ use crate::types::*; use core::ffi::c_void; -extern "C" { - fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; -} #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_simple_x86 { diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index c9c56fae..a1bc00a6 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -1,4 +1,4 @@ -use core::ffi::{c_char, c_int, c_uchar, c_uint, c_void}; +use core::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; // Platform-dependent type aliases pub type size_t = libc::size_t; @@ -291,6 +291,83 @@ pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_CONCATENATED | LZMA_FAIL_FAST; +// Common constants used across many modules +pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; +pub const SIZE_MAX: c_ulong = UINTPTR_MAX; +pub const INDEX_INDICATOR: u8 = 0; +pub const UNPADDED_SIZE_MIN: c_ulonglong = 5; +pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; +pub const LZMA_THREADS_MAX: u32 = 16384; +pub const LZMA_DELTA_DIST_MIN: u32 = 1; +pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; + +// LZMA range coder and match constants +pub const RC_BIT_MODEL_TOTAL_BITS: u32 = 11; +pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; +pub const MATCH_LEN_MIN: u32 = 2; +pub const REPS: u32 = 4; +pub const LIT_STATES: u32 = 7; +pub const FASTPOS_BITS: u32 = 13; +pub const OPTS: u32 = 1 << 12; +pub const LZ_DICT_REPEAT_MAX: u32 = 288; +pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; + +// LZMA encoder/decoder shared constants +pub const ALIGN_BITS: u32 = 4; +pub const ALIGN_SIZE: u32 = 1 << ALIGN_BITS; +pub const ALIGN_MASK: u32 = ALIGN_SIZE - 1; +pub const DIST_STATES: u32 = 4; +pub const DIST_SLOT_BITS: u32 = 6; +pub const DIST_MODEL_START: u32 = 4; +pub const DIST_MODEL_END: u32 = 14; +pub const FULL_DISTANCES_BITS: u32 = DIST_MODEL_END / 2; +pub const FULL_DISTANCES: u32 = 1 << FULL_DISTANCES_BITS; +pub const STATES: u32 = 12; +pub const LITERAL_CODER_SIZE: c_uint = 0x300; +pub const LEN_LOW_BITS: u32 = 3; +pub const LEN_LOW_SYMBOLS: u32 = 1 << LEN_LOW_BITS; +pub const LEN_MID_BITS: u32 = 3; +pub const LEN_MID_SYMBOLS: u32 = 1 << LEN_MID_BITS; +pub const LEN_HIGH_BITS: u32 = 8; +pub const LEN_HIGH_SYMBOLS: u32 = 1 << LEN_HIGH_BITS; +pub const RC_MOVE_BITS: u32 = 5; +pub const RC_SHIFT_BITS: u32 = 8; +pub const RC_TOP_BITS: u32 = 24; +pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; +pub const RC_MOVE_REDUCING_BITS: u32 = 4; +pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; +pub const LZMA2_HEADER_UNCOMPRESSED: u32 = 3; + +// LZ encoder constants +pub const HASH_2_SIZE: c_uint = 1u32 << 10; +pub const HASH_3_SIZE: c_uint = 1u32 << 16; + +// Stream/block constants +pub const LZMA_CHECK_SIZE_MAX: u32 = 64; +pub const LZMA_STREAM_FLAGS_SIZE: u32 = 2; +pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; +pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX + .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) + .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64); + +// Thread-related constants +pub const MYTHREAD_RET_VALUE: *mut c_void = core::ptr::null_mut(); +pub const SIG_SETMASK: c_int = 3; + +// Type aliases used in multiple modules +pub type worker_state = c_uint; +pub type lzma_index_iter_mode = c_uint; + +// Worker state constants +pub const THR_IDLE: worker_state = 0; +pub const THR_RUN: worker_state = 1; + +// Index iterator mode constants +pub const LZMA_INDEX_ITER_ANY: lzma_index_iter_mode = 0; +pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; +pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; +pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; + // lzma_block struct (shared across 12 modules) #[derive(Copy, Clone)] #[repr(C)] @@ -529,6 +606,466 @@ pub struct lzma_outq { pub bufs_limit: u32, } +// Opaque struct forward declarations (used by files that only need pointer types) +#[repr(C)] +pub struct lzma_index_s { + _opaque: [u8; 0], +} +pub type lzma_index = lzma_index_s; + +#[repr(C)] +pub struct lzma_index_hash_s { + _opaque: [u8; 0], +} +pub type lzma_index_hash = lzma_index_hash_s; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_lzma1_encoder_s { + pub rc: lzma_range_encoder, + pub uncomp_size: u64, + pub out_limit: u64, + pub uncomp_size_ptr: *mut u64, + pub state: lzma_lzma_state, + pub reps: [u32; 4], + pub matches: [lzma_match; 274], + pub matches_count: u32, + pub longest_match_length: u32, + pub fast_mode: bool, + pub is_initialized: bool, + pub is_flushed: bool, + pub use_eopm: bool, + pub pos_mask: u32, + pub literal_context_bits: u32, + pub literal_mask: u32, + pub literal: [probability; 12288], + pub is_match: [[probability; 16]; 12], + pub is_rep: [probability; 12], + pub is_rep0: [probability; 12], + pub is_rep1: [probability; 12], + pub is_rep2: [probability; 12], + pub is_rep0_long: [[probability; 16]; 12], + pub dist_slot: [[probability; 64]; 4], + pub dist_special: [probability; 114], + pub dist_align: [probability; 16], + pub match_len_encoder: lzma_length_encoder, + pub rep_len_encoder: lzma_length_encoder, + pub dist_slot_prices: [[u32; 64]; 4], + pub dist_prices: [[u32; 128]; 4], + pub dist_table_size: u32, + pub match_price_count: u32, + pub align_prices: [u32; 16], + pub align_price_count: u32, + pub opts_end_index: u32, + pub opts_current_index: u32, + pub opts: [lzma_optimal; OPTS as usize], +} +pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; + +// Byte-order helper functions (shared across many modules) +#[inline] +pub extern "C" fn read32le(buf: *const u8) -> u32 { + return unsafe { + let mut num: u32 = *buf as u32; + num |= (*buf.offset(1) as u32) << 8; + num |= (*buf.offset(2) as u32) << 16; + num |= (*buf.offset(3) as u32) << 24; + num + }; +} +#[inline] +pub extern "C" fn write32le(buf: *mut u8, num: u32) { + unsafe { + *buf = num as u8; + *buf.offset(1) = (num >> 8) as u8; + *buf.offset(2) = (num >> 16) as u8; + *buf.offset(3) = (num >> 24) as u8; + } +} + +// Darwin/pthread types (shared by stream_decoder_mt and stream_encoder_mt) +pub type __uint32_t = u32; +pub type __darwin_time_t = c_long; +pub type __darwin_sigset_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __darwin_pthread_handler_rec { + pub __routine: Option ()>, + pub __arg: *mut c_void, + pub __next: *mut __darwin_pthread_handler_rec, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_attr_t { + pub __sig: c_long, + pub __opaque: [c_char; 56], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_cond_t { + pub __sig: c_long, + pub __opaque: [c_char; 40], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_condattr_t { + pub __sig: c_long, + pub __opaque: [c_char; 8], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_mutex_t { + pub __sig: c_long, + pub __opaque: [c_char; 56], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_mutexattr_t { + pub __sig: c_long, + pub __opaque: [c_char; 8], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _opaque_pthread_t { + pub __sig: c_long, + pub __cleanup_stack: *mut __darwin_pthread_handler_rec, + pub __opaque: [c_char; 8176], +} +pub type __darwin_pthread_attr_t = _opaque_pthread_attr_t; +pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t; +pub type __darwin_pthread_condattr_t = _opaque_pthread_condattr_t; +pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; +pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t; +pub type __darwin_pthread_t = *mut _opaque_pthread_t; +pub type pthread_attr_t = __darwin_pthread_attr_t; +pub type sigset_t = __darwin_sigset_t; +pub type time_t = __darwin_time_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct timespec { + pub tv_sec: __darwin_time_t, + pub tv_nsec: c_long, +} +pub type clockid_t = c_uint; +pub const _CLOCK_THREAD_CPUTIME_ID: clockid_t = 16; +pub const _CLOCK_PROCESS_CPUTIME_ID: clockid_t = 12; +pub const _CLOCK_UPTIME_RAW_APPROX: clockid_t = 9; +pub const _CLOCK_UPTIME_RAW: clockid_t = 8; +pub const _CLOCK_MONOTONIC_RAW_APPROX: clockid_t = 5; +pub const _CLOCK_MONOTONIC_RAW: clockid_t = 4; +pub const _CLOCK_MONOTONIC: clockid_t = 6; +pub const _CLOCK_REALTIME: clockid_t = 0; +pub type pthread_cond_t = __darwin_pthread_cond_t; +pub type pthread_condattr_t = __darwin_pthread_condattr_t; +pub type pthread_mutex_t = __darwin_pthread_mutex_t; +pub type pthread_mutexattr_t = __darwin_pthread_mutexattr_t; +pub type pthread_t = __darwin_pthread_t; +pub type mythread = pthread_t; +pub type mythread_mutex = pthread_mutex_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mythread_cond { + pub cond: pthread_cond_t, + pub clk_id: clockid_t, +} +pub type mythread_condtime = timespec; + +// Shared inline helper functions (mythread wrappers, used by mt modules) +#[inline] +pub extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { + let _ret: c_int = + unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; +} +#[inline] +pub extern "C" fn mythread_create( + thread: *mut mythread, + func: Option *mut c_void>, + arg: *mut c_void, +) -> c_int { + let mut old: sigset_t = 0; + let mut all: sigset_t = 0; + all = !(0 as sigset_t); + mythread_sigmask(SIG_SETMASK, &raw mut all, &raw mut old); + let ret: c_int = unsafe { + pthread_create( + thread as *mut pthread_t, + core::ptr::null(), + func as Option *mut c_void>, + arg as *mut c_void, + ) + }; + mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); + ret +} +#[inline] +pub extern "C" fn mythread_join(thread: mythread) -> c_int { + unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) } +} +#[inline] +pub extern "C" fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { + unsafe { pthread_mutex_init(mutex as *mut pthread_mutex_t, core::ptr::null()) } +} +#[inline] +pub extern "C" fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_destroy(mutex as *mut pthread_mutex_t) }; +} +#[inline] +pub extern "C" fn mythread_mutex_lock(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_lock(mutex as *mut pthread_mutex_t) }; +} +#[inline] +pub extern "C" fn mythread_mutex_unlock(mutex: *mut mythread_mutex) { + let _ret: c_int = unsafe { pthread_mutex_unlock(mutex as *mut pthread_mutex_t) }; +} +#[inline] +pub extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { + return unsafe { + (*mycond).clk_id = _CLOCK_REALTIME; + pthread_cond_init(&raw mut (*mycond).cond, core::ptr::null()) + }; +} +#[inline] +pub extern "C" fn mythread_cond_destroy(cond: *mut mythread_cond) { + let _ret: c_int = unsafe { pthread_cond_destroy(&raw mut (*cond).cond) }; +} +#[inline] +pub extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { + let _ret: c_int = unsafe { pthread_cond_signal(&raw mut (*cond).cond) }; +} +#[inline] +pub extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { + let _ret: c_int = + unsafe { pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) }; +} +#[inline] +pub extern "C" fn mythread_cond_timedwait( + cond: *mut mythread_cond, + mutex: *mut mythread_mutex, + condtime: *const mythread_condtime, +) -> c_int { + let ret: c_int = unsafe { + pthread_cond_timedwait( + &raw mut (*cond).cond, + mutex as *mut pthread_mutex_t, + condtime as *const timespec, + ) + }; + ret +} +#[inline] +pub extern "C" fn mythread_condtime_set( + condtime: *mut mythread_condtime, + cond: *const mythread_cond, + timeout_ms: u32, +) { + unsafe { + (*condtime).tv_sec = timeout_ms.wrapping_div(1000) as time_t as __darwin_time_t; + (*condtime).tv_nsec = timeout_ms.wrapping_rem(1000).wrapping_mul(1_000_000) as c_long; + let mut now: timespec = timespec { + tv_sec: 0, + tv_nsec: 0, + }; + let _ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); + (*condtime).tv_sec += now.tv_sec; + (*condtime).tv_nsec += now.tv_nsec; + if (*condtime).tv_nsec >= 1_000_000_000 { + (*condtime).tv_nsec -= 1_000_000_000; + (*condtime).tv_sec += 1; + } + } +} + +// Shared inline helpers (used by index, block, and mt modules) +#[inline] +pub extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { + vli.wrapping_add(3) & !(3) +} +#[inline] +pub extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { + (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) + .wrapping_add(index_list_size) + .wrapping_add(4) +} +#[inline] +pub extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { + unsafe { (*outq).bufs_in_use < (*outq).bufs_limit } +} +#[inline] +pub extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { + unsafe { (*outq).bufs_in_use == 0 } +} + +// Shared inline helpers (encoder match-finder and range coder) +#[inline] +pub unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { + (*mf).buffer.offset((*mf).read_pos as isize) +} +#[inline] +pub unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { + (*mf).write_pos.wrapping_sub((*mf).read_pos) +} +#[inline] +pub unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { + if amount != 0 { + (*mf).skip.unwrap()(mf, amount); + (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); + } +} +#[inline(always)] +pub unsafe extern "C" fn lzma_memcmplen( + buf1: *const u8, + buf2: *const u8, + mut len: u32, + limit: u32, +) -> u32 { + while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { + len += 1; + } + len +} +#[inline] +pub unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { + if dist < 1 << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { + return lzma_fastpos[dist as usize] as u32; + } + if dist < 1 << FASTPOS_BITS + (0 + 1 * (FASTPOS_BITS - 1)) { + return (lzma_fastpos[(dist >> 0 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 1 * (FASTPOS_BITS - 1))) as u32); + } + (lzma_fastpos[(dist >> 0 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) + .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) +} +#[inline] +pub extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { + unsafe { + lzma_rc_prices[((prob as u32 + ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) + >> RC_MOVE_REDUCING_BITS) as usize] as u32 + } +} +#[inline] +pub extern "C" fn rc_bit_0_price(prob: probability) -> u32 { + unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 } +} +#[inline] +pub extern "C" fn rc_bit_1_price(prob: probability) -> u32 { + unsafe { + lzma_rc_prices + [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] + as u32 + } +} +#[inline] +pub unsafe extern "C" fn rc_bittree_price( + probs: *const probability, + bit_levels: u32, + mut symbol: u32, +) -> u32 { + let mut price: u32 = 0; + symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; + loop { + let bit: u32 = symbol & 1; + symbol >>= 1; + price = price.wrapping_add(rc_bit_price(*probs.offset(symbol as isize), bit)); + if symbol == 1 { + break; + } + } + price +} + +// Shared inline helpers (misc) +#[inline] +pub extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { + match_finder as u32 & 0xf +} +#[inline] +pub unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { + (*options).lc <= LZMA_LCLP_MAX + && (*options).lp <= LZMA_LCLP_MAX + && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX + && (*options).pb <= LZMA_PB_MAX +} +#[inline] +pub unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { + let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; + let mut i: size_t = 0; + while i < coders { + *probs.offset(i as isize) = (RC_BIT_MODEL_TOTAL >> 1) as probability; + i += 1; + } +} +pub extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { + unsafe { + (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli + && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX + && (*options).backward_size & 3 == 0 + } +} +#[inline] +pub extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { + vli_ceil4(index_size_unpadded(count, index_list_size)) +} +pub extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { + (core::mem::size_of::()).wrapping_add(buf_size as usize) as u64 +} +#[inline] +pub unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { + *(buf as *const u32) +} + +// Range coder symbol type and constants (shared across encoder modules) +pub type rc_symbol = c_uint; +pub const RC_FLUSH: rc_symbol = 4; +pub const RC_DIRECT_1: rc_symbol = 3; +pub const RC_DIRECT_0: rc_symbol = 2; +pub const RC_BIT_1: rc_symbol = 1; +pub const RC_BIT_0: rc_symbol = 0; + +// lzma_range_encoder struct (shared across encoder modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_range_encoder { + pub low: u64, + pub cache_size: u64, + pub range: u32, + pub cache: u8, + pub out_total: u64, + pub count: size_t, + pub pos: size_t, + pub symbols: [rc_symbol; 53], + pub probs: [*mut probability; 53], +} + +// lzma_optimal struct (shared across encoder modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_optimal { + pub state: lzma_lzma_state, + pub prev_1_is_literal: bool, + pub prev_2: bool, + pub pos_prev_2: u32, + pub back_prev_2: u32, + pub price: u32, + pub pos_prev: u32, + pub back_prev: u32, + pub backs: [u32; 4], +} + +// lzma_length_encoder struct (shared across encoder modules) +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_length_encoder { + pub choice: probability, + pub choice2: probability, + pub low: [[probability; 8]; 16], + pub mid: [[probability; 8]; 16], + pub high: [probability; 256], + pub prices: [[u32; 272]; 16], + pub table_size: u32, + pub counters: [u32; 16], +} + // lzma_options_bcj struct (shared across simple/filter modules) #[derive(Copy, Clone)] #[repr(C)] @@ -596,7 +1133,227 @@ extern "C" { pub fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; pub fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; pub fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); + pub fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); + pub fn lzma_next_filter_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + pub fn lzma_next_filter_update( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + reversed_filters: *const lzma_filter, + ) -> lzma_ret; + pub fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; + pub fn lzma_end(strm: *mut lzma_stream); + pub fn lzma_bufcpy( + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + ) -> size_t; + pub fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; + pub fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; + pub fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; + pub fn lzma_check_size(check: lzma_check) -> u32; + pub fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); + pub fn lzma_check_update( + check: *mut lzma_check_state, + type_0: lzma_check, + buf: *const u8, + size: size_t, + ); + pub fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); + pub fn lzma_vli_size(vli: lzma_vli) -> u32; + pub fn lzma_vli_decode( + vli: *mut lzma_vli, + vli_pos: *mut size_t, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + pub fn lzma_stream_flags_compare( + a: *const lzma_stream_flags, + b: *const lzma_stream_flags, + ) -> lzma_ret; + pub fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; + pub fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); + pub fn lzma_simple_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + filter: Option size_t>, + simple_size: size_t, + unfiltered_max: size_t, + alignment: u32, + is_encoder: bool, + ) -> lzma_ret; + pub fn lzma_vli_encode( + vli: lzma_vli, + vli_pos: *mut size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + ) -> lzma_ret; + pub fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; + pub fn lzma_stream_header_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; + pub fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; + pub fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; + pub fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; + pub fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret; + pub fn lzma_block_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, + ) -> lzma_ret; + pub fn lzma_raw_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + ) -> lzma_ret; + pub fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; + pub fn lzma_lzma_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + pub fn lzma_lzma_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + pub fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; + pub fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; + pub fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; + pub fn lzma_delta_coder_memusage(options: *const c_void) -> u64; + pub fn lzma_block_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + block: *mut lzma_block, + ) -> lzma_ret; + pub fn lzma_block_header_decode( + block: *mut lzma_block, + allocator: *const lzma_allocator, + in_0: *const u8, + ) -> lzma_ret; + pub fn lzma_filters_copy( + src: *const lzma_filter, + dest: *mut lzma_filter, + allocator: *const lzma_allocator, + ) -> lzma_ret; + pub fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64; + pub fn lzma_raw_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + options: *const lzma_filter, + ) -> lzma_ret; + pub fn lzma_raw_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + coder_find: lzma_filter_find, + is_encoder: bool, + ) -> lzma_ret; + pub fn lzma_raw_coder_memusage( + coder_find: lzma_filter_find, + filters: *const lzma_filter, + ) -> u64; + pub fn lzma_stream_decoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + memlimit: u64, + flags: u32, + ) -> lzma_ret; + pub fn lzma_delta_coder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter_info, + ) -> lzma_ret; + pub fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64; + pub fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; + pub fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; + pub fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64; + pub fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; + pub fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); + pub fn lzma_index_append( + i: *mut lzma_index, + allocator: *const lzma_allocator, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, + ) -> lzma_ret; + pub fn lzma_index_size(i: *const lzma_index) -> lzma_vli; + pub fn lzma_index_padding_size(i: *const lzma_index) -> u32; + pub fn lzma_index_encoder_init( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, + i: *const lzma_index, + ) -> lzma_ret; + pub fn lzma_index_hash_init( + index_hash: *mut lzma_index_hash, + allocator: *const lzma_allocator, + ) -> *mut lzma_index_hash; + pub fn lzma_index_hash_end(index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator); + pub fn lzma_index_hash_append( + index_hash: *mut lzma_index_hash, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, + ) -> lzma_ret; + pub fn lzma_index_hash_decode( + index_hash: *mut lzma_index_hash, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + ) -> lzma_ret; + pub fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; + pub fn lzma_outq_init( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + threads: u32, + ) -> lzma_ret; + pub fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator); + pub fn lzma_outq_prealloc_buf( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + size: size_t, + ) -> lzma_ret; + pub fn lzma_outq_get_buf(outq: *mut lzma_outq, worker: *mut c_void) -> *mut lzma_outbuf; + pub fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool; + pub fn lzma_outq_read( + outq: *mut lzma_outq, + allocator: *const lzma_allocator, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + unpadded_size: *mut lzma_vli, + uncompressed_size: *mut lzma_vli, + ) -> lzma_ret; + pub fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; + pub fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> c_int; + pub fn pthread_cond_signal(_: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_timedwait( + _: *mut pthread_cond_t, + _: *mut pthread_mutex_t, + _: *const timespec, + ) -> c_int; + pub fn pthread_cond_wait(_: *mut pthread_cond_t, _: *mut pthread_mutex_t) -> c_int; + pub fn pthread_create( + _: *mut pthread_t, + _: *const pthread_attr_t, + _: Option *mut c_void>, + _: *mut c_void, + ) -> c_int; + pub fn pthread_join(_: pthread_t, _: *mut *mut c_void) -> c_int; + pub fn pthread_mutex_destroy(_: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_init(_: *mut pthread_mutex_t, _: *const pthread_mutexattr_t) -> c_int; + pub fn pthread_mutex_lock(_: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> c_int; + pub fn pthread_sigmask(_: c_int, _: *const sigset_t, _: *mut sigset_t) -> c_int; pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; pub fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn strlen(s: *const c_char) -> size_t; + pub static lzma_rc_prices: [u8; 128]; + pub static lzma_fastpos: [u8; 8192]; } From d7425a4720e8ae174633c241f65d3b624dd37ee2 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Mon, 2 Mar 2026 20:19:20 +0900 Subject: [PATCH 11/51] move C ABI boundary to liblzma-rs-sys --- liblzma-rs-sys/src/lib.rs | 242 ++++++++++-------- liblzma-rs/src/check/check.rs | 2 - liblzma-rs/src/check/crc32_fast.rs | 1 - liblzma-rs/src/check/crc64_fast.rs | 1 - liblzma-rs/src/common/alone_decoder.rs | 15 +- liblzma-rs/src/common/alone_encoder.rs | 9 +- liblzma-rs/src/common/auto_decoder.rs | 11 +- liblzma-rs/src/common/block_decoder.rs | 10 +- liblzma-rs/src/common/block_encoder.rs | 10 +- liblzma-rs/src/common/common.rs | 9 - liblzma-rs/src/common/easy_buffer_encoder.rs | 1 - .../src/common/easy_decoder_memusage.rs | 1 - liblzma-rs/src/common/easy_encoder.rs | 1 - .../src/common/easy_encoder_memusage.rs | 1 - liblzma-rs/src/common/file_info.rs | 22 +- .../src/common/filter_buffer_decoder.rs | 1 - .../src/common/filter_buffer_encoder.rs | 1 - liblzma-rs/src/common/filter_common.rs | 31 ++- liblzma-rs/src/common/filter_decoder.rs | 4 - liblzma-rs/src/common/filter_encoder.rs | 7 - liblzma-rs/src/common/hardware_cputhreads.rs | 1 - liblzma-rs/src/common/hardware_physmem.rs | 1 - liblzma-rs/src/common/index.rs | 76 +----- liblzma-rs/src/common/index_decoder.rs | 25 +- liblzma-rs/src/common/index_encoder.rs | 78 +----- liblzma-rs/src/common/index_hash.rs | 22 +- liblzma-rs/src/common/lzip_decoder.rs | 17 +- .../src/common/stream_buffer_decoder.rs | 1 - .../src/common/stream_buffer_encoder.rs | 2 - liblzma-rs/src/common/stream_decoder.rs | 19 +- liblzma-rs/src/common/stream_decoder_mt.rs | 29 +-- liblzma-rs/src/common/stream_encoder.rs | 17 +- liblzma-rs/src/common/stream_encoder_mt.rs | 14 +- liblzma-rs/src/common/stream_flags_common.rs | 1 - liblzma-rs/src/common/stream_flags_decoder.rs | 2 - liblzma-rs/src/common/stream_flags_encoder.rs | 2 - liblzma-rs/src/common/string_conversion.rs | 102 ++++---- liblzma-rs/src/common/vli_decoder.rs | 1 - liblzma-rs/src/common/vli_encoder.rs | 1 - liblzma-rs/src/common/vli_size.rs | 1 - liblzma-rs/src/lz/lz_decoder.rs | 4 +- liblzma-rs/src/lz/lz_encoder.rs | 1 - liblzma-rs/src/lzma/lzma2_encoder.rs | 14 +- liblzma-rs/src/lzma/lzma_decoder.rs | 50 ++-- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 1 - liblzma-rs/src/types.rs | 57 ++++- 46 files changed, 414 insertions(+), 505 deletions(-) diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs index db97cf2c..62a4e5d0 100644 --- a/liblzma-rs-sys/src/lib.rs +++ b/liblzma-rs-sys/src/lib.rs @@ -120,30 +120,47 @@ pub const LZMA_STREAM_HEADER_SIZE: u32 = liblzma_rs::types::LZMA_STREAM_HEADER_S // Functions // ========================================================================= // -// Functions defined in common::common use the canonical lzma_stream type, -// so they can be re-exported directly. Functions in other modules use -// module-local struct definitions that are structurally identical (#[repr(C)]) -// but nominally different, so we provide thin wrappers with pointer casts. +// Functions are exposed as thin C ABI wrappers from this crate. +// Wrappers cast to canonical Rust implementation types and forward the call. -// --- Direct re-exports (canonical types from common::common) --- -pub use liblzma_rs::common::common::{lzma_code, lzma_end, lzma_memlimit_get, lzma_memlimit_set}; +// --- Common stream API --- + +#[no_mangle] +pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret { + liblzma_rs::common::common::lzma_code(strm.cast(), action) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { + liblzma_rs::common::common::lzma_end(strm.cast()) +} + +#[no_mangle] +pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { + liblzma_rs::common::common::lzma_memlimit_get(strm.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_memlimit_set(strm: *mut lzma_stream, new_memlimit: u64) -> lzma_ret { + liblzma_rs::common::common::lzma_memlimit_set(strm.cast(), new_memlimit) +} // --- Version --- -#[inline] -pub unsafe fn lzma_version_number() -> u32 { +#[no_mangle] +pub unsafe extern "C" fn lzma_version_number() -> u32 { liblzma_rs::common::common::lzma_version_number() } -#[inline] -pub unsafe fn lzma_version_string() -> *const c_char { +#[no_mangle] +pub unsafe extern "C" fn lzma_version_string() -> *const c_char { liblzma_rs::common::common::lzma_version_string() } // --- Progress / memusage --- -#[inline] -pub unsafe fn lzma_get_progress( +#[no_mangle] +pub unsafe extern "C" fn lzma_get_progress( strm: *mut lzma_stream, progress_in: *mut u64, progress_out: *mut u64, @@ -151,52 +168,52 @@ pub unsafe fn lzma_get_progress( liblzma_rs::common::common::lzma_get_progress(strm.cast(), progress_in, progress_out) } -#[inline] -pub unsafe fn lzma_memusage(strm: *const lzma_stream) -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { liblzma_rs::common::common::lzma_memusage(strm.cast()) } -#[inline] -pub unsafe fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { +#[no_mangle] +pub unsafe extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { liblzma_rs::common::common::lzma_get_check(strm.cast()) } // --- Check --- -#[inline] -pub unsafe fn lzma_check_is_supported(check: lzma_check) -> lzma_bool { +#[no_mangle] +pub unsafe extern "C" fn lzma_check_is_supported(check: lzma_check) -> lzma_bool { liblzma_rs::check::check::lzma_check_is_supported(check) } -#[inline] -pub unsafe fn lzma_check_size(check: lzma_check) -> u32 { +#[no_mangle] +pub unsafe extern "C" fn lzma_check_size(check: lzma_check) -> u32 { liblzma_rs::check::check::lzma_check_size(check) } -#[inline] -pub unsafe fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32 { +#[no_mangle] +pub unsafe extern "C" fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32 { liblzma_rs::check::crc32_fast::lzma_crc32(buf, size, crc) } -#[inline] -pub unsafe fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64 { liblzma_rs::check::crc64_fast::lzma_crc64(buf, size, crc) } // --- Easy encoder --- -#[inline] -pub unsafe fn lzma_easy_encoder_memusage(preset: u32) -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { liblzma_rs::common::easy_encoder_memusage::lzma_easy_encoder_memusage(preset) } -#[inline] -pub unsafe fn lzma_easy_decoder_memusage(preset: u32) -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { liblzma_rs::common::easy_decoder_memusage::lzma_easy_decoder_memusage(preset) } -#[inline] -pub unsafe fn lzma_easy_encoder( +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_encoder( strm: *mut lzma_stream, preset: u32, check: lzma_check, @@ -204,8 +221,8 @@ pub unsafe fn lzma_easy_encoder( liblzma_rs::common::easy_encoder::lzma_easy_encoder(strm.cast(), preset, check) } -#[inline] -pub unsafe fn lzma_easy_buffer_encode( +#[no_mangle] +pub unsafe extern "C" fn lzma_easy_buffer_encode( preset: u32, check: lzma_check, allocator: *const lzma_allocator, @@ -229,8 +246,8 @@ pub unsafe fn lzma_easy_buffer_encode( // --- Stream encoder/decoder --- -#[inline] -pub unsafe fn lzma_stream_encoder( +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_encoder( strm: *mut lzma_stream, filters: *const lzma_filter, check: lzma_check, @@ -238,47 +255,47 @@ pub unsafe fn lzma_stream_encoder( liblzma_rs::common::stream_encoder::lzma_stream_encoder(strm.cast(), filters.cast(), check) } -#[inline] -pub unsafe fn lzma_stream_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { liblzma_rs::common::stream_decoder::lzma_stream_decoder(strm.cast(), memlimit, flags) } // --- Alone encoder/decoder --- -#[inline] -pub unsafe fn lzma_alone_encoder( +#[no_mangle] +pub unsafe extern "C" fn lzma_alone_encoder( strm: *mut lzma_stream, options: *const lzma_options_lzma, ) -> lzma_ret { liblzma_rs::common::alone_encoder::lzma_alone_encoder(strm.cast(), options.cast()) } -#[inline] -pub unsafe fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { liblzma_rs::common::alone_decoder::lzma_alone_decoder(strm.cast(), memlimit) } // --- Auto/lzip decoder --- -#[inline] -pub unsafe fn lzma_auto_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_auto_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { liblzma_rs::common::auto_decoder::lzma_auto_decoder(strm.cast(), memlimit, flags) } -#[inline] -pub unsafe fn lzma_lzip_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_lzip_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { liblzma_rs::common::lzip_decoder::lzma_lzip_decoder(strm.cast(), memlimit, flags) } // --- Stream buffer --- -#[inline] -pub unsafe fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { liblzma_rs::common::stream_buffer_encoder::lzma_stream_buffer_bound(uncompressed_size) } -#[inline] -pub unsafe fn lzma_stream_buffer_encode( +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_buffer_encode( filters: *mut lzma_filter, check: lzma_check, allocator: *const lzma_allocator, @@ -300,8 +317,8 @@ pub unsafe fn lzma_stream_buffer_encode( ) } -#[inline] -pub unsafe fn lzma_stream_buffer_decode( +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_buffer_decode( memlimit: *mut u64, flags: u32, allocator: *const lzma_allocator, @@ -327,18 +344,18 @@ pub unsafe fn lzma_stream_buffer_decode( // --- Filter --- -#[inline] -pub unsafe fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { liblzma_rs::common::filter_encoder::lzma_filter_encoder_is_supported(id) } -#[inline] -pub unsafe fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { liblzma_rs::common::filter_decoder::lzma_filter_decoder_is_supported(id) } -#[inline] -pub unsafe fn lzma_filters_copy( +#[no_mangle] +pub unsafe extern "C" fn lzma_filters_copy( src: *const lzma_filter, dest: *mut lzma_filter, allocator: *const lzma_allocator, @@ -346,35 +363,35 @@ pub unsafe fn lzma_filters_copy( liblzma_rs::common::filter_common::lzma_filters_copy(src.cast(), dest.cast(), allocator.cast()) } -#[inline] -pub unsafe fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64 { liblzma_rs::common::filter_encoder::lzma_raw_encoder_memusage(filters.cast()) } -#[inline] -pub unsafe fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { liblzma_rs::common::filter_decoder::lzma_raw_decoder_memusage(filters.cast()) } -#[inline] -pub unsafe fn lzma_raw_encoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_encoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_raw_encoder(strm.cast(), filters.cast()) } -#[inline] -pub unsafe fn lzma_raw_decoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_decoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { liblzma_rs::common::filter_decoder::lzma_raw_decoder(strm.cast(), filters.cast()) } -#[inline] -pub unsafe fn lzma_filters_update(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_filters_update(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_filters_update(strm.cast(), filters.cast()) } // --- Raw buffer --- -#[inline] -pub unsafe fn lzma_raw_buffer_encode( +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_buffer_encode( filters: *const lzma_filter, allocator: *const lzma_allocator, input: *const u8, @@ -394,8 +411,8 @@ pub unsafe fn lzma_raw_buffer_encode( ) } -#[inline] -pub unsafe fn lzma_raw_buffer_decode( +#[no_mangle] +pub unsafe extern "C" fn lzma_raw_buffer_decode( filters: *const lzma_filter, allocator: *const lzma_allocator, input: *const u8, @@ -419,18 +436,18 @@ pub unsafe fn lzma_raw_buffer_decode( // --- Properties --- -#[inline] -pub unsafe fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_properties_size(size, filter.cast()) } -#[inline] -pub unsafe fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_properties_encode(filter.cast(), props) } -#[inline] -pub unsafe fn lzma_properties_decode( +#[no_mangle] +pub unsafe extern "C" fn lzma_properties_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, props: *const u8, @@ -444,59 +461,59 @@ pub unsafe fn lzma_properties_decode( ) } -#[inline] -pub unsafe fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { liblzma_rs::common::filter_encoder::lzma_mt_block_size(filters.cast()) } // --- LZMA preset --- -#[inline] -pub unsafe fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool { +#[no_mangle] +pub unsafe extern "C" fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool { liblzma_rs::lzma::lzma_encoder_presets::lzma_lzma_preset(options.cast(), preset) } -#[inline] -pub unsafe fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { +#[no_mangle] +pub unsafe extern "C" fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { liblzma_rs::lz::lz_encoder::lzma_mf_is_supported(mf) } // --- Stream header/footer --- -#[inline] -pub unsafe fn lzma_stream_header_encode( +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_header_encode( options: *const lzma_stream_flags, out: *mut u8, ) -> lzma_ret { liblzma_rs::common::stream_flags_encoder::lzma_stream_header_encode(options.cast(), out) } -#[inline] -pub unsafe fn lzma_stream_footer_encode( +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_footer_encode( options: *const lzma_stream_flags, out: *mut u8, ) -> lzma_ret { liblzma_rs::common::stream_flags_encoder::lzma_stream_footer_encode(options.cast(), out) } -#[inline] -pub unsafe fn lzma_stream_header_decode( +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_header_decode( options: *mut lzma_stream_flags, input: *const u8, ) -> lzma_ret { liblzma_rs::common::stream_flags_decoder::lzma_stream_header_decode(options.cast(), input) } -#[inline] -pub unsafe fn lzma_stream_footer_decode( +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_footer_decode( options: *mut lzma_stream_flags, input: *const u8, ) -> lzma_ret { liblzma_rs::common::stream_flags_decoder::lzma_stream_footer_decode(options.cast(), input) } -#[inline] -pub unsafe fn lzma_stream_flags_compare( +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_flags_compare( a: *const lzma_stream_flags, b: *const lzma_stream_flags, ) -> lzma_ret { @@ -505,8 +522,8 @@ pub unsafe fn lzma_stream_flags_compare( // --- VLI --- -#[inline] -pub unsafe fn lzma_vli_encode( +#[no_mangle] +pub unsafe extern "C" fn lzma_vli_encode( vli: lzma_vli, vli_pos: *mut size_t, out: *mut u8, @@ -516,8 +533,8 @@ pub unsafe fn lzma_vli_encode( liblzma_rs::common::vli_encoder::lzma_vli_encode(vli, vli_pos, out, out_pos, out_size) } -#[inline] -pub unsafe fn lzma_vli_decode( +#[no_mangle] +pub unsafe extern "C" fn lzma_vli_decode( vli: *mut lzma_vli, vli_pos: *mut size_t, input: *const u8, @@ -527,27 +544,27 @@ pub unsafe fn lzma_vli_decode( liblzma_rs::common::vli_decoder::lzma_vli_decode(vli, vli_pos, input, in_pos, in_size) } -#[inline] -pub unsafe fn lzma_vli_size(vli: lzma_vli) -> u32 { +#[no_mangle] +pub unsafe extern "C" fn lzma_vli_size(vli: lzma_vli) -> u32 { liblzma_rs::common::vli_size::lzma_vli_size(vli) } // --- Hardware --- -#[inline] -pub unsafe fn lzma_physmem() -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_physmem() -> u64 { liblzma_rs::common::hardware_physmem::lzma_physmem() } -#[inline] -pub unsafe fn lzma_cputhreads() -> u32 { +#[no_mangle] +pub unsafe extern "C" fn lzma_cputhreads() -> u32 { liblzma_rs::common::hardware_cputhreads::lzma_cputhreads() } // --- Index --- -#[inline] -pub unsafe fn lzma_index_buffer_decode( +#[no_mangle] +pub unsafe extern "C" fn lzma_index_buffer_decode( i: *mut *mut lzma_index, memlimit: *mut u64, allocator: *const lzma_allocator, @@ -565,13 +582,13 @@ pub unsafe fn lzma_index_buffer_decode( ) } -#[inline] -pub unsafe fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { +#[no_mangle] +pub unsafe extern "C" fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { liblzma_rs::common::index::lzma_index_uncompressed_size(i.cast()) } -#[inline] -pub unsafe fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { +#[no_mangle] +pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { liblzma_rs::common::index::lzma_index_end(i.cast(), allocator.cast()) } @@ -607,16 +624,19 @@ pub struct lzma_mt { } #[cfg(feature = "parallel")] -pub unsafe fn lzma_stream_encoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_encoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { liblzma_rs::common::stream_mt::lzma_stream_encoder_mt(strm.cast(), options.cast()) } #[cfg(feature = "parallel")] -pub unsafe fn lzma_stream_decoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_decoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { liblzma_rs::common::stream_mt::lzma_stream_decoder_mt(strm.cast(), options.cast()) } #[cfg(feature = "parallel")] -pub unsafe fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64 { +#[no_mangle] +pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64 { liblzma_rs::common::stream_mt::lzma_stream_encoder_mt_memusage(options.cast()) } diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index ca2c6609..341ab9ad 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -5,7 +5,6 @@ extern "C" { fn lzma_sha256_update(buf: *const u8, size: size_t, check: *mut lzma_check_state); fn lzma_sha256_finish(check: *mut lzma_check_state); } -#[no_mangle] pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { if type_0 > LZMA_CHECK_ID_MAX { return false as lzma_bool; @@ -30,7 +29,6 @@ pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { ]; available_checks[type_0 as usize] } -#[no_mangle] pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { if type_0 > LZMA_CHECK_ID_MAX { return UINT32_MAX; diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index 3af34d0b..34234807 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -351,7 +351,6 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu } !crc } -#[no_mangle] pub unsafe extern "C" fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32 { lzma_crc32_generic(buf, size, crc) } diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index f6760428..b7c9c644 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1065,7 +1065,6 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu } !crc } -#[no_mangle] pub unsafe extern "C" fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64 { lzma_crc64_generic(buf, size, crc) } diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index f121eb6b..4282f6ee 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -4,7 +4,7 @@ use core::ffi::{c_uint, c_void}; #[repr(C)] pub struct lzma_alone_coder { pub next: lzma_next_coder, - pub sequence: C2RustUnnamed_0, + pub sequence: alone_decoder_seq, pub picky: bool, pub pos: size_t, pub uncompressed_size: lzma_vli, @@ -12,12 +12,12 @@ pub struct lzma_alone_coder { pub memusage: u64, pub options: lzma_options_lzma, } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_CODE: C2RustUnnamed_0 = 4; -pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; -pub const SEQ_UNCOMPRESSED_SIZE: C2RustUnnamed_0 = 2; -pub const SEQ_DICTIONARY_SIZE: C2RustUnnamed_0 = 1; -pub const SEQ_PROPERTIES: C2RustUnnamed_0 = 0; +pub type alone_decoder_seq = c_uint; +pub const SEQ_CODE: alone_decoder_seq = 4; +pub const SEQ_CODER_INIT: alone_decoder_seq = 3; +pub const SEQ_UNCOMPRESSED_SIZE: alone_decoder_seq = 2; +pub const SEQ_DICTIONARY_SIZE: alone_decoder_seq = 1; +pub const SEQ_PROPERTIES: alone_decoder_seq = 0; unsafe extern "C" fn alone_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -275,7 +275,6 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( (*coder).memusage = LZMA_MEMUSAGE_BASE; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index 14d1f40f..d2fe9755 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -4,13 +4,13 @@ use core::ffi::{c_uint, c_void}; #[repr(C)] pub struct lzma_alone_coder { pub next: lzma_next_coder, - pub sequence: C2RustUnnamed_0, + pub sequence: alone_encoder_seq, pub header_pos: size_t, pub header: [u8; 13], } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_CODE: C2RustUnnamed_0 = 1; -pub const SEQ_HEADER: C2RustUnnamed_0 = 0; +pub type alone_encoder_seq = c_uint; +pub const SEQ_CODE: alone_encoder_seq = 1; +pub const SEQ_HEADER: alone_encoder_seq = 0; pub const ALONE_HEADER_SIZE: u32 = 1 + 4 + 8; unsafe extern "C" fn alone_encode( coder_ptr: *mut c_void, @@ -191,7 +191,6 @@ unsafe extern "C" fn alone_encoder_init( &raw const filters as *const lzma_filter_info, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_alone_encoder( strm: *mut lzma_stream, options: *const lzma_options_lzma, diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index e2882a75..952e8df0 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -8,17 +8,17 @@ extern "C" { picky: bool, ) -> lzma_ret; } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_FINISH: C2RustUnnamed_0 = 2; -pub const SEQ_CODE: C2RustUnnamed_0 = 1; -pub const SEQ_INIT: C2RustUnnamed_0 = 0; +pub type auto_decoder_seq = c_uint; +pub const SEQ_FINISH: auto_decoder_seq = 2; +pub const SEQ_CODE: auto_decoder_seq = 1; +pub const SEQ_INIT: auto_decoder_seq = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_auto_coder { pub next: lzma_next_coder, pub memlimit: u64, pub flags: u32, - pub sequence: C2RustUnnamed_0, + pub sequence: auto_decoder_seq, } unsafe extern "C" fn auto_decode( coder_ptr: *mut c_void, @@ -237,7 +237,6 @@ unsafe extern "C" fn auto_decoder_init( (*coder).sequence = SEQ_INIT; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_auto_decoder( strm: *mut lzma_stream, memlimit: u64, diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index a9fedc5b..89371e76 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -3,7 +3,7 @@ use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block_coder { - pub sequence: C2RustUnnamed_2, + pub sequence: block_decoder_seq, pub next: lzma_next_coder, pub block: *mut lzma_block, pub compressed_size: lzma_vli, @@ -14,10 +14,10 @@ pub struct lzma_block_coder { pub check: lzma_check_state, pub ignore_check: bool, } -pub type C2RustUnnamed_2 = c_uint; -pub const SEQ_CHECK: C2RustUnnamed_2 = 2; -pub const SEQ_PADDING: C2RustUnnamed_2 = 1; -pub const SEQ_CODE: C2RustUnnamed_2 = 0; +pub type block_decoder_seq = c_uint; +pub const SEQ_CHECK: block_decoder_seq = 2; +pub const SEQ_PADDING: block_decoder_seq = 1; +pub const SEQ_CODE: block_decoder_seq = 0; #[inline] extern "C" fn is_size_valid(size: lzma_vli, reference: lzma_vli) -> bool { reference == LZMA_VLI_UNKNOWN || reference == size diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 36b498b2..9d0f2651 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -5,16 +5,16 @@ use core::ffi::{c_uint, c_void}; pub struct lzma_block_coder { pub next: lzma_next_coder, pub block: *mut lzma_block, - pub sequence: C2RustUnnamed_2, + pub sequence: block_encoder_seq, pub compressed_size: lzma_vli, pub uncompressed_size: lzma_vli, pub pos: size_t, pub check: lzma_check_state, } -pub type C2RustUnnamed_2 = c_uint; -pub const SEQ_CHECK: C2RustUnnamed_2 = 2; -pub const SEQ_PADDING: C2RustUnnamed_2 = 1; -pub const SEQ_CODE: C2RustUnnamed_2 = 0; +pub type block_encoder_seq = c_uint; +pub const SEQ_CHECK: block_encoder_seq = 2; +pub const SEQ_PADDING: block_encoder_seq = 1; +pub const SEQ_CODE: block_encoder_seq = 0; unsafe extern "C" fn block_encode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index ece75228..5eac54cb 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -16,11 +16,9 @@ pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR) .wrapping_add((LZMA_VERSION_PATCH).wrapping_mul(10)) .wrapping_add(LZMA_VERSION_STABILITY); pub const LZMA_TIMED_OUT: c_uint = 101; -#[no_mangle] pub extern "C" fn lzma_version_number() -> u32 { LZMA_VERSION as u32 } -#[no_mangle] pub extern "C" fn lzma_version_string() -> *const c_char { c"5.8.2".as_ptr() } @@ -190,7 +188,6 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { (*strm).total_out = 0; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret { if (*strm).next_in.is_null() && (*strm).avail_in != 0 || (*strm).next_out.is_null() && (*strm).avail_out != 0 @@ -329,7 +326,6 @@ pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) } ret } -#[no_mangle] pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { if !strm.is_null() && !(*strm).internal.is_null() { lzma_next_end(&raw mut (*(*strm).internal).next, (*strm).allocator); @@ -337,7 +333,6 @@ pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { (*strm).internal = core::ptr::null_mut(); } } -#[no_mangle] pub unsafe extern "C" fn lzma_get_progress( strm: *mut lzma_stream, progress_in: *mut u64, @@ -354,7 +349,6 @@ pub unsafe extern "C" fn lzma_get_progress( *progress_out = (*strm).total_out; }; } -#[no_mangle] pub extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { return unsafe { if (*(*strm).internal).next.get_check.is_none() { @@ -363,7 +357,6 @@ pub extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { (*(*strm).internal).next.get_check.unwrap()((*(*strm).internal).next.coder) }; } -#[no_mangle] pub extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { return unsafe { let mut memusage: u64 = 0; @@ -383,7 +376,6 @@ pub extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { memusage }; } -#[no_mangle] pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { return unsafe { let mut old_memlimit: u64 = 0; @@ -403,7 +395,6 @@ pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { old_memlimit }; } -#[no_mangle] pub unsafe extern "C" fn lzma_memlimit_set( strm: *mut lzma_stream, mut new_memlimit: u64, diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 3d1871ad..84bb6a74 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -11,7 +11,6 @@ extern "C" { out_size: size_t, ) -> lzma_ret; } -#[no_mangle] pub unsafe extern "C" fn lzma_easy_buffer_encode( preset: u32, check: lzma_check, diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index 5494145e..6dd7c0c6 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index e698d97d..1a8fb73e 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -6,7 +6,6 @@ extern "C" { check: lzma_check, ) -> lzma_ret; } -#[no_mangle] pub unsafe extern "C" fn lzma_easy_encoder( strm: *mut lzma_stream, preset: u32, diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index 1f635250..e67c1f3d 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 63e555ba..39307b5c 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -23,7 +23,7 @@ extern "C" { #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_file_info_coder { - pub sequence: C2RustUnnamed_0, + pub sequence: file_info_seq, pub file_cur_pos: u64, pub file_target_pos: u64, pub file_size: u64, @@ -42,15 +42,15 @@ pub struct lzma_file_info_coder { pub temp_size: size_t, pub temp: [u8; 8192], } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_HEADER_COMPARE: C2RustUnnamed_0 = 7; -pub const SEQ_HEADER_DECODE: C2RustUnnamed_0 = 6; -pub const SEQ_INDEX_DECODE: C2RustUnnamed_0 = 5; -pub const SEQ_INDEX_INIT: C2RustUnnamed_0 = 4; -pub const SEQ_FOOTER: C2RustUnnamed_0 = 3; -pub const SEQ_PADDING_DECODE: C2RustUnnamed_0 = 2; -pub const SEQ_PADDING_SEEK: C2RustUnnamed_0 = 1; -pub const SEQ_MAGIC_BYTES: C2RustUnnamed_0 = 0; +pub type file_info_seq = c_uint; +pub const SEQ_HEADER_COMPARE: file_info_seq = 7; +pub const SEQ_HEADER_DECODE: file_info_seq = 6; +pub const SEQ_INDEX_DECODE: file_info_seq = 5; +pub const SEQ_INDEX_INIT: file_info_seq = 4; +pub const SEQ_FOOTER: file_info_seq = 3; +pub const SEQ_PADDING_DECODE: file_info_seq = 2; +pub const SEQ_PADDING_SEEK: file_info_seq = 1; +pub const SEQ_MAGIC_BYTES: file_info_seq = 0; unsafe extern "C" fn fill_temp( coder: *mut lzma_file_info_coder, in_0: *const u8, @@ -484,7 +484,7 @@ unsafe extern "C" fn file_info_decode( SEQ_PADDING_DECODE } else { SEQ_PADDING_SEEK - }) as C2RustUnnamed_0; + }) as file_info_seq; } _ => {} } diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index 74455faa..608c4ba8 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_decode( filters: *const lzma_filter, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index 5d04d8b4..3623eb2f 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_raw_buffer_encode( filters: *const lzma_filter, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 133ca6fc..050b75e4 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -1,99 +1,99 @@ use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] -pub struct C2RustUnnamed { +pub struct filter_features { pub id: lzma_vli, pub options_size: size_t, pub non_last_ok: bool, pub last_ok: bool, pub changes_size: bool, } -static mut features: [C2RustUnnamed; 13] = [ - C2RustUnnamed { +static mut features: [filter_features; 13] = [ + filter_features { id: LZMA_FILTER_LZMA1, options_size: core::mem::size_of::(), non_last_ok: false, last_ok: true, changes_size: true, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_LZMA1EXT, options_size: core::mem::size_of::(), non_last_ok: false, last_ok: true, changes_size: true, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_LZMA2, options_size: core::mem::size_of::(), non_last_ok: false, last_ok: true, changes_size: true, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_X86, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_POWERPC, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_IA64, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_ARM, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_ARMTHUMB, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_ARM64, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_SPARC, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_RISCV, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_FILTER_DELTA, options_size: core::mem::size_of::(), non_last_ok: true, last_ok: false, changes_size: false, }, - C2RustUnnamed { + filter_features { id: LZMA_VLI_UNKNOWN, options_size: 0, non_last_ok: false, @@ -101,7 +101,6 @@ static mut features: [C2RustUnnamed; 13] = [ changes_size: false, }, ]; -#[no_mangle] pub unsafe extern "C" fn lzma_filters_copy( src: *const lzma_filter, real_dest: *mut lzma_filter, diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 717105c7..14a8327d 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -363,7 +363,6 @@ extern "C" fn decoder_find(id: lzma_vli) -> *const lzma_filter_decoder { extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { decoder_find(id) as *const lzma_filter_coder } -#[no_mangle] pub extern "C" fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { !decoder_find(id).is_null() as lzma_bool } @@ -381,7 +380,6 @@ pub unsafe extern "C" fn lzma_raw_decoder_init( false, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder( strm: *mut lzma_stream, options: *const lzma_filter, @@ -403,14 +401,12 @@ pub unsafe extern "C" fn lzma_raw_decoder( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_properties_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index 8564f0d5..bc8af4e7 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -320,11 +320,9 @@ extern "C" fn encoder_find(id: lzma_vli) -> *const lzma_filter_encoder { extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { encoder_find(id) as *const lzma_filter_coder } -#[no_mangle] pub extern "C" fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { !encoder_find(id).is_null() as lzma_bool } -#[no_mangle] pub unsafe extern "C" fn lzma_filters_update( strm: *mut lzma_stream, filters: *const lzma_filter, @@ -371,7 +369,6 @@ pub unsafe extern "C" fn lzma_raw_encoder_init( true, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_raw_encoder( strm: *mut lzma_stream, filters: *const lzma_filter, @@ -396,14 +393,12 @@ pub unsafe extern "C" fn lzma_raw_encoder( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64 { lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { if filters.is_null() { return UINT64_MAX; @@ -430,7 +425,6 @@ pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 max } } -#[no_mangle] pub unsafe extern "C" fn lzma_properties_size( size: *mut u32, filter: *const lzma_filter, @@ -449,7 +443,6 @@ pub unsafe extern "C" fn lzma_properties_size( } (*fe).props_size_get.unwrap()(size, (*filter).options) } -#[no_mangle] pub unsafe extern "C" fn lzma_properties_encode( filter: *const lzma_filter, props: *mut u8, diff --git a/liblzma-rs/src/common/hardware_cputhreads.rs b/liblzma-rs/src/common/hardware_cputhreads.rs index 71e3fcd4..d095c552 100644 --- a/liblzma-rs/src/common/hardware_cputhreads.rs +++ b/liblzma-rs/src/common/hardware_cputhreads.rs @@ -1,6 +1,5 @@ use crate::tuklib::tuklib_cpucores::tuklib_cpucores; -#[no_mangle] pub extern "C" fn lzma_cputhreads() -> u32 { tuklib_cpucores() } diff --git a/liblzma-rs/src/common/hardware_physmem.rs b/liblzma-rs/src/common/hardware_physmem.rs index 6010242c..bc925a16 100644 --- a/liblzma-rs/src/common/hardware_physmem.rs +++ b/liblzma-rs/src/common/hardware_physmem.rs @@ -1,6 +1,5 @@ use crate::tuklib::tuklib_physmem::tuklib_physmem; -#[no_mangle] pub extern "C" fn lzma_physmem() -> u64 { tuklib_physmem() } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 470773a4..33f3e136 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -32,60 +32,6 @@ pub struct index_tree_node_s { pub type lzma_index = lzma_index_s; #[derive(Copy, Clone)] #[repr(C)] -pub struct lzma_index_iter { - pub stream: C2RustUnnamed_1, - pub block: C2RustUnnamed_0, - pub internal: [C2RustUnnamed; 6], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed { - pub p: *const c_void, - pub s: size_t, - pub v: lzma_vli, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct C2RustUnnamed_0 { - pub number_in_file: lzma_vli, - pub compressed_file_offset: lzma_vli, - pub uncompressed_file_offset: lzma_vli, - pub number_in_stream: lzma_vli, - pub compressed_stream_offset: lzma_vli, - pub uncompressed_stream_offset: lzma_vli, - pub uncompressed_size: lzma_vli, - pub unpadded_size: lzma_vli, - pub total_size: lzma_vli, - pub reserved_vli1: lzma_vli, - pub reserved_vli2: lzma_vli, - pub reserved_vli3: lzma_vli, - pub reserved_vli4: lzma_vli, - pub reserved_ptr1: *const c_void, - pub reserved_ptr2: *const c_void, - pub reserved_ptr3: *const c_void, - pub reserved_ptr4: *const c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct C2RustUnnamed_1 { - pub flags: *const lzma_stream_flags, - pub reserved_ptr1: *const c_void, - pub reserved_ptr2: *const c_void, - pub reserved_ptr3: *const c_void, - pub number: lzma_vli, - pub block_count: lzma_vli, - pub compressed_offset: lzma_vli, - pub uncompressed_offset: lzma_vli, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub padding: lzma_vli, - pub reserved_vli1: lzma_vli, - pub reserved_vli2: lzma_vli, - pub reserved_vli3: lzma_vli, - pub reserved_vli4: lzma_vli, -} -#[derive(Copy, Clone)] -#[repr(C)] pub struct index_record { pub uncompressed_sum: lzma_vli, pub unpadded_sum: lzma_vli, @@ -111,14 +57,14 @@ pub struct index_stream { pub stream_flags: lzma_stream_flags, pub stream_padding: lzma_vli, } -pub const ITER_METHOD_NORMAL: C2RustUnnamed_3 = 0; -pub const ITER_METHOD: C2RustUnnamed_2 = 4; -pub const ITER_RECORD: C2RustUnnamed_2 = 3; -pub const ITER_GROUP: C2RustUnnamed_2 = 2; -pub const ITER_STREAM: C2RustUnnamed_2 = 1; -pub const ITER_INDEX: C2RustUnnamed_2 = 0; -pub const ITER_METHOD_LEFTMOST: C2RustUnnamed_3 = 2; -pub const ITER_METHOD_NEXT: C2RustUnnamed_3 = 1; +pub const ITER_METHOD_NORMAL: iter_method = 0; +pub const ITER_METHOD: iter_mode = 4; +pub const ITER_RECORD: iter_mode = 3; +pub const ITER_GROUP: iter_mode = 2; +pub const ITER_STREAM: iter_mode = 1; +pub const ITER_INDEX: iter_mode = 0; +pub const ITER_METHOD_LEFTMOST: iter_method = 2; +pub const ITER_METHOD_NEXT: iter_method = 1; #[derive(Copy, Clone)] #[repr(C)] pub struct index_cat_info { @@ -128,8 +74,8 @@ pub struct index_cat_info { pub stream_number_add: u32, pub streams: *mut index_tree, } -pub type C2RustUnnamed_2 = c_uint; -pub type C2RustUnnamed_3 = c_uint; +pub type iter_mode = c_uint; +pub type iter_method = c_uint; #[inline] extern "C" fn bsr32(n: u32) -> u32 { n.leading_zeros() as i32 as u32 ^ 31 @@ -297,7 +243,6 @@ pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *m index_tree_append(&raw mut (*i).streams, &raw mut (*s).node); i } -#[no_mangle] pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { if !i.is_null() { index_tree_end( @@ -416,7 +361,6 @@ pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli (*s).stream_padding, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { (*i).uncompressed_size } diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index bd169791..ac0bbc9c 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -6,7 +6,7 @@ extern "C" { #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_coder { - pub sequence: C2RustUnnamed_0, + pub sequence: index_decoder_seq, pub memlimit: u64, pub index: *mut lzma_index, pub index_ptr: *mut *mut lzma_index, @@ -16,15 +16,15 @@ pub struct lzma_index_coder { pub pos: size_t, pub crc32: u32, } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_CRC32: C2RustUnnamed_0 = 7; -pub const SEQ_PADDING: C2RustUnnamed_0 = 6; -pub const SEQ_PADDING_INIT: C2RustUnnamed_0 = 5; -pub const SEQ_UNCOMPRESSED: C2RustUnnamed_0 = 4; -pub const SEQ_UNPADDED: C2RustUnnamed_0 = 3; -pub const SEQ_MEMUSAGE: C2RustUnnamed_0 = 2; -pub const SEQ_COUNT: C2RustUnnamed_0 = 1; -pub const SEQ_INDICATOR: C2RustUnnamed_0 = 0; +pub type index_decoder_seq = c_uint; +pub const SEQ_CRC32: index_decoder_seq = 7; +pub const SEQ_PADDING: index_decoder_seq = 6; +pub const SEQ_PADDING_INIT: index_decoder_seq = 5; +pub const SEQ_UNCOMPRESSED: index_decoder_seq = 4; +pub const SEQ_UNPADDED: index_decoder_seq = 3; +pub const SEQ_MEMUSAGE: index_decoder_seq = 2; +pub const SEQ_COUNT: index_decoder_seq = 1; +pub const SEQ_INDICATOR: index_decoder_seq = 0; unsafe extern "C" fn index_decode( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -103,7 +103,7 @@ unsafe extern "C" fn index_decode( SEQ_PADDING_INIT } else { SEQ_UNPADDED - }) as C2RustUnnamed_0; + }) as index_decoder_seq; } continue; } @@ -150,7 +150,7 @@ unsafe extern "C" fn index_decode( SEQ_PADDING_INIT } else { SEQ_UNPADDED - }) as C2RustUnnamed_0; + }) as index_decoder_seq; continue; } } @@ -334,7 +334,6 @@ pub unsafe extern "C" fn lzma_index_decoder( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_index_buffer_decode( i: *mut *mut lzma_index, memlimit: *mut u64, diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index 377b365f..bd28ce35 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -7,75 +7,21 @@ extern "C" { } #[derive(Copy, Clone)] #[repr(C)] -pub struct lzma_index_iter { - pub stream: C2RustUnnamed_2, - pub block: C2RustUnnamed_1, - pub internal: [C2RustUnnamed_0; 6], -} -#[derive(Copy, Clone)] -#[repr(C)] -pub union C2RustUnnamed_0 { - pub p: *const c_void, - pub s: size_t, - pub v: lzma_vli, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct C2RustUnnamed_1 { - pub number_in_file: lzma_vli, - pub compressed_file_offset: lzma_vli, - pub uncompressed_file_offset: lzma_vli, - pub number_in_stream: lzma_vli, - pub compressed_stream_offset: lzma_vli, - pub uncompressed_stream_offset: lzma_vli, - pub uncompressed_size: lzma_vli, - pub unpadded_size: lzma_vli, - pub total_size: lzma_vli, - pub reserved_vli1: lzma_vli, - pub reserved_vli2: lzma_vli, - pub reserved_vli3: lzma_vli, - pub reserved_vli4: lzma_vli, - pub reserved_ptr1: *const c_void, - pub reserved_ptr2: *const c_void, - pub reserved_ptr3: *const c_void, - pub reserved_ptr4: *const c_void, -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct C2RustUnnamed_2 { - pub flags: *const lzma_stream_flags, - pub reserved_ptr1: *const c_void, - pub reserved_ptr2: *const c_void, - pub reserved_ptr3: *const c_void, - pub number: lzma_vli, - pub block_count: lzma_vli, - pub compressed_offset: lzma_vli, - pub uncompressed_offset: lzma_vli, - pub compressed_size: lzma_vli, - pub uncompressed_size: lzma_vli, - pub padding: lzma_vli, - pub reserved_vli1: lzma_vli, - pub reserved_vli2: lzma_vli, - pub reserved_vli3: lzma_vli, - pub reserved_vli4: lzma_vli, -} -#[derive(Copy, Clone)] -#[repr(C)] pub struct lzma_index_coder { - pub sequence: C2RustUnnamed_3, + pub sequence: index_encoder_seq, pub index: *const lzma_index, pub iter: lzma_index_iter, pub pos: size_t, pub crc32: u32, } -pub type C2RustUnnamed_3 = c_uint; -pub const SEQ_CRC32: C2RustUnnamed_3 = 6; -pub const SEQ_PADDING: C2RustUnnamed_3 = 5; -pub const SEQ_NEXT: C2RustUnnamed_3 = 4; -pub const SEQ_UNCOMPRESSED: C2RustUnnamed_3 = 3; -pub const SEQ_UNPADDED: C2RustUnnamed_3 = 2; -pub const SEQ_COUNT: C2RustUnnamed_3 = 1; -pub const SEQ_INDICATOR: C2RustUnnamed_3 = 0; +pub type index_encoder_seq = c_uint; +pub const SEQ_CRC32: index_encoder_seq = 6; +pub const SEQ_PADDING: index_encoder_seq = 5; +pub const SEQ_NEXT: index_encoder_seq = 4; +pub const SEQ_UNCOMPRESSED: index_encoder_seq = 3; +pub const SEQ_UNPADDED: index_encoder_seq = 2; +pub const SEQ_COUNT: index_encoder_seq = 1; +pub const SEQ_INDICATOR: index_encoder_seq = 0; unsafe extern "C" fn index_encode( coder_ptr: *mut c_void, _allocator: *const lzma_allocator, @@ -300,7 +246,7 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( sequence: SEQ_INDICATOR, index: core::ptr::null(), iter: lzma_index_iter { - stream: C2RustUnnamed_2 { + stream: lzma_index_iter_stream { flags: core::ptr::null(), reserved_ptr1: core::ptr::null(), reserved_ptr2: core::ptr::null(), @@ -317,7 +263,7 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( reserved_vli3: 0, reserved_vli4: 0, }, - block: C2RustUnnamed_1 { + block: lzma_index_iter_block { number_in_file: 0, compressed_file_offset: 0, uncompressed_file_offset: 0, @@ -336,7 +282,7 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( reserved_ptr3: core::ptr::null(), reserved_ptr4: core::ptr::null(), }, - internal: [C2RustUnnamed_0 { + internal: [lzma_index_iter_internal { p: core::ptr::null(), }; 6], }, diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 71743a2f..f5a97375 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -3,7 +3,7 @@ use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_hash_s { - pub sequence: C2RustUnnamed_1, + pub sequence: index_hash_seq, pub blocks: lzma_index_hash_info, pub records: lzma_index_hash_info, pub remaining: lzma_vli, @@ -21,14 +21,14 @@ pub struct lzma_index_hash_info { pub index_list_size: lzma_vli, pub check: lzma_check_state, } -pub type C2RustUnnamed_1 = c_uint; -pub const SEQ_CRC32: C2RustUnnamed_1 = 6; -pub const SEQ_PADDING: C2RustUnnamed_1 = 5; -pub const SEQ_PADDING_INIT: C2RustUnnamed_1 = 4; -pub const SEQ_UNCOMPRESSED: C2RustUnnamed_1 = 3; -pub const SEQ_UNPADDED: C2RustUnnamed_1 = 2; -pub const SEQ_COUNT: C2RustUnnamed_1 = 1; -pub const SEQ_BLOCK: C2RustUnnamed_1 = 0; +pub type index_hash_seq = c_uint; +pub const SEQ_CRC32: index_hash_seq = 6; +pub const SEQ_PADDING: index_hash_seq = 5; +pub const SEQ_PADDING_INIT: index_hash_seq = 4; +pub const SEQ_UNCOMPRESSED: index_hash_seq = 3; +pub const SEQ_UNPADDED: index_hash_seq = 2; +pub const SEQ_COUNT: index_hash_seq = 1; +pub const SEQ_BLOCK: index_hash_seq = 0; pub type lzma_index_hash = lzma_index_hash_s; #[inline] extern "C" fn index_stream_size( @@ -184,7 +184,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( SEQ_PADDING_INIT } else { SEQ_UNPADDED - }) as C2RustUnnamed_1; + }) as index_hash_seq; continue; } 2 | 3 => { @@ -225,7 +225,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( SEQ_PADDING_INIT } else { SEQ_UNPADDED - }) as C2RustUnnamed_1; + }) as index_hash_seq; } continue; } diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 384308f3..aa0d39ec 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -3,7 +3,7 @@ use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzip_coder { - pub sequence: C2RustUnnamed_0, + pub sequence: lzip_decoder_seq, pub version: u32, pub crc32: u32, pub uncompressed_size: u64, @@ -19,13 +19,13 @@ pub struct lzma_lzip_coder { pub options: lzma_options_lzma, pub lzma_decoder: lzma_next_coder, } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_MEMBER_FOOTER: C2RustUnnamed_0 = 5; -pub const SEQ_LZMA_STREAM: C2RustUnnamed_0 = 4; -pub const SEQ_CODER_INIT: C2RustUnnamed_0 = 3; -pub const SEQ_DICT_SIZE: C2RustUnnamed_0 = 2; -pub const SEQ_VERSION: C2RustUnnamed_0 = 1; -pub const SEQ_ID_STRING: C2RustUnnamed_0 = 0; +pub type lzip_decoder_seq = c_uint; +pub const SEQ_MEMBER_FOOTER: lzip_decoder_seq = 5; +pub const SEQ_LZMA_STREAM: lzip_decoder_seq = 4; +pub const SEQ_CODER_INIT: lzip_decoder_seq = 3; +pub const SEQ_DICT_SIZE: lzip_decoder_seq = 2; +pub const SEQ_VERSION: lzip_decoder_seq = 1; +pub const SEQ_ID_STRING: lzip_decoder_seq = 0; #[inline] extern "C" fn read64le(buf: *const u8) -> u64 { return unsafe { @@ -383,7 +383,6 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( (*coder).pos = 0; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_lzip_decoder( strm: *mut lzma_stream, memlimit: u64, diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index 2595a2d9..6eed8728 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_decode( memlimit: *mut u64, flags: u32, diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 82cd10a0..d131ed6f 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -19,7 +19,6 @@ extern "C" { } pub const INDEX_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3 & !(3); pub const HEADERS_BOUND: u32 = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; -#[no_mangle] pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { let block_bound: size_t = unsafe { lzma_block_buffer_bound(uncompressed_size) } as size_t; if block_bound == 0 { @@ -33,7 +32,6 @@ pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t } block_bound.wrapping_add(HEADERS_BOUND as size_t) } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_buffer_encode( filters: *mut lzma_filter, check: lzma_check, diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 5742eeb9..978da765 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -3,7 +3,7 @@ use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { - pub sequence: C2RustUnnamed_0, + pub sequence: stream_decoder_seq, pub block_decoder: lzma_next_coder, pub block_options: lzma_block, pub stream_flags: lzma_stream_flags, @@ -19,14 +19,14 @@ pub struct lzma_stream_coder { pub pos: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 6; -pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; -pub const SEQ_INDEX: C2RustUnnamed_0 = 4; -pub const SEQ_BLOCK_RUN: C2RustUnnamed_0 = 3; -pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; -pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; -pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; +pub type stream_decoder_seq = c_uint; +pub const SEQ_STREAM_PADDING: stream_decoder_seq = 6; +pub const SEQ_STREAM_FOOTER: stream_decoder_seq = 5; +pub const SEQ_INDEX: stream_decoder_seq = 4; +pub const SEQ_BLOCK_RUN: stream_decoder_seq = 3; +pub const SEQ_BLOCK_INIT: stream_decoder_seq = 2; +pub const SEQ_BLOCK_HEADER: stream_decoder_seq = 1; +pub const SEQ_STREAM_HEADER: stream_decoder_seq = 0; unsafe extern "C" fn stream_decoder_reset( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, @@ -450,7 +450,6 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( (*coder).first_stream = true; stream_decoder_reset(coder, allocator) } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder( strm: *mut lzma_stream, memlimit: u64, diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 6374a358..1f4ee8ac 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -15,7 +15,7 @@ extern "C" { #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { - pub sequence: C2RustUnnamed_0, + pub sequence: stream_decoder_mt_seq, pub block_decoder: lzma_next_coder, pub block_options: lzma_block, pub filters: [lzma_filter; 5], @@ -78,19 +78,19 @@ pub struct worker_thread { pub thread_id: mythread, } pub const THR_EXIT: worker_state = 2; -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_ERROR: C2RustUnnamed_0 = 11; -pub const SEQ_STREAM_PADDING: C2RustUnnamed_0 = 10; -pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 9; -pub const SEQ_INDEX_DECODE: C2RustUnnamed_0 = 8; -pub const SEQ_INDEX_WAIT_OUTPUT: C2RustUnnamed_0 = 7; -pub const SEQ_BLOCK_DIRECT_RUN: C2RustUnnamed_0 = 6; -pub const SEQ_BLOCK_DIRECT_INIT: C2RustUnnamed_0 = 5; -pub const SEQ_BLOCK_THR_RUN: C2RustUnnamed_0 = 4; -pub const SEQ_BLOCK_THR_INIT: C2RustUnnamed_0 = 3; -pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 2; -pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 1; -pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; +pub type stream_decoder_mt_seq = c_uint; +pub const SEQ_ERROR: stream_decoder_mt_seq = 11; +pub const SEQ_STREAM_PADDING: stream_decoder_mt_seq = 10; +pub const SEQ_STREAM_FOOTER: stream_decoder_mt_seq = 9; +pub const SEQ_INDEX_DECODE: stream_decoder_mt_seq = 8; +pub const SEQ_INDEX_WAIT_OUTPUT: stream_decoder_mt_seq = 7; +pub const SEQ_BLOCK_DIRECT_RUN: stream_decoder_mt_seq = 6; +pub const SEQ_BLOCK_DIRECT_INIT: stream_decoder_mt_seq = 5; +pub const SEQ_BLOCK_THR_RUN: stream_decoder_mt_seq = 4; +pub const SEQ_BLOCK_THR_INIT: stream_decoder_mt_seq = 3; +pub const SEQ_BLOCK_INIT: stream_decoder_mt_seq = 2; +pub const SEQ_BLOCK_HEADER: stream_decoder_mt_seq = 1; +pub const SEQ_STREAM_HEADER: stream_decoder_mt_seq = 0; unsafe extern "C" fn worker_enable_partial_update(thr_ptr: *mut c_void) { let thr: *mut worker_thread = thr_ptr as *mut worker_thread; let mut mythread_i_325: c_uint = 0; @@ -1532,7 +1532,6 @@ unsafe extern "C" fn stream_decoder_mt_init( } stream_decoder_reset(coder, allocator) } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder_mt( strm: *mut lzma_stream, options: *const lzma_mt, diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 84166c7c..0b471eff 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -3,7 +3,7 @@ use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { - pub sequence: C2RustUnnamed_0, + pub sequence: stream_encoder_seq, pub block_encoder_is_initialized: bool, pub block_encoder: lzma_next_coder, pub block_options: lzma_block, @@ -14,13 +14,13 @@ pub struct lzma_stream_coder { pub buffer_size: size_t, pub buffer: [u8; LZMA_BLOCK_HEADER_SIZE_MAX as usize], } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 5; -pub const SEQ_INDEX_ENCODE: C2RustUnnamed_0 = 4; -pub const SEQ_BLOCK_ENCODE: C2RustUnnamed_0 = 3; -pub const SEQ_BLOCK_HEADER: C2RustUnnamed_0 = 2; -pub const SEQ_BLOCK_INIT: C2RustUnnamed_0 = 1; -pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; +pub type stream_encoder_seq = c_uint; +pub const SEQ_STREAM_FOOTER: stream_encoder_seq = 5; +pub const SEQ_INDEX_ENCODE: stream_encoder_seq = 4; +pub const SEQ_BLOCK_ENCODE: stream_encoder_seq = 3; +pub const SEQ_BLOCK_HEADER: stream_encoder_seq = 2; +pub const SEQ_BLOCK_INIT: stream_encoder_seq = 1; +pub const SEQ_STREAM_HEADER: stream_encoder_seq = 0; unsafe extern "C" fn block_encoder_init( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, @@ -405,7 +405,6 @@ unsafe extern "C" fn stream_encoder_init( (*coder).buffer_size = LZMA_STREAM_HEADER_SIZE as size_t; stream_encoder_update(coder as *mut c_void, allocator, filters, core::ptr::null()) } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder( strm: *mut lzma_stream, filters: *const lzma_filter, diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 683ac11f..8cb53e3e 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -37,7 +37,7 @@ pub type lzma_stream_coder = lzma_stream_coder_s; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder_s { - pub sequence: C2RustUnnamed_0, + pub sequence: stream_encoder_mt_seq, pub block_size: size_t, pub filters: [lzma_filter; 5], pub filters_cache: [lzma_filter; 5], @@ -60,11 +60,11 @@ pub struct lzma_stream_coder_s { pub mutex: mythread_mutex, pub cond: mythread_cond, } -pub type C2RustUnnamed_0 = c_uint; -pub const SEQ_STREAM_FOOTER: C2RustUnnamed_0 = 3; -pub const SEQ_INDEX: C2RustUnnamed_0 = 2; -pub const SEQ_BLOCK: C2RustUnnamed_0 = 1; -pub const SEQ_STREAM_HEADER: C2RustUnnamed_0 = 0; +pub type stream_encoder_mt_seq = c_uint; +pub const SEQ_STREAM_FOOTER: stream_encoder_mt_seq = 3; +pub const SEQ_INDEX: stream_encoder_mt_seq = 2; +pub const SEQ_BLOCK: stream_encoder_mt_seq = 1; +pub const SEQ_STREAM_HEADER: stream_encoder_mt_seq = 0; pub const THR_EXIT: worker_state = 4; pub const THR_STOP: worker_state = 3; pub const THR_FINISH: worker_state = 2; @@ -1247,7 +1247,6 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).progress_out = LZMA_STREAM_HEADER_SIZE as u64; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder_mt( strm: *mut lzma_stream, options: *const lzma_mt, @@ -1271,7 +1270,6 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64 { let mut easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index 9e8997c6..280cdd1f 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -5,7 +5,6 @@ pub static mut lzma_header_magic: [u8; 6] = [ ]; #[no_mangle] pub static mut lzma_footer_magic: [u8; 2] = [0x59 as u8, 0x5a as u8]; -#[no_mangle] pub unsafe extern "C" fn lzma_stream_flags_compare( a: *const lzma_stream_flags, b: *const lzma_stream_flags, diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index d51eb6b5..c04532d0 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -14,7 +14,6 @@ extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const false }; } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_header_decode( options: *mut lzma_stream_flags, in_0: *const u8, @@ -49,7 +48,6 @@ pub unsafe extern "C" fn lzma_stream_header_decode( (*options).backward_size = LZMA_VLI_UNKNOWN; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_footer_decode( options: *mut lzma_stream_flags, in_0: *const u8, diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 2ed6ac82..bb0ac757 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -13,7 +13,6 @@ extern "C" fn stream_flags_encode(options: *const lzma_stream_flags, out: *mut u false }; } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_header_encode( options: *const lzma_stream_flags, out: *mut u8, @@ -44,7 +43,6 @@ pub unsafe extern "C" fn lzma_stream_header_encode( ); LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_footer_encode( options: *const lzma_stream_flags, out: *mut u8, diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index aaa89e2a..ad3c3dbf 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -5,7 +5,7 @@ extern "C" { } #[derive(Copy, Clone)] #[repr(C)] -pub struct C2RustUnnamed { +pub struct filter_codec_def { pub name: [c_char; 12], pub opts_size: u32, pub id: lzma_vli, @@ -24,17 +24,17 @@ pub struct option_map { pub type_0: u8, pub flags: u8, pub offset: u16, - pub u: C2RustUnnamed_0, + pub u: option_value, } #[derive(Copy, Clone)] #[repr(C)] -pub union C2RustUnnamed_0 { +pub union option_value { pub map: *const name_value_map, - pub range: C2RustUnnamed_1, + pub range: option_value_range, } #[derive(Copy, Clone)] #[repr(C)] -pub struct C2RustUnnamed_1 { +pub struct option_value_range { pub min: u32, pub max: u32, } @@ -44,17 +44,17 @@ pub struct name_value_map { pub name: [c_char; 12], pub value: u32, } -pub const OPTMAP_TYPE_LZMA_MATCH_FINDER: C2RustUnnamed_2 = 2; -pub const OPTMAP_TYPE_LZMA_MODE: C2RustUnnamed_2 = 1; -pub const OPTMAP_TYPE_LZMA_PRESET: C2RustUnnamed_2 = 3; +pub const OPTMAP_TYPE_LZMA_MATCH_FINDER: option_type = 2; +pub const OPTMAP_TYPE_LZMA_MODE: option_type = 1; +pub const OPTMAP_TYPE_LZMA_PRESET: option_type = 3; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_str { pub buf: *mut c_char, pub pos: size_t, } -pub type C2RustUnnamed_2 = u8; -pub const OPTMAP_TYPE_UINT32: C2RustUnnamed_2 = 0; +pub type option_type = u8; +pub const OPTMAP_TYPE_UINT32: option_type = 0; pub const INT_MAX: c_int = c_int::MAX; pub const LZMA_STR_ALL_FILTERS: c_uint = 0x1; pub const LZMA_STR_NO_VALIDATION: c_uint = 0x2; @@ -159,8 +159,8 @@ static mut bcj_optmap: [option_map; 1] = unsafe { type_0: 0, flags: (OPTMAP_NO_STRFY_ZERO | OPTMAP_USE_BYTE_SUFFIX) as u8, offset: 0, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { + u: option_value { + range: option_value_range { min: 0, max: UINT32_MAX, }, @@ -189,8 +189,8 @@ static mut delta_optmap: [option_map; 1] = unsafe { type_0: 0, flags: 0, offset: 4, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { + u: option_value { + range: option_value_range { min: LZMA_DELTA_DIST_MIN, max: LZMA_DELTA_DIST_MAX, }, @@ -308,7 +308,7 @@ static mut lzma12_optmap: [option_map; 9] = [option_map { type_0: 0, flags: 0, offset: 0, - u: C2RustUnnamed_0 { + u: option_value { map: core::ptr::null(), }, }; 9]; @@ -334,9 +334,9 @@ unsafe extern "C" fn parse_lzma12( } core::ptr::null() } -static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { +static mut filter_name_map: [filter_codec_def; 11] = unsafe { [ - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma1\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_LZMA1, @@ -353,7 +353,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 5, allow_null: false, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"lzma2\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_LZMA2, @@ -370,7 +370,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 2, allow_null: false, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"x86\0\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_X86, @@ -387,7 +387,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 1, allow_null: true, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm\0\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARM, @@ -404,7 +404,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 1, allow_null: true, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"armthumb\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARMTHUMB, @@ -421,7 +421,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 1, allow_null: true, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"arm64\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_ARM64, @@ -438,7 +438,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 1, allow_null: true, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"riscv\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_RISCV, @@ -455,7 +455,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 1, allow_null: true, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"powerpc\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_POWERPC, @@ -472,7 +472,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 1, allow_null: true, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"ia64\0\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_IA64, @@ -489,7 +489,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 1, allow_null: true, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"sparc\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_SPARC, @@ -506,7 +506,7 @@ static mut filter_name_map: [C2RustUnnamed; 11] = unsafe { strfy_decoder: 1, allow_null: true, }, - C2RustUnnamed { + filter_codec_def { name: core::mem::transmute::<[u8; 12], [c_char; 12]>(*b"delta\0\0\0\0\0\0\0"), opts_size: core::mem::size_of::() as u32, id: LZMA_FILTER_DELTA, @@ -721,12 +721,12 @@ unsafe extern "C" fn parse_filter( } let mut i: size_t = 0; while i - < (core::mem::size_of::<[C2RustUnnamed; 11]>()) - .wrapping_div(core::mem::size_of::()) + < (core::mem::size_of::<[filter_codec_def; 11]>()) + .wrapping_div(core::mem::size_of::()) { if memcmp( *str as *const c_void, - &raw const (*(&raw const filter_name_map as *const C2RustUnnamed).offset(i as isize)) + &raw const (*(&raw const filter_name_map as *const filter_codec_def).offset(i as isize)) .name as *const c_void, name_len, ) == 0 @@ -1055,8 +1055,8 @@ pub unsafe extern "C" fn lzma_str_from_filters( } let mut j: size_t = 0; loop { - if j == (core::mem::size_of::<[C2RustUnnamed; 11]>()) - .wrapping_div(core::mem::size_of::()) + if j == (core::mem::size_of::<[filter_codec_def; 11]>()) + .wrapping_div(core::mem::size_of::()) { str_free(&raw mut dest, allocator); return LZMA_OPTIONS_ERROR; @@ -1064,7 +1064,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( if filter_name_map[j as usize].id == (*filters.offset(i as isize)).id { str_append_str( &raw mut dest, - &raw const (*(&raw const filter_name_map as *const C2RustUnnamed) + &raw const (*(&raw const filter_name_map as *const filter_codec_def) .offset(j as isize)) .name as *const c_char, ); @@ -1140,8 +1140,8 @@ pub unsafe extern "C" fn lzma_str_list_filters( let mut first_filter_printed: bool = false; let mut i: size_t = 0; while i - < (core::mem::size_of::<[C2RustUnnamed; 11]>()) - .wrapping_div(core::mem::size_of::()) + < (core::mem::size_of::<[filter_codec_def; 11]>()) + .wrapping_div(core::mem::size_of::()) { if filter_id == LZMA_VLI_UNKNOWN || filter_id == filter_name_map[i as usize].id { if filter_name_map[i as usize].id < LZMA_FILTER_RESERVED_START @@ -1157,7 +1157,7 @@ pub unsafe extern "C" fn lzma_str_list_filters( } str_append_str( &raw mut dest, - &raw const (*(&raw const filter_name_map as *const C2RustUnnamed) + &raw const (*(&raw const filter_name_map as *const filter_codec_def) .offset(i as isize)) .name as *const c_char, ); @@ -1231,7 +1231,7 @@ unsafe extern "C" fn run_static_initializers() { type_0: OPTMAP_TYPE_LZMA_PRESET, flags: 0, offset: 0, - u: C2RustUnnamed_0 { + u: option_value { map: core::ptr::null(), }, }, @@ -1240,8 +1240,8 @@ unsafe extern "C" fn run_static_initializers() { type_0: 0, flags: OPTMAP_USE_BYTE_SUFFIX, offset: 0, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { + u: option_value { + range: option_value_range { min: LZMA_DICT_SIZE_MIN as u32, max: (1u32 << 30).wrapping_add(1 << 29), }, @@ -1252,8 +1252,8 @@ unsafe extern "C" fn run_static_initializers() { type_0: 0, flags: 0, offset: 20, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { + u: option_value { + range: option_value_range { min: LZMA_LCLP_MIN, max: LZMA_LCLP_MAX, }, @@ -1264,8 +1264,8 @@ unsafe extern "C" fn run_static_initializers() { type_0: 0, flags: 0, offset: 24, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { + u: option_value { + range: option_value_range { min: LZMA_LCLP_MIN, max: LZMA_LCLP_MAX, }, @@ -1276,8 +1276,8 @@ unsafe extern "C" fn run_static_initializers() { type_0: 0, flags: 0, offset: 28, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { + u: option_value { + range: option_value_range { min: LZMA_PB_MIN, max: LZMA_PB_MAX, }, @@ -1288,7 +1288,7 @@ unsafe extern "C" fn run_static_initializers() { type_0: OPTMAP_TYPE_LZMA_MODE, flags: OPTMAP_USE_NAME_VALUE_MAP, offset: 32, - u: C2RustUnnamed_0 { + u: option_value { map: &raw const lzma12_mode_map as *const name_value_map, }, }, @@ -1297,8 +1297,8 @@ unsafe extern "C" fn run_static_initializers() { type_0: 0, flags: 0, offset: 36, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { min: 2, max: 273 }, + u: option_value { + range: option_value_range { min: 2, max: 273 }, }, }, option_map { @@ -1306,7 +1306,7 @@ unsafe extern "C" fn run_static_initializers() { type_0: OPTMAP_TYPE_LZMA_MATCH_FINDER, flags: OPTMAP_USE_NAME_VALUE_MAP, offset: 40, - u: C2RustUnnamed_0 { + u: option_value { map: &raw const lzma12_mf_map as *const name_value_map, }, }, @@ -1315,8 +1315,8 @@ unsafe extern "C" fn run_static_initializers() { type_0: 0, flags: 0, offset: 44, - u: C2RustUnnamed_0 { - range: C2RustUnnamed_1 { + u: option_value { + range: option_value_range { min: 0, max: UINT32_MAX, }, diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index b956a795..33079f74 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_vli_decode( vli: *mut lzma_vli, mut vli_pos: *mut size_t, diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index 6055bc00..d918d31b 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_vli_encode( mut vli: lzma_vli, mut vli_pos: *mut size_t, diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index 43036f7c..184869ac 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { if vli > LZMA_VLI_MAX { return 0; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 5d88aac0..77ae7065 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -15,11 +15,11 @@ pub struct lzma_coder { pub next: lzma_next_coder, pub next_finished: bool, pub this_finished: bool, - pub temp: C2RustUnnamed, + pub temp: lz_decoder_temp_buf, } #[derive(Copy, Clone)] #[repr(C)] -pub struct C2RustUnnamed { +pub struct lz_decoder_temp_buf { pub pos: size_t, pub size: size_t, pub buffer: [u8; LZMA_BUFFER_SIZE as usize], diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 177d0f2b..a9b4aaa5 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -522,7 +522,6 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( } lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) } -#[no_mangle] pub extern "C" fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { match mf { 3 => return true as lzma_bool, diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 89bbb95a..2f453b8a 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -51,7 +51,7 @@ pub struct lzma_lz_options { #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma2_coder { - pub sequence: C2RustUnnamed, + pub sequence: lzma2_encoder_seq, pub lzma: *mut c_void, pub opt_cur: lzma_options_lzma, pub need_properties: bool, @@ -62,12 +62,12 @@ pub struct lzma_lzma2_coder { pub buf_pos: size_t, pub buf: [u8; 65542], } -pub type C2RustUnnamed = c_uint; -pub const SEQ_UNCOMPRESSED_COPY: C2RustUnnamed = 4; -pub const SEQ_UNCOMPRESSED_HEADER: C2RustUnnamed = 3; -pub const SEQ_LZMA_COPY: C2RustUnnamed = 2; -pub const SEQ_LZMA_ENCODE: C2RustUnnamed = 1; -pub const SEQ_INIT: C2RustUnnamed = 0; +pub type lzma2_encoder_seq = c_uint; +pub const SEQ_UNCOMPRESSED_COPY: lzma2_encoder_seq = 4; +pub const SEQ_UNCOMPRESSED_HEADER: lzma2_encoder_seq = 3; +pub const SEQ_LZMA_COPY: lzma2_encoder_seq = 2; +pub const SEQ_LZMA_ENCODE: lzma2_encoder_seq = 1; +pub const SEQ_INIT: lzma2_encoder_seq = 0; #[inline] unsafe extern "C" fn mf_unencoded(mf: *const lzma_mf) -> u32 { (*mf) diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 577a5009..bbf7ba26 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -50,37 +50,37 @@ pub struct lzma_lzma1_decoder { pub literal_mask: u32, pub uncompressed_size: lzma_vli, pub allow_eopm: bool, - pub sequence: C2RustUnnamed, + pub sequence: lzma_decoder_seq, pub probs: *mut probability, pub symbol: u32, pub limit: u32, pub offset: u32, pub len: u32, } -pub type C2RustUnnamed = c_uint; -pub const SEQ_COPY: C2RustUnnamed = 22; -pub const SEQ_REP_LEN_BITTREE: C2RustUnnamed = 21; -pub const SEQ_REP_LEN_CHOICE2: C2RustUnnamed = 20; -pub const SEQ_REP_LEN_CHOICE: C2RustUnnamed = 19; -pub const SEQ_IS_REP2: C2RustUnnamed = 18; -pub const SEQ_IS_REP1: C2RustUnnamed = 17; -pub const SEQ_IS_REP0_LONG: C2RustUnnamed = 16; -pub const SEQ_SHORTREP: C2RustUnnamed = 15; -pub const SEQ_IS_REP0: C2RustUnnamed = 14; -pub const SEQ_EOPM: C2RustUnnamed = 13; -pub const SEQ_ALIGN: C2RustUnnamed = 12; -pub const SEQ_DIRECT: C2RustUnnamed = 11; -pub const SEQ_DIST_MODEL: C2RustUnnamed = 10; -pub const SEQ_DIST_SLOT: C2RustUnnamed = 9; -pub const SEQ_MATCH_LEN_BITTREE: C2RustUnnamed = 8; -pub const SEQ_MATCH_LEN_CHOICE2: C2RustUnnamed = 7; -pub const SEQ_MATCH_LEN_CHOICE: C2RustUnnamed = 6; -pub const SEQ_IS_REP: C2RustUnnamed = 5; -pub const SEQ_LITERAL_WRITE: C2RustUnnamed = 4; -pub const SEQ_LITERAL_MATCHED: C2RustUnnamed = 3; -pub const SEQ_LITERAL: C2RustUnnamed = 2; -pub const SEQ_IS_MATCH: C2RustUnnamed = 1; -pub const SEQ_NORMALIZE: C2RustUnnamed = 0; +pub type lzma_decoder_seq = c_uint; +pub const SEQ_COPY: lzma_decoder_seq = 22; +pub const SEQ_REP_LEN_BITTREE: lzma_decoder_seq = 21; +pub const SEQ_REP_LEN_CHOICE2: lzma_decoder_seq = 20; +pub const SEQ_REP_LEN_CHOICE: lzma_decoder_seq = 19; +pub const SEQ_IS_REP2: lzma_decoder_seq = 18; +pub const SEQ_IS_REP1: lzma_decoder_seq = 17; +pub const SEQ_IS_REP0_LONG: lzma_decoder_seq = 16; +pub const SEQ_SHORTREP: lzma_decoder_seq = 15; +pub const SEQ_IS_REP0: lzma_decoder_seq = 14; +pub const SEQ_EOPM: lzma_decoder_seq = 13; +pub const SEQ_ALIGN: lzma_decoder_seq = 12; +pub const SEQ_DIRECT: lzma_decoder_seq = 11; +pub const SEQ_DIST_MODEL: lzma_decoder_seq = 10; +pub const SEQ_DIST_SLOT: lzma_decoder_seq = 9; +pub const SEQ_MATCH_LEN_BITTREE: lzma_decoder_seq = 8; +pub const SEQ_MATCH_LEN_CHOICE2: lzma_decoder_seq = 7; +pub const SEQ_MATCH_LEN_CHOICE: lzma_decoder_seq = 6; +pub const SEQ_IS_REP: lzma_decoder_seq = 5; +pub const SEQ_LITERAL_WRITE: lzma_decoder_seq = 4; +pub const SEQ_LITERAL_MATCHED: lzma_decoder_seq = 3; +pub const SEQ_LITERAL: lzma_decoder_seq = 2; +pub const SEQ_IS_MATCH: lzma_decoder_seq = 1; +pub const SEQ_NORMALIZE: lzma_decoder_seq = 0; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_range_decoder { diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index 58936bd4..9d33e35f 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -4,7 +4,6 @@ pub const LZMA_LC_DEFAULT: u32 = 3; pub const LZMA_LP_DEFAULT: u32 = 0; pub const LZMA_PB_DEFAULT: u32 = 2; pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f; -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_preset( options: *mut lzma_options_lzma, preset: u32, diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index a1bc00a6..4f22f635 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -115,7 +115,7 @@ pub struct lzma_options_lzma { pub reserved_ptr2: *mut c_void, } -// lzma_internal sequence enum (C2RustUnnamed in lzma_internal_s) +// lzma_internal sequence enum pub type lzma_internal_sequence = c_uint; pub const ISEQ_RUN: lzma_internal_sequence = 0; pub const ISEQ_SYNC_FLUSH: lzma_internal_sequence = 1; @@ -368,6 +368,61 @@ pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_iter { + pub stream: lzma_index_iter_stream, + pub block: lzma_index_iter_block, + pub internal: [lzma_index_iter_internal; 6], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union lzma_index_iter_internal { + pub p: *const c_void, + pub s: size_t, + pub v: lzma_vli, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_iter_block { + pub number_in_file: lzma_vli, + pub compressed_file_offset: lzma_vli, + pub uncompressed_file_offset: lzma_vli, + pub number_in_stream: lzma_vli, + pub compressed_stream_offset: lzma_vli, + pub uncompressed_stream_offset: lzma_vli, + pub uncompressed_size: lzma_vli, + pub unpadded_size: lzma_vli, + pub total_size: lzma_vli, + pub reserved_vli1: lzma_vli, + pub reserved_vli2: lzma_vli, + pub reserved_vli3: lzma_vli, + pub reserved_vli4: lzma_vli, + pub reserved_ptr1: *const c_void, + pub reserved_ptr2: *const c_void, + pub reserved_ptr3: *const c_void, + pub reserved_ptr4: *const c_void, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct lzma_index_iter_stream { + pub flags: *const lzma_stream_flags, + pub reserved_ptr1: *const c_void, + pub reserved_ptr2: *const c_void, + pub reserved_ptr3: *const c_void, + pub number: lzma_vli, + pub block_count: lzma_vli, + pub compressed_offset: lzma_vli, + pub uncompressed_offset: lzma_vli, + pub compressed_size: lzma_vli, + pub uncompressed_size: lzma_vli, + pub padding: lzma_vli, + pub reserved_vli1: lzma_vli, + pub reserved_vli2: lzma_vli, + pub reserved_vli3: lzma_vli, + pub reserved_vli4: lzma_vli, +} + // lzma_block struct (shared across 12 modules) #[derive(Copy, Clone)] #[repr(C)] From 83e5c430c175e3e1256363da5f44ad3a4ceec66e Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Wed, 4 Mar 2026 01:23:51 +0900 Subject: [PATCH 12/51] build: raise msrv, fix CI, enable parallel tests --- .github/workflows/main.yml | 4 +- Cargo.lock.msrv | 722 ++++++++++++++---- Cargo.toml | 17 +- benches/backend_comparison.rs | 2 + liblzma-rs-sys/src/lib.rs | 70 +- liblzma-rs/src/check/sha256.rs | 14 +- liblzma-rs/src/common/alone_decoder.rs | 15 +- liblzma-rs/src/common/alone_encoder.rs | 27 +- liblzma-rs/src/common/auto_decoder.rs | 9 +- liblzma-rs/src/common/block_buffer_decoder.rs | 5 +- liblzma-rs/src/common/block_buffer_encoder.rs | 33 +- liblzma-rs/src/common/block_decoder.rs | 272 ++++--- liblzma-rs/src/common/block_encoder.rs | 177 +++-- liblzma-rs/src/common/block_header_decoder.rs | 10 +- liblzma-rs/src/common/block_header_encoder.rs | 12 +- liblzma-rs/src/common/common.rs | 83 +- liblzma-rs/src/common/easy_buffer_encoder.rs | 4 +- .../src/common/easy_decoder_memusage.rs | 6 +- liblzma-rs/src/common/easy_encoder.rs | 8 +- .../src/common/easy_encoder_memusage.rs | 6 +- liblzma-rs/src/common/easy_preset.rs | 5 +- liblzma-rs/src/common/file_info.rs | 58 +- .../src/common/filter_buffer_decoder.rs | 8 +- .../src/common/filter_buffer_encoder.rs | 6 +- liblzma-rs/src/common/filter_common.rs | 13 +- liblzma-rs/src/common/filter_decoder.rs | 10 +- liblzma-rs/src/common/filter_encoder.rs | 5 +- liblzma-rs/src/common/filter_flags_decoder.rs | 4 +- liblzma-rs/src/common/filter_flags_encoder.rs | 2 +- liblzma-rs/src/common/hardware_cputhreads.rs | 1 - liblzma-rs/src/common/hardware_physmem.rs | 1 - liblzma-rs/src/common/index.rs | 136 ++-- liblzma-rs/src/common/index_decoder.rs | 24 +- liblzma-rs/src/common/index_encoder.rs | 36 +- liblzma-rs/src/common/index_hash.rs | 51 +- liblzma-rs/src/common/lzip_decoder.rs | 34 +- liblzma-rs/src/common/microlzma_decoder.rs | 20 +- liblzma-rs/src/common/microlzma_encoder.rs | 13 +- liblzma-rs/src/common/outqueue.rs | 5 +- .../src/common/stream_buffer_decoder.rs | 12 +- .../src/common/stream_buffer_encoder.rs | 22 +- liblzma-rs/src/common/stream_decoder.rs | 52 +- liblzma-rs/src/common/stream_decoder_mt.rs | 309 +++++--- liblzma-rs/src/common/stream_encoder.rs | 66 +- liblzma-rs/src/common/stream_encoder_mt.rs | 599 ++++++++------- liblzma-rs/src/common/stream_flags_decoder.rs | 5 +- liblzma-rs/src/common/stream_flags_encoder.rs | 4 +- liblzma-rs/src/common/stream_mt.rs | 1 - liblzma-rs/src/common/string_conversion.rs | 223 +++--- liblzma-rs/src/common/vli_decoder.rs | 6 +- liblzma-rs/src/common/vli_encoder.rs | 6 +- liblzma-rs/src/delta/delta_common.rs | 15 +- liblzma-rs/src/delta/delta_decoder.rs | 1 - liblzma-rs/src/delta/delta_encoder.rs | 3 +- liblzma-rs/src/lib.rs | 10 +- liblzma-rs/src/lz/lz_decoder.rs | 23 +- liblzma-rs/src/lz/lz_encoder.rs | 39 +- liblzma-rs/src/lz/lz_encoder_mf.rs | 1 - liblzma-rs/src/lzma/lzma2_decoder.rs | 18 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 26 +- liblzma-rs/src/lzma/lzma_decoder.rs | 145 ++-- liblzma-rs/src/lzma/lzma_encoder.rs | 262 ++++--- .../src/lzma/lzma_encoder_optimum_fast.rs | 9 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 72 +- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 1 - liblzma-rs/src/simple/arm.rs | 1 - liblzma-rs/src/simple/arm64.rs | 1 - liblzma-rs/src/simple/armthumb.rs | 1 - liblzma-rs/src/simple/ia64.rs | 1 - liblzma-rs/src/simple/powerpc.rs | 1 - liblzma-rs/src/simple/riscv.rs | 1 - liblzma-rs/src/simple/simple_coder.rs | 39 +- liblzma-rs/src/simple/simple_decoder.rs | 1 - liblzma-rs/src/simple/simple_encoder.rs | 1 - liblzma-rs/src/simple/sparc.rs | 1 - liblzma-rs/src/simple/x86.rs | 5 +- liblzma-rs/src/tuklib/tuklib_physmem.rs | 5 - liblzma-rs/src/types.rs | 186 +---- liblzma-sys/Cargo.toml | 2 +- src/lib.rs | 8 +- src/read.rs | 9 +- src/write.rs | 9 +- tests/sys_equivalence.rs | 2 + 83 files changed, 2455 insertions(+), 1677 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ffd7fc38..ee75d9b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: matrix: include: - os: ubuntu-latest - rust: '1.60' # msrv + rust: '1.63' # msrv - os: ubuntu-latest rust: stable - os: ubuntu-latest @@ -56,7 +56,7 @@ jobs: run: echo LZMA_API_STATIC=1 >> $GITHUB_ENV shell: bash - name: copy Cargo.lock for msrv check - if: matrix.rust == '1.60' + if: matrix.rust == '1.63' run: | cp Cargo.lock.msrv Cargo.lock - run: | diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv index 7e0a1cef..24df8a95 100644 --- a/Cargo.lock.msrv +++ b/Cargo.lock.msrv @@ -4,13 +4,42 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + [[package]] name = "bitflags" version = "1.3.2" @@ -18,25 +47,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bitflags" -version = "2.9.0" +name = "bumpalo" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] -name = "bumpalo" -version = "3.17.0" +name = "cast" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.49" +version = "1.2.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e450b8da92aa6f274e7c6437692f9f2ce6d701fb73bacfcf87897b3f89a4c20e" +checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" dependencies = [ + "find-msvc-tools", "jobserver", - "num_cpus", + "libc", + "shlex", ] [[package]] @@ -47,20 +78,129 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] -name = "console_error_panic_hook" -version = "0.1.7" +name = "ciborium" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen", + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "clap" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "is-terminal", + "itertools", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + [[package]] name = "ctest2" version = "0.4.10" @@ -93,6 +233,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + [[package]] name = "env_logger" version = "0.8.4" @@ -103,6 +249,36 @@ dependencies = [ "regex", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + [[package]] name = "garando_errors" version = "0.1.0" @@ -131,7 +307,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d8a383861d12fc78c251bbcb1ec252dd8338714ce02ab0cc393cfd02f40d32b" dependencies = [ - "bitflags 1.3.2", + "bitflags", "garando_errors", "garando_pos", "log", @@ -142,56 +318,87 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.4", + "js-sys", "libc", - "wasi 0.9.0+wasi-snapshot-preview1", + "wasi", + "wasm-bindgen", ] [[package]] name = "getrandom" -version = "0.2.5" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ - "cfg-if 1.0.0", - "js-sys", + "cfg-if 1.0.4", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", - "wasm-bindgen", + "r-efi", + "wasip2", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if 1.0.4", + "crunchy", + "zerocopy", ] [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "is-terminal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "jobserver" -version = "0.1.16" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f74e73053eaf95399bf926e48fc7a2a3ce50bd0eaaa2357d391e95b2dcdd4f10" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" dependencies = [ + "getrandom 0.3.4", "libc", - "log", - "rand 0.7.3", ] [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ "once_cell", "wasm-bindgen", @@ -199,22 +406,41 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.150" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "liblzma" version = "0.4.6" dependencies = [ - "getrandom 0.2.5", + "criterion", + "getrandom 0.2.17", + "liblzma-rs-sys", "liblzma-sys", + "log", "num_cpus", "quickcheck", - "rand 0.8.5", + "rand", + "regex", "wasm-bindgen-test", ] +[[package]] +name = "liblzma-rs" +version = "0.1.0" +dependencies = [ + "libc", +] + +[[package]] +name = "liblzma-rs-sys" +version = "0.1.0" +dependencies = [ + "libc", + "liblzma-rs", +] + [[package]] name = "liblzma-sys" version = "0.4.5" @@ -224,33 +450,67 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + [[package]] name = "libredox" -version = "0.1.3" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" dependencies = [ - "bitflags 2.9.0", "libc", ] [[package]] name = "log" -version = "0.4.27" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.6.0" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "minicov" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c" +checksum = "4869b6a491569605d66d3952bcdf03df789e5b536e5f0cf7758a7f08a55ae24d" +dependencies = [ + "cc", + "walkdir", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ "hermit-abi", "libc", @@ -258,120 +518,158 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pkg-config" -version = "0.3.18" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-svg" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +dependencies = [ + "plotters-backend", +] [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quickcheck" -version = "1.0.3" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" +checksum = "efc008b226fa5bdeabfc788d6679692223e940da371a95e26d87678333dac7c8" dependencies = [ "env_logger", "log", - "rand 0.8.5", + "rand", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] [[package]] -name = "rand" -version = "0.7.3" +name = "r-efi" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" -version = "0.8.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "a76330fb486679b4ace3670f117bbc9e16204005c4bde9c4bd372f45bed34f12" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", + "rand_chacha", + "rand_core", + "rand_hc", ] [[package]] name = "rand_chacha" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", + "rand_core", ] [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "rand_core" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", + "getrandom 0.2.17", ] [[package]] -name = "rand_core" -version = "0.5.1" +name = "rand_hc" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "7b363d4f6370f88d62bf586c80405657bde0f0e1b8945d47d2ad59b906cb4f54" dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] -name = "rand_core" -version = "0.6.4" +name = "rayon" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" dependencies = [ - "getrandom 0.2.5", + "either", + "rayon-core", ] [[package]] -name = "rand_hc" -version = "0.2.0" +name = "rayon-core" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" dependencies = [ - "rand_core 0.5.1", + "crossbeam-deque", + "crossbeam-utils", ] [[package]] @@ -380,7 +678,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom 0.2.5", + "getrandom 0.2.17", "libredox", "thiserror", ] @@ -425,42 +723,49 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] -name = "ryu" -version = "1.0.20" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] [[package]] -name = "scoped-tls" -version = "1.0.1" +name = "semver" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] -name = "semver" -version = "1.0.26" +name = "serde" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] [[package]] -name = "serde" -version = "1.0.219" +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -469,21 +774,34 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", - "ryu", "serde", + "serde_core", + "zmij", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + [[package]] name = "syn" -version = "2.0.100" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -496,6 +814,7 @@ version = "0.1.0" dependencies = [ "ctest2", "libc", + "liblzma-rs-sys", "liblzma-sys", ] @@ -529,11 +848,21 @@ dependencies = [ "syn", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-xid" @@ -542,50 +871,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +name = "walkdir" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "wasm-bindgen" -version = "0.2.100" +name = "wasip2" +version = "1.0.2+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" dependencies = [ - "cfg-if 1.0.0", - "once_cell", - "rustversion", - "wasm-bindgen-macro", + "wit-bindgen", ] [[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" +name = "wasm-bindgen" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", + "cfg-if 1.0.4", + "once_cell", + "rustversion", + "wasm-bindgen-macro", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.4", + "futures-util", "js-sys", "once_cell", "wasm-bindgen", @@ -594,9 +924,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -604,56 +934,70 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" dependencies = [ + "bumpalo", "proc-macro2", "quote", "syn", - "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-bindgen-test" -version = "0.3.42" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" +checksum = "6311c867385cc7d5602463b31825d454d0837a3aba7cdb5e56d5201792a3f7fe" dependencies = [ - "console_error_panic_hook", + "async-trait", + "cast", "js-sys", - "scoped-tls", + "libm", + "minicov", + "nu-ansi-term", + "num-traits", + "oorandom", + "serde", + "serde_json", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", + "wasm-bindgen-test-shared", ] [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.42" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" +checksum = "67008cdde4769831958536b0f11b3bdd0380bde882be17fff9c2f34bb4549abd" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "wasm-bindgen-test-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe29135b180b72b04c74aa97b2b4a2ef275161eff9a6c7955ea9eaedc7e1d4e" + [[package]] name = "web-sys" -version = "0.3.77" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" dependencies = [ "js-sys", "wasm-bindgen", @@ -675,8 +1019,64 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" + +[[package]] +name = "zerocopy" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 24998498..4a057039 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ in-memory encoding/decoding. forked from xz2. """ categories = ["compression", "api-bindings"] edition = "2021" -rust-version = "1.60" +rust-version = "1.63" exclude = [".github/"] [workspace] @@ -21,22 +21,26 @@ members = ["systest", "liblzma-rs", "liblzma-rs-sys"] [dependencies] liblzma-sys = { package = "liblzma-rs-sys", path = "liblzma-rs-sys" } -liblzma-c-sys = { package = "liblzma-sys", path = "liblzma-sys", version = "0.4.3", default-features = false, optional = true } num_cpus = { version = "1.16.0", optional = true } +criterion = { version = "0.5", features = ["html_reports"], optional = true } [dev-dependencies] -rand = "0.8.0" -quickcheck = "1.0.1" -criterion = { version = "0.5", features = ["html_reports"] } -liblzma-c-sys-test = { package = "liblzma-sys", path = "liblzma-sys", version = "0.4.5", default-features = false, features = ["bindgen"] } +rand = "=0.8.0" +regex = "=1.9.0" +log = "=0.4.20" [[bench]] name = "backend_comparison" harness = false +required-features = ["bench"] [target.'cfg(target_arch = "wasm32")'.dev-dependencies] getrandom = { version = "0.2", features = ["js"] } +[target.'cfg(not(target_family = "wasm"))'.dev-dependencies] +quickcheck = "=1.0.1" +liblzma-c-sys-test = { package = "liblzma-sys", path = "liblzma-sys", version = "0.4.5", default-features = false, features = ["bindgen"] } + [target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dev-dependencies] wasm-bindgen-test = "0.3" @@ -47,6 +51,7 @@ parallel = ["liblzma-sys/parallel", "num_cpus"] bindgen = ["liblzma-sys/bindgen"] wasm = ["liblzma-sys/wasm"] uncheck_liblzma_version = ["liblzma-sys/uncheck_liblzma_version"] # Disables version checking for the system-installed liblzma. This is not recommended under normal circumstances. +bench = ["criterion"] # These two are for cross-language LTO. # Will only work if `clang` is used to build the C library. diff --git a/benches/backend_comparison.rs b/benches/backend_comparison.rs index 10fb5637..65c14d56 100644 --- a/benches/backend_comparison.rs +++ b/benches/backend_comparison.rs @@ -1,3 +1,5 @@ +#![cfg(not(target_family = "wasm"))] + use std::ptr; use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs index 62a4e5d0..e0ee2ef8 100644 --- a/liblzma-rs-sys/src/lib.rs +++ b/liblzma-rs-sys/src/lib.rs @@ -15,14 +15,22 @@ clippy::all )] -use core::ffi::{c_char, c_uchar, c_uint, c_void}; +#[cfg(not(all(target_family = "wasm", target_os = "unknown")))] use libc::size_t; +#[cfg(not(all(target_family = "wasm", target_os = "unknown")))] +use libc::{c_char, c_int, c_uchar, c_uint, c_void}; +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +use std::os::raw::{c_char, c_int, c_uchar, c_uint, c_void}; +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +type wasm_size_t = usize; +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +use self::wasm_size_t as size_t; // === Canonical type aliases === // On MSVC, C enums are c_int; elsewhere c_uint (matching liblzma-sys manual.rs) #[cfg(target_env = "msvc")] #[doc(hidden)] -pub type __enum_ty = core::ffi::c_int; +pub type __enum_ty = c_int; #[cfg(not(target_env = "msvc"))] #[doc(hidden)] pub type __enum_ty = c_uint; @@ -256,7 +264,11 @@ pub unsafe extern "C" fn lzma_stream_encoder( } #[no_mangle] -pub unsafe extern "C" fn lzma_stream_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { +pub unsafe extern "C" fn lzma_stream_decoder( + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, +) -> lzma_ret { liblzma_rs::common::stream_decoder::lzma_stream_decoder(strm.cast(), memlimit, flags) } @@ -278,12 +290,20 @@ pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u6 // --- Auto/lzip decoder --- #[no_mangle] -pub unsafe extern "C" fn lzma_auto_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { +pub unsafe extern "C" fn lzma_auto_decoder( + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, +) -> lzma_ret { liblzma_rs::common::auto_decoder::lzma_auto_decoder(strm.cast(), memlimit, flags) } #[no_mangle] -pub unsafe extern "C" fn lzma_lzip_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { +pub unsafe extern "C" fn lzma_lzip_decoder( + strm: *mut lzma_stream, + memlimit: u64, + flags: u32, +) -> lzma_ret { liblzma_rs::common::lzip_decoder::lzma_lzip_decoder(strm.cast(), memlimit, flags) } @@ -374,17 +394,26 @@ pub unsafe extern "C" fn lzma_raw_decoder_memusage(filters: *const lzma_filter) } #[no_mangle] -pub unsafe extern "C" fn lzma_raw_encoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { +pub unsafe extern "C" fn lzma_raw_encoder( + strm: *mut lzma_stream, + filters: *const lzma_filter, +) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_raw_encoder(strm.cast(), filters.cast()) } #[no_mangle] -pub unsafe extern "C" fn lzma_raw_decoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { +pub unsafe extern "C" fn lzma_raw_decoder( + strm: *mut lzma_stream, + filters: *const lzma_filter, +) -> lzma_ret { liblzma_rs::common::filter_decoder::lzma_raw_decoder(strm.cast(), filters.cast()) } #[no_mangle] -pub unsafe extern "C" fn lzma_filters_update(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { +pub unsafe extern "C" fn lzma_filters_update( + strm: *mut lzma_stream, + filters: *const lzma_filter, +) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_filters_update(strm.cast(), filters.cast()) } @@ -437,12 +466,18 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( // --- Properties --- #[no_mangle] -pub unsafe extern "C" fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret { +pub unsafe extern "C" fn lzma_properties_size( + size: *mut u32, + filter: *const lzma_filter, +) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_properties_size(size, filter.cast()) } #[no_mangle] -pub unsafe extern "C" fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret { +pub unsafe extern "C" fn lzma_properties_encode( + filter: *const lzma_filter, + props: *mut u8, +) -> lzma_ret { liblzma_rs::common::filter_encoder::lzma_properties_encode(filter.cast(), props) } @@ -469,7 +504,10 @@ pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 // --- LZMA preset --- #[no_mangle] -pub unsafe extern "C" fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool { +pub unsafe extern "C" fn lzma_lzma_preset( + options: *mut lzma_options_lzma, + preset: u32, +) -> lzma_bool { liblzma_rs::lzma::lzma_encoder_presets::lzma_lzma_preset(options.cast(), preset) } @@ -625,13 +663,19 @@ pub struct lzma_mt { #[cfg(feature = "parallel")] #[no_mangle] -pub unsafe extern "C" fn lzma_stream_encoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { +pub unsafe extern "C" fn lzma_stream_encoder_mt( + strm: *mut lzma_stream, + options: *const lzma_mt, +) -> lzma_ret { liblzma_rs::common::stream_mt::lzma_stream_encoder_mt(strm.cast(), options.cast()) } #[cfg(feature = "parallel")] #[no_mangle] -pub unsafe extern "C" fn lzma_stream_decoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { +pub unsafe extern "C" fn lzma_stream_decoder_mt( + strm: *mut lzma_stream, + options: *const lzma_mt, +) -> lzma_ret { liblzma_rs::common::stream_mt::lzma_stream_decoder_mt(strm.cast(), options.cast()) } diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index cc9cdbdc..43699b5b 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_uint; #[inline] extern "C" fn rotr_32(num: u32, amount: c_uint) -> u32 { num >> amount | num << 32u32.wrapping_sub(amount) @@ -19,7 +18,7 @@ unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { let mut T: [u32; 8] = [0; 8]; core::ptr::copy_nonoverlapping( state as *const u8, - &raw mut T as *mut u8, + ::core::ptr::addr_of_mut!(T) as *mut u8, core::mem::size_of::<[u32; 8]>(), ); W[0] = (*data & 0xff) << 24 @@ -528,8 +527,8 @@ unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { } unsafe extern "C" fn process(check: *mut lzma_check_state) { transform( - &raw mut (*check).state.sha256.state as *mut u32, - &raw mut (*check).buffer.u32_0 as *const u32, + ::core::ptr::addr_of_mut!((*check).state.sha256.state) as *mut u32, + ::core::ptr::addr_of_mut!((*check).buffer.u32_0) as *const u32, ); } #[no_mangle] @@ -539,8 +538,8 @@ pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { 0x5be0cd19, ]; core::ptr::copy_nonoverlapping( - &raw const s as *const u8, - &raw mut (*check).state.sha256.state as *mut u8, + ::core::ptr::addr_of!(s) as *const u8, + ::core::ptr::addr_of_mut!((*check).state.sha256.state) as *mut u8, core::mem::size_of::<[u32; 8]>(), ); (*check).state.sha256.size = 0; @@ -559,7 +558,8 @@ pub unsafe extern "C" fn lzma_sha256_update( } core::ptr::copy_nonoverlapping( buf as *const u8, - (&raw mut (*check).buffer.u8_0 as *mut u8).offset(copy_start as isize) as *mut u8, + (::core::ptr::addr_of_mut!((*check).buffer.u8_0) as *mut u8).offset(copy_start as isize) + as *mut u8, copy_size, ); buf = buf.offset(copy_size as isize); diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 4282f6ee..45fe3f4c 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_alone_coder { @@ -35,7 +34,7 @@ unsafe extern "C" fn alone_decode( match (*coder).sequence { 0 => { if lzma_lzma_lclppb_decode( - &raw mut (*coder).options, + ::core::ptr::addr_of_mut!((*coder).options), *in_0.offset(*in_pos as isize), ) { return LZMA_FORMAT_ERROR; @@ -86,7 +85,7 @@ unsafe extern "C" fn alone_decode( (*coder).options.ext_size_low = (*coder).uncompressed_size as u32; (*coder).options.ext_size_high = ((*coder).uncompressed_size >> 32) as u32; (*coder).memusage = lzma_lzma_decoder_memusage_nocheck( - &raw mut (*coder).options as *const c_void, + ::core::ptr::addr_of_mut!((*coder).options) as *const c_void, ) .wrapping_add(LZMA_MEMUSAGE_BASE); (*coder).pos = 0; @@ -129,7 +128,7 @@ unsafe extern "C" fn alone_decode( ) -> lzma_ret, ), - options: &raw mut (*coder).options as *mut c_void, + options: ::core::ptr::addr_of_mut!((*coder).options) as *mut c_void, }, lzma_filter_info_s { id: 0, @@ -138,9 +137,9 @@ unsafe extern "C" fn alone_decode( }, ]; let ret_: lzma_ret = lzma_next_filter_init( - &raw mut (*coder).next, + ::core::ptr::addr_of_mut!((*coder).next), allocator, - &raw mut filters as *mut lzma_filter_info, + ::core::ptr::addr_of_mut!(filters) as *mut lzma_filter_info, ); if ret_ != LZMA_OK { return ret_; @@ -154,7 +153,7 @@ unsafe extern "C" fn alone_decode( } unsafe extern "C" fn alone_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn alone_decoder_memconfig( @@ -281,7 +280,7 @@ pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u6 return ret_; } let ret__0: lzma_ret = lzma_alone_decoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, memlimit, false, diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index d2fe9755..bb4be1d4 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_alone_coder { @@ -28,8 +27,8 @@ unsafe extern "C" fn alone_encode( match (*coder).sequence { 0 => { lzma_bufcpy( - &raw mut (*coder).header as *mut u8, - &raw mut (*coder).header_pos, + ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).header_pos), ALONE_HEADER_SIZE as size_t, out, out_pos, @@ -60,7 +59,7 @@ unsafe extern "C" fn alone_encode( } unsafe extern "C" fn alone_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn alone_encoder_init( @@ -145,7 +144,10 @@ unsafe extern "C" fn alone_encoder_init( } (*coder).sequence = SEQ_HEADER; (*coder).header_pos = 0; - if lzma_lzma_lclppb_encode(options, &raw mut (*coder).header as *mut u8) { + if lzma_lzma_lclppb_encode( + options, + ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, + ) { return LZMA_OPTIONS_ERROR; } if (*options).dict_size < LZMA_DICT_SIZE_MIN as u32 { @@ -160,9 +162,14 @@ unsafe extern "C" fn alone_encoder_init( if d != UINT32_MAX { d += 1; } - write32le((&raw mut (*coder).header as *mut u8).offset(1), d); + write32le( + (::core::ptr::addr_of_mut!((*coder).header) as *mut u8).offset(1), + d, + ); core::ptr::write_bytes( - (&raw mut (*coder).header as *mut u8).offset(1).offset(4) as *mut u8, + (::core::ptr::addr_of_mut!((*coder).header) as *mut u8) + .offset(1) + .offset(4) as *mut u8, 0xff as u8, 8, ); @@ -186,9 +193,9 @@ unsafe extern "C" fn alone_encoder_init( }, ]; lzma_next_filter_init( - &raw mut (*coder).next, + ::core::ptr::addr_of_mut!((*coder).next), allocator, - &raw const filters as *const lzma_filter_info, + ::core::ptr::addr_of!(filters) as *const lzma_filter_info, ) } pub unsafe extern "C" fn lzma_alone_encoder( @@ -200,7 +207,7 @@ pub unsafe extern "C" fn lzma_alone_encoder( return ret_; } let ret__0: lzma_ret = alone_encoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, options, ); diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 952e8df0..edc1ba50 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_alone_decoder_init( next: *mut lzma_next_coder, @@ -41,7 +40,7 @@ unsafe extern "C" fn auto_decode( (*coder).sequence = SEQ_CODE; if *in_0.offset(*in_pos as isize) == 0xfd { let ret_: lzma_ret = lzma_stream_decoder_init( - &raw mut (*coder).next, + ::core::ptr::addr_of_mut!((*coder).next), allocator, (*coder).memlimit, (*coder).flags, @@ -51,7 +50,7 @@ unsafe extern "C" fn auto_decode( } } else { let ret__0: lzma_ret = lzma_alone_decoder_init( - &raw mut (*coder).next, + ::core::ptr::addr_of_mut!((*coder).next), allocator, (*coder).memlimit, true, @@ -107,7 +106,7 @@ unsafe extern "C" fn auto_decode( } unsafe extern "C" fn auto_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free(coder as *mut c_void, allocator); } extern "C" fn auto_decoder_get_check(coder_ptr: *const c_void) -> lzma_check { @@ -247,7 +246,7 @@ pub unsafe extern "C" fn lzma_auto_decoder( return ret_; } let ret__0: lzma_ret = auto_decoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, memlimit, flags, diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index dbe12462..074587c9 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -31,7 +31,8 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( update: None, set_out_limit: None, }; - let mut ret: lzma_ret = lzma_block_decoder_init(&raw mut block_decoder, allocator, block); + let mut ret: lzma_ret = + lzma_block_decoder_init(::core::ptr::addr_of_mut!(block_decoder), allocator, block); if ret == LZMA_OK { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; @@ -60,6 +61,6 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( *out_pos = out_start; } } - lzma_next_end(&raw mut block_decoder, allocator); + lzma_next_end(::core::ptr::addr_of_mut!(block_decoder), allocator); ret } diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 23f9f976..ad2257c2 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; pub const HEADERS_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 + LZMA_CHECK_SIZE_MAX + 3 & !(3); extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { @@ -70,10 +69,10 @@ unsafe extern "C" fn block_encode_uncompressed( options: core::ptr::null_mut(), }; 2]; filters[0].id = LZMA_FILTER_LZMA2; - filters[0].options = &raw mut lzma2 as *mut c_void; + filters[0].options = ::core::ptr::addr_of_mut!(lzma2) as *mut c_void; filters[1].id = LZMA_VLI_UNKNOWN; let filters_orig: *mut lzma_filter = (*block).filters; - (*block).filters = &raw mut filters as *mut lzma_filter; + (*block).filters = ::core::ptr::addr_of_mut!(filters) as *mut lzma_filter; if lzma_block_header_size(block) != LZMA_OK { (*block).filters = filters_orig; return LZMA_PROG_ERROR; @@ -150,15 +149,18 @@ unsafe extern "C" fn block_encode_normal( update: None, set_out_limit: None, }; - let mut ret: lzma_ret = - lzma_raw_encoder_init(&raw mut raw_encoder, allocator, (*block).filters); + let mut ret: lzma_ret = lzma_raw_encoder_init( + ::core::ptr::addr_of_mut!(raw_encoder), + allocator, + (*block).filters, + ); if ret == LZMA_OK { let mut in_pos: size_t = 0; ret = raw_encoder.code.unwrap()( raw_encoder.coder, allocator, in_0, - &raw mut in_pos, + ::core::ptr::addr_of_mut!(in_pos), in_size, out, out_pos, @@ -166,7 +168,7 @@ unsafe extern "C" fn block_encode_normal( LZMA_FINISH, ); } - lzma_next_end(&raw mut raw_encoder, allocator); + lzma_next_end(::core::ptr::addr_of_mut!(raw_encoder), allocator); if ret == LZMA_STREAM_END { (*block).compressed_size = (*out_pos) .wrapping_sub(out_start.wrapping_add((*block).header_size as size_t)) @@ -246,16 +248,21 @@ unsafe extern "C" fn block_buffer_encode( buffer: lzma_check_state_buffer { u8_0: [0; 64] }, state: lzma_check_state_inner { crc32: 0 }, }; - lzma_check_init(&raw mut check, (*block).check); - lzma_check_update(&raw mut check, (*block).check, in_0, in_size); - lzma_check_finish(&raw mut check, (*block).check); + lzma_check_init(::core::ptr::addr_of_mut!(check), (*block).check); + lzma_check_update( + ::core::ptr::addr_of_mut!(check), + (*block).check, + in_0, + in_size, + ); + lzma_check_finish(::core::ptr::addr_of_mut!(check), (*block).check); core::ptr::copy_nonoverlapping( - &raw mut check.buffer.u8_0 as *const u8, - &raw mut (*block).raw_check as *mut u8, + ::core::ptr::addr_of_mut!(check.buffer.u8_0) as *const u8, + ::core::ptr::addr_of_mut!((*block).raw_check) as *mut u8, check_size, ); core::ptr::copy_nonoverlapping( - &raw mut check.buffer.u8_0 as *const u8, + ::core::ptr::addr_of_mut!(check.buffer.u8_0) as *const u8, out.offset(*out_pos as isize) as *mut u8, check_size, ); diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 89371e76..9e52f7cb 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block_coder { @@ -34,157 +33,145 @@ unsafe extern "C" fn block_decode( action: lzma_action, ) -> lzma_ret { let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; - 's_177: { - let current_block_40: u64; - match (*coder).sequence { - 0 => { - let in_start: size_t = *in_pos; - let out_start: size_t = *out_pos; - let in_stop: size_t = (*in_pos).wrapping_add( - (if (in_size.wrapping_sub(*in_pos) as lzma_vli) - < (*coder) - .compressed_limit - .wrapping_sub((*coder).compressed_size) - { - in_size.wrapping_sub(*in_pos) as lzma_vli - } else { - (*coder) - .compressed_limit - .wrapping_sub((*coder).compressed_size) - }) as size_t, - ); - let out_stop: size_t = (*out_pos).wrapping_add( - (if (out_size.wrapping_sub(*out_pos) as lzma_vli) - < (*coder) - .uncompressed_limit - .wrapping_sub((*coder).uncompressed_size) - { - out_size.wrapping_sub(*out_pos) as lzma_vli - } else { - (*coder) - .uncompressed_limit - .wrapping_sub((*coder).uncompressed_size) - }) as size_t, - ); - let ret: lzma_ret = (*coder).next.code.unwrap()( - (*coder).next.coder, - allocator, - in_0, - in_pos, - in_stop, - out, - out_pos, - out_stop, - action, - ); - let in_used: size_t = (*in_pos).wrapping_sub(in_start); - let out_used: size_t = (*out_pos).wrapping_sub(out_start); - (*coder).compressed_size = - (*coder).compressed_size.wrapping_add(in_used as lzma_vli); - (*coder).uncompressed_size = (*coder) - .uncompressed_size - .wrapping_add(out_used as lzma_vli); - if ret == LZMA_OK { - let comp_done: bool = - (*coder).compressed_size == (*(*coder).block).compressed_size; - let uncomp_done: bool = - (*coder).uncompressed_size == (*(*coder).block).uncompressed_size; - if comp_done && uncomp_done { - return LZMA_DATA_ERROR; - } - if comp_done && *out_pos < out_size { - return LZMA_DATA_ERROR; - } - if uncomp_done && *in_pos < in_size { - return LZMA_DATA_ERROR; - } - } - if !(*coder).ignore_check && out_used > 0 { - lzma_check_update( - &raw mut (*coder).check, - (*(*coder).block).check, - out.offset(out_start as isize), - out_used, - ); + let current_block_40: u64 = match (*coder).sequence { + 0 => { + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + let in_stop: size_t = (*in_pos).wrapping_add( + (if (in_size.wrapping_sub(*in_pos) as lzma_vli) + < (*coder) + .compressed_limit + .wrapping_sub((*coder).compressed_size) + { + in_size.wrapping_sub(*in_pos) as lzma_vli + } else { + (*coder) + .compressed_limit + .wrapping_sub((*coder).compressed_size) + }) as size_t, + ); + let out_stop: size_t = (*out_pos).wrapping_add( + (if (out_size.wrapping_sub(*out_pos) as lzma_vli) + < (*coder) + .uncompressed_limit + .wrapping_sub((*coder).uncompressed_size) + { + out_size.wrapping_sub(*out_pos) as lzma_vli + } else { + (*coder) + .uncompressed_limit + .wrapping_sub((*coder).uncompressed_size) + }) as size_t, + ); + let ret: lzma_ret = (*coder).next.code.unwrap()( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_stop, + out, + out_pos, + out_stop, + action, + ); + let in_used: size_t = (*in_pos).wrapping_sub(in_start); + let out_used: size_t = (*out_pos).wrapping_sub(out_start); + (*coder).compressed_size = (*coder).compressed_size.wrapping_add(in_used as lzma_vli); + (*coder).uncompressed_size = (*coder) + .uncompressed_size + .wrapping_add(out_used as lzma_vli); + if ret == LZMA_OK { + let comp_done: bool = (*coder).compressed_size == (*(*coder).block).compressed_size; + let uncomp_done: bool = + (*coder).uncompressed_size == (*(*coder).block).uncompressed_size; + if comp_done && uncomp_done { + return LZMA_DATA_ERROR; } - if ret != LZMA_STREAM_END { - return ret; + if comp_done && *out_pos < out_size { + return LZMA_DATA_ERROR; } - if !is_size_valid((*coder).compressed_size, (*(*coder).block).compressed_size) - || !is_size_valid( - (*coder).uncompressed_size, - (*(*coder).block).uncompressed_size, - ) - { + if uncomp_done && *in_pos < in_size { return LZMA_DATA_ERROR; } - (*(*coder).block).compressed_size = (*coder).compressed_size; - (*(*coder).block).uncompressed_size = (*coder).uncompressed_size; - (*coder).sequence = SEQ_PADDING; - current_block_40 = 17473121293339793080; } - 1 => { - current_block_40 = 17473121293339793080; + if !(*coder).ignore_check && out_used > 0 { + lzma_check_update( + ::core::ptr::addr_of_mut!((*coder).check), + (*(*coder).block).check, + out.offset(out_start as isize), + out_used, + ); } - 2 => { - current_block_40 = 9393557385011460022; + if ret != LZMA_STREAM_END { + return ret; } - _ => { - break 's_177; + if !is_size_valid((*coder).compressed_size, (*(*coder).block).compressed_size) + || !is_size_valid( + (*coder).uncompressed_size, + (*(*coder).block).uncompressed_size, + ) + { + return LZMA_DATA_ERROR; } + (*(*coder).block).compressed_size = (*coder).compressed_size; + (*(*coder).block).uncompressed_size = (*coder).uncompressed_size; + (*coder).sequence = SEQ_PADDING; + 17473121293339793080 } - match current_block_40 { - 17473121293339793080 => { - while (*coder).compressed_size & 3 != 0 { - if *in_pos >= in_size { - return LZMA_OK; - } - (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); - let byte = *in_0.offset(*in_pos as isize); - *in_pos += 1; - if byte != 0 { - return LZMA_DATA_ERROR; - } - } - if (*(*coder).block).check == LZMA_CHECK_NONE { - return LZMA_STREAM_END; - } - if !(*coder).ignore_check { - lzma_check_finish(&raw mut (*coder).check, (*(*coder).block).check); - } - (*coder).sequence = SEQ_CHECK; + 1 => 17473121293339793080, + 2 => 9393557385011460022, + _ => return LZMA_PROG_ERROR, + }; + if current_block_40 == 17473121293339793080 { + while (*coder).compressed_size & 3 != 0 { + if *in_pos >= in_size { + return LZMA_OK; + } + (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); + let byte = *in_0.offset(*in_pos as isize); + *in_pos += 1; + if byte != 0 { + return LZMA_DATA_ERROR; } - _ => {} } - let check_size: size_t = lzma_check_size((*(*coder).block).check) as size_t; - lzma_bufcpy( - in_0, - in_pos, - in_size, - &raw mut (*(*coder).block).raw_check as *mut u8, - &raw mut (*coder).check_pos, - check_size, - ); - if (*coder).check_pos < check_size { - return LZMA_OK; + if (*(*coder).block).check == LZMA_CHECK_NONE { + return LZMA_STREAM_END; } - if !(*coder).ignore_check - && lzma_check_is_supported((*(*coder).block).check) != 0 - && memcmp( - &raw mut (*(*coder).block).raw_check as *const c_void, - &raw mut (*coder).check.buffer.u8_0 as *const c_void, - check_size, - ) != 0 - { - return LZMA_DATA_ERROR; + if !(*coder).ignore_check { + lzma_check_finish( + ::core::ptr::addr_of_mut!((*coder).check), + (*(*coder).block).check, + ); } - return LZMA_STREAM_END; + (*coder).sequence = SEQ_CHECK; + } + let check_size: size_t = lzma_check_size((*(*coder).block).check) as size_t; + lzma_bufcpy( + in_0, + in_pos, + in_size, + ::core::ptr::addr_of_mut!((*(*coder).block).raw_check) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).check_pos), + check_size, + ); + if (*coder).check_pos < check_size { + return LZMA_OK; + } + if !(*coder).ignore_check + && lzma_check_is_supported((*(*coder).block).check) != 0 + && memcmp( + ::core::ptr::addr_of_mut!((*(*coder).block).raw_check) as *const c_void, + ::core::ptr::addr_of_mut!((*coder).check.buffer.u8_0) as *const c_void, + check_size, + ) != 0 + { + return LZMA_DATA_ERROR; } - LZMA_PROG_ERROR + LZMA_STREAM_END } unsafe extern "C" fn block_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free(coder as *mut c_void, allocator); } #[no_mangle] @@ -291,13 +278,17 @@ pub unsafe extern "C" fn lzma_block_decoder_init( (*block).uncompressed_size }; (*coder).check_pos = 0; - lzma_check_init(&raw mut (*coder).check, (*block).check); + lzma_check_init(::core::ptr::addr_of_mut!((*coder).check), (*block).check); (*coder).ignore_check = if (*block).version >= 1 { (*block).ignore_check != 0 } else { false }; - lzma_raw_decoder_init(&raw mut (*coder).next, allocator, (*block).filters) + lzma_raw_decoder_init( + ::core::ptr::addr_of_mut!((*coder).next), + allocator, + (*block).filters, + ) } #[no_mangle] pub unsafe extern "C" fn lzma_block_decoder( @@ -308,8 +299,11 @@ pub unsafe extern "C" fn lzma_block_decoder( if ret_ != LZMA_OK { return ret_; } - let ret__0: lzma_ret = - lzma_block_decoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block); + let ret__0: lzma_ret = lzma_block_decoder_init( + ::core::ptr::addr_of_mut!((*(*strm).internal).next), + (*strm).allocator, + block, + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 9d0f2651..41c85d90 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block_coder { @@ -32,102 +31,89 @@ unsafe extern "C" fn block_encode( { return LZMA_DATA_ERROR; } - 's_142: { - let current_block_34: u64; - match (*coder).sequence { - 0 => { - let in_start: size_t = *in_pos; - let out_start: size_t = *out_pos; - let ret: lzma_ret = (*coder).next.code.unwrap()( - (*coder).next.coder, - allocator, - in_0, - in_pos, - in_size, - out, - out_pos, - out_size, - action, - ); - let in_used: size_t = (*in_pos).wrapping_sub(in_start); - let out_used: size_t = (*out_pos).wrapping_sub(out_start); - if (COMPRESSED_SIZE_MAX).wrapping_sub((*coder).compressed_size) - < out_used as lzma_vli - { - return LZMA_DATA_ERROR; - } - (*coder).compressed_size = - (*coder).compressed_size.wrapping_add(out_used as lzma_vli); - (*coder).uncompressed_size = - (*coder).uncompressed_size.wrapping_add(in_used as lzma_vli); - if in_used > 0 { - lzma_check_update( - &raw mut (*coder).check, - (*(*coder).block).check, - in_0.offset(in_start as isize), - in_used, - ); - } - if ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH { - return ret; - } - (*(*coder).block).compressed_size = (*coder).compressed_size; - (*(*coder).block).uncompressed_size = (*coder).uncompressed_size; - (*coder).sequence = SEQ_PADDING; - current_block_34 = 6470892831169497455; - } - 1 => { - current_block_34 = 6470892831169497455; + let current_block_34: u64 = match (*coder).sequence { + 0 => { + let in_start: size_t = *in_pos; + let out_start: size_t = *out_pos; + let ret: lzma_ret = (*coder).next.code.unwrap()( + (*coder).next.coder, + allocator, + in_0, + in_pos, + in_size, + out, + out_pos, + out_size, + action, + ); + let in_used: size_t = (*in_pos).wrapping_sub(in_start); + let out_used: size_t = (*out_pos).wrapping_sub(out_start); + if (COMPRESSED_SIZE_MAX).wrapping_sub((*coder).compressed_size) < out_used as lzma_vli { + return LZMA_DATA_ERROR; } - 2 => { - current_block_34 = 47327340716975230; + (*coder).compressed_size = (*coder).compressed_size.wrapping_add(out_used as lzma_vli); + (*coder).uncompressed_size = + (*coder).uncompressed_size.wrapping_add(in_used as lzma_vli); + if in_used > 0 { + lzma_check_update( + ::core::ptr::addr_of_mut!((*coder).check), + (*(*coder).block).check, + in_0.offset(in_start as isize), + in_used, + ); } - _ => { - break 's_142; + if ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH { + return ret; } + (*(*coder).block).compressed_size = (*coder).compressed_size; + (*(*coder).block).uncompressed_size = (*coder).uncompressed_size; + (*coder).sequence = SEQ_PADDING; + 6470892831169497455 } - match current_block_34 { - 6470892831169497455 => { - while (*coder).compressed_size & 3 != 0 { - if *out_pos >= out_size { - return LZMA_OK; - } - *out.offset(*out_pos as isize) = 0; - *out_pos = (*out_pos).wrapping_add(1); - (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); - } - if (*(*coder).block).check == LZMA_CHECK_NONE { - return LZMA_STREAM_END; - } - lzma_check_finish(&raw mut (*coder).check, (*(*coder).block).check); - (*coder).sequence = SEQ_CHECK; + 1 => 6470892831169497455, + 2 => 47327340716975230, + _ => return LZMA_PROG_ERROR, + }; + if current_block_34 == 6470892831169497455 { + while (*coder).compressed_size & 3 != 0 { + if *out_pos >= out_size { + return LZMA_OK; } - _ => {} + *out.offset(*out_pos as isize) = 0; + *out_pos = (*out_pos).wrapping_add(1); + (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); } - let check_size: size_t = lzma_check_size((*(*coder).block).check) as size_t; - lzma_bufcpy( - &raw mut (*coder).check.buffer.u8_0 as *mut u8, - &raw mut (*coder).pos, - check_size, - out, - out_pos, - out_size, - ); - if (*coder).pos < check_size { - return LZMA_OK; + if (*(*coder).block).check == LZMA_CHECK_NONE { + return LZMA_STREAM_END; } - core::ptr::copy_nonoverlapping( - &raw mut (*coder).check.buffer.u8_0 as *const u8, - &raw mut (*(*coder).block).raw_check as *mut u8, - check_size, + lzma_check_finish( + ::core::ptr::addr_of_mut!((*coder).check), + (*(*coder).block).check, ); - return LZMA_STREAM_END; + (*coder).sequence = SEQ_CHECK; + } + let check_size: size_t = lzma_check_size((*(*coder).block).check) as size_t; + lzma_bufcpy( + ::core::ptr::addr_of_mut!((*coder).check.buffer.u8_0) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), + check_size, + out, + out_pos, + out_size, + ); + if (*coder).pos < check_size { + return LZMA_OK; } - LZMA_PROG_ERROR + core::ptr::copy_nonoverlapping( + ::core::ptr::addr_of_mut!((*coder).check.buffer.u8_0) as *const u8, + ::core::ptr::addr_of_mut!((*(*coder).block).raw_check) as *mut u8, + check_size, + ); + LZMA_STREAM_END } unsafe extern "C" fn block_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn block_encoder_update( @@ -140,7 +126,11 @@ unsafe extern "C" fn block_encoder_update( if (*coder).sequence != SEQ_CODE { return LZMA_PROG_ERROR; } - lzma_next_filter_update(&raw mut (*coder).next, allocator, reversed_filters) + lzma_next_filter_update( + ::core::ptr::addr_of_mut!((*coder).next), + allocator, + reversed_filters, + ) } #[no_mangle] pub unsafe extern "C" fn lzma_block_encoder_init( @@ -249,8 +239,12 @@ pub unsafe extern "C" fn lzma_block_encoder_init( (*coder).compressed_size = 0; (*coder).uncompressed_size = 0; (*coder).pos = 0; - lzma_check_init(&raw mut (*coder).check, (*block).check); - lzma_raw_encoder_init(&raw mut (*coder).next, allocator, (*block).filters) + lzma_check_init(::core::ptr::addr_of_mut!((*coder).check), (*block).check); + lzma_raw_encoder_init( + ::core::ptr::addr_of_mut!((*coder).next), + allocator, + (*block).filters, + ) } #[no_mangle] pub unsafe extern "C" fn lzma_block_encoder( @@ -261,8 +255,11 @@ pub unsafe extern "C" fn lzma_block_encoder( if ret_ != LZMA_OK { return ret_; } - let ret__0: lzma_ret = - lzma_block_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, block); + let ret__0: lzma_ret = lzma_block_encoder_init( + ::core::ptr::addr_of_mut!((*(*strm).internal).next), + (*strm).allocator, + block, + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index ad34c3ee..cf0929fe 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -42,10 +42,10 @@ pub unsafe extern "C" fn lzma_block_header_decode( let mut in_pos: size_t = 2; if *in_0.offset(1) & 0x40 != 0 { let ret_: lzma_ret = lzma_vli_decode( - &raw mut (*block).compressed_size, + ::core::ptr::addr_of_mut!((*block).compressed_size), core::ptr::null_mut(), in_0, - &raw mut in_pos, + ::core::ptr::addr_of_mut!(in_pos), in_size, ); if ret_ != LZMA_OK { @@ -59,10 +59,10 @@ pub unsafe extern "C" fn lzma_block_header_decode( } if *in_0.offset(1) & 0x80 != 0 { let ret__0: lzma_ret = lzma_vli_decode( - &raw mut (*block).uncompressed_size, + ::core::ptr::addr_of_mut!((*block).uncompressed_size), core::ptr::null_mut(), in_0, - &raw mut in_pos, + ::core::ptr::addr_of_mut!(in_pos), in_size, ); if ret__0 != LZMA_OK { @@ -78,7 +78,7 @@ pub unsafe extern "C" fn lzma_block_header_decode( (*block).filters.offset(i_0 as isize) as *mut lzma_filter, allocator, in_0, - &raw mut in_pos, + ::core::ptr::addr_of_mut!(in_pos), in_size, ); if ret != LZMA_OK { diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index b452031f..6a032d54 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -37,8 +37,10 @@ pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ return LZMA_PROG_ERROR; } let mut add_1: u32 = 0; - let ret_: lzma_ret = - lzma_filter_flags_size(&raw mut add_1, (*block).filters.offset(i as isize)); + let ret_: lzma_ret = lzma_filter_flags_size( + ::core::ptr::addr_of_mut!(add_1), + (*block).filters.offset(i as isize), + ); if ret_ != LZMA_OK { return ret_; } @@ -68,7 +70,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( (*block).compressed_size, core::ptr::null_mut(), out, - &raw mut out_pos, + ::core::ptr::addr_of_mut!(out_pos), out_size, ); if ret_ != LZMA_OK { @@ -81,7 +83,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( (*block).uncompressed_size, core::ptr::null_mut(), out, - &raw mut out_pos, + ::core::ptr::addr_of_mut!(out_pos), out_size, ); if ret__0 != LZMA_OK { @@ -100,7 +102,7 @@ pub unsafe extern "C" fn lzma_block_header_encode( let ret__1: lzma_ret = lzma_filter_flags_encode( (*block).filters.offset(filter_count as isize), out, - &raw mut out_pos, + ::core::ptr::addr_of_mut!(out_pos), out_size, ); if ret__1 != LZMA_OK { diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index 5eac54cb..b59cbe15 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -1,10 +1,66 @@ use crate::types::*; -use core::ffi::{c_char, c_uint, c_void}; +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +use std::alloc::{alloc, alloc_zeroed, dealloc, Layout}; + +#[cfg(not(all(target_family = "wasm", target_os = "unknown")))] extern "C" { fn malloc(__size: size_t) -> *mut c_void; fn calloc(__count: size_t, __size: size_t) -> *mut c_void; fn free(_: *mut c_void); } + +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +const LZMA_ALLOC_ALIGN: usize = 16; +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +const LZMA_ALLOC_HEADER_SIZE: usize = 16; + +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +unsafe fn wasm_alloc_layout(size: size_t) -> Option { + let total_size = (size as usize).checked_add(LZMA_ALLOC_HEADER_SIZE)?; + Layout::from_size_align(total_size, LZMA_ALLOC_ALIGN).ok() +} + +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +unsafe fn malloc(size: size_t) -> *mut c_void { + let Some(layout) = wasm_alloc_layout(size) else { + return core::ptr::null_mut(); + }; + let ptr = alloc(layout); + if ptr.is_null() { + return core::ptr::null_mut(); + } + *(ptr as *mut usize) = layout.size(); + ptr.add(LZMA_ALLOC_HEADER_SIZE) as *mut c_void +} + +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +unsafe fn calloc(count: size_t, size: size_t) -> *mut c_void { + let Some(total_size) = (count as usize).checked_mul(size as usize) else { + return core::ptr::null_mut(); + }; + let Some(layout) = wasm_alloc_layout(total_size as size_t) else { + return core::ptr::null_mut(); + }; + let ptr = alloc_zeroed(layout); + if ptr.is_null() { + return core::ptr::null_mut(); + } + *(ptr as *mut usize) = layout.size(); + ptr.add(LZMA_ALLOC_HEADER_SIZE) as *mut c_void +} + +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +unsafe fn free(ptr: *mut c_void) { + if ptr.is_null() { + return; + } + let base = (ptr as *mut u8).sub(LZMA_ALLOC_HEADER_SIZE); + let total_size = *(base as *const usize); + let Ok(layout) = Layout::from_size_align(total_size, LZMA_ALLOC_ALIGN) else { + return; + }; + dealloc(base, layout); +} pub const LZMA_VERSION_MAJOR: u32 = 5; pub const LZMA_VERSION_MINOR: u32 = 8; pub const LZMA_VERSION_PATCH: u32 = 2; @@ -20,7 +76,7 @@ pub extern "C" fn lzma_version_number() -> u32 { LZMA_VERSION as u32 } pub extern "C" fn lzma_version_string() -> *const c_char { - c"5.8.2".as_ptr() + crate::c_str!("5.8.2") } #[no_mangle] pub unsafe extern "C" fn lzma_alloc( @@ -178,7 +234,7 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { }; } core::ptr::write_bytes( - &raw mut (*(*strm).internal).supported_actions as *mut u8, + ::core::ptr::addr_of_mut!((*(*strm).internal).supported_actions) as *mut u8, 0 as u8, core::mem::size_of::<[bool; 5]>(), ); @@ -255,10 +311,10 @@ pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) (*(*strm).internal).next.coder, (*strm).allocator, (*strm).next_in, - &raw mut in_pos, + ::core::ptr::addr_of_mut!(in_pos), (*strm).avail_in, (*strm).next_out, - &raw mut out_pos, + ::core::ptr::addr_of_mut!(out_pos), (*strm).avail_out, action, ); @@ -328,7 +384,10 @@ pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) } pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { if !strm.is_null() && !(*strm).internal.is_null() { - lzma_next_end(&raw mut (*(*strm).internal).next, (*strm).allocator); + lzma_next_end( + ::core::ptr::addr_of_mut!((*(*strm).internal).next), + (*strm).allocator, + ); lzma_free((*strm).internal as *mut c_void, (*strm).allocator); (*strm).internal = core::ptr::null_mut(); } @@ -366,8 +425,8 @@ pub extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { || (*(*strm).internal).next.memconfig.is_none() || (*(*strm).internal).next.memconfig.unwrap()( (*(*strm).internal).next.coder, - &raw mut memusage, - &raw mut old_memlimit, + ::core::ptr::addr_of_mut!(memusage), + ::core::ptr::addr_of_mut!(old_memlimit), 0, ) != LZMA_OK { @@ -385,8 +444,8 @@ pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { || (*(*strm).internal).next.memconfig.is_none() || (*(*strm).internal).next.memconfig.unwrap()( (*(*strm).internal).next.coder, - &raw mut memusage, - &raw mut old_memlimit, + ::core::ptr::addr_of_mut!(memusage), + ::core::ptr::addr_of_mut!(old_memlimit), 0, ) != LZMA_OK { @@ -410,8 +469,8 @@ pub unsafe extern "C" fn lzma_memlimit_set( } (*(*strm).internal).next.memconfig.unwrap()( (*(*strm).internal).next.coder, - &raw mut memusage, - &raw mut old_memlimit, + ::core::ptr::addr_of_mut!(memusage), + ::core::ptr::addr_of_mut!(old_memlimit), new_memlimit, ) } diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 84bb6a74..457c734d 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -53,11 +53,11 @@ pub unsafe extern "C" fn lzma_easy_buffer_encode( reserved_ptr2: core::ptr::null_mut(), }, }; - if lzma_easy_preset(&raw mut opt_easy, preset) { + if lzma_easy_preset(::core::ptr::addr_of_mut!(opt_easy), preset) { return LZMA_OPTIONS_ERROR; } lzma_stream_buffer_encode( - &raw mut opt_easy.filters as *mut lzma_filter, + ::core::ptr::addr_of_mut!(opt_easy.filters) as *mut lzma_filter, check, allocator, in_0, diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index 6dd7c0c6..c28b952f 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -32,8 +32,10 @@ pub extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { reserved_ptr2: core::ptr::null_mut(), }, }; - if unsafe { lzma_easy_preset(&raw mut opt_easy, preset) } { + if unsafe { lzma_easy_preset(::core::ptr::addr_of_mut!(opt_easy), preset) } { return UINT32_MAX as u64; } - unsafe { lzma_raw_decoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter) } + unsafe { + lzma_raw_decoder_memusage(::core::ptr::addr_of_mut!(opt_easy.filters) as *mut lzma_filter) + } } diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index 1a8fb73e..4c2a0a17 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -43,8 +43,12 @@ pub unsafe extern "C" fn lzma_easy_encoder( reserved_ptr2: core::ptr::null_mut(), }, }; - if lzma_easy_preset(&raw mut opt_easy, preset) { + if lzma_easy_preset(::core::ptr::addr_of_mut!(opt_easy), preset) { return LZMA_OPTIONS_ERROR; } - lzma_stream_encoder(strm, &raw mut opt_easy.filters as *mut lzma_filter, check) + lzma_stream_encoder( + strm, + ::core::ptr::addr_of_mut!(opt_easy.filters) as *mut lzma_filter, + check, + ) } diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index e67c1f3d..06b0d369 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -32,8 +32,10 @@ pub extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { reserved_ptr2: core::ptr::null_mut(), }, }; - if unsafe { lzma_easy_preset(&raw mut opt_easy, preset) } { + if unsafe { lzma_easy_preset(::core::ptr::addr_of_mut!(opt_easy), preset) } { return UINT32_MAX as u64; } - unsafe { lzma_raw_encoder_memusage(&raw mut opt_easy.filters as *mut lzma_filter) } + unsafe { + lzma_raw_encoder_memusage(::core::ptr::addr_of_mut!(opt_easy.filters) as *mut lzma_filter) + } } diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index 01a7447b..8bb9c2fe 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -1,12 +1,11 @@ use crate::types::*; -use core::ffi::c_void; #[no_mangle] pub unsafe extern "C" fn lzma_easy_preset(opt_easy: *mut lzma_options_easy, preset: u32) -> bool { - if lzma_lzma_preset(&raw mut (*opt_easy).opt_lzma, preset) != 0 { + if lzma_lzma_preset(::core::ptr::addr_of_mut!((*opt_easy).opt_lzma), preset) != 0 { return true; } (*opt_easy).filters[0].id = LZMA_FILTER_LZMA2; - (*opt_easy).filters[0].options = &raw mut (*opt_easy).opt_lzma as *mut c_void; + (*opt_easy).filters[0].options = ::core::ptr::addr_of_mut!((*opt_easy).opt_lzma) as *mut c_void; (*opt_easy).filters[1].id = LZMA_VLI_UNKNOWN; false } diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 39307b5c..e83d1f9a 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_index_memused(i: *const lzma_index) -> u64; fn lzma_index_stream_flags( @@ -61,8 +60,8 @@ unsafe extern "C" fn fill_temp( in_0, in_pos, in_size, - &raw mut (*coder).temp as *mut u8, - &raw mut (*coder).temp_pos, + ::core::ptr::addr_of_mut!((*coder).temp) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).temp_pos), (*coder).temp_size, ) as u64); (*coder).temp_pos < (*coder).temp_size @@ -202,8 +201,8 @@ unsafe extern "C" fn file_info_decode( return LZMA_OK; } let ret_: lzma_ret = lzma_stream_header_decode( - &raw mut (*coder).first_header_flags, - &raw mut (*coder).temp as *mut u8, + ::core::ptr::addr_of_mut!((*coder).first_header_flags), + ::core::ptr::addr_of_mut!((*coder).temp) as *mut u8, ); if ret_ != LZMA_OK { return ret_; @@ -253,9 +252,10 @@ unsafe extern "C" fn file_info_decode( if fill_temp(coder, in_0, in_pos, in_size) { return LZMA_OK; } - let new_padding: size_t = - get_padding_size(&raw mut (*coder).temp as *mut u8, (*coder).temp_size) - as size_t; + let new_padding: size_t = get_padding_size( + ::core::ptr::addr_of_mut!((*coder).temp) as *mut u8, + (*coder).temp_size, + ) as size_t; (*coder).stream_padding = (*coder) .stream_padding .wrapping_add(new_padding as lzma_vli); @@ -294,8 +294,9 @@ unsafe extern "C" fn file_info_decode( .temp_size .wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); let ret__2: lzma_ret = hide_format_error(lzma_stream_footer_decode( - &raw mut (*coder).footer_flags, - (&raw mut (*coder).temp as *mut u8).offset((*coder).temp_size as isize), + ::core::ptr::addr_of_mut!((*coder).footer_flags), + (::core::ptr::addr_of_mut!((*coder).temp) as *mut u8) + .offset((*coder).temp_size as isize), )); if ret__2 != LZMA_OK { return ret__2; @@ -337,9 +338,9 @@ unsafe extern "C" fn file_info_decode( } } let ret__3: lzma_ret = lzma_index_decoder_init( - &raw mut (*coder).index_decoder, + ::core::ptr::addr_of_mut!((*coder).index_decoder), allocator, - &raw mut (*coder).this_index, + ::core::ptr::addr_of_mut!((*coder).this_index), (*coder).memlimit.wrapping_sub(memused), ); if ret__3 != LZMA_OK { @@ -358,8 +359,8 @@ unsafe extern "C" fn file_info_decode( ret = decode_index( coder, allocator, - &raw mut (*coder).temp as *mut u8, - &raw mut (*coder).temp_pos, + ::core::ptr::addr_of_mut!((*coder).temp) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).temp_pos), (*coder).temp_size, false, ); @@ -434,8 +435,9 @@ unsafe extern "C" fn file_info_decode( .wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); (*coder).temp_pos = (*coder).temp_size; let ret__5: lzma_ret = hide_format_error(lzma_stream_header_decode( - &raw mut (*coder).header_flags, - (&raw mut (*coder).temp as *mut u8).offset((*coder).temp_size as isize), + ::core::ptr::addr_of_mut!((*coder).header_flags), + (::core::ptr::addr_of_mut!((*coder).temp) as *mut u8) + .offset((*coder).temp_size as isize), )); if ret__5 != LZMA_OK { return ret__5; @@ -448,14 +450,16 @@ unsafe extern "C" fn file_info_decode( match current_block_142 { 6010056518000876263 => { let ret__6: lzma_ret = lzma_stream_flags_compare( - &raw mut (*coder).header_flags, - &raw mut (*coder).footer_flags, + ::core::ptr::addr_of_mut!((*coder).header_flags), + ::core::ptr::addr_of_mut!((*coder).footer_flags), ); if ret__6 != LZMA_OK { return ret__6; } - if lzma_index_stream_flags((*coder).this_index, &raw mut (*coder).footer_flags) - != LZMA_OK + if lzma_index_stream_flags( + (*coder).this_index, + ::core::ptr::addr_of_mut!((*coder).footer_flags), + ) != LZMA_OK { return LZMA_PROG_ERROR; } @@ -508,8 +512,8 @@ unsafe extern "C" fn file_info_decoder_memconfig( let mut dummy: u64 = 0; if (*coder).index_decoder.memconfig.unwrap()( (*coder).index_decoder.coder, - &raw mut this_index_memusage, - &raw mut dummy, + ::core::ptr::addr_of_mut!(this_index_memusage), + ::core::ptr::addr_of_mut!(dummy), 0, ) != LZMA_OK { @@ -531,8 +535,8 @@ unsafe extern "C" fn file_info_decoder_memconfig( let mut dummy2: u64 = 0; if (*coder).index_decoder.memconfig.unwrap()( (*coder).index_decoder.coder, - &raw mut dummy1, - &raw mut dummy2, + ::core::ptr::addr_of_mut!(dummy1), + ::core::ptr::addr_of_mut!(dummy2), idec_new_memlimit, ) != LZMA_OK { @@ -548,7 +552,7 @@ unsafe extern "C" fn file_info_decoder_end( allocator: *const lzma_allocator, ) { let coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; - lzma_next_end(&raw mut (*coder).index_decoder, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).index_decoder), allocator); lzma_index_end((*coder).this_index, allocator); lzma_index_end((*coder).combined_index, allocator); lzma_free(coder as *mut c_void, allocator); @@ -685,9 +689,9 @@ pub unsafe extern "C" fn lzma_file_info_decoder( return ret_; } let ret__0: lzma_ret = lzma_file_info_decoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, - &raw mut (*strm).seek_pos, + ::core::ptr::addr_of_mut!((*strm).seek_pos), dest_index, memlimit, file_size, diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index 608c4ba8..6cdddee9 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -30,7 +30,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( update: None, set_out_limit: None, }; - let ret_: lzma_ret = lzma_raw_decoder_init(&raw mut next, allocator, filters); + let ret_: lzma_ret = lzma_raw_decoder_init(::core::ptr::addr_of_mut!(next), allocator, filters); if ret_ != LZMA_OK { return ret_; } @@ -64,8 +64,8 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( in_0, in_pos, in_size, - &raw mut tmp as *mut u8, - &raw mut tmp_pos, + ::core::ptr::addr_of_mut!(tmp) as *mut u8, + ::core::ptr::addr_of_mut!(tmp_pos), 1, LZMA_FINISH, ); @@ -79,6 +79,6 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( *in_pos = in_start; *out_pos = out_start; } - lzma_next_end(&raw mut next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!(next), allocator); ret } diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index 3623eb2f..dce2985a 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -23,7 +23,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( update: None, set_out_limit: None, }; - let ret_: lzma_ret = lzma_raw_encoder_init(&raw mut next, allocator, filters); + let ret_: lzma_ret = lzma_raw_encoder_init(::core::ptr::addr_of_mut!(next), allocator, filters); if ret_ != LZMA_OK { return ret_; } @@ -33,14 +33,14 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( next.coder, allocator, in_0, - &raw mut in_pos, + ::core::ptr::addr_of_mut!(in_pos), in_size, out, out_pos, out_size, LZMA_FINISH, ); - lzma_next_end(&raw mut next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!(next), allocator); if ret == LZMA_STREAM_END { ret = LZMA_OK; } else { diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 050b75e4..771ea8ff 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -170,7 +170,7 @@ pub unsafe extern "C" fn lzma_filters_copy( dest[i as usize].id = LZMA_VLI_UNKNOWN; dest[i as usize].options = core::ptr::null_mut(); core::ptr::copy_nonoverlapping( - &raw mut dest as *const u8, + ::core::ptr::addr_of_mut!(dest) as *const u8, real_dest as *mut u8, i.wrapping_add(1) .wrapping_mul(core::mem::size_of::()), @@ -246,7 +246,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( is_encoder: bool, ) -> lzma_ret { let mut count: size_t = 0; - let ret_: lzma_ret = lzma_validate_chain(options, &raw mut count); + let ret_: lzma_ret = lzma_validate_chain(options, ::core::ptr::addr_of_mut!(count)); if ret_ != LZMA_OK { return ret_; } @@ -285,8 +285,11 @@ pub unsafe extern "C" fn lzma_raw_coder_init( } filters[count as usize].id = LZMA_VLI_UNKNOWN; filters[count as usize].init = None; - let ret: lzma_ret = - lzma_next_filter_init(next, allocator, &raw mut filters as *mut lzma_filter_info); + let ret: lzma_ret = lzma_next_filter_init( + next, + allocator, + ::core::ptr::addr_of_mut!(filters) as *mut lzma_filter_info, + ); if ret != LZMA_OK { lzma_next_end(next, allocator); } @@ -298,7 +301,7 @@ pub unsafe extern "C" fn lzma_raw_coder_memusage( filters: *const lzma_filter, ) -> u64 { let mut tmp: size_t = 0; - if lzma_validate_chain(filters, &raw mut tmp) != LZMA_OK { + if lzma_validate_chain(filters, ::core::ptr::addr_of_mut!(tmp)) != LZMA_OK { return UINT64_MAX; } let mut total: u64 = 0; diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 14a8327d..982ccfc8 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64; fn lzma_lzma_props_decode( @@ -389,7 +388,7 @@ pub unsafe extern "C" fn lzma_raw_decoder( return ret_; } let ret__0: lzma_ret = lzma_raw_decoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, options, ); @@ -425,5 +424,10 @@ pub unsafe extern "C" fn lzma_properties_decode( LZMA_OPTIONS_ERROR }; } - (*fd).props_decode.unwrap()(&raw mut (*filter).options, allocator, props, props_size) + (*fd).props_decode.unwrap()( + ::core::ptr::addr_of_mut!((*filter).options), + allocator, + props, + props_size, + ) } diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index bc8af4e7..d3495838 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { fn lzma_lzma_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; fn lzma_lzma2_encoder_init( @@ -352,7 +351,7 @@ pub unsafe extern "C" fn lzma_filters_update( (*(*strm).internal).next.coder, (*strm).allocator, filters, - &raw mut reversed_filters as *mut lzma_filter, + ::core::ptr::addr_of_mut!(reversed_filters) as *mut lzma_filter, ) } #[no_mangle] @@ -378,7 +377,7 @@ pub unsafe extern "C" fn lzma_raw_encoder( return ret_; } let ret__0: lzma_ret = lzma_raw_coder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, filters, Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index a458f6a7..5df0d1ac 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -17,7 +17,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( ) -> lzma_ret { (*filter).options = core::ptr::null_mut(); let ret_: lzma_ret = lzma_vli_decode( - &raw mut (*filter).id, + ::core::ptr::addr_of_mut!((*filter).id), core::ptr::null_mut(), in_0, in_pos, @@ -31,7 +31,7 @@ pub unsafe extern "C" fn lzma_filter_flags_decode( } let mut props_size: lzma_vli = 0; let ret__0: lzma_ret = lzma_vli_decode( - &raw mut props_size, + ::core::ptr::addr_of_mut!(props_size), core::ptr::null_mut(), in_0, in_pos, diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index 110c639d..7c33235e 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -35,7 +35,7 @@ pub unsafe extern "C" fn lzma_filter_flags_encode( return ret_; } let mut props_size: u32 = 0; - let ret__0: lzma_ret = lzma_properties_size(&raw mut props_size, filter); + let ret__0: lzma_ret = lzma_properties_size(::core::ptr::addr_of_mut!(props_size), filter); if ret__0 != LZMA_OK { return ret__0; } diff --git a/liblzma-rs/src/common/hardware_cputhreads.rs b/liblzma-rs/src/common/hardware_cputhreads.rs index d095c552..58217f8d 100644 --- a/liblzma-rs/src/common/hardware_cputhreads.rs +++ b/liblzma-rs/src/common/hardware_cputhreads.rs @@ -1,5 +1,4 @@ use crate::tuklib::tuklib_cpucores::tuklib_cpucores; - pub extern "C" fn lzma_cputhreads() -> u32 { tuklib_cpucores() } diff --git a/liblzma-rs/src/common/hardware_physmem.rs b/liblzma-rs/src/common/hardware_physmem.rs index bc925a16..44e8815c 100644 --- a/liblzma-rs/src/common/hardware_physmem.rs +++ b/liblzma-rs/src/common/hardware_physmem.rs @@ -1,5 +1,4 @@ use crate::tuklib::tuklib_physmem::tuklib_physmem; - pub extern "C" fn lzma_physmem() -> u64 { tuklib_physmem() } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 33f3e136..f3bf95ad 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_s { @@ -199,7 +198,7 @@ unsafe extern "C" fn index_stream_init( (*s).node.right = core::ptr::null_mut(); (*s).number = stream_number; (*s).block_number_base = block_number_base; - index_tree_init(&raw mut (*s).groups); + index_tree_init(::core::ptr::addr_of_mut!((*s).groups)); (*s).record_count = 0; (*s).index_list_size = 0; (*s).stream_flags.version = UINT32_MAX; @@ -209,7 +208,7 @@ unsafe extern "C" fn index_stream_init( unsafe extern "C" fn index_stream_end(node: *mut c_void, allocator: *const lzma_allocator) { let s: *mut index_stream = node as *mut index_stream; index_tree_end( - &raw mut (*s).groups, + ::core::ptr::addr_of_mut!((*s).groups), allocator, Some(lzma_free as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> ()), ); @@ -219,7 +218,7 @@ unsafe extern "C" fn index_init_plain(allocator: *const lzma_allocator) -> *mut let i: *mut lzma_index = lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_index; if !i.is_null() { - index_tree_init(&raw mut (*i).streams); + index_tree_init(::core::ptr::addr_of_mut!((*i).streams)); (*i).uncompressed_size = 0; (*i).total_size = 0; (*i).record_count = 0; @@ -240,13 +239,16 @@ pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *m lzma_free(i as *mut c_void, allocator); return core::ptr::null_mut(); } - index_tree_append(&raw mut (*i).streams, &raw mut (*s).node); + index_tree_append( + ::core::ptr::addr_of_mut!((*i).streams), + ::core::ptr::addr_of_mut!((*s).node), + ); i } pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { if !i.is_null() { index_tree_end( - &raw mut (*i).streams, + ::core::ptr::addr_of_mut!((*i).streams), allocator, Some( index_stream_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), @@ -353,8 +355,9 @@ pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli if g.is_null() { 0 } else { - (*(&raw const (*g).records as *const index_record).offset((*g).last as isize)) - .unpadded_sum + (*(::core::ptr::addr_of!((*g).records) as *const index_record) + .offset((*g).last as isize)) + .unpadded_sum }, (*s).record_count, (*s).index_list_size, @@ -431,13 +434,16 @@ pub unsafe extern "C" fn lzma_index_append( 0 } else { vli_ceil4( - (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).unpadded_sum, + (*(::core::ptr::addr_of_mut!((*g).records) as *mut index_record) + .offset((*g).last as isize)) + .unpadded_sum, ) as lzma_vli }; let uncompressed_base: lzma_vli = if g.is_null() { 0 } else { - (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).uncompressed_sum + (*(::core::ptr::addr_of_mut!((*g).records) as *mut index_record).offset((*g).last as isize)) + .uncompressed_sum }; let index_list_size_add: u32 = (lzma_vli_size(unpadded_size) as u32).wrapping_add(lzma_vli_size(uncompressed_size) as u32); @@ -485,12 +491,15 @@ pub unsafe extern "C" fn lzma_index_append( (*g).node.uncompressed_base = uncompressed_base; (*g).node.compressed_base = compressed_base; (*g).number_base = (*s).record_count.wrapping_add(1); - index_tree_append(&raw mut (*s).groups, &raw mut (*g).node); + index_tree_append( + ::core::ptr::addr_of_mut!((*s).groups), + ::core::ptr::addr_of_mut!((*g).node), + ); } - (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).uncompressed_sum = - uncompressed_base.wrapping_add(uncompressed_size); - (*(&raw mut (*g).records as *mut index_record).offset((*g).last as isize)).unpadded_sum = - compressed_base.wrapping_add(unpadded_size); + (*(::core::ptr::addr_of_mut!((*g).records) as *mut index_record).offset((*g).last as isize)) + .uncompressed_sum = uncompressed_base.wrapping_add(uncompressed_size); + (*(::core::ptr::addr_of_mut!((*g).records) as *mut index_record).offset((*g).last as isize)) + .unpadded_sum = compressed_base.wrapping_add(unpadded_size); (*s).record_count = (*s).record_count.wrapping_add(1); (*s).index_list_size = (*s) .index_list_size @@ -518,7 +527,7 @@ unsafe extern "C" fn index_cat_helper(info: *const index_cat_info, this: *mut in (*this).block_number_base = (*this) .block_number_base .wrapping_add((*info).block_number_add); - index_tree_append((*info).streams, &raw mut (*this).node); + index_tree_append((*info).streams, ::core::ptr::addr_of_mut!((*this).node)); if !right.is_null() { index_cat_helper(info, right); } @@ -567,20 +576,20 @@ pub unsafe extern "C" fn lzma_index_cat( (*newg).last = (*g).last; (*newg).number_base = (*g).number_base; core::ptr::copy_nonoverlapping( - &raw mut (*g).records as *const u8, - &raw mut (*newg).records as *mut u8, + ::core::ptr::addr_of_mut!((*g).records) as *const u8, + ::core::ptr::addr_of_mut!((*newg).records) as *mut u8, (*newg) .allocated .wrapping_mul(core::mem::size_of::()), ); if !(*g).node.parent.is_null() { - (*(*g).node.parent).right = &raw mut (*newg).node; + (*(*g).node.parent).right = ::core::ptr::addr_of_mut!((*newg).node); } - if (*s).groups.leftmost == &raw mut (*g).node { - (*s).groups.leftmost = &raw mut (*newg).node; - (*s).groups.root = &raw mut (*newg).node; + if (*s).groups.leftmost == ::core::ptr::addr_of_mut!((*g).node) { + (*s).groups.leftmost = ::core::ptr::addr_of_mut!((*newg).node); + (*s).groups.root = ::core::ptr::addr_of_mut!((*newg).node); } - (*s).groups.rightmost = &raw mut (*newg).node; + (*s).groups.rightmost = ::core::ptr::addr_of_mut!((*newg).node); lzma_free(g as *mut c_void, allocator); } (*dest).checks = lzma_index_checks(dest); @@ -589,9 +598,12 @@ pub unsafe extern "C" fn lzma_index_cat( file_size: dest_file_size, block_number_add: (*dest).record_count, stream_number_add: (*dest).streams.count, - streams: &raw mut (*dest).streams, + streams: ::core::ptr::addr_of_mut!((*dest).streams), }; - index_cat_helper(&raw const info, (*src).streams.root as *mut index_stream); + index_cat_helper( + ::core::ptr::addr_of!(info), + (*src).streams.root as *mut index_stream, + ); (*dest).uncompressed_size = (*dest) .uncompressed_size .wrapping_add((*src).uncompressed_size); @@ -647,20 +659,24 @@ unsafe extern "C" fn index_dup_stream( let mut i: size_t = 0; loop { core::ptr::copy_nonoverlapping( - &raw const (*srcg).records as *const u8, - (&raw mut (*destg).records as *mut index_record).offset(i as isize) as *mut u8, + ::core::ptr::addr_of!((*srcg).records) as *const u8, + (::core::ptr::addr_of_mut!((*destg).records) as *mut index_record).offset(i as isize) + as *mut u8, (*srcg) .last .wrapping_add(1) .wrapping_mul(core::mem::size_of::()), ); i = i.wrapping_add((*srcg).last.wrapping_add(1)); - srcg = index_tree_next(&raw const (*srcg).node) as *const index_group; + srcg = index_tree_next(::core::ptr::addr_of!((*srcg).node)) as *const index_group; if srcg.is_null() { break; } } - index_tree_append(&raw mut (*dest).groups, &raw mut (*destg).node); + index_tree_append( + ::core::ptr::addr_of_mut!((*dest).groups), + ::core::ptr::addr_of_mut!((*destg).node), + ); dest } #[no_mangle] @@ -683,8 +699,12 @@ pub unsafe extern "C" fn lzma_index_dup( lzma_index_end(dest, allocator); return core::ptr::null_mut(); } - index_tree_append(&raw mut (*dest).streams, &raw mut (*deststream).node); - srcstream = index_tree_next(&raw const (*srcstream).node) as *const index_stream; + index_tree_append( + ::core::ptr::addr_of_mut!((*dest).streams), + ::core::ptr::addr_of_mut!((*deststream).node), + ); + srcstream = + index_tree_next(::core::ptr::addr_of!((*srcstream).node)) as *const index_stream; if srcstream.is_null() { break; } @@ -699,11 +719,15 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { let record: size_t = (*iter).internal[ITER_RECORD as usize].s; if group.is_null() { (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_LEFTMOST as size_t; - } else if (*i).streams.rightmost != &raw const (*stream).node as *mut index_tree_node - || (*stream).groups.rightmost != &raw const (*group).node as *mut index_tree_node + } else if (*i).streams.rightmost + != ::core::ptr::addr_of!((*stream).node) as *mut index_tree_node + || (*stream).groups.rightmost + != ::core::ptr::addr_of!((*group).node) as *mut index_tree_node { (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NORMAL as size_t; - } else if (*stream).groups.leftmost != &raw const (*group).node as *mut index_tree_node { + } else if (*stream).groups.leftmost + != ::core::ptr::addr_of!((*group).node) as *mut index_tree_node + { (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NEXT as size_t; (*iter).internal[ITER_GROUP as usize].p = (*group).node.parent as *const c_void; } else { @@ -717,7 +741,7 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { (*iter).stream.flags = if (*stream).stream_flags.version == UINT32_MAX { core::ptr::null() } else { - &raw const (*stream).stream_flags + ::core::ptr::addr_of!((*stream).stream_flags) }; (*iter).stream.padding = (*stream).stream_padding; if (*stream).groups.rightmost.is_null() { @@ -732,10 +756,12 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { (*stream).index_list_size, )) .wrapping_add(vli_ceil4( - (*(&raw const (*g).records as *const index_record).offset((*g).last as isize)) - .unpadded_sum, + (*(::core::ptr::addr_of!((*g).records) as *const index_record) + .offset((*g).last as isize)) + .unpadded_sum, )); - (*iter).stream.uncompressed_size = (*(&raw const (*g).records as *const index_record) + (*iter).stream.uncompressed_size = (*(::core::ptr::addr_of!((*g).records) + as *const index_record) .offset((*g).last as isize)) .uncompressed_sum; } @@ -749,7 +775,7 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { (*group).node.compressed_base } else { vli_ceil4( - (*(&raw const (*group).records as *const index_record) + (*(::core::ptr::addr_of!((*group).records) as *const index_record) .offset(record.wrapping_sub(1) as isize)) .unpadded_sum, ) @@ -757,15 +783,17 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { (*iter).block.uncompressed_stream_offset = if record == 0 { (*group).node.uncompressed_base } else { - (*(&raw const (*group).records as *const index_record) + (*(::core::ptr::addr_of!((*group).records) as *const index_record) .offset(record.wrapping_sub(1) as isize)) .uncompressed_sum }; - (*iter).block.uncompressed_size = (*(&raw const (*group).records as *const index_record) + (*iter).block.uncompressed_size = (*(::core::ptr::addr_of!((*group).records) + as *const index_record) .offset(record as isize)) .uncompressed_sum .wrapping_sub((*iter).block.uncompressed_stream_offset); - (*iter).block.unpadded_size = (*(&raw const (*group).records as *const index_record) + (*iter).block.unpadded_size = (*(::core::ptr::addr_of!((*group).records) + as *const index_record) .offset(record as isize)) .unpadded_sum .wrapping_sub((*iter).block.compressed_stream_offset); @@ -830,7 +858,8 @@ pub unsafe extern "C" fn lzma_index_iter_next( stream = (*i).streams.leftmost as *const index_stream; if mode >= LZMA_INDEX_ITER_BLOCK { while (*stream).groups.leftmost.is_null() { - stream = index_tree_next(&raw const (*stream).node) as *const index_stream; + stream = index_tree_next(::core::ptr::addr_of!((*stream).node)) + as *const index_stream; if stream.is_null() { return true as lzma_bool; } @@ -843,11 +872,12 @@ pub unsafe extern "C" fn lzma_index_iter_next( } else { record = 0; if !group.is_null() { - group = index_tree_next(&raw const (*group).node) as *const index_group; + group = index_tree_next(::core::ptr::addr_of!((*group).node)) as *const index_group; } if group.is_null() { loop { - stream = index_tree_next(&raw const (*stream).node) as *const index_stream; + stream = index_tree_next(::core::ptr::addr_of!((*stream).node)) + as *const index_stream; if stream.is_null() { return true as lzma_bool; } @@ -863,15 +893,17 @@ pub unsafe extern "C" fn lzma_index_iter_next( } if record == 0 { if (*group).node.uncompressed_base - != (*(&raw const (*group).records as *const index_record)).uncompressed_sum + != (*(::core::ptr::addr_of!((*group).records) as *const index_record)) + .uncompressed_sum { break; } - } else if (*(&raw const (*group).records as *const index_record) + } else if (*(::core::ptr::addr_of!((*group).records) as *const index_record) .offset(record.wrapping_sub(1) as isize)) .uncompressed_sum - != (*(&raw const (*group).records as *const index_record).offset(record as isize)) - .uncompressed_sum + != (*(::core::ptr::addr_of!((*group).records) as *const index_record) + .offset(record as isize)) + .uncompressed_sum { break; } @@ -892,15 +924,15 @@ pub unsafe extern "C" fn lzma_index_iter_locate( return true as lzma_bool; } let stream: *const index_stream = - index_tree_locate(&raw const (*i).streams, target) as *const index_stream; + index_tree_locate(::core::ptr::addr_of!((*i).streams), target) as *const index_stream; target = target.wrapping_sub((*stream).node.uncompressed_base); let group: *const index_group = - index_tree_locate(&raw const (*stream).groups, target) as *const index_group; + index_tree_locate(::core::ptr::addr_of!((*stream).groups), target) as *const index_group; let mut left: size_t = 0; let mut right: size_t = (*group).last; while left < right { let pos: size_t = left.wrapping_add(right.wrapping_sub(left).wrapping_div(2)); - if (*(&raw const (*group).records as *const index_record).offset(pos as isize)) + if (*(::core::ptr::addr_of!((*group).records) as *const index_record).offset(pos as isize)) .uncompressed_sum <= target { diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index ac0bbc9c..301a22eb 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_index_prealloc(i: *mut lzma_index, records: lzma_vli); } @@ -53,8 +52,8 @@ unsafe extern "C" fn index_decode( } 1 => { ret = lzma_vli_decode( - &raw mut (*coder).count, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).count), + ::core::ptr::addr_of_mut!((*coder).pos), in_0, in_pos, in_size, @@ -71,11 +70,17 @@ unsafe extern "C" fn index_decode( } 3 | 4 => { let size: *mut lzma_vli = if (*coder).sequence == SEQ_UNPADDED { - &raw mut (*coder).unpadded_size + ::core::ptr::addr_of_mut!((*coder).unpadded_size) } else { - &raw mut (*coder).uncompressed_size + ::core::ptr::addr_of_mut!((*coder).uncompressed_size) }; - ret = lzma_vli_decode(size, &raw mut (*coder).pos, in_0, in_pos, in_size); + ret = lzma_vli_decode( + size, + ::core::ptr::addr_of_mut!((*coder).pos), + in_0, + in_pos, + in_size, + ); if ret != LZMA_STREAM_END { break; } @@ -321,7 +326,7 @@ pub unsafe extern "C" fn lzma_index_decoder( return ret_; } let ret__0: lzma_ret = lzma_index_decoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, i, memlimit, @@ -360,13 +365,14 @@ pub unsafe extern "C" fn lzma_index_buffer_decode( pos: 0, crc32: 0, }; - let ret_: lzma_ret = index_decoder_reset(&raw mut coder, allocator, i, *memlimit); + let ret_: lzma_ret = + index_decoder_reset(::core::ptr::addr_of_mut!(coder), allocator, i, *memlimit); if ret_ != LZMA_OK { return ret_; } let in_start: size_t = *in_pos; let mut ret: lzma_ret = index_decode( - &raw mut coder as *mut c_void, + ::core::ptr::addr_of_mut!(coder) as *mut c_void, allocator, in_0, in_pos, diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index bd28ce35..ab4353f4 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli; fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index); @@ -47,7 +46,13 @@ unsafe extern "C" fn index_encode( } 1 => { let count: lzma_vli = lzma_index_block_count((*coder).index) as lzma_vli; - ret = lzma_vli_encode(count, &raw mut (*coder).pos, out, out_pos, out_size); + ret = lzma_vli_encode( + count, + ::core::ptr::addr_of_mut!((*coder).pos), + out, + out_pos, + out_size, + ); if ret != LZMA_STREAM_END { break; } @@ -57,7 +62,11 @@ unsafe extern "C" fn index_encode( continue; } 4 => { - if lzma_index_iter_next(&raw mut (*coder).iter, LZMA_INDEX_ITER_BLOCK) != 0 { + if lzma_index_iter_next( + ::core::ptr::addr_of_mut!((*coder).iter), + LZMA_INDEX_ITER_BLOCK, + ) != 0 + { (*coder).pos = lzma_index_padding_size((*coder).index) as size_t; (*coder).sequence = SEQ_PADDING; continue; @@ -97,7 +106,13 @@ unsafe extern "C" fn index_encode( } else { (*coder).iter.block.uncompressed_size }; - ret = lzma_vli_encode(size, &raw mut (*coder).pos, out, out_pos, out_size); + ret = lzma_vli_encode( + size, + ::core::ptr::addr_of_mut!((*coder).pos), + out, + out_pos, + out_size, + ); if ret != LZMA_STREAM_END { break; } @@ -132,7 +147,7 @@ unsafe extern "C" fn index_encoder_end(coder: *mut c_void, allocator: *const lzm lzma_free(coder, allocator); } unsafe extern "C" fn index_encoder_reset(coder: *mut lzma_index_coder, i: *const lzma_index) { - lzma_index_iter_init(&raw mut (*coder).iter, i); + lzma_index_iter_init(::core::ptr::addr_of_mut!((*coder).iter), i); (*coder).sequence = SEQ_INDICATOR; (*coder).index = i; (*coder).pos = 0; @@ -219,8 +234,11 @@ pub unsafe extern "C" fn lzma_index_encoder( if ret_ != LZMA_OK { return ret_; } - let ret__0: lzma_ret = - lzma_index_encoder_init(&raw mut (*(*strm).internal).next, (*strm).allocator, i); + let ret__0: lzma_ret = lzma_index_encoder_init( + ::core::ptr::addr_of_mut!((*(*strm).internal).next), + (*strm).allocator, + i, + ); if ret__0 != LZMA_OK { lzma_end(strm); return ret__0; @@ -289,10 +307,10 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( pos: 0, crc32: 0, }; - index_encoder_reset(&raw mut coder, i); + index_encoder_reset(::core::ptr::addr_of_mut!(coder), i); let out_start: size_t = *out_pos; let mut ret: lzma_ret = index_encode( - &raw mut coder as *mut c_void, + ::core::ptr::addr_of_mut!(coder) as *mut c_void, core::ptr::null(), core::ptr::null(), core::ptr::null_mut(), diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index f5a97375..49477dc4 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_hash_s { @@ -66,8 +65,14 @@ pub unsafe extern "C" fn lzma_index_hash_init( (*index_hash).uncompressed_size = 0; (*index_hash).pos = 0; (*index_hash).crc32 = 0; - lzma_check_init(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); - lzma_check_init(&raw mut (*index_hash).records.check, LZMA_CHECK_SHA256); + lzma_check_init( + ::core::ptr::addr_of_mut!((*index_hash).blocks.check), + LZMA_CHECK_SHA256, + ); + lzma_check_init( + ::core::ptr::addr_of_mut!((*index_hash).records.check), + LZMA_CHECK_SHA256, + ); index_hash } #[no_mangle] @@ -99,9 +104,9 @@ unsafe extern "C" fn hash_append( (*info).count = (*info).count.wrapping_add(1); let sizes: [lzma_vli; 2] = [unpadded_size, uncompressed_size]; lzma_check_update( - &raw mut (*info).check, + ::core::ptr::addr_of_mut!((*info).check), LZMA_CHECK_SHA256, - &raw const sizes as *const lzma_vli as *const u8, + ::core::ptr::addr_of!(sizes) as *const lzma_vli as *const u8, core::mem::size_of::<[lzma_vli; 2]>(), ); } @@ -120,7 +125,7 @@ pub unsafe extern "C" fn lzma_index_hash_append( return LZMA_PROG_ERROR; } hash_append( - &raw mut (*index_hash).blocks, + ::core::ptr::addr_of_mut!((*index_hash).blocks), unpadded_size, uncompressed_size, ); @@ -166,8 +171,8 @@ pub unsafe extern "C" fn lzma_index_hash_decode( } 1 => { ret = lzma_vli_decode( - &raw mut (*index_hash).remaining, - &raw mut (*index_hash).pos, + ::core::ptr::addr_of_mut!((*index_hash).remaining), + ::core::ptr::addr_of_mut!((*index_hash).pos), in_0, in_pos, in_size, @@ -189,11 +194,17 @@ pub unsafe extern "C" fn lzma_index_hash_decode( } 2 | 3 => { let size: *mut lzma_vli = if (*index_hash).sequence == SEQ_UNPADDED { - &raw mut (*index_hash).unpadded_size + ::core::ptr::addr_of_mut!((*index_hash).unpadded_size) } else { - &raw mut (*index_hash).uncompressed_size + ::core::ptr::addr_of_mut!((*index_hash).uncompressed_size) }; - ret = lzma_vli_decode(size, &raw mut (*index_hash).pos, in_0, in_pos, in_size); + ret = lzma_vli_decode( + size, + ::core::ptr::addr_of_mut!((*index_hash).pos), + in_0, + in_pos, + in_size, + ); if ret != LZMA_STREAM_END { break; } @@ -208,7 +219,7 @@ pub unsafe extern "C" fn lzma_index_hash_decode( (*index_hash).sequence = SEQ_UNCOMPRESSED; } else { hash_append( - &raw mut (*index_hash).records, + ::core::ptr::addr_of_mut!((*index_hash).records), (*index_hash).unpadded_size, (*index_hash).uncompressed_size, ); @@ -264,11 +275,19 @@ pub unsafe extern "C" fn lzma_index_hash_decode( { return LZMA_DATA_ERROR; } - lzma_check_finish(&raw mut (*index_hash).blocks.check, LZMA_CHECK_SHA256); - lzma_check_finish(&raw mut (*index_hash).records.check, LZMA_CHECK_SHA256); + lzma_check_finish( + ::core::ptr::addr_of_mut!((*index_hash).blocks.check), + LZMA_CHECK_SHA256, + ); + lzma_check_finish( + ::core::ptr::addr_of_mut!((*index_hash).records.check), + LZMA_CHECK_SHA256, + ); if memcmp( - &raw mut (*index_hash).blocks.check.buffer.u8_0 as *const c_void, - &raw mut (*index_hash).records.check.buffer.u8_0 as *const c_void, + ::core::ptr::addr_of_mut!((*index_hash).blocks.check.buffer.u8_0) + as *const c_void, + ::core::ptr::addr_of_mut!((*index_hash).records.check.buffer.u8_0) + as *const c_void, lzma_check_size(LZMA_CHECK_SHA256) as size_t, ) != 0 { diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index aa0d39ec..f0ccadf1 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzip_coder { @@ -142,9 +141,11 @@ unsafe extern "C" fn lzip_decode( (*coder).options.lc = LZIP_LC; (*coder).options.lp = LZIP_LP; (*coder).options.pb = LZIP_PB; - (*coder).memusage = - lzma_lzma_decoder_memusage_nocheck(&raw mut (*coder).options as *const c_void) - .wrapping_add(LZMA_MEMUSAGE_BASE); + (*coder).memusage = lzma_lzma_decoder_memusage_nocheck(::core::ptr::addr_of_mut!( + (*coder).options + ) + as *const c_void) + .wrapping_add(LZMA_MEMUSAGE_BASE); (*coder).sequence = SEQ_CODER_INIT; current_block_80 = 15476230294461844687; } @@ -167,7 +168,7 @@ unsafe extern "C" fn lzip_decode( ) -> lzma_ret, ), - options: &raw mut (*coder).options as *mut c_void, + options: ::core::ptr::addr_of_mut!((*coder).options) as *mut c_void, }, lzma_filter_info_s { id: 0, @@ -176,9 +177,9 @@ unsafe extern "C" fn lzip_decode( }, ]; let ret_: lzma_ret = lzma_next_filter_init( - &raw mut (*coder).lzma_decoder, + ::core::ptr::addr_of_mut!((*coder).lzma_decoder), allocator, - &raw const filters as *const lzma_filter_info, + ::core::ptr::addr_of!(filters) as *const lzma_filter_info, ); if ret_ != LZMA_OK { return ret_; @@ -230,8 +231,8 @@ unsafe extern "C" fn lzip_decode( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), footer_size, ); if (*coder).pos < footer_size { @@ -240,18 +241,23 @@ unsafe extern "C" fn lzip_decode( (*coder).pos = 0; (*coder).member_size = (*coder).member_size.wrapping_add(footer_size as u64); if !(*coder).ignore_check - && (*coder).crc32 != read32le((&raw mut (*coder).buffer as *mut u8) as *mut u8) + && (*coder).crc32 + != read32le((::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8) as *mut u8) { return LZMA_DATA_ERROR; } if (*coder).uncompressed_size - != read64le((&raw mut (*coder).buffer as *mut u8).offset(4) as *mut u8) + != read64le( + (::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8).offset(4) as *mut u8, + ) { return LZMA_DATA_ERROR; } if (*coder).version > 0 { if (*coder).member_size - != read64le((&raw mut (*coder).buffer as *mut u8).offset(12) as *mut u8) + != read64le( + (::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8).offset(12) as *mut u8, + ) { return LZMA_DATA_ERROR; } @@ -265,7 +271,7 @@ unsafe extern "C" fn lzip_decode( } unsafe extern "C" fn lzip_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; - lzma_next_end(&raw mut (*coder).lzma_decoder, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).lzma_decoder), allocator); lzma_free(coder as *mut c_void, allocator); } extern "C" fn lzip_decoder_get_check(_coder_ptr: *const c_void) -> lzma_check { @@ -393,7 +399,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder( return ret_; } let ret__0: lzma_ret = lzma_lzip_decoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, memlimit, flags, diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index 66a3455e..3daf671c 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_microlzma_coder { @@ -66,7 +65,10 @@ unsafe extern "C" fn microlzma_decode( options.ext_size_low = (*coder).uncomp_size as u32; options.ext_size_high = ((*coder).uncomp_size >> 32) as u32; } - if lzma_lzma_lclppb_decode(&raw mut options, !*in_0.offset(*in_pos as isize)) { + if lzma_lzma_lclppb_decode( + ::core::ptr::addr_of_mut!(options), + !*in_0.offset(*in_pos as isize), + ) { return LZMA_OPTIONS_ERROR; } *in_pos = (*in_pos).wrapping_add(1); @@ -81,7 +83,7 @@ unsafe extern "C" fn microlzma_decode( *const lzma_filter_info, ) -> lzma_ret, ), - options: &raw mut options as *mut c_void, + options: ::core::ptr::addr_of_mut!(options) as *mut c_void, }, lzma_filter_info_s { id: 0, @@ -90,9 +92,9 @@ unsafe extern "C" fn microlzma_decode( }, ]; let ret_: lzma_ret = lzma_next_filter_init( - &raw mut (*coder).lzma, + ::core::ptr::addr_of_mut!((*coder).lzma), allocator, - &raw mut filters as *mut lzma_filter_info, + ::core::ptr::addr_of_mut!(filters) as *mut lzma_filter_info, ); if ret_ != LZMA_OK { return ret_; @@ -102,8 +104,8 @@ unsafe extern "C" fn microlzma_decode( if (*coder).lzma.code.unwrap()( (*coder).lzma.coder, allocator, - &raw const dummy_in, - &raw mut dummy_in_pos, + ::core::ptr::addr_of!(dummy_in), + ::core::ptr::addr_of_mut!(dummy_in_pos), 1, out, out_pos, @@ -150,7 +152,7 @@ unsafe extern "C" fn microlzma_decoder_end( allocator: *const lzma_allocator, ) { let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; - lzma_next_end(&raw mut (*coder).lzma, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).lzma), allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn microlzma_decoder_init( @@ -271,7 +273,7 @@ pub unsafe extern "C" fn lzma_microlzma_decoder( return ret_; } let ret__0: lzma_ret = microlzma_decoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, comp_size, uncomp_size, diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index bffbd1e8..edc9c6fc 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_microlzma_coder { @@ -23,7 +22,7 @@ unsafe extern "C" fn microlzma_encode( let mut uncomp_size: u64 = 0; if (*coder).lzma.set_out_limit.unwrap()( (*coder).lzma.coder, - &raw mut uncomp_size, + ::core::ptr::addr_of_mut!(uncomp_size), out_size.wrapping_sub(*out_pos) as u64, ) != LZMA_OK { @@ -55,7 +54,7 @@ unsafe extern "C" fn microlzma_encoder_end( allocator: *const lzma_allocator, ) { let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; - lzma_next_end(&raw mut (*coder).lzma, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).lzma), allocator); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn microlzma_encoder_init( @@ -138,7 +137,7 @@ unsafe extern "C" fn microlzma_encoder_init( set_out_limit: None, }; } - if lzma_lzma_lclppb_encode(options, &raw mut (*coder).props) { + if lzma_lzma_lclppb_encode(options, ::core::ptr::addr_of_mut!((*coder).props)) { return LZMA_OPTIONS_ERROR; } let filters: [lzma_filter_info; 2] = [ @@ -161,9 +160,9 @@ unsafe extern "C" fn microlzma_encoder_init( }, ]; lzma_next_filter_init( - &raw mut (*coder).lzma, + ::core::ptr::addr_of_mut!((*coder).lzma), allocator, - &raw const filters as *const lzma_filter_info, + ::core::ptr::addr_of!(filters) as *const lzma_filter_info, ) } #[no_mangle] @@ -176,7 +175,7 @@ pub unsafe extern "C" fn lzma_microlzma_encoder( return ret_; } let ret__0: lzma_ret = microlzma_encoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, options, ); diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index c6cece9d..7d316462 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[no_mangle] pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { let limit: u64 = (UINT64_MAX) @@ -164,8 +163,8 @@ pub unsafe extern "C" fn lzma_outq_read( } let buf: *mut lzma_outbuf = (*outq).head; lzma_bufcpy( - &raw mut (*buf).buf as *mut u8, - &raw mut (*outq).read_pos, + ::core::ptr::addr_of_mut!((*buf).buf) as *mut u8, + ::core::ptr::addr_of_mut!((*outq).read_pos), (*buf).pos, out, out_pos, diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index 6eed8728..dcfada7c 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -34,8 +34,12 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( update: None, set_out_limit: None, }; - let mut ret: lzma_ret = - lzma_stream_decoder_init(&raw mut stream_decoder, allocator, *memlimit, flags); + let mut ret: lzma_ret = lzma_stream_decoder_init( + ::core::ptr::addr_of_mut!(stream_decoder), + allocator, + *memlimit, + flags, + ); if ret == LZMA_OK { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; @@ -66,12 +70,12 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( stream_decoder.memconfig.unwrap()( stream_decoder.coder, memlimit, - &raw mut memusage, + ::core::ptr::addr_of_mut!(memusage), 0, ); } } } - lzma_next_end(&raw mut stream_decoder, allocator); + lzma_next_end(::core::ptr::addr_of_mut!(stream_decoder), allocator); ret } diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index d131ed6f..91676bd4 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -24,8 +24,6 @@ pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t if block_bound == 0 { return 0; } - - // Match C: my_min(SIZE_MAX, LZMA_VLI_MAX) - block_bound < HEADERS_BOUND. let stream_bound_max: size_t = core::cmp::min(size_t::MAX, LZMA_VLI_MAX as size_t); if stream_bound_max.wrapping_sub(block_bound) < HEADERS_BOUND as size_t { return 0; @@ -78,7 +76,11 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( reserved_int1: 0, reserved_int2: 0, }; - if lzma_stream_header_encode(&raw mut stream_flags, out.offset(out_pos as isize)) != LZMA_OK { + if lzma_stream_header_encode( + ::core::ptr::addr_of_mut!(stream_flags), + out.offset(out_pos as isize), + ) != LZMA_OK + { return LZMA_PROG_ERROR; } out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); @@ -116,12 +118,12 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( }; if in_size > 0 { let ret_: lzma_ret = lzma_block_buffer_encode( - &raw mut block, + ::core::ptr::addr_of_mut!(block), allocator, in_0, in_size, out, - &raw mut out_pos, + ::core::ptr::addr_of_mut!(out_pos), out_size, ); if ret_ != LZMA_OK { @@ -137,19 +139,23 @@ pub unsafe extern "C" fn lzma_stream_buffer_encode( ret = lzma_index_append( i, allocator, - lzma_block_unpadded_size(&raw mut block), + lzma_block_unpadded_size(::core::ptr::addr_of_mut!(block)), block.uncompressed_size, ); } if ret == LZMA_OK { - ret = lzma_index_buffer_encode(i, out, &raw mut out_pos, out_size); + ret = lzma_index_buffer_encode(i, out, ::core::ptr::addr_of_mut!(out_pos), out_size); stream_flags.backward_size = lzma_index_size(i); } lzma_index_end(i, allocator); if ret != LZMA_OK { return ret; } - if lzma_stream_footer_encode(&raw mut stream_flags, out.offset(out_pos as isize)) != LZMA_OK { + if lzma_stream_footer_encode( + ::core::ptr::addr_of_mut!(stream_flags), + out.offset(out_pos as isize), + ) != LZMA_OK + { return LZMA_PROG_ERROR; } out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 978da765..5e18045f 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { @@ -59,8 +58,8 @@ unsafe extern "C" fn stream_decode( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), LZMA_STREAM_HEADER_SIZE as size_t, ); if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { @@ -68,8 +67,8 @@ unsafe extern "C" fn stream_decode( } (*coder).pos = 0; let ret: lzma_ret = lzma_stream_header_decode( - &raw mut (*coder).stream_flags, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of_mut!((*coder).stream_flags), + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, ); if ret != LZMA_OK { return if ret == LZMA_FORMAT_ERROR && !(*coder).first_stream { @@ -149,8 +148,8 @@ unsafe extern "C" fn stream_decode( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), (*coder).block_options.header_size as size_t, ); if (*coder).pos < (*coder).block_options.header_size as size_t { @@ -167,8 +166,8 @@ unsafe extern "C" fn stream_decode( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), LZMA_STREAM_HEADER_SIZE as size_t, ); if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { @@ -195,8 +194,8 @@ unsafe extern "C" fn stream_decode( reserved_int2: 0, }; let ret_3: lzma_ret = lzma_stream_footer_decode( - &raw mut footer_flags, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of_mut!(footer_flags), + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, ); if ret_3 != LZMA_OK { return if ret_3 == LZMA_FORMAT_ERROR { @@ -209,8 +208,8 @@ unsafe extern "C" fn stream_decode( return LZMA_DATA_ERROR; } let ret__1: lzma_ret = lzma_stream_flags_compare( - &raw mut (*coder).stream_flags, - &raw mut footer_flags, + ::core::ptr::addr_of_mut!((*coder).stream_flags), + ::core::ptr::addr_of_mut!(footer_flags), ); if ret__1 != LZMA_OK { return ret__1; @@ -258,18 +257,20 @@ unsafe extern "C" fn stream_decode( id: 0, options: core::ptr::null_mut(), }; 5]; - (*coder).block_options.filters = &raw mut filters as *mut lzma_filter; + (*coder).block_options.filters = + ::core::ptr::addr_of_mut!(filters) as *mut lzma_filter; let ret_: lzma_ret = lzma_block_header_decode( - &raw mut (*coder).block_options, + ::core::ptr::addr_of_mut!((*coder).block_options), allocator, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, ); if ret_ != LZMA_OK { return ret_; } (*coder).block_options.ignore_check = (*coder).ignore_check as lzma_bool; - let memusage: u64 = - lzma_raw_decoder_memusage(&raw mut filters as *mut lzma_filter) as u64; + let memusage: u64 = lzma_raw_decoder_memusage( + ::core::ptr::addr_of_mut!(filters) as *mut lzma_filter + ) as u64; let mut ret_0: lzma_ret = LZMA_OK; if memusage == UINT64_MAX { ret_0 = LZMA_OPTIONS_ERROR; @@ -279,13 +280,16 @@ unsafe extern "C" fn stream_decode( ret_0 = LZMA_MEMLIMIT_ERROR; } else { ret_0 = lzma_block_decoder_init( - &raw mut (*coder).block_decoder, + ::core::ptr::addr_of_mut!((*coder).block_decoder), allocator, - &raw mut (*coder).block_options, + ::core::ptr::addr_of_mut!((*coder).block_options), ); } } - lzma_filters_free(&raw mut filters as *mut lzma_filter, allocator); + lzma_filters_free( + ::core::ptr::addr_of_mut!(filters) as *mut lzma_filter, + allocator, + ); (*coder).block_options.filters = core::ptr::null_mut(); if ret_0 != LZMA_OK { return ret_0; @@ -313,7 +317,7 @@ unsafe extern "C" fn stream_decode( } let ret__0: lzma_ret = lzma_index_hash_append( (*coder).index_hash, - lzma_block_unpadded_size(&raw mut (*coder).block_options), + lzma_block_unpadded_size(::core::ptr::addr_of_mut!((*coder).block_options)), (*coder).block_options.uncompressed_size, ); if ret__0 != LZMA_OK { @@ -327,7 +331,7 @@ unsafe extern "C" fn stream_decode( } unsafe extern "C" fn stream_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - lzma_next_end(&raw mut (*coder).block_decoder, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).block_decoder), allocator); lzma_index_hash_end((*coder).index_hash, allocator); lzma_free(coder as *mut c_void, allocator); } @@ -460,7 +464,7 @@ pub unsafe extern "C" fn lzma_stream_decoder( return ret_; } let ret__0: lzma_ret = lzma_stream_decoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, memlimit, flags, diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 1f4ee8ac..1c0e2d25 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_ulong, c_void}; extern "C" { fn lzma_outq_clear_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator); fn lzma_outq_clear_cache2( @@ -95,17 +94,17 @@ unsafe extern "C" fn worker_enable_partial_update(thr_ptr: *mut c_void) { let thr: *mut worker_thread = thr_ptr as *mut worker_thread; let mut mythread_i_325: c_uint = 0; while if mythread_i_325 != 0 { - mythread_mutex_unlock(&raw mut (*thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*thr).mutex)); 1 } != 0 { let mut mythread_j_325: c_uint = 0; while mythread_j_325 == 0 { (*thr).partial_update_enabled = true; - mythread_cond_signal(&raw mut (*thr).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*thr).cond)); mythread_j_325 = 1; } mythread_i_325 = 1; @@ -117,17 +116,23 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { let mut partial_update_enabled: bool = false; let mut ret: lzma_ret = LZMA_OK; loop { - mythread_mutex_lock(&raw mut (*thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*thr).mutex)); loop { if (*thr).state == THR_IDLE { - mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + mythread_cond_wait( + ::core::ptr::addr_of_mut!((*thr).cond), + ::core::ptr::addr_of_mut!((*thr).mutex), + ); } else { if (*thr).state == THR_EXIT { - mythread_mutex_unlock(&raw mut (*thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); - lzma_next_end(&raw mut (*thr).block_decoder, (*thr).allocator); - mythread_mutex_destroy(&raw mut (*thr).mutex); - mythread_cond_destroy(&raw mut (*thr).cond); + lzma_next_end( + ::core::ptr::addr_of_mut!((*thr).block_decoder), + (*thr).allocator, + ); + mythread_mutex_destroy(::core::ptr::addr_of_mut!((*thr).mutex)); + mythread_cond_destroy(::core::ptr::addr_of_mut!((*thr).cond)); return MYTHREAD_RET_VALUE; } (*thr).progress_in = (*thr).in_pos; @@ -139,10 +144,13 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { { break; } - mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + mythread_cond_wait( + ::core::ptr::addr_of_mut!((*thr).cond), + ::core::ptr::addr_of_mut!((*thr).mutex), + ); } } - mythread_mutex_unlock(&raw mut (*thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); let chunk_size: size_t = 16384; if in_filled.wrapping_sub((*thr).in_pos) > chunk_size { in_filled = (*thr).in_pos.wrapping_add(chunk_size); @@ -151,10 +159,10 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { (*thr).block_decoder.coder, (*thr).allocator, (*thr).in_0, - &raw mut (*thr).in_pos, + ::core::ptr::addr_of_mut!((*thr).in_pos), in_filled, - &raw mut (*(*thr).outbuf).buf as *mut u8, - &raw mut (*thr).out_pos, + ::core::ptr::addr_of_mut!((*(*thr).outbuf).buf) as *mut u8, + ::core::ptr::addr_of_mut!((*thr).out_pos), (*(*thr).outbuf).allocated, LZMA_RUN, ); @@ -163,10 +171,10 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { (*thr).partial_update_started = true; let mut mythread_i_415: c_uint = 0; while if mythread_i_415 != 0 { - mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); 1 } != 0 { @@ -174,7 +182,7 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { while mythread_j_415 == 0 { (*(*thr).outbuf).pos = (*thr).out_pos; (*(*thr).outbuf).decoder_in_pos = (*thr).in_pos; - mythread_cond_signal(&raw mut (*(*thr).coder).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*(*thr).coder).cond)); mythread_j_415 = 1; } mythread_i_415 = 1; @@ -183,10 +191,10 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { } else { let mut mythread_i_434: c_uint = 0; while if mythread_i_434 != 0 { - mythread_mutex_unlock(&raw mut (*thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*thr).mutex)); 1 } != 0 { @@ -208,10 +216,10 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { } let mut mythread_i_458: c_uint = 0; while if mythread_i_458 != 0 { - mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); 1 } != 0 { @@ -244,7 +252,7 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { (*thr).next = (*(*thr).coder).threads_free; (*(*thr).coder).threads_free = thr; } - mythread_cond_signal(&raw mut (*(*thr).coder).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*(*thr).coder).cond)); mythread_j_458 = 1; } mythread_i_458 = 1; @@ -257,17 +265,23 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons while i < (*coder).threads_initialized { let mut mythread_i_502: c_uint = 0; while if mythread_i_502 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 1 } != 0 { let mut mythread_j_502: c_uint = 0; while mythread_j_502 == 0 { (*(*coder).threads.offset(i as isize)).state = THR_EXIT; - mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).cond + )); mythread_j_502 = 1; } mythread_i_502 = 1; @@ -291,10 +305,14 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder) { while i < (*coder).threads_initialized { let mut mythread_i_538: c_uint = 0; while if mythread_i_538 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 1 } != 0 { @@ -325,8 +343,8 @@ unsafe extern "C" fn initialize_new_thread( .threads .offset((*coder).threads_initialized as isize) as *mut worker_thread; - if mythread_mutex_init(&raw mut (*thr).mutex) == 0 { - if mythread_cond_init(&raw mut (*thr).cond) == 0 { + if mythread_mutex_init(::core::ptr::addr_of_mut!((*thr).mutex)) == 0 { + if mythread_cond_init(::core::ptr::addr_of_mut!((*thr).cond)) == 0 { (*thr).state = THR_IDLE; (*thr).in_0 = core::ptr::null_mut(); (*thr).in_size = 0; @@ -347,19 +365,19 @@ unsafe extern "C" fn initialize_new_thread( }; (*thr).mem_filters = 0; if mythread_create( - &raw mut (*thr).thread_id, + ::core::ptr::addr_of_mut!((*thr).thread_id), Some(worker_decoder as unsafe extern "C" fn(*mut c_void) -> *mut c_void), thr as *mut c_void, ) != 0 { - mythread_cond_destroy(&raw mut (*thr).cond); + mythread_cond_destroy(::core::ptr::addr_of_mut!((*thr).cond)); } else { (*coder).threads_initialized = (*coder).threads_initialized.wrapping_add(1); (*coder).thr = thr; return LZMA_OK; } } - mythread_mutex_destroy(&raw mut (*thr).mutex); + mythread_mutex_destroy(::core::ptr::addr_of_mut!((*thr).mutex)); } LZMA_MEM_ERROR } @@ -369,10 +387,10 @@ unsafe extern "C" fn get_thread( ) -> lzma_ret { let mut mythread_i_608: c_uint = 0; while if mythread_i_608 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -418,10 +436,10 @@ unsafe extern "C" fn read_output_and_wait( let mut ret: lzma_ret = LZMA_OK; let mut mythread_i_654: c_uint = 0; while if mythread_i_654 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -431,7 +449,7 @@ unsafe extern "C" fn read_output_and_wait( let out_start: size_t = *out_pos; loop { ret = lzma_outq_read( - &raw mut (*coder).outq, + ::core::ptr::addr_of_mut!((*coder).outq), allocator, out, out_pos, @@ -441,7 +459,7 @@ unsafe extern "C" fn read_output_and_wait( ); if ret == LZMA_STREAM_END { lzma_outq_enable_partial_output( - &raw mut (*coder).outq, + ::core::ptr::addr_of_mut!((*coder).outq), Some( worker_enable_partial_update as unsafe extern "C" fn(*mut c_void) -> (), @@ -472,7 +490,7 @@ unsafe extern "C" fn read_output_and_wait( .wrapping_sub((*coder).mem_in_use) .wrapping_sub((*coder).outq.mem_in_use) >= (*coder).mem_next_block - && lzma_outq_has_buf(&raw mut (*coder).outq) + && lzma_outq_has_buf(::core::ptr::addr_of_mut!((*coder).outq)) && ((*coder).threads_initialized < (*coder).threads_max || !(*coder).threads_free.is_null()) { @@ -482,10 +500,10 @@ unsafe extern "C" fn read_output_and_wait( if !waiting_allowed { break; } - if lzma_outq_is_empty(&raw mut (*coder).outq) { + if lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { break; } - if lzma_outq_is_readable(&raw mut (*coder).outq) { + if lzma_outq_is_readable(::core::ptr::addr_of_mut!((*coder).outq)) { break; } if !(*coder).thr.is_null() && (*(*coder).thr).partial_update_enabled { @@ -498,13 +516,13 @@ unsafe extern "C" fn read_output_and_wait( *has_blocked = true; mythread_condtime_set( wait_abs, - &raw mut (*coder).cond, + ::core::ptr::addr_of_mut!((*coder).cond), (*coder).timeout, ); } if mythread_cond_timedwait( - &raw mut (*coder).cond, - &raw mut (*coder).mutex, + ::core::ptr::addr_of_mut!((*coder).cond), + ::core::ptr::addr_of_mut!((*coder).mutex), wait_abs, ) != 0 { @@ -512,7 +530,10 @@ unsafe extern "C" fn read_output_and_wait( break; } } else { - mythread_cond_wait(&raw mut (*coder).cond, &raw mut (*coder).mutex); + mythread_cond_wait( + ::core::ptr::addr_of_mut!((*coder).cond), + ::core::ptr::addr_of_mut!((*coder).mutex), + ); } if ret != LZMA_OK { break; @@ -550,8 +571,8 @@ unsafe extern "C" fn decode_block_header( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), (*coder).block_options.header_size as size_t, ); if (*coder).pos < (*coder).block_options.header_size as size_t { @@ -559,11 +580,12 @@ unsafe extern "C" fn decode_block_header( } (*coder).pos = 0; (*coder).block_options.version = 1; - (*coder).block_options.filters = &raw mut (*coder).filters as *mut lzma_filter; + (*coder).block_options.filters = + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter; let ret_: lzma_ret = lzma_block_header_decode( - &raw mut (*coder).block_options, + ::core::ptr::addr_of_mut!((*coder).block_options), allocator, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, ); if ret_ != LZMA_OK { return ret_; @@ -622,8 +644,8 @@ unsafe extern "C" fn stream_decode_mt( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), LZMA_STREAM_HEADER_SIZE as size_t, ); (*coder).progress_in = (*coder) @@ -634,8 +656,8 @@ unsafe extern "C" fn stream_decode_mt( } (*coder).pos = 0; let ret: lzma_ret = lzma_stream_header_decode( - &raw mut (*coder).stream_flags, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of_mut!((*coder).stream_flags), + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, ); if ret != LZMA_OK { return if ret == LZMA_FORMAT_ERROR && !(*coder).first_stream { @@ -681,23 +703,26 @@ unsafe extern "C" fn stream_decode_mt( out_size, core::ptr::null_mut(), true, - &raw mut wait_abs, - &raw mut has_blocked, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), ); if ret__3 != LZMA_OK { return ret__3; } - if !lzma_outq_is_empty(&raw mut (*coder).outq) { + if !lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { return LZMA_OK; } - lzma_outq_clear_cache(&raw mut (*coder).outq, allocator); + lzma_outq_clear_cache(::core::ptr::addr_of_mut!((*coder).outq), allocator); threads_end(coder, allocator); let ret_3: lzma_ret = lzma_block_decoder_init( - &raw mut (*coder).block_decoder, + ::core::ptr::addr_of_mut!((*coder).block_decoder), + allocator, + ::core::ptr::addr_of_mut!((*coder).block_options), + ); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, allocator, - &raw mut (*coder).block_options, ); - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); (*coder).block_options.filters = core::ptr::null_mut(); if ret_3 != LZMA_OK { return ret_3; @@ -718,13 +743,13 @@ unsafe extern "C" fn stream_decode_mt( out_size, core::ptr::null_mut(), true, - &raw mut wait_abs, - &raw mut has_blocked, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), ); if ret__5 != LZMA_OK { return ret__5; } - if !lzma_outq_is_empty(&raw mut (*coder).outq) { + if !lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { return LZMA_OK; } (*coder).sequence = SEQ_INDEX_DECODE; @@ -749,13 +774,13 @@ unsafe extern "C" fn stream_decode_mt( out_size, core::ptr::null_mut(), true, - &raw mut wait_abs, - &raw mut has_blocked, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), ); if ret__8 != LZMA_OK { return ret__8; } - if !lzma_outq_is_empty(&raw mut (*coder).outq) { + if !lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { return LZMA_OK; } } @@ -789,7 +814,7 @@ unsafe extern "C" fn stream_decode_mt( } let ret__4: lzma_ret = lzma_index_hash_append( (*coder).index_hash, - lzma_block_unpadded_size(&raw mut (*coder).block_options), + lzma_block_unpadded_size(::core::ptr::addr_of_mut!((*coder).block_options)), (*coder).block_options.uncompressed_size, ); if ret__4 != LZMA_OK { @@ -817,8 +842,8 @@ unsafe extern "C" fn stream_decode_mt( out_size, core::ptr::null_mut(), waiting_allowed, - &raw mut wait_abs, - &raw mut has_blocked, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), ); if ret_ != LZMA_OK { return ret_; @@ -837,8 +862,9 @@ unsafe extern "C" fn stream_decode_mt( (*coder).sequence = SEQ_ERROR; current_block_239 = 11639917216603986996; } else { - (*coder).mem_next_filters = - lzma_raw_decoder_memusage(&raw mut (*coder).filters as *mut lzma_filter); + (*coder).mem_next_filters = lzma_raw_decoder_memusage( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + ); if (*coder).mem_next_filters == UINT64_MAX { (*coder).pending_error = LZMA_OPTIONS_ERROR; (*coder).sequence = SEQ_ERROR; @@ -878,13 +904,13 @@ unsafe extern "C" fn stream_decode_mt( out_size, core::ptr::null_mut(), true, - &raw mut wait_abs, - &raw mut has_blocked, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), ); if ret__0 != LZMA_OK { return ret__0; } - if !lzma_outq_is_empty(&raw mut (*coder).outq) { + if !lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { return LZMA_OK; } return LZMA_MEMLIMIT_ERROR; @@ -910,11 +936,16 @@ unsafe extern "C" fn stream_decode_mt( (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; current_block_239 = 11639917216603986996; } else { - lzma_next_end(&raw mut (*coder).block_decoder, allocator); + lzma_next_end( + ::core::ptr::addr_of_mut!((*coder).block_decoder), + allocator, + ); (*coder).mem_direct_mode = 0; let ret_1: lzma_ret = lzma_index_hash_append( (*coder).index_hash, - lzma_block_unpadded_size(&raw mut (*coder).block_options), + lzma_block_unpadded_size(::core::ptr::addr_of_mut!( + (*coder).block_options + )), (*coder).block_options.uncompressed_size, ); if ret_1 != LZMA_OK { @@ -935,8 +966,8 @@ unsafe extern "C" fn stream_decode_mt( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), LZMA_STREAM_HEADER_SIZE as size_t, ); (*coder).progress_in = (*coder) @@ -966,8 +997,8 @@ unsafe extern "C" fn stream_decode_mt( reserved_int2: 0, }; let ret_6: lzma_ret = lzma_stream_footer_decode( - &raw mut footer_flags, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of_mut!(footer_flags), + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, ); if ret_6 != LZMA_OK { return if ret_6 == LZMA_FORMAT_ERROR { @@ -980,8 +1011,8 @@ unsafe extern "C" fn stream_decode_mt( return LZMA_DATA_ERROR; } let ret__6: lzma_ret = lzma_stream_flags_compare( - &raw mut (*coder).stream_flags, - &raw mut footer_flags, + ::core::ptr::addr_of_mut!((*coder).stream_flags), + ::core::ptr::addr_of_mut!(footer_flags), ); if ret__6 != LZMA_OK { return ret__6; @@ -1033,10 +1064,10 @@ unsafe extern "C" fn stream_decode_mt( out, out_pos, out_size, - &raw mut block_can_start, + ::core::ptr::addr_of_mut!(block_can_start), true, - &raw mut wait_abs, - &raw mut has_blocked, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), ); if ret__1 != LZMA_OK { return ret__1; @@ -1053,10 +1084,10 @@ unsafe extern "C" fn stream_decode_mt( let mut thr: *mut worker_thread = core::ptr::null_mut(); let mut mythread_i_1347: c_uint = 0; while if mythread_i_1347 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -1078,7 +1109,7 @@ unsafe extern "C" fn stream_decode_mt( > mem_max { lzma_outq_clear_cache2( - &raw mut (*coder).outq, + ::core::ptr::addr_of_mut!((*coder).outq), allocator, (*coder).block_options.uncompressed_size as size_t, ); @@ -1094,7 +1125,10 @@ unsafe extern "C" fn stream_decode_mt( thr = (*thr).next; } while !thr.is_null() { - lzma_next_end(&raw mut (*thr).block_decoder, allocator); + lzma_next_end( + ::core::ptr::addr_of_mut!((*thr).block_decoder), + allocator, + ); mem_freed = mem_freed.wrapping_add((*thr).mem_filters); (*thr).mem_filters = 0; thr = (*thr).next; @@ -1102,10 +1136,10 @@ unsafe extern "C" fn stream_decode_mt( } let mut mythread_i_1410: c_uint = 0; while if mythread_i_1410 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -1120,7 +1154,7 @@ unsafe extern "C" fn stream_decode_mt( mythread_i_1410 = 1; } let mut ret_2: lzma_ret = lzma_outq_prealloc_buf( - &raw mut (*coder).outq, + ::core::ptr::addr_of_mut!((*coder).outq), allocator, (*coder).block_options.uncompressed_size as size_t, ); @@ -1136,11 +1170,14 @@ unsafe extern "C" fn stream_decode_mt( (*(*coder).thr).mem_filters = (*coder).mem_next_filters; (*(*coder).thr).block_options = (*coder).block_options; ret_2 = lzma_block_decoder_init( - &raw mut (*(*coder).thr).block_decoder, + ::core::ptr::addr_of_mut!((*(*coder).thr).block_decoder), + allocator, + ::core::ptr::addr_of_mut!((*(*coder).thr).block_options), + ); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, allocator, - &raw mut (*(*coder).thr).block_options, ); - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); (*(*coder).thr).block_options.filters = core::ptr::null_mut(); if ret_2 != LZMA_OK { (*coder).pending_error = ret_2; @@ -1154,38 +1191,42 @@ unsafe extern "C" fn stream_decode_mt( threads_stop(coder); return LZMA_MEM_ERROR; } - (*(*coder).thr).outbuf = - lzma_outq_get_buf(&raw mut (*coder).outq, (*coder).thr as *mut c_void); + (*(*coder).thr).outbuf = lzma_outq_get_buf( + ::core::ptr::addr_of_mut!((*coder).outq), + (*coder).thr as *mut c_void, + ); let mut mythread_i_1478: c_uint = 0; while if mythread_i_1478 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); 1 } != 0 { let mut mythread_j_1478: c_uint = 0; while mythread_j_1478 == 0 { (*(*coder).thr).state = THR_RUN; - mythread_cond_signal(&raw mut (*(*coder).thr).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!( + (*(*coder).thr).cond + )); mythread_j_1478 = 1; } mythread_i_1478 = 1; } let mut mythread_i_1486: c_uint = 0; while if mythread_i_1486 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { let mut mythread_j_1486: c_uint = 0; while mythread_j_1486 == 0 { lzma_outq_enable_partial_output( - &raw mut (*coder).outq, + ::core::ptr::addr_of_mut!((*coder).outq), Some( worker_enable_partial_update as unsafe extern "C" fn(*mut c_void) -> (), @@ -1220,22 +1261,22 @@ unsafe extern "C" fn stream_decode_mt( in_pos, in_size, (*(*coder).thr).in_0, - &raw mut cur_in_filled, + ::core::ptr::addr_of_mut!(cur_in_filled), (*(*coder).thr).in_size, ); let mut mythread_i_1517: c_uint = 0; while if mythread_i_1517 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); 1 } != 0 { let mut mythread_j_1517: c_uint = 0; while mythread_j_1517 == 0 { (*(*coder).thr).in_filled = cur_in_filled; - mythread_cond_signal(&raw mut (*(*coder).thr).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*(*coder).thr).cond)); mythread_j_1517 = 1; } mythread_i_1517 = 1; @@ -1248,8 +1289,8 @@ unsafe extern "C" fn stream_decode_mt( out_size, core::ptr::null_mut(), waiting_allowed && *in_pos == in_size, - &raw mut wait_abs, - &raw mut has_blocked, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), ); if ret__2 != LZMA_OK { return ret__2; @@ -1274,9 +1315,12 @@ unsafe extern "C" fn stream_decoder_mt_end( ) { let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; threads_end(coder, allocator); - lzma_outq_end(&raw mut (*coder).outq, allocator); - lzma_next_end(&raw mut (*coder).block_decoder, allocator); - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_outq_end(::core::ptr::addr_of_mut!((*coder).outq), allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).block_decoder), allocator); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + allocator, + ); lzma_index_hash_end((*coder).index_hash, allocator); lzma_free(coder as *mut c_void, allocator); } @@ -1295,10 +1339,10 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; let mut mythread_i_1829: c_uint = 0; while if mythread_i_1829 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -1333,10 +1377,10 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; let mut mythread_i_1862: c_uint = 0; while if mythread_i_1862 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -1348,10 +1392,14 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( while i < (*coder).threads_initialized as size_t { let mut mythread_i_1867: c_uint = 0; while if mythread_i_1867 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 1 } != 0 { @@ -1431,12 +1479,12 @@ unsafe extern "C" fn stream_decoder_mt_init( return LZMA_MEM_ERROR; } (*next).coder = coder as *mut c_void; - if mythread_mutex_init(&raw mut (*coder).mutex) != 0 { + if mythread_mutex_init(::core::ptr::addr_of_mut!((*coder).mutex)) != 0 { lzma_free(coder as *mut c_void, allocator); return LZMA_MEM_ERROR; } - if mythread_cond_init(&raw mut (*coder).cond) != 0 { - mythread_mutex_destroy(&raw mut (*coder).mutex); + if mythread_cond_init(::core::ptr::addr_of_mut!((*coder).cond)) != 0 { + mythread_mutex_destroy(::core::ptr::addr_of_mut!((*coder).mutex)); lzma_free(coder as *mut c_void, allocator); return LZMA_MEM_ERROR; } @@ -1469,7 +1517,7 @@ unsafe extern "C" fn stream_decoder_mt_init( ); (*coder).filters[0].id = LZMA_VLI_UNKNOWN; core::ptr::write_bytes( - &raw mut (*coder).outq as *mut u8, + ::core::ptr::addr_of_mut!((*coder).outq) as *mut u8, 0 as u8, core::mem::size_of::(), ); @@ -1491,7 +1539,10 @@ unsafe extern "C" fn stream_decoder_mt_init( (*coder).threads_free = core::ptr::null_mut(); (*coder).threads_initialized = 0; } - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + allocator, + ); threads_end(coder, allocator); (*coder).mem_in_use = 0; (*coder).mem_cached = 0; @@ -1526,7 +1577,11 @@ unsafe extern "C" fn stream_decoder_mt_init( (*coder).out_was_filled = false; (*coder).pos = 0; (*coder).threads_max = (*options).threads; - let ret_: lzma_ret = lzma_outq_init(&raw mut (*coder).outq, allocator, (*coder).threads_max); + let ret_: lzma_ret = lzma_outq_init( + ::core::ptr::addr_of_mut!((*coder).outq), + allocator, + (*coder).threads_max, + ); if ret_ != LZMA_OK { return ret_; } @@ -1541,7 +1596,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_mt( return ret_; } let ret__0: lzma_ret = stream_decoder_mt_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, options, ); diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 0b471eff..c2f7c39b 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { @@ -27,14 +26,14 @@ unsafe extern "C" fn block_encoder_init( ) -> lzma_ret { (*coder).block_options.compressed_size = LZMA_VLI_UNKNOWN; (*coder).block_options.uncompressed_size = LZMA_VLI_UNKNOWN; - let ret_: lzma_ret = lzma_block_header_size(&raw mut (*coder).block_options); + let ret_: lzma_ret = lzma_block_header_size(::core::ptr::addr_of_mut!((*coder).block_options)); if ret_ != LZMA_OK { return ret_; } lzma_block_encoder_init( - &raw mut (*coder).block_encoder, + ::core::ptr::addr_of_mut!((*coder).block_encoder), allocator, - &raw mut (*coder).block_options, + ::core::ptr::addr_of_mut!((*coder).block_options), ) } unsafe extern "C" fn stream_encode( @@ -53,8 +52,8 @@ unsafe extern "C" fn stream_encode( match (*coder).sequence { 0 | 2 | 5 => { lzma_bufcpy( - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).buffer_pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).buffer_pos), (*coder).buffer_size, out, out_pos, @@ -79,7 +78,7 @@ unsafe extern "C" fn stream_encode( }; } let ret_: lzma_ret = lzma_index_encoder_init( - &raw mut (*coder).index_encoder, + ::core::ptr::addr_of_mut!((*coder).index_encoder), allocator, (*coder).index, ); @@ -96,8 +95,8 @@ unsafe extern "C" fn stream_encode( } (*coder).block_encoder_is_initialized = false; if lzma_block_header_encode( - &raw mut (*coder).block_options, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of_mut!((*coder).block_options), + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, ) != LZMA_OK { return LZMA_PROG_ERROR; @@ -129,7 +128,8 @@ unsafe extern "C" fn stream_encode( return ret; } let unpadded_size: lzma_vli = - lzma_block_unpadded_size(&raw mut (*coder).block_options) as lzma_vli; + lzma_block_unpadded_size(::core::ptr::addr_of_mut!((*coder).block_options)) + as lzma_vli; let ret__1: lzma_ret = lzma_index_append( (*coder).index, allocator, @@ -176,8 +176,8 @@ unsafe extern "C" fn stream_encode( reserved_int2: 0, }; if lzma_stream_footer_encode( - &raw const stream_flags, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of!(stream_flags), + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, ) != LZMA_OK { return LZMA_PROG_ERROR; @@ -192,10 +192,13 @@ unsafe extern "C" fn stream_encode( } unsafe extern "C" fn stream_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - lzma_next_end(&raw mut (*coder).block_encoder, allocator); - lzma_next_end(&raw mut (*coder).index_encoder, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).block_encoder), allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).index_encoder), allocator); lzma_index_end((*coder).index, allocator); - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + allocator, + ); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn stream_encoder_update( @@ -211,15 +214,20 @@ unsafe extern "C" fn stream_encoder_update( id: 0, options: core::ptr::null_mut(), }; 5]; - let ret_: lzma_ret = lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator); + let ret_: lzma_ret = lzma_filters_copy( + filters, + ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter, + allocator, + ); if ret_ != LZMA_OK { return ret_; } if (*coder).sequence <= SEQ_BLOCK_INIT { (*coder).block_encoder_is_initialized = false; - (*coder).block_options.filters = &raw mut temp as *mut lzma_filter; + (*coder).block_options.filters = ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter; ret = block_encoder_init(coder, allocator); - (*coder).block_options.filters = &raw mut (*coder).filters as *mut lzma_filter; + (*coder).block_options.filters = + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter; if ret != LZMA_OK { current_block = 9913398440939854562; } else { @@ -244,14 +252,20 @@ unsafe extern "C" fn stream_encoder_update( } match current_block { 9913398440939854562 => { - lzma_filters_free(&raw mut temp as *mut lzma_filter, allocator); + lzma_filters_free( + ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter, + allocator, + ); return ret; } _ => { - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + allocator, + ); core::ptr::copy_nonoverlapping( - &raw mut temp as *const u8, - &raw mut (*coder).filters as *mut u8, + ::core::ptr::addr_of_mut!(temp) as *const u8, + ::core::ptr::addr_of_mut!((*coder).filters) as *mut u8, core::mem::size_of::<[lzma_filter; 5]>(), ); return LZMA_OK; @@ -396,8 +410,10 @@ unsafe extern "C" fn stream_encoder_init( reserved_int1: 0, reserved_int2: 0, }; - let ret_: lzma_ret = - lzma_stream_header_encode(&raw mut stream_flags, &raw mut (*coder).buffer as *mut u8); + let ret_: lzma_ret = lzma_stream_header_encode( + ::core::ptr::addr_of_mut!(stream_flags), + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ); if ret_ != LZMA_OK { return ret_; } @@ -415,7 +431,7 @@ pub unsafe extern "C" fn lzma_stream_encoder( return ret_; } let ret__0: lzma_ret = stream_encoder_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, filters, check, diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 8cb53e3e..262d9022 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_int, c_uint, c_ulonglong, c_void}; extern "C" { fn lzma_mt_block_size(filters: *const lzma_filter) -> u64; fn lzma_block_uncomp_encode( @@ -72,10 +71,10 @@ pub const BLOCK_SIZE_MAX: c_ulonglong = UINT64_MAX.wrapping_div(LZMA_THREADS_MAX unsafe extern "C" fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { let mut mythread_i_207: c_uint = 0; while if mythread_i_207 != 0 { - mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); 1 } != 0 { @@ -84,7 +83,7 @@ unsafe extern "C" fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { if (*(*thr).coder).thread_error == LZMA_OK { (*(*thr).coder).thread_error = ret; } - mythread_cond_signal(&raw mut (*(*thr).coder).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*(*thr).coder).cond)); mythread_j_207 = 1; } mythread_i_207 = 1; @@ -101,7 +100,7 @@ unsafe extern "C" fn worker_encode( check: (*(*thr).coder).stream_flags.check, compressed_size: (*(*thr).outbuf).allocated as lzma_vli, uncompressed_size: (*(*thr).coder).block_size as lzma_vli, - filters: &raw mut (*thr).filters as *mut lzma_filter, + filters: ::core::ptr::addr_of_mut!((*thr).filters) as *mut lzma_filter, raw_check: [0; 64], reserved_ptr1: core::ptr::null_mut(), reserved_ptr2: core::ptr::null_mut(), @@ -127,15 +126,15 @@ unsafe extern "C" fn worker_encode( reserved_bool7: 0, reserved_bool8: 0, }; - let mut ret: lzma_ret = lzma_block_header_size(&raw mut (*thr).block_options); + let mut ret: lzma_ret = lzma_block_header_size(::core::ptr::addr_of_mut!((*thr).block_options)); if ret != LZMA_OK { worker_error(thr, ret); return THR_STOP; } ret = lzma_block_encoder_init( - &raw mut (*thr).block_encoder, + ::core::ptr::addr_of_mut!((*thr).block_encoder), (*thr).allocator, - &raw mut (*thr).block_options, + ::core::ptr::addr_of_mut!((*thr).block_options), ); if ret != LZMA_OK { worker_error(thr, ret); @@ -148,10 +147,10 @@ unsafe extern "C" fn worker_encode( loop { let mut mythread_i_258: c_uint = 0; while if mythread_i_258 != 0 { - mythread_mutex_unlock(&raw mut (*thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*thr).mutex)); 1 } != 0 { @@ -160,7 +159,10 @@ unsafe extern "C" fn worker_encode( (*thr).progress_in = in_pos as u64; (*thr).progress_out = *out_pos as u64; while in_size == (*thr).in_size && (*thr).state == THR_RUN { - mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + mythread_cond_wait( + ::core::ptr::addr_of_mut!((*thr).cond), + ::core::ptr::addr_of_mut!((*thr).mutex), + ); } state = (*thr).state; in_size = (*thr).in_size; @@ -186,9 +188,9 @@ unsafe extern "C" fn worker_encode( (*thr).block_encoder.coder, (*thr).allocator, (*thr).in_0, - &raw mut in_pos, + ::core::ptr::addr_of_mut!(in_pos), in_limit, - &raw mut (*(*thr).outbuf).buf as *mut u8, + ::core::ptr::addr_of_mut!((*(*thr).outbuf).buf) as *mut u8, out_pos, out_size, action, @@ -200,8 +202,8 @@ unsafe extern "C" fn worker_encode( match ret { 1 => { ret = lzma_block_header_encode( - &raw mut (*thr).block_options, - &raw mut (*(*thr).outbuf).buf as *mut u8, + ::core::ptr::addr_of_mut!((*thr).block_options), + ::core::ptr::addr_of_mut!((*(*thr).outbuf).buf) as *mut u8, ); if ret != LZMA_OK { worker_error(thr, ret); @@ -211,17 +213,20 @@ unsafe extern "C" fn worker_encode( 0 => { let mut mythread_i_321: c_uint = 0; while if mythread_i_321 != 0 { - mythread_mutex_unlock(&raw mut (*thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*thr).mutex)); 1 } != 0 { let mut mythread_j_321: c_uint = 0; while mythread_j_321 == 0 { while (*thr).state == THR_RUN { - mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + mythread_cond_wait( + ::core::ptr::addr_of_mut!((*thr).cond), + ::core::ptr::addr_of_mut!((*thr).mutex), + ); } state = (*thr).state; in_size = (*thr).in_size; @@ -234,10 +239,10 @@ unsafe extern "C" fn worker_encode( } *out_pos = 0; ret = lzma_block_uncomp_encode( - &raw mut (*thr).block_options, + ::core::ptr::addr_of_mut!((*thr).block_options), (*thr).in_0, in_size, - &raw mut (*(*thr).outbuf).buf as *mut u8, + ::core::ptr::addr_of_mut!((*(*thr).outbuf).buf) as *mut u8, out_pos, out_size, ); @@ -251,7 +256,8 @@ unsafe extern "C" fn worker_encode( return THR_STOP; } } - (*(*thr).outbuf).unpadded_size = lzma_block_unpadded_size(&raw mut (*thr).block_options); + (*(*thr).outbuf).unpadded_size = + lzma_block_unpadded_size(::core::ptr::addr_of_mut!((*thr).block_options)); (*(*thr).outbuf).uncompressed_size = (*thr).block_options.uncompressed_size; THR_FINISH } @@ -261,10 +267,10 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { loop { let mut mythread_i_370: c_uint = 0; while if mythread_i_370 != 0 { - mythread_mutex_unlock(&raw mut (*thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*thr).mutex)); 1 } != 0 { @@ -273,13 +279,16 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { loop { if (*thr).state == THR_STOP { (*thr).state = THR_IDLE; - mythread_cond_signal(&raw mut (*thr).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*thr).cond)); } state = (*thr).state; if state != THR_IDLE { break; } - mythread_cond_wait(&raw mut (*thr).cond, &raw mut (*thr).mutex); + mythread_cond_wait( + ::core::ptr::addr_of_mut!((*thr).cond), + ::core::ptr::addr_of_mut!((*thr).mutex), + ); } mythread_j_370 = 1; } @@ -287,17 +296,17 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { } let mut out_pos: size_t = 0; if state <= THR_FINISH { - state = worker_encode(thr, &raw mut out_pos, state); + state = worker_encode(thr, ::core::ptr::addr_of_mut!(out_pos), state); } if state == THR_EXIT { break; } let mut mythread_i_401: c_uint = 0; while if mythread_i_401 != 0 { - mythread_mutex_unlock(&raw mut (*thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*thr).mutex)); 1 } != 0 { @@ -305,7 +314,7 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { while mythread_j_401 == 0 { if (*thr).state != THR_EXIT { (*thr).state = THR_IDLE; - mythread_cond_signal(&raw mut (*thr).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*thr).cond)); } mythread_j_401 = 1; } @@ -313,10 +322,10 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { } let mut mythread_i_408: c_uint = 0; while if mythread_i_408 != 0 { - mythread_mutex_unlock(&raw mut (*(*thr).coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*(*thr).coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); 1 } != 0 { @@ -335,19 +344,22 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { (*thr).progress_out = 0; (*thr).next = (*(*thr).coder).threads_free; (*(*thr).coder).threads_free = thr; - mythread_cond_signal(&raw mut (*(*thr).coder).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*(*thr).coder).cond)); mythread_j_408 = 1; } mythread_i_408 = 1; } } lzma_filters_free( - &raw mut (*thr).filters as *mut lzma_filter, + ::core::ptr::addr_of_mut!((*thr).filters) as *mut lzma_filter, + (*thr).allocator, + ); + mythread_mutex_destroy(::core::ptr::addr_of_mut!((*thr).mutex)); + mythread_cond_destroy(::core::ptr::addr_of_mut!((*thr).cond)); + lzma_next_end( + ::core::ptr::addr_of_mut!((*thr).block_encoder), (*thr).allocator, ); - mythread_mutex_destroy(&raw mut (*thr).mutex); - mythread_cond_destroy(&raw mut (*thr).cond); - lzma_next_end(&raw mut (*thr).block_encoder, (*thr).allocator); lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); MYTHREAD_RET_VALUE } @@ -356,17 +368,23 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_thread while i < (*coder).threads_initialized { let mut mythread_i_449: c_uint = 0; while if mythread_i_449 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 1 } != 0 { let mut mythread_j_449: c_uint = 0; while mythread_j_449 == 0 { (*(*coder).threads.offset(i as isize)).state = THR_STOP; - mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).cond + )); mythread_j_449 = 1; } mythread_i_449 = 1; @@ -380,10 +398,14 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_thread while i_0 < (*coder).threads_initialized { let mut mythread_i_460: c_uint = 0; while if mythread_i_460 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i_0 as isize)).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i_0 as isize)).mutex + )); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i_0 as isize)).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i_0 as isize)).mutex + )); 1 } != 0 { @@ -391,8 +413,8 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_thread while mythread_j_460 == 0 { while (*(*coder).threads.offset(i_0 as isize)).state != THR_IDLE { mythread_cond_wait( - &raw mut (*(*coder).threads.offset(i_0 as isize)).cond, - &raw mut (*(*coder).threads.offset(i_0 as isize)).mutex, + ::core::ptr::addr_of_mut!((*(*coder).threads.offset(i_0 as isize)).cond), + ::core::ptr::addr_of_mut!((*(*coder).threads.offset(i_0 as isize)).mutex), ); } mythread_j_460 = 1; @@ -407,17 +429,23 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons while i < (*coder).threads_initialized { let mut mythread_i_477: c_uint = 0; while if mythread_i_477 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 1 } != 0 { let mut mythread_j_477: c_uint = 0; while mythread_j_477 == 0 { (*(*coder).threads.offset(i as isize)).state = THR_EXIT; - mythread_cond_signal(&raw mut (*(*coder).threads.offset(i as isize)).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).cond + )); mythread_j_477 = 1; } mythread_i_477 = 1; @@ -443,8 +471,8 @@ unsafe extern "C" fn initialize_new_thread( if (*thr).in_0.is_null() { return LZMA_MEM_ERROR; } - if mythread_mutex_init(&raw mut (*thr).mutex) == 0 { - if mythread_cond_init(&raw mut (*thr).cond) == 0 { + if mythread_mutex_init(::core::ptr::addr_of_mut!((*thr).mutex)) == 0 { + if mythread_cond_init(::core::ptr::addr_of_mut!((*thr).cond)) == 0 { (*thr).state = THR_IDLE; (*thr).allocator = allocator; (*thr).coder = coder; @@ -464,19 +492,19 @@ unsafe extern "C" fn initialize_new_thread( }; (*thr).filters[0].id = LZMA_VLI_UNKNOWN; if mythread_create( - &raw mut (*thr).thread_id, + ::core::ptr::addr_of_mut!((*thr).thread_id), Some(worker_start as unsafe extern "C" fn(*mut c_void) -> *mut c_void), thr as *mut c_void, ) != 0 { - mythread_cond_destroy(&raw mut (*thr).cond); + mythread_cond_destroy(::core::ptr::addr_of_mut!((*thr).cond)); } else { (*coder).threads_initialized = (*coder).threads_initialized.wrapping_add(1); (*coder).thr = thr; return LZMA_OK; } } - mythread_mutex_destroy(&raw mut (*thr).mutex); + mythread_mutex_destroy(::core::ptr::addr_of_mut!((*thr).mutex)); } lzma_free((*thr).in_0 as *mut c_void, allocator); LZMA_MEM_ERROR @@ -485,11 +513,11 @@ unsafe extern "C" fn get_thread( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { - if !lzma_outq_has_buf(&raw mut (*coder).outq) { + if !lzma_outq_has_buf(::core::ptr::addr_of_mut!((*coder).outq)) { return LZMA_OK; } let ret_: lzma_ret = lzma_outq_prealloc_buf( - &raw mut (*coder).outq, + ::core::ptr::addr_of_mut!((*coder).outq), allocator, (*coder).outbuf_alloc_size, ); @@ -498,8 +526,8 @@ unsafe extern "C" fn get_thread( } if (*coder).filters_cache[0].id == LZMA_VLI_UNKNOWN { let ret__0: lzma_ret = lzma_filters_copy( - &raw mut (*coder).filters as *mut lzma_filter, - &raw mut (*coder).filters_cache as *mut lzma_filter, + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + ::core::ptr::addr_of_mut!((*coder).filters_cache) as *mut lzma_filter, allocator, ); if ret__0 != LZMA_OK { @@ -508,10 +536,10 @@ unsafe extern "C" fn get_thread( } let mut mythread_i_560: c_uint = 0; while if mythread_i_560 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -536,10 +564,10 @@ unsafe extern "C" fn get_thread( } let mut mythread_i_578: c_uint = 0; while if mythread_i_578 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); 1 } != 0 { @@ -547,19 +575,21 @@ unsafe extern "C" fn get_thread( while mythread_j_578 == 0 { (*(*coder).thr).state = THR_RUN; (*(*coder).thr).in_size = 0; - (*(*coder).thr).outbuf = - lzma_outq_get_buf(&raw mut (*coder).outq, core::ptr::null_mut()); + (*(*coder).thr).outbuf = lzma_outq_get_buf( + ::core::ptr::addr_of_mut!((*coder).outq), + core::ptr::null_mut(), + ); lzma_filters_free( - &raw mut (*(*coder).thr).filters as *mut lzma_filter, + ::core::ptr::addr_of_mut!((*(*coder).thr).filters) as *mut lzma_filter, allocator, ); core::ptr::copy_nonoverlapping( - &raw mut (*coder).filters_cache as *const u8, - &raw mut (*(*coder).thr).filters as *mut u8, + ::core::ptr::addr_of_mut!((*coder).filters_cache) as *const u8, + ::core::ptr::addr_of_mut!((*(*coder).thr).filters) as *mut u8, core::mem::size_of::<[lzma_filter; 5]>(), ); (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; - mythread_cond_signal(&raw mut (*(*coder).thr).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*(*coder).thr).cond)); mythread_j_578 = 1; } mythread_i_578 = 1; @@ -587,7 +617,7 @@ unsafe extern "C" fn stream_encode_in( in_pos, in_size, (*(*coder).thr).in_0, - &raw mut thr_in_size, + ::core::ptr::addr_of_mut!(thr_in_size), (*coder).block_size, ); let finish: bool = @@ -595,10 +625,10 @@ unsafe extern "C" fn stream_encode_in( let mut block_error: bool = false; let mut mythread_i_628: c_uint = 0; while if mythread_i_628 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).thr).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).thr).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); 1 } != 0 { @@ -611,7 +641,7 @@ unsafe extern "C" fn stream_encode_in( if finish { (*(*coder).thr).state = THR_FINISH; } - mythread_cond_signal(&raw mut (*(*coder).thr).cond); + mythread_cond_signal(::core::ptr::addr_of_mut!((*(*coder).thr).cond)); } mythread_j_628 = 1; } @@ -621,10 +651,10 @@ unsafe extern "C" fn stream_encode_in( let mut ret_0: lzma_ret = LZMA_OK; let mut mythread_i_649: c_uint = 0; while if mythread_i_649 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -651,15 +681,19 @@ unsafe extern "C" fn wait_for_work( ) -> bool { if (*coder).timeout != 0 && !*has_blocked { *has_blocked = true; - mythread_condtime_set(wait_abs, &raw mut (*coder).cond, (*coder).timeout); + mythread_condtime_set( + wait_abs, + ::core::ptr::addr_of_mut!((*coder).cond), + (*coder).timeout, + ); } let mut timed_out: bool = false; let mut mythread_i_689: c_uint = 0; while if mythread_i_689 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -667,19 +701,22 @@ unsafe extern "C" fn wait_for_work( while mythread_j_689 == 0 { while (!has_input || (*coder).threads_free.is_null() - || !lzma_outq_has_buf(&raw mut (*coder).outq)) - && !lzma_outq_is_readable(&raw mut (*coder).outq) + || !lzma_outq_has_buf(::core::ptr::addr_of_mut!((*coder).outq))) + && !lzma_outq_is_readable(::core::ptr::addr_of_mut!((*coder).outq)) && (*coder).thread_error == LZMA_OK && !timed_out { if (*coder).timeout != 0 { timed_out = mythread_cond_timedwait( - &raw mut (*coder).cond, - &raw mut (*coder).mutex, + ::core::ptr::addr_of_mut!((*coder).cond), + ::core::ptr::addr_of_mut!((*coder).mutex), wait_abs, ) != 0; } else { - mythread_cond_wait(&raw mut (*coder).cond, &raw mut (*coder).mutex); + mythread_cond_wait( + ::core::ptr::addr_of_mut!((*coder).cond), + ::core::ptr::addr_of_mut!((*coder).mutex), + ); } } mythread_j_689 = 1; @@ -700,190 +737,167 @@ unsafe extern "C" fn stream_encode_mt( action: lzma_action, ) -> lzma_ret { let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - 's_270: { - let mut current_block_53: u64; - match (*coder).sequence { - 0 => { - lzma_bufcpy( - &raw mut (*coder).header as *mut u8, - &raw mut (*coder).header_pos, - core::mem::size_of::<[u8; 12]>(), - out, - out_pos, - out_size, - ); - if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() { - return LZMA_OK; - } - (*coder).header_pos = 0; - (*coder).sequence = SEQ_BLOCK; - current_block_53 = 18046538441878631153; - } - 1 => { - current_block_53 = 18046538441878631153; - } - 2 => { - current_block_53 = 7301844830188010456; - } - 3 => { - current_block_53 = 8365064614624041636; - } - _ => { - break 's_270; + let mut current_block_53: u64 = match (*coder).sequence { + 0 => { + lzma_bufcpy( + ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).header_pos), + core::mem::size_of::<[u8; 12]>(), + out, + out_pos, + out_size, + ); + if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() { + return LZMA_OK; } + (*coder).header_pos = 0; + (*coder).sequence = SEQ_BLOCK; + 18046538441878631153 } - match current_block_53 { - 18046538441878631153 => { - let mut unpadded_size: lzma_vli = 0; - let mut uncompressed_size: lzma_vli = 0; - let mut ret: lzma_ret = LZMA_OK; - let mut has_blocked: bool = false; - let mut wait_abs: mythread_condtime = timespec { - tv_sec: 0 as __darwin_time_t, - tv_nsec: 0, - }; - loop { - let mut mythread_i_747: c_uint = 0; - while if mythread_i_747 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); - 0 - } else { - mythread_mutex_lock(&raw mut (*coder).mutex); - 1 - } != 0 - { - let mut mythread_j_747: c_uint = 0; - while mythread_j_747 == 0 { - ret = (*coder).thread_error; - if ret != LZMA_OK { - break; - } - ret = lzma_outq_read( - &raw mut (*coder).outq, - allocator, - out, - out_pos, - out_size, - &raw mut unpadded_size, - &raw mut uncompressed_size, - ); - mythread_j_747 = 1; - } - mythread_i_747 = 1; - } - if ret == LZMA_STREAM_END { - ret = lzma_index_append( - (*coder).index, - allocator, - unpadded_size, - uncompressed_size, - ); - if ret != LZMA_OK { - threads_stop(coder, false); - return ret; - } - if *out_pos < out_size { - continue; - } - } - if ret != LZMA_OK { - threads_stop(coder, false); - return ret; - } - ret = stream_encode_in(coder, allocator, in_0, in_pos, in_size, action); + 1 => 18046538441878631153, + 2 => 7301844830188010456, + 3 => 8365064614624041636, + _ => return LZMA_PROG_ERROR, + }; + if current_block_53 == 18046538441878631153 { + let mut unpadded_size: lzma_vli = 0; + let mut uncompressed_size: lzma_vli = 0; + let mut ret: lzma_ret = LZMA_OK; + let mut has_blocked: bool = false; + let mut wait_abs: mythread_condtime = timespec { + tv_sec: 0 as __darwin_time_t, + tv_nsec: 0, + }; + loop { + let mut mythread_i_747: c_uint = 0; + while if mythread_i_747 != 0 { + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); + 0 + } else { + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); + 1 + } != 0 + { + let mut mythread_j_747: c_uint = 0; + while mythread_j_747 == 0 { + ret = (*coder).thread_error; if ret != LZMA_OK { - threads_stop(coder, false); - return ret; - } - if *in_pos == in_size { - if action == LZMA_RUN { - return LZMA_OK; - } - if action == LZMA_FULL_BARRIER { - return LZMA_STREAM_END; - } - if lzma_outq_is_empty(&raw mut (*coder).outq) { - if action == LZMA_FINISH { - break; - } - if action == LZMA_FULL_FLUSH { - return LZMA_STREAM_END; - } - } - } - if *out_pos == out_size { - return LZMA_OK; - } - if wait_for_work( - coder, - &raw mut wait_abs, - &raw mut has_blocked, - *in_pos < in_size, - ) { - return LZMA_RET_INTERNAL1; + break; } + ret = lzma_outq_read( + ::core::ptr::addr_of_mut!((*coder).outq), + allocator, + out, + out_pos, + out_size, + ::core::ptr::addr_of_mut!(unpadded_size), + ::core::ptr::addr_of_mut!(uncompressed_size), + ); + mythread_j_747 = 1; } - let ret_: lzma_ret = lzma_index_encoder_init( - &raw mut (*coder).index_encoder, - allocator, - (*coder).index, - ); - if ret_ != LZMA_OK { - return ret_; + mythread_i_747 = 1; + } + if ret == LZMA_STREAM_END { + ret = + lzma_index_append((*coder).index, allocator, unpadded_size, uncompressed_size); + if ret != LZMA_OK { + threads_stop(coder, false); + return ret; + } + if *out_pos < out_size { + continue; } - (*coder).sequence = SEQ_INDEX; - (*coder).progress_out = (*coder).progress_out.wrapping_add( - lzma_index_size((*coder).index) - .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) - as u64, - ); - current_block_53 = 7301844830188010456; } - _ => {} - } - match current_block_53 { - 7301844830188010456 => { - let ret_0: lzma_ret = (*coder).index_encoder.code.unwrap()( - (*coder).index_encoder.coder, - allocator, - core::ptr::null(), - core::ptr::null_mut(), - 0, - out, - out_pos, - out_size, - LZMA_RUN, - ); - if ret_0 != LZMA_STREAM_END { - return ret_0; + if ret != LZMA_OK { + threads_stop(coder, false); + return ret; + } + ret = stream_encode_in(coder, allocator, in_0, in_pos, in_size, action); + if ret != LZMA_OK { + threads_stop(coder, false); + return ret; + } + if *in_pos == in_size { + if action == LZMA_RUN { + return LZMA_OK; } - (*coder).stream_flags.backward_size = lzma_index_size((*coder).index); - if lzma_stream_footer_encode( - &raw mut (*coder).stream_flags, - &raw mut (*coder).header as *mut u8, - ) != LZMA_OK - { - return LZMA_PROG_ERROR; + if action == LZMA_FULL_BARRIER { + return LZMA_STREAM_END; } - (*coder).sequence = SEQ_STREAM_FOOTER; + if lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { + if action == LZMA_FINISH { + break; + } + if action == LZMA_FULL_FLUSH { + return LZMA_STREAM_END; + } + } + } + if *out_pos == out_size { + return LZMA_OK; + } + if wait_for_work( + coder, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), + *in_pos < in_size, + ) { + return LZMA_RET_INTERNAL1; } - _ => {} } - lzma_bufcpy( - &raw mut (*coder).header as *mut u8, - &raw mut (*coder).header_pos, - core::mem::size_of::<[u8; 12]>(), + let ret_: lzma_ret = lzma_index_encoder_init( + ::core::ptr::addr_of_mut!((*coder).index_encoder), + allocator, + (*coder).index, + ); + if ret_ != LZMA_OK { + return ret_; + } + (*coder).sequence = SEQ_INDEX; + (*coder).progress_out = (*coder).progress_out.wrapping_add( + lzma_index_size((*coder).index).wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) + as u64, + ); + current_block_53 = 7301844830188010456; + } + if current_block_53 == 7301844830188010456 { + let ret_0: lzma_ret = (*coder).index_encoder.code.unwrap()( + (*coder).index_encoder.coder, + allocator, + core::ptr::null(), + core::ptr::null_mut(), + 0, out, out_pos, out_size, + LZMA_RUN, ); - return if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() { - LZMA_OK - } else { - LZMA_STREAM_END - }; + if ret_0 != LZMA_STREAM_END { + return ret_0; + } + (*coder).stream_flags.backward_size = lzma_index_size((*coder).index); + if lzma_stream_footer_encode( + ::core::ptr::addr_of_mut!((*coder).stream_flags), + ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, + ) != LZMA_OK + { + return LZMA_PROG_ERROR; + } + (*coder).sequence = SEQ_STREAM_FOOTER; + } + lzma_bufcpy( + ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).header_pos), + core::mem::size_of::<[u8; 12]>(), + out, + out_pos, + out_size, + ); + if (*coder).header_pos < core::mem::size_of::<[u8; 12]>() { + LZMA_OK + } else { + LZMA_STREAM_END } - LZMA_PROG_ERROR } unsafe extern "C" fn stream_encoder_mt_end( coder_ptr: *mut c_void, @@ -891,16 +905,19 @@ unsafe extern "C" fn stream_encoder_mt_end( ) { let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; threads_end(coder, allocator); - lzma_outq_end(&raw mut (*coder).outq, allocator); - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); + lzma_outq_end(::core::ptr::addr_of_mut!((*coder).outq), allocator); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + allocator, + ); lzma_filters_free( - &raw mut (*coder).filters_cache as *mut lzma_filter, + ::core::ptr::addr_of_mut!((*coder).filters_cache) as *mut lzma_filter, allocator, ); - lzma_next_end(&raw mut (*coder).index_encoder, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).index_encoder), allocator); lzma_index_end((*coder).index, allocator); - mythread_cond_destroy(&raw mut (*coder).cond); - mythread_mutex_destroy(&raw mut (*coder).mutex); + mythread_cond_destroy(::core::ptr::addr_of_mut!((*coder).cond)); + mythread_mutex_destroy(::core::ptr::addr_of_mut!((*coder).mutex)); lzma_free(coder as *mut c_void, allocator); } unsafe extern "C" fn stream_encoder_mt_update( @@ -923,18 +940,25 @@ unsafe extern "C" fn stream_encoder_mt_update( id: 0, options: core::ptr::null_mut(), }; 5]; - let ret_: lzma_ret = lzma_filters_copy(filters, &raw mut temp as *mut lzma_filter, allocator); + let ret_: lzma_ret = lzma_filters_copy( + filters, + ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter, + allocator, + ); if ret_ != LZMA_OK { return ret_; } - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); lzma_filters_free( - &raw mut (*coder).filters_cache as *mut lzma_filter, + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + allocator, + ); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters_cache) as *mut lzma_filter, allocator, ); core::ptr::copy_nonoverlapping( - &raw mut temp as *const u8, - &raw mut (*coder).filters as *mut u8, + ::core::ptr::addr_of_mut!(temp) as *const u8, + ::core::ptr::addr_of_mut!((*coder).filters) as *mut u8, core::mem::size_of::<[lzma_filter; 5]>(), ); LZMA_OK @@ -958,7 +982,7 @@ unsafe extern "C" fn get_options( if lzma_easy_preset(opt_easy, (*options).preset) { return LZMA_OPTIONS_ERROR; } - *filters = &raw mut (*opt_easy).filters as *mut lzma_filter; + *filters = ::core::ptr::addr_of_mut!((*opt_easy).filters) as *mut lzma_filter; } if (*options).block_size > 0 { *block_size = (*options).block_size; @@ -982,10 +1006,10 @@ unsafe extern "C" fn get_progress( let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; let mut mythread_i_1010: c_uint = 0; while if mythread_i_1010 != 0 { - mythread_mutex_unlock(&raw mut (*coder).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); 0 } else { - mythread_mutex_lock(&raw mut (*coder).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); 1 } != 0 { @@ -997,10 +1021,14 @@ unsafe extern "C" fn get_progress( while i < (*coder).threads_initialized as size_t { let mut mythread_i_1015: c_uint = 0; while if mythread_i_1015 != 0 { - mythread_mutex_unlock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_unlock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 0 } else { - mythread_mutex_lock(&raw mut (*(*coder).threads.offset(i as isize)).mutex); + mythread_mutex_lock(::core::ptr::addr_of_mut!( + (*(*coder).threads.offset(i as isize)).mutex + )); 1 } != 0 { @@ -1100,10 +1128,10 @@ unsafe extern "C" fn stream_encoder_mt_init( let mut outbuf_size_max: u64 = 0; let ret_: lzma_ret = get_options( options, - &raw mut easy, - &raw mut filters, - &raw mut block_size, - &raw mut outbuf_size_max, + ::core::ptr::addr_of_mut!(easy), + ::core::ptr::addr_of_mut!(filters), + ::core::ptr::addr_of_mut!(block_size), + ::core::ptr::addr_of_mut!(outbuf_size_max), ); if ret_ != LZMA_OK { return ret_; @@ -1125,13 +1153,13 @@ unsafe extern "C" fn stream_encoder_mt_init( return LZMA_MEM_ERROR; } (*next).coder = coder as *mut c_void; - if mythread_mutex_init(&raw mut (*coder).mutex) != 0 { + if mythread_mutex_init(::core::ptr::addr_of_mut!((*coder).mutex)) != 0 { lzma_free(coder as *mut c_void, allocator); (*next).coder = core::ptr::null_mut(); return LZMA_MEM_ERROR; } - if mythread_cond_init(&raw mut (*coder).cond) != 0 { - mythread_mutex_destroy(&raw mut (*coder).mutex); + if mythread_cond_init(::core::ptr::addr_of_mut!((*coder).cond)) != 0 { + mythread_mutex_destroy(::core::ptr::addr_of_mut!((*coder).mutex)); lzma_free(coder as *mut c_void, allocator); (*next).coder = core::ptr::null_mut(); return LZMA_MEM_ERROR; @@ -1180,7 +1208,7 @@ unsafe extern "C" fn stream_encoder_mt_init( }; (*coder).index = core::ptr::null_mut(); core::ptr::write_bytes( - &raw mut (*coder).outq as *mut u8, + ::core::ptr::addr_of_mut!((*coder).outq) as *mut u8, 0 as u8, core::mem::size_of::(), ); @@ -1210,19 +1238,26 @@ unsafe extern "C" fn stream_encoder_mt_init( } else { threads_stop(coder, true); } - let ret__0: lzma_ret = lzma_outq_init(&raw mut (*coder).outq, allocator, (*options).threads); + let ret__0: lzma_ret = lzma_outq_init( + ::core::ptr::addr_of_mut!((*coder).outq), + allocator, + (*options).threads, + ); if ret__0 != LZMA_OK { return ret__0; } (*coder).timeout = (*options).timeout; - lzma_filters_free(&raw mut (*coder).filters as *mut lzma_filter, allocator); lzma_filters_free( - &raw mut (*coder).filters_cache as *mut lzma_filter, + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + allocator, + ); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters_cache) as *mut lzma_filter, allocator, ); let ret__1: lzma_ret = lzma_filters_copy( filters, - &raw mut (*coder).filters as *mut lzma_filter, + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, allocator, ); if ret__1 != LZMA_OK { @@ -1236,8 +1271,8 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).stream_flags.version = 0; (*coder).stream_flags.check = (*options).check; let ret__2: lzma_ret = lzma_stream_header_encode( - &raw mut (*coder).stream_flags, - &raw mut (*coder).header as *mut u8, + ::core::ptr::addr_of_mut!((*coder).stream_flags), + ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, ); if ret__2 != LZMA_OK { return ret__2; @@ -1256,7 +1291,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( return ret_; } let ret__0: lzma_ret = stream_encoder_mt_init( - &raw mut (*(*strm).internal).next, + ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, options, ); @@ -1308,10 +1343,10 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt let mut outbuf_size_max: u64 = 0; if get_options( options, - &raw mut easy, - &raw mut filters, - &raw mut block_size, - &raw mut outbuf_size_max, + ::core::ptr::addr_of_mut!(easy), + ::core::ptr::addr_of_mut!(filters), + ::core::ptr::addr_of_mut!(block_size), + ::core::ptr::addr_of_mut!(outbuf_size_max), ) != LZMA_OK { return UINT64_MAX; diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index c04532d0..957191ed 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { static lzma_header_magic: [u8; 6]; static lzma_footer_magic: [u8; 2]; @@ -20,7 +19,7 @@ pub unsafe extern "C" fn lzma_stream_header_decode( ) -> lzma_ret { if memcmp( in_0 as *const c_void, - &raw const lzma_header_magic as *const c_void, + ::core::ptr::addr_of!(lzma_header_magic) as *const c_void, core::mem::size_of::<[u8; 6]>(), ) != 0 { @@ -55,7 +54,7 @@ pub unsafe extern "C" fn lzma_stream_footer_decode( if memcmp( in_0.offset((core::mem::size_of::()).wrapping_mul(2) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *const c_void, - &raw const lzma_footer_magic as *const c_void, + ::core::ptr::addr_of!(lzma_footer_magic) as *const c_void, core::mem::size_of::<[u8; 2]>(), ) != 0 { diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index bb0ac757..58bb0727 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -21,7 +21,7 @@ pub unsafe extern "C" fn lzma_stream_header_encode( return LZMA_OPTIONS_ERROR; } core::ptr::copy_nonoverlapping( - &raw const lzma_header_magic as *const u8, + ::core::ptr::addr_of!(lzma_header_magic) as *const u8, out as *mut u8, core::mem::size_of::<[u8; 6]>(), ); @@ -63,7 +63,7 @@ pub unsafe extern "C" fn lzma_stream_footer_encode( let crc: u32 = lzma_crc32(out.offset(4), (4 + LZMA_STREAM_FLAGS_SIZE) as size_t, 0) as u32; write32le(out, crc); core::ptr::copy_nonoverlapping( - &raw const lzma_footer_magic as *const u8, + ::core::ptr::addr_of!(lzma_footer_magic) as *const u8, out.offset((2 * 4) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *mut u8, core::mem::size_of::<[u8; 2]>(), diff --git a/liblzma-rs/src/common/stream_mt.rs b/liblzma-rs/src/common/stream_mt.rs index 99f44eb2..cd11ca6c 100644 --- a/liblzma-rs/src/common/stream_mt.rs +++ b/liblzma-rs/src/common/stream_mt.rs @@ -1,5 +1,4 @@ pub type lzma_mt = crate::types::lzma_mt; - pub use crate::common::stream_decoder_mt::lzma_stream_decoder_mt; pub use crate::common::stream_encoder_mt::{ lzma_stream_encoder_mt, lzma_stream_encoder_mt_memusage, diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index ad3c3dbf..07a533bb 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_char, c_int, c_uint, c_void}; extern "C" { fn lzma_validate_chain(filters: *const lzma_filter, count: *mut size_t) -> lzma_ret; } @@ -108,7 +107,7 @@ unsafe extern "C" fn str_append_str(str: *mut lzma_str, s: *const c_char) { } unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) { if v == 0 { - str_append_str(str, c"0".as_ptr()); + str_append_str(str, crate::c_str!("0")); } else { static mut suffixes: [[c_char; 4]; 4] = unsafe { [ @@ -141,11 +140,15 @@ unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suf break; } } - str_append_str(str, (&raw mut buf as *mut c_char).offset(pos as isize)); str_append_str( str, - &raw const *(&raw const suffixes as *const [c_char; 4]).offset(suf as isize) - as *const c_char, + (::core::ptr::addr_of_mut!(buf) as *mut c_char).offset(pos as isize), + ); + str_append_str( + str, + ::core::ptr::addr_of!( + *(::core::ptr::addr_of!(suffixes) as *const [c_char; 4]).offset(suf as isize) + ) as *const c_char, ); }; } @@ -177,7 +180,7 @@ extern "C" fn parse_bcj( str, str_end, filter_options, - &raw const bcj_optmap as *const option_map, + ::core::ptr::addr_of!(bcj_optmap) as *const option_map, (core::mem::size_of::<[option_map; 1]>()) .wrapping_div(core::mem::size_of::()), ) @@ -210,7 +213,7 @@ extern "C" fn parse_delta( str, str_end, filter_options, - &raw const delta_optmap as *const option_map, + ::core::ptr::addr_of!(delta_optmap) as *const option_map, (core::mem::size_of::<[option_map; 1]>()) .wrapping_div(core::mem::size_of::()), ) @@ -224,7 +227,7 @@ unsafe extern "C" fn parse_lzma12_preset( preset: *mut u32, ) -> *const c_char { if (**str as u8) < b'0' || (**str as u8) > b'9' { - return c"Unsupported preset".as_ptr(); + return crate::c_str!("Unsupported preset"); } *preset = (**str as u8 - b'0') as u32; loop { @@ -237,7 +240,7 @@ unsafe extern "C" fn parse_lzma12_preset( *preset = (*preset | LZMA_PRESET_EXTREME) as u32; } _ => { - return c"Unsupported flag in the preset".as_ptr(); + return crate::c_str!("Unsupported flag in the preset"); } } } @@ -249,13 +252,14 @@ unsafe extern "C" fn set_lzma12_preset( filter_options: *mut c_void, ) -> *const c_char { let mut preset: u32 = 0; - let errmsg: *const c_char = parse_lzma12_preset(str, str_end, &raw mut preset); + let errmsg: *const c_char = + parse_lzma12_preset(str, str_end, ::core::ptr::addr_of_mut!(preset)); if !errmsg.is_null() { return errmsg; } let opts: *mut lzma_options_lzma = filter_options as *mut lzma_options_lzma; if lzma_lzma_preset(opts, preset) != 0 { - return c"Unsupported preset".as_ptr(); + return crate::c_str!("Unsupported preset"); } core::ptr::null() } @@ -323,14 +327,14 @@ unsafe extern "C" fn parse_lzma12( str, str_end, filter_options, - &raw const lzma12_optmap as *const option_map, + ::core::ptr::addr_of!(lzma12_optmap) as *const option_map, (core::mem::size_of::<[option_map; 9]>()).wrapping_div(core::mem::size_of::()), ); if !errmsg.is_null() { return errmsg; } if (*opts).lc.wrapping_add((*opts).lp) > LZMA_LCLP_MAX { - return c"The sum of lc and lp must not exceed 4".as_ptr(); + return crate::c_str!("The sum of lc and lp must not exceed 4"); } core::ptr::null() } @@ -348,7 +352,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const lzma12_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(lzma12_optmap) as *const option_map, strfy_encoder: 9, strfy_decoder: 5, allow_null: false, @@ -365,7 +369,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const lzma12_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(lzma12_optmap) as *const option_map, strfy_encoder: 9, strfy_decoder: 2, allow_null: false, @@ -382,7 +386,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const bcj_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(bcj_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: true, @@ -399,7 +403,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const bcj_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(bcj_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: true, @@ -416,7 +420,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const bcj_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(bcj_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: true, @@ -433,7 +437,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const bcj_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(bcj_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: true, @@ -450,7 +454,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const bcj_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(bcj_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: true, @@ -467,7 +471,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const bcj_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(bcj_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: true, @@ -484,7 +488,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const bcj_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(bcj_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: true, @@ -501,7 +505,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const bcj_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(bcj_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: true, @@ -518,7 +522,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { *mut c_void, ) -> *const c_char, ), - optmap: &raw const delta_optmap as *const option_map, + optmap: ::core::ptr::addr_of!(delta_optmap) as *const option_map, strfy_encoder: 1, strfy_decoder: 1, allow_null: false, @@ -553,16 +557,16 @@ unsafe extern "C" fn parse_options( } let name_len: size_t = equals_sign.offset_from(*str) as size_t; if name_len > NAME_LEN_MAX as size_t { - return c"Unknown option name".as_ptr(); + return crate::c_str!("Unknown option name"); } let mut i: size_t = 0; loop { if i == optmap_size { - return c"Unknown option name".as_ptr(); + return crate::c_str!("Unknown option name"); } if memcmp( *str as *const c_void, - &raw const (*optmap.offset(i as isize)).name as *const c_void, + ::core::ptr::addr_of!((*optmap.offset(i as isize)).name) as *const c_void, name_len, ) == 0 && (*optmap.offset(i as isize)).name[name_len as usize] == 0 @@ -574,7 +578,7 @@ unsafe extern "C" fn parse_options( *str = equals_sign.offset(1); let value_len: size_t = name_eq_value_end.offset_from(*str) as size_t; if value_len == 0 { - return c"Option value cannot be empty".as_ptr(); + return crate::c_str!("Option value cannot be empty"); } if (*optmap.offset(i as isize)).type_0 == OPTMAP_TYPE_LZMA_PRESET { let errmsg: *const c_char = @@ -586,17 +590,17 @@ unsafe extern "C" fn parse_options( let mut v: u32 = 0; if (*optmap.offset(i as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP != 0 { if value_len > NAME_LEN_MAX as size_t { - return c"Invalid option value".as_ptr(); + return crate::c_str!("Invalid option value"); } let map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0; loop { if (*map.offset(j as isize)).name[0] == 0 { - return c"Invalid option value".as_ptr(); + return crate::c_str!("Invalid option value"); } if memcmp( *str as *const c_void, - &raw const (*map.offset(j as isize)).name as *const c_void, + ::core::ptr::addr_of!((*map.offset(j as isize)).name) as *const c_void, value_len, ) == 0 && (*map.offset(j as isize)).name[value_len as usize] == 0 @@ -615,12 +619,12 @@ unsafe extern "C" fn parse_options( v = 0; loop { if v > (UINT32_MAX).wrapping_div(10) { - return c"Value out of range".as_ptr(); + return crate::c_str!("Value out of range"); } v = v.wrapping_mul(10); let add: u32 = (*p as u8 - b'0') as u32; if (UINT32_MAX).wrapping_sub(add) < v { - return c"Value out of range".as_ptr(); + return crate::c_str!("Value out of range"); } v = v.wrapping_add(add); p = p.offset(1); @@ -666,14 +670,14 @@ unsafe extern "C" fn parse_options( as *const c_char; } if v > UINT32_MAX >> shift { - return c"Value out of range".as_ptr(); + return crate::c_str!("Value out of range"); } v <<= shift; } if v < (*optmap.offset(i as isize)).u.range.min || v > (*optmap.offset(i as isize)).u.range.max { - return c"Value out of range".as_ptr(); + return crate::c_str!("Value out of range"); } } let ptr: *mut c_void = (filter_options as *mut c_char) @@ -717,7 +721,7 @@ unsafe extern "C" fn parse_filter( } let name_len: size_t = name_end.offset_from(*str) as size_t; if name_len > NAME_LEN_MAX as size_t { - return c"Unknown filter name".as_ptr(); + return crate::c_str!("Unknown filter name"); } let mut i: size_t = 0; while i @@ -726,8 +730,11 @@ unsafe extern "C" fn parse_filter( { if memcmp( *str as *const c_void, - &raw const (*(&raw const filter_name_map as *const filter_codec_def).offset(i as isize)) - .name as *const c_void, + ::core::ptr::addr_of!( + (*(::core::ptr::addr_of!(filter_name_map) as *const filter_codec_def) + .offset(i as isize)) + .name + ) as *const c_void, name_len, ) == 0 && filter_name_map[i as usize].name[name_len as usize] == 0 @@ -739,7 +746,7 @@ unsafe extern "C" fn parse_filter( let options: *mut c_void = lzma_alloc_zero(filter_name_map[i as usize].opts_size as size_t, allocator); if options.is_null() { - return c"Memory allocation failed".as_ptr(); + return crate::c_str!("Memory allocation failed"); } *str = opts_start; let errmsg: *const c_char = @@ -754,7 +761,7 @@ unsafe extern "C" fn parse_filter( } i += 1; } - c"Unknown filter name".as_ptr() + crate::c_str!("Unknown filter name") } unsafe extern "C" fn str_to_filters( str: *mut *const c_char, @@ -785,7 +792,7 @@ unsafe extern "C" fn str_to_filters( let mut i: size_t = 1; while *str_end.offset(i as isize) != 0 { if *str_end.offset(i as isize) as u8 != b' ' { - return c"Unsupported preset".as_ptr(); + return crate::c_str!("Unsupported preset"); } i += 1; } @@ -793,7 +800,7 @@ unsafe extern "C" fn str_to_filters( str_end = (*str).offset(str_len as isize); } let mut preset: u32 = 0; - errmsg = parse_lzma12_preset(str, str_end, &raw mut preset); + errmsg = parse_lzma12_preset(str, str_end, ::core::ptr::addr_of_mut!(preset)); if !errmsg.is_null() { return errmsg; } @@ -801,11 +808,11 @@ unsafe extern "C" fn str_to_filters( lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_options_lzma; if opts.is_null() { - return c"Memory allocation failed".as_ptr(); + return crate::c_str!("Memory allocation failed"); } if lzma_lzma_preset(opts, preset) != 0 { lzma_free(opts as *mut c_void, allocator); - return c"Unsupported preset".as_ptr(); + return crate::c_str!("Unsupported preset"); } (*filters).id = LZMA_FILTER_LZMA2; (*filters).options = opts as *mut c_void; @@ -821,7 +828,7 @@ unsafe extern "C" fn str_to_filters( let mut i_0: size_t = 0; loop { if i_0 == LZMA_FILTERS_MAX as size_t { - errmsg = c"The maximum number of filters is four".as_ptr(); + errmsg = crate::c_str!("The maximum number of filters is four"); current_block = 6100283484465977373; break; } else { @@ -838,15 +845,15 @@ unsafe extern "C" fn str_to_filters( filter_end = filter_end.offset(1); } if filter_end == *str { - errmsg = c"Filter name is missing".as_ptr(); + errmsg = crate::c_str!("Filter name is missing"); current_block = 6100283484465977373; break; } else { errmsg = parse_filter( str, filter_end, - (&raw mut temp_filters as *mut lzma_filter).offset(i_0 as isize) - as *mut lzma_filter, + (::core::ptr::addr_of_mut!(temp_filters) as *mut lzma_filter) + .offset(i_0 as isize) as *mut lzma_filter, allocator, only_xz, ); @@ -871,8 +878,10 @@ unsafe extern "C" fn str_to_filters( temp_filters[i_0 as usize].options = core::ptr::null_mut(); if flags & LZMA_STR_NO_VALIDATION as u32 == 0 { let mut dummy: size_t = 0; - let ret: lzma_ret = - lzma_validate_chain(&raw mut temp_filters as *mut lzma_filter, &raw mut dummy); + let ret: lzma_ret = lzma_validate_chain( + ::core::ptr::addr_of_mut!(temp_filters) as *mut lzma_filter, + ::core::ptr::addr_of_mut!(dummy), + ); if ret != LZMA_OK { errmsg = b"Invalid filter chain ('lzma2' missing at the end?)\0" as *const u8 as *const c_char; @@ -887,7 +896,7 @@ unsafe extern "C" fn str_to_filters( 6100283484465977373 => {} _ => { core::ptr::copy_nonoverlapping( - &raw mut temp_filters as *const u8, + ::core::ptr::addr_of_mut!(temp_filters) as *const u8, filters as *mut u8, i_0.wrapping_add(1) .wrapping_mul(core::mem::size_of::()), @@ -925,10 +934,11 @@ pub unsafe extern "C" fn lzma_str_to_filters( } let supported_flags: u32 = LZMA_STR_ALL_FILTERS as u32 | LZMA_STR_NO_VALIDATION as u32; if flags & !supported_flags != 0 { - return c"Unsupported flags to lzma_str_to_filters()".as_ptr(); + return crate::c_str!("Unsupported flags to lzma_str_to_filters()"); } let mut used: *const c_char = str; - let errmsg: *const c_char = str_to_filters(&raw mut used, filters, flags, allocator); + let errmsg: *const c_char = + str_to_filters(::core::ptr::addr_of_mut!(used), filters, flags, allocator); if !error_pos.is_null() { let n: size_t = used.offset_from(str) as size_t; *error_pos = if n > INT_MAX as size_t { @@ -966,23 +976,24 @@ unsafe extern "C" fn strfy_filter( } if v != 0 || (*optmap.offset(i as isize)).flags & OPTMAP_NO_STRFY_ZERO == 0 { str_append_str(dest, delimiter); - delimiter = c",".as_ptr(); + delimiter = crate::c_str!(","); str_append_str( dest, - &raw const (*optmap.offset(i as isize)).name as *const c_char, + ::core::ptr::addr_of!((*optmap.offset(i as isize)).name) as *const c_char, ); - str_append_str(dest, c"=".as_ptr()); + str_append_str(dest, crate::c_str!("=")); if (*optmap.offset(i as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP != 0 { let map: *const name_value_map = (*optmap.offset(i as isize)).u.map; let mut j: size_t = 0; loop { if (*map.offset(j as isize)).name[0] == 0 { - str_append_str(dest, c"UNKNOWN".as_ptr()); + str_append_str(dest, crate::c_str!("UNKNOWN")); break; } else if (*map.offset(j as isize)).value == v { str_append_str( dest, - &raw const (*map.offset(j as isize)).name as *const c_char, + ::core::ptr::addr_of!((*map.offset(j as isize)).name) + as *const c_char, ); break; } else { @@ -1029,51 +1040,53 @@ pub unsafe extern "C" fn lzma_str_from_filters( buf: core::ptr::null_mut(), pos: 0, }; - let ret_: lzma_ret = str_init(&raw mut dest, allocator); + let ret_: lzma_ret = str_init(::core::ptr::addr_of_mut!(dest), allocator); if ret_ != LZMA_OK { return ret_; } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; let opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { - c"=".as_ptr() + crate::c_str!("=") } else { - c":".as_ptr() + crate::c_str!(":") }; let mut i: size_t = 0; while (*filters.offset(i as isize)).id != LZMA_VLI_UNKNOWN { if i == LZMA_FILTERS_MAX as size_t { - str_free(&raw mut dest, allocator); + str_free(::core::ptr::addr_of_mut!(dest), allocator); return LZMA_OPTIONS_ERROR; } if i > 0 && flags & LZMA_STR_NO_SPACES as u32 == 0 { - str_append_str(&raw mut dest, c" ".as_ptr()); + str_append_str(::core::ptr::addr_of_mut!(dest), crate::c_str!(" ")); } if flags & LZMA_STR_GETOPT_LONG as u32 != 0 || i > 0 && flags & LZMA_STR_NO_SPACES as u32 != 0 { - str_append_str(&raw mut dest, c"--".as_ptr()); + str_append_str(::core::ptr::addr_of_mut!(dest), crate::c_str!("--")); } let mut j: size_t = 0; loop { if j == (core::mem::size_of::<[filter_codec_def; 11]>()) .wrapping_div(core::mem::size_of::()) { - str_free(&raw mut dest, allocator); + str_free(::core::ptr::addr_of_mut!(dest), allocator); return LZMA_OPTIONS_ERROR; } if filter_name_map[j as usize].id == (*filters.offset(i as isize)).id { str_append_str( - &raw mut dest, - &raw const (*(&raw const filter_name_map as *const filter_codec_def) - .offset(j as isize)) - .name as *const c_char, + ::core::ptr::addr_of_mut!(dest), + ::core::ptr::addr_of!( + (*(::core::ptr::addr_of!(filter_name_map) as *const filter_codec_def) + .offset(j as isize)) + .name + ) as *const c_char, ); if !show_opts { break; } if (*filters.offset(i as isize)).options.is_null() { if !filter_name_map[j as usize].allow_null { - str_free(&raw mut dest, allocator); + str_free(::core::ptr::addr_of_mut!(dest), allocator); return LZMA_OPTIONS_ERROR; } break; @@ -1084,7 +1097,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( filter_name_map[j as usize].strfy_decoder }) as size_t; strfy_filter( - &raw mut dest, + ::core::ptr::addr_of_mut!(dest), opt_delim, filter_name_map[j as usize].optmap, optmap_count, @@ -1098,7 +1111,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( } i += 1; } - str_finish(output_str, &raw mut dest, allocator) + str_finish(output_str, ::core::ptr::addr_of_mut!(dest), allocator) } #[no_mangle] pub unsafe extern "C" fn lzma_str_list_filters( @@ -1122,20 +1135,20 @@ pub unsafe extern "C" fn lzma_str_list_filters( buf: core::ptr::null_mut(), pos: 0, }; - let ret_: lzma_ret = str_init(&raw mut dest, allocator); + let ret_: lzma_ret = str_init(::core::ptr::addr_of_mut!(dest), allocator); if ret_ != LZMA_OK { return ret_; } let show_opts: bool = flags & (LZMA_STR_ENCODER as u32 | LZMA_STR_DECODER as u32) != 0; let filter_delim: *const c_char = if show_opts { - c"\n".as_ptr() + crate::c_str!("\n") } else { - c" ".as_ptr() + crate::c_str!(" ") }; let opt_delim: *const c_char = if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { - c"=".as_ptr() + crate::c_str!("=") } else { - c":".as_ptr() + crate::c_str!(":") }; let mut first_filter_printed: bool = false; let mut i: size_t = 0; @@ -1149,17 +1162,19 @@ pub unsafe extern "C" fn lzma_str_list_filters( || filter_id != LZMA_VLI_UNKNOWN { if first_filter_printed { - str_append_str(&raw mut dest, filter_delim); + str_append_str(::core::ptr::addr_of_mut!(dest), filter_delim); } first_filter_printed = true; if flags & LZMA_STR_GETOPT_LONG as u32 != 0 { - str_append_str(&raw mut dest, c"--".as_ptr()); + str_append_str(::core::ptr::addr_of_mut!(dest), crate::c_str!("--")); } str_append_str( - &raw mut dest, - &raw const (*(&raw const filter_name_map as *const filter_codec_def) - .offset(i as isize)) - .name as *const c_char, + ::core::ptr::addr_of_mut!(dest), + ::core::ptr::addr_of!( + (*(::core::ptr::addr_of!(filter_name_map) as *const filter_codec_def) + .offset(i as isize)) + .name + ) as *const c_char, ); if show_opts { let optmap: *const option_map = filter_name_map[i as usize].optmap; @@ -1171,15 +1186,19 @@ pub unsafe extern "C" fn lzma_str_list_filters( }) as size_t; let mut j: size_t = 0; while j < end { - str_append_str(&raw mut dest, d); - d = c",".as_ptr(); + str_append_str(::core::ptr::addr_of_mut!(dest), d); + d = crate::c_str!(","); str_append_str( - &raw mut dest, - &raw const (*optmap.offset(j as isize)).name as *const c_char, + ::core::ptr::addr_of_mut!(dest), + ::core::ptr::addr_of!((*optmap.offset(j as isize)).name) + as *const c_char, ); - str_append_str(&raw mut dest, c"=<".as_ptr()); + str_append_str(::core::ptr::addr_of_mut!(dest), crate::c_str!("=<")); if (*optmap.offset(j as isize)).type_0 == OPTMAP_TYPE_LZMA_PRESET { - str_append_str(&raw mut dest, LZMA12_PRESET_STR.as_ptr()); + str_append_str( + ::core::ptr::addr_of_mut!(dest), + LZMA12_PRESET_STR.as_ptr(), + ); } else if (*optmap.offset(j as isize)).flags & OPTMAP_USE_NAME_VALUE_MAP != 0 { @@ -1187,11 +1206,15 @@ pub unsafe extern "C" fn lzma_str_list_filters( let mut k: size_t = 0; while (*m.offset(k as isize)).name[0] != 0 { if k > 0 { - str_append_str(&raw mut dest, c"|".as_ptr()); + str_append_str( + ::core::ptr::addr_of_mut!(dest), + crate::c_str!("|"), + ); } str_append_str( - &raw mut dest, - &raw const (*m.offset(k as isize)).name as *const c_char, + ::core::ptr::addr_of_mut!(dest), + ::core::ptr::addr_of!((*m.offset(k as isize)).name) + as *const c_char, ); k += 1; } @@ -1199,18 +1222,18 @@ pub unsafe extern "C" fn lzma_str_list_filters( let use_byte_suffix: bool = (*optmap.offset(j as isize)).flags & OPTMAP_USE_BYTE_SUFFIX != 0; str_append_u32( - &raw mut dest, + ::core::ptr::addr_of_mut!(dest), (*optmap.offset(j as isize)).u.range.min, use_byte_suffix, ); - str_append_str(&raw mut dest, c"-".as_ptr()); + str_append_str(::core::ptr::addr_of_mut!(dest), crate::c_str!("-")); str_append_u32( - &raw mut dest, + ::core::ptr::addr_of_mut!(dest), (*optmap.offset(j as isize)).u.range.max, use_byte_suffix, ); } - str_append_str(&raw mut dest, c">".as_ptr()); + str_append_str(::core::ptr::addr_of_mut!(dest), crate::c_str!(">")); j += 1; } } @@ -1219,10 +1242,10 @@ pub unsafe extern "C" fn lzma_str_list_filters( i += 1; } if !first_filter_printed { - str_free(&raw mut dest, allocator); + str_free(::core::ptr::addr_of_mut!(dest), allocator); return LZMA_OPTIONS_ERROR; } - str_finish(output_str, &raw mut dest, allocator) + str_finish(output_str, ::core::ptr::addr_of_mut!(dest), allocator) } unsafe extern "C" fn run_static_initializers() { lzma12_optmap = [ @@ -1289,7 +1312,7 @@ unsafe extern "C" fn run_static_initializers() { flags: OPTMAP_USE_NAME_VALUE_MAP, offset: 32, u: option_value { - map: &raw const lzma12_mode_map as *const name_value_map, + map: ::core::ptr::addr_of!(lzma12_mode_map) as *const name_value_map, }, }, option_map { @@ -1307,7 +1330,7 @@ unsafe extern "C" fn run_static_initializers() { flags: OPTMAP_USE_NAME_VALUE_MAP, offset: 40, u: option_value { - map: &raw const lzma12_mf_map as *const name_value_map, + map: ::core::ptr::addr_of!(lzma12_mf_map) as *const name_value_map, }, }, option_map { diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index 33079f74..c4ec4ffb 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -8,7 +8,7 @@ pub unsafe extern "C" fn lzma_vli_decode( ) -> lzma_ret { let mut vli_pos_internal: size_t = 0; if vli_pos.is_null() { - vli_pos = &raw mut vli_pos_internal; + vli_pos = ::core::ptr::addr_of_mut!(vli_pos_internal); *vli = 0; if *in_pos >= in_size { return LZMA_DATA_ERROR; @@ -33,7 +33,7 @@ pub unsafe extern "C" fn lzma_vli_decode( if byte == 0 && *vli_pos > 1 { return LZMA_DATA_ERROR; } - return if vli_pos == &raw mut vli_pos_internal { + return if vli_pos == ::core::ptr::addr_of_mut!(vli_pos_internal) { LZMA_OK } else { LZMA_STREAM_END @@ -46,7 +46,7 @@ pub unsafe extern "C" fn lzma_vli_decode( break; } } - if vli_pos == &raw mut vli_pos_internal { + if vli_pos == ::core::ptr::addr_of_mut!(vli_pos_internal) { LZMA_DATA_ERROR } else { LZMA_OK diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index d918d31b..0e73f3e6 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -8,7 +8,7 @@ pub unsafe extern "C" fn lzma_vli_encode( ) -> lzma_ret { let mut vli_pos_internal: size_t = 0; if vli_pos.is_null() { - vli_pos = &raw mut vli_pos_internal; + vli_pos = ::core::ptr::addr_of_mut!(vli_pos_internal); if *out_pos >= out_size { return LZMA_PROG_ERROR; } @@ -25,7 +25,7 @@ pub unsafe extern "C" fn lzma_vli_encode( vli >>= 7; *out_pos = (*out_pos).wrapping_add(1); if *out_pos == out_size { - return if vli_pos == &raw mut vli_pos_internal { + return if vli_pos == ::core::ptr::addr_of_mut!(vli_pos_internal) { LZMA_PROG_ERROR } else { LZMA_OK @@ -35,7 +35,7 @@ pub unsafe extern "C" fn lzma_vli_encode( *out.offset(*out_pos as isize) = vli as u8; *out_pos = (*out_pos).wrapping_add(1); *vli_pos = (*vli_pos).wrapping_add(1); - if vli_pos == &raw mut vli_pos_internal { + if vli_pos == ::core::ptr::addr_of_mut!(vli_pos_internal) { LZMA_OK } else { LZMA_STREAM_END diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index 48b2fcec..3adb822b 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -1,8 +1,7 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn delta_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free(coder as *mut c_void, allocator); } #[no_mangle] @@ -40,8 +39,16 @@ pub unsafe extern "C" fn lzma_delta_coder_init( let opt: *const lzma_options_delta = (*filters).options as *const lzma_options_delta; (*coder).distance = (*opt).dist as size_t; (*coder).pos = 0; - core::ptr::write_bytes(&raw mut (*coder).history as *mut u8, 0 as u8, 256); - lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) + core::ptr::write_bytes( + ::core::ptr::addr_of_mut!((*coder).history) as *mut u8, + 0 as u8, + 256, + ); + lzma_next_filter_init( + ::core::ptr::addr_of_mut!((*coder).next), + allocator, + filters.offset(1), + ) } #[no_mangle] pub unsafe extern "C" fn lzma_delta_coder_memusage(options: *const c_void) -> u64 { diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 8c547b6f..58c5aba1 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { let distance: size_t = (*coder).distance; let mut i: size_t = 0; diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index 6248b1bb..66ea3753 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn copy_and_encode( coder: *mut lzma_delta_coder, in_0: *const u8, @@ -93,7 +92,7 @@ unsafe extern "C" fn delta_encoder_update( ) -> lzma_ret { let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; lzma_next_filter_update( - &raw mut (*coder).next, + ::core::ptr::addr_of_mut!((*coder).next), allocator, reversed_filters.offset(1), ) diff --git a/liblzma-rs/src/lib.rs b/liblzma-rs/src/lib.rs index f591703b..20f38746 100644 --- a/liblzma-rs/src/lib.rs +++ b/liblzma-rs/src/lib.rs @@ -7,9 +7,12 @@ unused_assignments, clippy::all )] - -pub mod types; - +#[macro_export] +macro_rules! c_str { + ($s:literal) => { + concat!($s, "\0").as_ptr() as *const ::std::os::raw::c_char + }; +} pub mod check; pub mod common; pub mod delta; @@ -18,3 +21,4 @@ pub mod lzma; pub mod rangecoder; pub mod simple; pub mod tuklib; +pub mod types; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 77ae7065..7cc4636b 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -74,7 +73,7 @@ unsafe extern "C" fn decode_buffer( ); let ret: lzma_ret = (*coder).lz.code.unwrap()( (*coder).lz.coder, - &raw mut (*coder).dict, + ::core::ptr::addr_of_mut!((*coder).dict), in_0, in_pos, in_size, @@ -123,8 +122,8 @@ unsafe extern "C" fn lz_decode( in_0, in_pos, in_size, - &raw mut (*coder).temp.buffer as *mut u8, - &raw mut (*coder).temp.size, + ::core::ptr::addr_of_mut!((*coder).temp.buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).temp.size), LZMA_BUFFER_SIZE as size_t, action, ); @@ -145,8 +144,8 @@ unsafe extern "C" fn lz_decode( } let ret_0: lzma_ret = decode_buffer( coder, - &raw mut (*coder).temp.buffer as *mut u8, - &raw mut (*coder).temp.pos, + ::core::ptr::addr_of_mut!((*coder).temp.buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).temp.pos), (*coder).temp.size, out, out_pos, @@ -164,7 +163,7 @@ unsafe extern "C" fn lz_decode( } unsafe extern "C" fn lz_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free((*coder).dict.buf as *mut c_void, allocator); if (*coder).lz.end.is_some() { (*coder).lz.end.unwrap()((*coder).lz.coder, allocator); @@ -233,11 +232,11 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( preset_dict_size: 0, }; let ret_: lzma_ret = lz_init.unwrap()( - &raw mut (*coder).lz, + ::core::ptr::addr_of_mut!((*coder).lz), allocator, (*filters).id, (*filters).options, - &raw mut lz_options, + ::core::ptr::addr_of_mut!(lz_options), ); if ret_ != LZMA_OK { return ret_; @@ -286,7 +285,11 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( (*coder).this_finished = false; (*coder).temp.pos = 0; (*coder).temp.size = 0; - lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) + lzma_next_filter_init( + ::core::ptr::addr_of_mut!((*coder).next), + allocator, + filters.offset(1), + ) } #[no_mangle] pub extern "C" fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64 { diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index a9b4aaa5..3ba1486f 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { fn lzma_mf_hc3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; fn lzma_mf_hc3_skip(dict: *mut lzma_mf, amount: u32); @@ -55,7 +54,7 @@ unsafe extern "C" fn fill_window( action: lzma_action, ) -> lzma_ret { if (*coder).mf.read_pos >= (*coder).mf.size.wrapping_sub((*coder).mf.keep_size_after) { - move_window(&raw mut (*coder).mf); + move_window(::core::ptr::addr_of_mut!((*coder).mf)); } let mut write_pos: size_t = (*coder).mf.write_pos as size_t; let mut ret: lzma_ret = LZMA_OK; @@ -65,7 +64,7 @@ unsafe extern "C" fn fill_window( in_pos, in_size, (*coder).mf.buffer, - &raw mut write_pos, + ::core::ptr::addr_of_mut!(write_pos), (*coder).mf.size as size_t, ); ret = if action != LZMA_RUN && *in_pos == in_size { @@ -81,7 +80,7 @@ unsafe extern "C" fn fill_window( in_pos, in_size, (*coder).mf.buffer, - &raw mut write_pos, + ::core::ptr::addr_of_mut!(write_pos), (*coder).mf.size as size_t, action, ); @@ -106,7 +105,7 @@ unsafe extern "C" fn fill_window( let pending: u32 = (*coder).mf.pending; (*coder).mf.pending = 0; (*coder).mf.read_pos = (*coder).mf.read_pos.wrapping_sub(pending); - (*coder).mf.skip.unwrap()(&raw mut (*coder).mf, pending); + (*coder).mf.skip.unwrap()(::core::ptr::addr_of_mut!((*coder).mf), pending); } ret } @@ -131,7 +130,7 @@ unsafe extern "C" fn lz_encode( } let ret: lzma_ret = (*coder).lz.code.unwrap()( (*coder).lz.coder, - &raw mut (*coder).mf, + ::core::ptr::addr_of_mut!((*coder).mf), out, out_pos, out_size, @@ -365,7 +364,7 @@ pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) - hash_count: 0, sons_count: 0, }; - if unsafe { lz_encoder_prepare(&raw mut mf, core::ptr::null(), lz_options) } { + if unsafe { lz_encoder_prepare(::core::ptr::addr_of_mut!(mf), core::ptr::null(), lz_options) } { return UINT64_MAX; } (mf.hash_count as u64) @@ -376,7 +375,7 @@ pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) - } unsafe extern "C" fn lz_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free((*coder).mf.son as *mut c_void, allocator); lzma_free((*coder).mf.hash as *mut c_void, allocator); lzma_free((*coder).mf.buffer as *mut c_void, allocator); @@ -402,7 +401,7 @@ unsafe extern "C" fn lz_encoder_update( return ret_; } lzma_next_filter_update( - &raw mut (*coder).next, + ::core::ptr::addr_of_mut!((*coder).next), allocator, reversed_filters.offset(1), ) @@ -505,22 +504,34 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( preset_dict_size: 0, }; let ret_: lzma_ret = lz_init.unwrap()( - &raw mut (*coder).lz, + ::core::ptr::addr_of_mut!((*coder).lz), allocator, (*filters).id, (*filters).options, - &raw mut lz_options, + ::core::ptr::addr_of_mut!(lz_options), ); if ret_ != LZMA_OK { return ret_; } - if lz_encoder_prepare(&raw mut (*coder).mf, allocator, &raw mut lz_options) { + if lz_encoder_prepare( + ::core::ptr::addr_of_mut!((*coder).mf), + allocator, + ::core::ptr::addr_of_mut!(lz_options), + ) { return LZMA_OPTIONS_ERROR; } - if lz_encoder_init(&raw mut (*coder).mf, allocator, &raw mut lz_options) { + if lz_encoder_init( + ::core::ptr::addr_of_mut!((*coder).mf), + allocator, + ::core::ptr::addr_of_mut!(lz_options), + ) { return LZMA_MEM_ERROR; } - lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) + lzma_next_filter_init( + ::core::ptr::addr_of_mut!((*coder).next), + allocator, + filters.offset(1), + ) } pub extern "C" fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { match mf { diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 87b45658..766d8011 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_uint; extern "C" { static lzma_crc32_table: [[u32; 256]; 8]; } diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index 15fd866b..0c37e6db 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_lz_decoder_init( next: *mut lzma_next_coder, @@ -73,7 +72,7 @@ unsafe extern "C" fn dict_write( in_pos, in_size, (*dict).buf, - &raw mut (*dict).pos, + ::core::ptr::addr_of_mut!((*dict).pos), (*dict).limit, )); if !(*dict).has_wrapped { @@ -119,7 +118,7 @@ unsafe extern "C" fn lzma2_decode( if control >= 0xa0 { (*coder).lzma.reset.unwrap()( (*coder).lzma.coder, - &raw mut (*coder).options as *const c_void, + ::core::ptr::addr_of_mut!((*coder).options) as *const c_void, ); } } @@ -170,12 +169,12 @@ unsafe extern "C" fn lzma2_decode( 5 => { let prop_byte = *in_0.offset(*in_pos as isize); *in_pos += 1; - if lzma_lzma_lclppb_decode(&raw mut (*coder).options, prop_byte) { + if lzma_lzma_lclppb_decode(::core::ptr::addr_of_mut!((*coder).options), prop_byte) { return LZMA_DATA_ERROR; } (*coder).lzma.reset.unwrap()( (*coder).lzma.coder, - &raw mut (*coder).options as *const c_void, + ::core::ptr::addr_of_mut!((*coder).options) as *const c_void, ); (*coder).sequence = SEQ_LZMA; } @@ -202,7 +201,7 @@ unsafe extern "C" fn lzma2_decode( in_0, in_pos, in_size, - &raw mut (*coder).compressed_size, + ::core::ptr::addr_of_mut!((*coder).compressed_size), ); if (*coder).compressed_size != 0 { return LZMA_OK; @@ -254,7 +253,12 @@ unsafe extern "C" fn lzma2_decoder_init( (*coder).need_properties = true; (*coder).need_dictionary_reset = (*options).preset_dict.is_null() || (*options).preset_dict_size == 0; - lzma_lzma_decoder_create(&raw mut (*coder).lzma, allocator, options, lz_options) + lzma_lzma_decoder_create( + ::core::ptr::addr_of_mut!((*coder).lzma), + allocator, + options, + lz_options, + ) } #[no_mangle] pub unsafe extern "C" fn lzma_lzma2_decoder_init( diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 2f453b8a..ea6b89da 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_lz_encoder_init( next: *mut lzma_next_coder, @@ -131,8 +130,8 @@ unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { pos += 1; if (*coder).need_properties { lzma_lzma_lclppb_encode( - &raw mut (*coder).opt_cur, - (&raw mut (*coder).buf as *mut u8).offset(pos as isize), + ::core::ptr::addr_of_mut!((*coder).opt_cur), + (::core::ptr::addr_of_mut!((*coder).buf) as *mut u8).offset(pos as isize), ); } (*coder).need_properties = false; @@ -179,7 +178,7 @@ unsafe extern "C" fn lzma2_encode( if (*coder).need_state_reset { let ret_: lzma_ret = lzma_lzma_encoder_reset( (*coder).lzma as *mut lzma_lzma1_encoder, - &raw mut (*coder).opt_cur, + ::core::ptr::addr_of_mut!((*coder).opt_cur), ); if ret_ != LZMA_OK { return ret_; @@ -198,8 +197,8 @@ unsafe extern "C" fn lzma2_encode( } 3 => { lzma_bufcpy( - &raw mut (*coder).buf as *mut u8, - &raw mut (*coder).buf_pos, + ::core::ptr::addr_of_mut!((*coder).buf) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).buf_pos), LZMA2_HEADER_UNCOMPRESSED as size_t, out, out_pos, @@ -225,7 +224,7 @@ unsafe extern "C" fn lzma2_encode( out, out_pos, out_size, - &raw mut (*coder).uncompressed_size, + ::core::ptr::addr_of_mut!((*coder).uncompressed_size), ); if (*coder).uncompressed_size != 0 { return LZMA_OK; @@ -251,8 +250,9 @@ unsafe extern "C" fn lzma2_encode( let ret: lzma_ret = lzma_lzma_encode( (*coder).lzma as *mut lzma_lzma1_encoder, mf, - (&raw mut (*coder).buf as *mut u8).offset(LZMA2_HEADER_MAX as isize), - &raw mut (*coder).compressed_size, + (::core::ptr::addr_of_mut!((*coder).buf) as *mut u8) + .offset(LZMA2_HEADER_MAX as isize), + ::core::ptr::addr_of_mut!((*coder).compressed_size), LZMA2_CHUNK_MAX as size_t, limit, ); @@ -285,8 +285,8 @@ unsafe extern "C" fn lzma2_encode( match current_block_45 { 13410404938545238636 => { lzma_bufcpy( - &raw mut (*coder).buf as *mut u8, - &raw mut (*coder).buf_pos, + ::core::ptr::addr_of_mut!((*coder).buf) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).buf_pos), (*coder).compressed_size, out, out_pos, @@ -379,10 +379,10 @@ unsafe extern "C" fn lzma2_encoder_init( (*coder).need_dictionary_reset = (*coder).opt_cur.preset_dict.is_null() || (*coder).opt_cur.preset_dict_size == 0; let ret_: lzma_ret = lzma_lzma_encoder_create( - &raw mut (*coder).lzma, + ::core::ptr::addr_of_mut!((*coder).lzma), allocator, 0x21, - &raw mut (*coder).opt_cur, + ::core::ptr::addr_of_mut!((*coder).opt_cur), lz_options, ); if ret_ != LZMA_OK { diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index bbf7ba26..f4c773bb 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::{c_uint, c_void}; extern "C" { fn lzma_lz_decoder_init( next: *mut lzma_next_coder, @@ -201,7 +200,12 @@ unsafe extern "C" fn lzma_decode( ) -> lzma_ret { let mut current_block: u64; let coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; - let ret: lzma_ret = rc_read_init(&raw mut (*coder).rc, in_0, in_pos, in_size); + let ret: lzma_ret = rc_read_init( + ::core::ptr::addr_of_mut!((*coder).rc), + in_0, + in_pos, + in_size, + ); if ret != LZMA_STREAM_END { return ret; } @@ -337,9 +341,12 @@ unsafe extern "C" fn lzma_decode( RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).rep_len_decoder.choice as u32) >> RC_MOVE_BITS, ) as probability; - probs = &raw mut *(&raw mut (*coder).rep_len_decoder.low + probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( + (*coder).rep_len_decoder.low + ) as *mut [probability; 8]) - .offset(pos_state as isize) as *mut probability; + .offset(pos_state as isize)) + as *mut probability; limit = LEN_LOW_SYMBOLS; len = MATCH_LEN_MIN; } else { @@ -427,7 +434,10 @@ unsafe extern "C" fn lzma_decode( current_block = 15498320742470848828; } 5341942013764523046 => { - if dict_put_safe(&raw mut dict, dict_get(&raw mut dict, rep0)) { + if dict_put_safe( + ::core::ptr::addr_of_mut!(dict), + dict_get(::core::ptr::addr_of_mut!(dict), rep0), + ) { (*coder).sequence = SEQ_SHORTREP; current_block = 4609795085482299213; continue; @@ -545,7 +555,7 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); - if dict_is_distance_valid(&raw mut dict, 0) { + if dict_is_distance_valid(::core::ptr::addr_of_mut!(dict), 0) { current_block = 4420799852307653083; continue; } @@ -724,7 +734,8 @@ unsafe extern "C" fn lzma_decode( rep0 = (2u32).wrapping_add(symbol & 1); if symbol < DIST_MODEL_END { rep0 <<= limit; - probs = (&raw mut (*coder).pos_special as *mut probability) + probs = (::core::ptr::addr_of_mut!((*coder).pos_special) + as *mut probability) .offset(rep0 as isize) .offset(-(symbol as isize)) .offset(-1); @@ -774,13 +785,15 @@ unsafe extern "C" fn lzma_decode( continue; } len = len.wrapping_add(symbol.wrapping_sub(limit)); - probs = &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]).offset( - (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN) - } else { - (DIST_STATES - 1) as u32 - }) as isize, - ) as *mut probability; + probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).dist_slot) + as *mut [probability; 64]) + .offset( + (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { + len.wrapping_sub(MATCH_LEN_MIN) + } else { + (DIST_STATES - 1) as u32 + }) as isize, + )) as *mut probability; symbol = 1; current_block = 4174862988780014241; continue; @@ -807,9 +820,12 @@ unsafe extern "C" fn lzma_decode( .wrapping_sub((*coder).match_len_decoder.choice2 as u32) >> RC_MOVE_BITS, ) as probability; - probs = &raw mut *(&raw mut (*coder).match_len_decoder.mid + probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( + (*coder).match_len_decoder.mid + ) as *mut [probability; 8]) - .offset(pos_state as isize) as *mut probability; + .offset(pos_state as isize)) + as *mut probability; limit = LEN_MID_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { @@ -817,7 +833,8 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.choice2 = (*coder).match_len_decoder.choice2 - ((*coder).match_len_decoder.choice2 >> RC_MOVE_BITS); - probs = &raw mut (*coder).match_len_decoder.high as *mut probability; + probs = ::core::ptr::addr_of_mut!((*coder).match_len_decoder.high) + as *mut probability; limit = LEN_HIGH_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32; } @@ -845,9 +862,12 @@ unsafe extern "C" fn lzma_decode( .wrapping_sub((*coder).match_len_decoder.choice as u32) >> RC_MOVE_BITS, ) as probability; - probs = &raw mut *(&raw mut (*coder).match_len_decoder.low + probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( + (*coder).match_len_decoder.low + ) as *mut [probability; 8]) - .offset(pos_state as isize) as *mut probability; + .offset(pos_state as isize)) + as *mut probability; limit = LEN_LOW_SYMBOLS; len = MATCH_LEN_MIN; } else { @@ -861,7 +881,7 @@ unsafe extern "C" fn lzma_decode( current_block = 8485842003490715114; } 10535798129821001304 => { - if dict_put_safe(&raw mut dict, symbol as u8) { + if dict_put_safe(::core::ptr::addr_of_mut!(dict), symbol as u8) { (*coder).sequence = SEQ_LITERAL_WRITE; current_block = 4609795085482299213; continue; @@ -962,13 +982,15 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - probs = (&raw mut (*coder).literal as *mut probability).offset( - (3_usize).wrapping_mul( - ((dict.pos << 8).wrapping_add(dict_get0(&raw mut dict) as size_t) - & literal_mask as size_t) - << literal_context_bits, - ) as isize, - ); + probs = (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability) + .offset( + (3_usize).wrapping_mul( + ((dict.pos << 8).wrapping_add( + dict_get0(::core::ptr::addr_of_mut!(dict)) as size_t, + ) & literal_mask as size_t) + << literal_context_bits, + ) as isize, + ); symbol = 1; if state < LIT_STATES { state = if state <= STATE_SHORTREP_LIT_LIT { @@ -984,7 +1006,7 @@ unsafe extern "C" fn lzma_decode( } else { state.wrapping_sub(6) }; - len = (dict_get(&raw mut dict, rep0) as u32) << 1; + len = (dict_get(::core::ptr::addr_of_mut!(dict), rep0) as u32) << 1; offset = 0x100; current_block = 18125716024132132232; continue; @@ -1074,7 +1096,11 @@ unsafe extern "C" fn lzma_decode( continue; } 17340485688450593529 => { - if dict_repeat(&raw mut dict, rep0, &raw mut len) { + if dict_repeat( + ::core::ptr::addr_of_mut!(dict), + rep0, + ::core::ptr::addr_of_mut!(len), + ) { (*coder).sequence = SEQ_COPY; current_block = 4609795085482299213; continue; @@ -1104,9 +1130,12 @@ unsafe extern "C" fn lzma_decode( .wrapping_sub((*coder).rep_len_decoder.choice2 as u32) >> RC_MOVE_BITS, ) as probability; - probs = &raw mut *(&raw mut (*coder).rep_len_decoder.mid + probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( + (*coder).rep_len_decoder.mid + ) as *mut [probability; 8]) - .offset(pos_state as isize) as *mut probability; + .offset(pos_state as isize)) + as *mut probability; limit = LEN_MID_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { @@ -1114,7 +1143,8 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.choice2 = (*coder).rep_len_decoder.choice2 - ((*coder).rep_len_decoder.choice2 >> RC_MOVE_BITS); - probs = &raw mut (*coder).rep_len_decoder.high as *mut probability; + probs = ::core::ptr::addr_of_mut!((*coder).rep_len_decoder.high) + as *mut probability; limit = LEN_HIGH_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32; } @@ -1123,7 +1153,7 @@ unsafe extern "C" fn lzma_decode( } match current_block { 13383302701878543647 => { - if dict_is_distance_valid(&raw mut dict, rep0 as size_t) { + if dict_is_distance_valid(::core::ptr::addr_of_mut!(dict), rep0 as size_t) { current_block = 17340485688450593529; continue; } @@ -1156,13 +1186,15 @@ unsafe extern "C" fn lzma_decode( ) as probability as probability; - probs = (&raw mut (*coder).literal as *mut probability).offset( - (3_usize).wrapping_mul( - ((dict.pos << 8).wrapping_add(dict_get0(&raw mut dict) as size_t) - & literal_mask as size_t) - << literal_context_bits, - ) as isize, - ); + probs = (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability) + .offset( + (3_usize).wrapping_mul( + ((dict.pos << 8).wrapping_add( + dict_get0(::core::ptr::addr_of_mut!(dict)) as size_t, + ) & literal_mask as size_t) + << literal_context_bits, + ) as isize, + ); if state < LIT_STATES { state = if state <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT @@ -1360,7 +1392,8 @@ unsafe extern "C" fn lzma_decode( } else { state.wrapping_sub(6) }; - let mut t_match_byte: u32 = dict_get(&raw mut dict, rep0) as u32; + let mut t_match_byte: u32 = + dict_get(::core::ptr::addr_of_mut!(dict), rep0) as u32; let mut t_match_bit: u32 = 0; let mut t_subcoder_index: u32 = 0; let mut t_offset: u32 = 0x100; @@ -1590,7 +1623,7 @@ unsafe extern "C" fn lzma_decode( t_offset &= t_match_bit; } } - dict_put(&raw mut dict, symbol as u8); + dict_put(::core::ptr::addr_of_mut!(dict), symbol as u8); } else { rc.range = rc.range.wrapping_sub(rc_bound); rc.code = rc.code.wrapping_sub(rc_bound); @@ -2132,14 +2165,17 @@ unsafe extern "C" fn lzma_decode( len = symbol; } } - probs = &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) + probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( + (*coder).dist_slot + ) + as *mut [probability; 64]) .offset( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { len.wrapping_sub(MATCH_LEN_MIN) } else { (DIST_STATES - 1) as u32 }) as isize, - ) as *mut probability; + )) as *mut probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2287,7 +2323,8 @@ unsafe extern "C" fn lzma_decode( rep0 = (2u32).wrapping_add(symbol & 1); if symbol < DIST_MODEL_END { rep0 <<= limit; - probs = (&raw mut (*coder).pos_special as *mut probability) + probs = (::core::ptr::addr_of_mut!((*coder).pos_special) + as *mut probability) .offset(rep0 as isize) .offset(-(symbol as isize)) .offset(-1); @@ -2476,7 +2513,8 @@ unsafe extern "C" fn lzma_decode( } } } - if !dict_is_distance_valid(&raw mut dict, rep0 as size_t) { + if !dict_is_distance_valid(::core::ptr::addr_of_mut!(dict), rep0 as size_t) + { ret_0 = LZMA_DATA_ERROR; current_block = 4609795085482299213; continue 'c_9380; @@ -2486,7 +2524,7 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); - if !dict_is_distance_valid(&raw mut dict, 0) { + if !dict_is_distance_valid(::core::ptr::addr_of_mut!(dict), 0) { ret_0 = LZMA_DATA_ERROR; current_block = 4609795085482299213; continue 'c_9380; @@ -2534,7 +2572,10 @@ unsafe extern "C" fn lzma_decode( } else { STATE_NONLIT_REP }) as u32; - dict_put(&raw mut dict, dict_get(&raw mut dict, rep0)); + dict_put( + ::core::ptr::addr_of_mut!(dict), + dict_get(::core::ptr::addr_of_mut!(dict), rep0), + ); continue; } else { rc.range = rc.range.wrapping_sub(rc_bound); @@ -3154,7 +3195,11 @@ unsafe extern "C" fn lzma_decode( } } } - if !dict_repeat(&raw mut dict, rep0, &raw mut len) { + if !dict_repeat( + ::core::ptr::addr_of_mut!(dict), + rep0, + ::core::ptr::addr_of_mut!(len), + ) { continue; } (*coder).sequence = SEQ_COPY; @@ -3238,7 +3283,7 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo let options: *const lzma_options_lzma = opt as *const lzma_options_lzma; (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; literal_init( - &raw mut (*coder).literal as *mut probability, + ::core::ptr::addr_of_mut!((*coder).literal) as *mut probability, (*options).lc, (*options).lp, ); diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index bd144255..22412945 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; extern "C" { fn lzma_lz_encoder_init( next: *mut lzma_next_coder, @@ -254,10 +253,10 @@ unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u loop { if range < RC_TOP_VALUE as u32 { if rc_shift_low_dummy( - &raw mut low, - &raw mut cache_size, - &raw mut cache, - &raw mut out_pos, + ::core::ptr::addr_of_mut!(low), + ::core::ptr::addr_of_mut!(cache_size), + ::core::ptr::addr_of_mut!(cache), + ::core::ptr::addr_of_mut!(out_pos), out_limit, ) { return true; @@ -292,10 +291,10 @@ unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u pos = 0; while pos < 5 { if rc_shift_low_dummy( - &raw mut low, - &raw mut cache_size, - &raw mut cache, - &raw mut out_pos, + ::core::ptr::addr_of_mut!(low), + ::core::ptr::addr_of_mut!(cache_size), + ::core::ptr::addr_of_mut!(cache), + ::core::ptr::addr_of_mut!(out_pos), out_limit, ) { return true; @@ -341,26 +340,32 @@ unsafe extern "C" fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, p let cur_byte: u8 = *(*mf) .buffer .offset((*mf).read_pos.wrapping_sub((*mf).read_ahead) as isize); - let subcoder: *mut probability = (&raw mut (*coder).literal as *mut probability).offset( - (3u32).wrapping_mul( - ((position << 8).wrapping_add( - *(*mf).buffer.offset( - (*mf) - .read_pos - .wrapping_sub((*mf).read_ahead) - .wrapping_sub(1) as isize, - ) as u32, - ) & (*coder).literal_mask) - << (*coder).literal_context_bits, - ) as isize, - ); + let subcoder: *mut probability = + (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability).offset( + (3u32).wrapping_mul( + ((position << 8).wrapping_add( + *(*mf).buffer.offset( + (*mf) + .read_pos + .wrapping_sub((*mf).read_ahead) + .wrapping_sub(1) as isize, + ) as u32, + ) & (*coder).literal_mask) + << (*coder).literal_context_bits, + ) as isize, + ); if ((*coder).state as u32) < LIT_STATES { (*coder).state = (if (*coder).state <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT } else { ((*coder).state as u32).wrapping_sub(3) }) as lzma_lzma_state; - rc_bittree(&raw mut (*coder).rc, subcoder, 8, cur_byte as u32); + rc_bittree( + ::core::ptr::addr_of_mut!((*coder).rc), + subcoder, + 8, + cur_byte as u32, + ); } else { (*coder).state = (if (*coder).state <= STATE_LIT_SHORTREP { ((*coder).state as u32).wrapping_sub(3) @@ -375,7 +380,7 @@ unsafe extern "C" fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, p .wrapping_sub((*mf).read_ahead) as isize, ); literal_matched( - &raw mut (*coder).rc, + ::core::ptr::addr_of_mut!((*coder).rc), subcoder, match_byte as u32, cur_byte as u32, @@ -389,14 +394,16 @@ unsafe extern "C" fn length_update_prices(lc: *mut lzma_length_encoder, pos_stat let a1: u32 = rc_bit_1_price((*lc).choice) as u32; let b0: u32 = a1.wrapping_add(rc_bit_0_price((*lc).choice2) as u32); let b1: u32 = a1.wrapping_add(rc_bit_1_price((*lc).choice2) as u32); - let prices: *mut u32 = - &raw mut *(&raw mut (*lc).prices as *mut [u32; 272]).offset(pos_state as isize) as *mut u32; + let prices: *mut u32 = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).prices) + as *mut [u32; 272]) + .offset(pos_state as isize)) as *mut u32; let mut i: u32 = 0; i = 0; while i < table_size && i < LEN_LOW_SYMBOLS { *prices.offset(i as isize) = a0.wrapping_add(rc_bittree_price( - &raw mut *(&raw mut (*lc).low as *mut [probability; 8]).offset(pos_state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).low) + as *mut [probability; 8]) + .offset(pos_state as isize)) as *mut probability, LEN_LOW_BITS, i, )); @@ -404,8 +411,9 @@ unsafe extern "C" fn length_update_prices(lc: *mut lzma_length_encoder, pos_stat } while i < table_size && i < (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32 { *prices.offset(i as isize) = b0.wrapping_add(rc_bittree_price( - &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]).offset(pos_state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).mid) + as *mut [probability; 8]) + .offset(pos_state as isize)) as *mut probability, LEN_MID_BITS, i.wrapping_sub(LEN_LOW_SYMBOLS), )); @@ -413,7 +421,7 @@ unsafe extern "C" fn length_update_prices(lc: *mut lzma_length_encoder, pos_stat } while i < table_size { *prices.offset(i as isize) = b1.wrapping_add(rc_bittree_price( - &raw mut (*lc).high as *mut probability, + ::core::ptr::addr_of_mut!((*lc).high) as *mut probability, LEN_HIGH_BITS, i.wrapping_sub(LEN_LOW_SYMBOLS) .wrapping_sub(LEN_MID_SYMBOLS), @@ -431,32 +439,34 @@ unsafe extern "C" fn length( ) { len = len.wrapping_sub(MATCH_LEN_MIN); if len < LEN_LOW_SYMBOLS { - rc_bit(rc, &raw mut (*lc).choice, 0); + rc_bit(rc, ::core::ptr::addr_of_mut!((*lc).choice), 0); rc_bittree( rc, - &raw mut *(&raw mut (*lc).low as *mut [probability; 8]).offset(pos_state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).low) + as *mut [probability; 8]) + .offset(pos_state as isize)) as *mut probability, LEN_LOW_BITS, len, ); } else { - rc_bit(rc, &raw mut (*lc).choice, 1); + rc_bit(rc, ::core::ptr::addr_of_mut!((*lc).choice), 1); len = len.wrapping_sub(LEN_LOW_SYMBOLS); if len < LEN_MID_SYMBOLS { - rc_bit(rc, &raw mut (*lc).choice2, 0); + rc_bit(rc, ::core::ptr::addr_of_mut!((*lc).choice2), 0); rc_bittree( rc, - &raw mut *(&raw mut (*lc).mid as *mut [probability; 8]).offset(pos_state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).mid) + as *mut [probability; 8]) + .offset(pos_state as isize)) as *mut probability, LEN_MID_BITS, len, ); } else { - rc_bit(rc, &raw mut (*lc).choice2, 1); + rc_bit(rc, ::core::ptr::addr_of_mut!((*lc).choice2), 1); len = len.wrapping_sub(LEN_MID_SYMBOLS); rc_bittree( rc, - &raw mut (*lc).high as *mut probability, + ::core::ptr::addr_of_mut!((*lc).high) as *mut probability, LEN_HIGH_BITS, len, ); @@ -482,8 +492,8 @@ unsafe extern "C" fn match_0( STATE_NONLIT_MATCH }) as lzma_lzma_state; length( - &raw mut (*coder).rc, - &raw mut (*coder).match_len_encoder, + ::core::ptr::addr_of_mut!((*coder).rc), + ::core::ptr::addr_of_mut!((*coder).match_len_encoder), pos_state, len, (*coder).fast_mode, @@ -495,9 +505,10 @@ unsafe extern "C" fn match_0( (DIST_STATES - 1) as u32 }; rc_bittree( - &raw mut (*coder).rc, - &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) - .offset(dist_state as isize) as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).dist_slot) + as *mut [probability; 64]) + .offset(dist_state as isize)) as *mut probability, DIST_SLOT_BITS, dist_slot, ); @@ -507,8 +518,8 @@ unsafe extern "C" fn match_0( let dist_reduced: u32 = distance.wrapping_sub(base); if dist_slot < DIST_MODEL_END { rc_bittree_reverse( - &raw mut (*coder).rc, - (&raw mut (*coder).dist_special as *mut probability) + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).dist_special) as *mut probability) .offset(base as isize) .offset(-(dist_slot as isize)) .offset(-1), @@ -517,13 +528,13 @@ unsafe extern "C" fn match_0( ); } else { rc_direct( - &raw mut (*coder).rc, + ::core::ptr::addr_of_mut!((*coder).rc), dist_reduced >> ALIGN_BITS, footer_bits.wrapping_sub(ALIGN_BITS), ); rc_bittree_reverse( - &raw mut (*coder).rc, - &raw mut (*coder).dist_align as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + ::core::ptr::addr_of_mut!((*coder).dist_align) as *mut probability, ALIGN_BITS, dist_reduced & ALIGN_MASK, ); @@ -540,44 +551,45 @@ unsafe extern "C" fn match_0( unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, rep: u32, len: u32) { if rep == 0 { rc_bit( - &raw mut (*coder).rc, - (&raw mut (*coder).is_rep0 as *mut probability).offset((*coder).state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).is_rep0) as *mut probability) + .offset((*coder).state as isize) as *mut probability, 0, ); rc_bit( - &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_rep0_long as *mut [probability; 16]) - .offset((*coder).state as isize) as *mut probability) + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_rep0_long) + as *mut [probability; 16]) + .offset((*coder).state as isize)) as *mut probability) .offset(pos_state as isize) as *mut probability, (len != 1) as u32, ); } else { let distance: u32 = (*coder).reps[rep as usize]; rc_bit( - &raw mut (*coder).rc, - (&raw mut (*coder).is_rep0 as *mut probability).offset((*coder).state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).is_rep0) as *mut probability) + .offset((*coder).state as isize) as *mut probability, 1, ); if rep == 1 { rc_bit( - &raw mut (*coder).rc, - (&raw mut (*coder).is_rep1 as *mut probability).offset((*coder).state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).is_rep1) as *mut probability) + .offset((*coder).state as isize) as *mut probability, 0, ); } else { rc_bit( - &raw mut (*coder).rc, - (&raw mut (*coder).is_rep1 as *mut probability).offset((*coder).state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).is_rep1) as *mut probability) + .offset((*coder).state as isize) as *mut probability, 1, ); rc_bit( - &raw mut (*coder).rc, - (&raw mut (*coder).is_rep2 as *mut probability).offset((*coder).state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).is_rep2) as *mut probability) + .offset((*coder).state as isize) as *mut probability, rep.wrapping_sub(2), ); if rep == 3 { @@ -596,8 +608,8 @@ unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, r }) as lzma_lzma_state; } else { length( - &raw mut (*coder).rc, - &raw mut (*coder).rep_len_encoder, + ::core::ptr::addr_of_mut!((*coder).rc), + ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), pos_state, len, (*coder).fast_mode, @@ -619,34 +631,36 @@ unsafe extern "C" fn encode_symbol( let pos_state: u32 = position & (*coder).pos_mask; if back == UINT32_MAX { rc_bit( - &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) - .offset((*coder).state as isize) as *mut probability) + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_match) + as *mut [probability; 16]) + .offset((*coder).state as isize)) as *mut probability) .offset(pos_state as isize) as *mut probability, 0, ); literal(coder, mf, position); } else { rc_bit( - &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) - .offset((*coder).state as isize) as *mut probability) + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_match) + as *mut [probability; 16]) + .offset((*coder).state as isize)) as *mut probability) .offset(pos_state as isize) as *mut probability, 1, ); if back < REPS { rc_bit( - &raw mut (*coder).rc, - (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).is_rep) as *mut probability) + .offset((*coder).state as isize) as *mut probability, 1, ); rep_match(coder, pos_state, back, len); } else { rc_bit( - &raw mut (*coder).rc, - (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).is_rep) as *mut probability) + .offset((*coder).state as isize) as *mut probability, 0, ); match_0(coder, pos_state, back.wrapping_sub(REPS), len); @@ -663,14 +677,15 @@ unsafe extern "C" fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_m mf_skip(mf, 1); (*mf).read_ahead = 0; rc_bit( - &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) as *mut probability) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!( + *(::core::ptr::addr_of_mut!((*coder).is_match) as *mut [probability; 16]) + ) as *mut probability) as *mut probability, 0, ); rc_bittree( - &raw mut (*coder).rc, - &raw mut (*coder).literal as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + ::core::ptr::addr_of_mut!((*coder).literal) as *mut probability, 8, *(*mf).buffer as u32, ); @@ -682,16 +697,17 @@ unsafe extern "C" fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_m unsafe extern "C" fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) { let pos_state: u32 = position & (*coder).pos_mask; rc_bit( - &raw mut (*coder).rc, - (&raw mut *(&raw mut (*coder).is_match as *mut [probability; 16]) - .offset((*coder).state as isize) as *mut probability) + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_match) + as *mut [probability; 16]) + .offset((*coder).state as isize)) as *mut probability) .offset(pos_state as isize) as *mut probability, 1, ); rc_bit( - &raw mut (*coder).rc, - (&raw mut (*coder).is_rep as *mut probability).offset((*coder).state as isize) - as *mut probability, + ::core::ptr::addr_of_mut!((*coder).rc), + (::core::ptr::addr_of_mut!((*coder).is_rep) as *mut probability) + .offset((*coder).state as isize) as *mut probability, 0, ); match_0(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN); @@ -709,7 +725,12 @@ pub unsafe extern "C" fn lzma_lzma_encode( if !(*coder).is_initialized && !encode_init(coder, mf) { return LZMA_OK; } - if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { + if rc_encode( + ::core::ptr::addr_of_mut!((*coder).rc), + out, + out_pos, + out_size, + ) { return LZMA_OK; } if (*coder).is_flushed { @@ -717,7 +738,7 @@ pub unsafe extern "C" fn lzma_lzma_encode( } while !(limit != UINT32_MAX && ((*mf).read_pos.wrapping_sub((*mf).read_ahead) >= limit - || (*out_pos as u64).wrapping_add(rc_pending(&raw mut (*coder).rc)) + || (*out_pos as u64).wrapping_add(rc_pending(::core::ptr::addr_of_mut!((*coder).rc))) >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX) as u64)) { if (*mf).read_pos >= (*mf).read_limit { @@ -731,23 +752,35 @@ pub unsafe extern "C" fn lzma_lzma_encode( let mut len: u32 = 0; let mut back: u32 = 0; if (*coder).fast_mode { - lzma_lzma_optimum_fast(coder, mf, &raw mut back, &raw mut len); + lzma_lzma_optimum_fast( + coder, + mf, + ::core::ptr::addr_of_mut!(back), + ::core::ptr::addr_of_mut!(len), + ); } else { lzma_lzma_optimum_normal( coder, mf, - &raw mut back, - &raw mut len, + ::core::ptr::addr_of_mut!(back), + ::core::ptr::addr_of_mut!(len), (*coder).uncomp_size as u32, ); } encode_symbol(coder, mf, back, len, (*coder).uncomp_size as u32); - if (*coder).out_limit != 0 && rc_encode_dummy(&raw mut (*coder).rc, (*coder).out_limit) { - rc_forget(&raw mut (*coder).rc); + if (*coder).out_limit != 0 + && rc_encode_dummy(::core::ptr::addr_of_mut!((*coder).rc), (*coder).out_limit) + { + rc_forget(::core::ptr::addr_of_mut!((*coder).rc)); break; } else { (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(len as u64); - if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { + if rc_encode( + ::core::ptr::addr_of_mut!((*coder).rc), + out, + out_pos, + out_size, + ) { return LZMA_OK; } } @@ -758,8 +791,13 @@ pub unsafe extern "C" fn lzma_lzma_encode( if (*coder).use_eopm { encode_eopm(coder, (*coder).uncomp_size as u32); } - rc_flush(&raw mut (*coder).rc); - if rc_encode(&raw mut (*coder).rc, out, out_pos, out_size) { + rc_flush(::core::ptr::addr_of_mut!((*coder).rc)); + if rc_encode( + ::core::ptr::addr_of_mut!((*coder).rc), + out, + out_pos, + out_size, + ) { (*coder).is_flushed = true; return LZMA_OK; } @@ -870,7 +908,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; (*coder).literal_context_bits = (*options).lc; (*coder).literal_mask = (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); - rc_reset(&raw mut (*coder).rc); + rc_reset(::core::ptr::addr_of_mut!((*coder).rc)); (*coder).state = STATE_LIT_LIT; let mut i: size_t = 0; while i < REPS as size_t { @@ -878,7 +916,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( i += 1; } literal_init( - &raw mut (*coder).literal as *mut probability, + ::core::ptr::addr_of_mut!((*coder).literal) as *mut probability, (*options).lc, (*options).lp, ); @@ -918,12 +956,12 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( bt_i_0 += 1; } length_encoder_reset( - &raw mut (*coder).match_len_encoder, + ::core::ptr::addr_of_mut!((*coder).match_len_encoder), 1 << (*options).pb, (*coder).fast_mode, ); length_encoder_reset( - &raw mut (*coder).rep_len_encoder, + ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), 1 << (*options).pb, (*coder).fast_mode, ); @@ -1013,7 +1051,7 @@ unsafe extern "C" fn lzma_encoder_init( lzma_lzma_set_out_limit as unsafe extern "C" fn(*mut c_void, *mut u64, u64) -> lzma_ret, ); lzma_lzma_encoder_create( - &raw mut (*lz).coder, + ::core::ptr::addr_of_mut!((*lz).coder), allocator, id, options as *const lzma_options_lzma, @@ -1058,8 +1096,12 @@ pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { preset_dict: core::ptr::null(), preset_dict_size: 0, }; - set_lz_options(&raw mut lz_options, options as *const lzma_options_lzma); - let lz_memusage: u64 = unsafe { lzma_lz_encoder_memusage(&raw mut lz_options) } as u64; + set_lz_options( + ::core::ptr::addr_of_mut!(lz_options), + options as *const lzma_options_lzma, + ); + let lz_memusage: u64 = + unsafe { lzma_lz_encoder_memusage(::core::ptr::addr_of_mut!(lz_options)) } as u64; if lz_memusage == UINT64_MAX { return UINT64_MAX; } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index b7a289fb..682fe371 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[no_mangle] pub unsafe extern "C" fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, @@ -13,8 +12,8 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( if (*mf).read_ahead == 0 { len_main = lzma_mf_find( mf, - &raw mut matches_count, - &raw mut (*coder).matches as *mut lzma_match, + ::core::ptr::addr_of_mut!(matches_count), + ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, ); } else { len_main = (*coder).longest_match_length; @@ -98,8 +97,8 @@ pub unsafe extern "C" fn lzma_lzma_optimum_fast( } (*coder).longest_match_length = lzma_mf_find( mf, - &raw mut (*coder).matches_count, - &raw mut (*coder).matches as *mut lzma_match, + ::core::ptr::addr_of_mut!((*coder).matches_count), + ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, ); if (*coder).longest_match_length >= 2 { let new_dist: u32 = (*coder).matches[(*coder).matches_count.wrapping_sub(1) as usize].dist; diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 52cd5ca9..c6bdd245 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_uint; pub const RC_BIT_PRICE_SHIFT_BITS: u32 = 4; pub const RC_INFINITY_PRICE: c_uint = 1u32 << 30; #[inline] @@ -47,8 +46,9 @@ unsafe extern "C" fn get_literal_price( mut match_byte: u32, mut symbol: u32, ) -> u32 { - let subcoder: *const probability = - (&raw const (*coder).literal as *const probability).offset((3u32).wrapping_mul( + let subcoder: *const probability = (::core::ptr::addr_of!((*coder).literal) + as *const probability) + .offset((3u32).wrapping_mul( ((pos << 8).wrapping_add(prev_byte) & (*coder).literal_mask) << (*coder).literal_context_bits, ) as isize); @@ -128,8 +128,12 @@ extern "C" fn get_rep_price( pos_state: u32, ) -> u32 { unsafe { - get_len_price(&raw const (*coder).rep_len_encoder, len, pos_state) - .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state)) + get_len_price( + ::core::ptr::addr_of!((*coder).rep_len_encoder), + len, + pos_state, + ) + .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state)) } } #[inline] @@ -154,7 +158,7 @@ extern "C" fn get_dist_len_price( .wrapping_add((*coder).align_prices[(dist & ALIGN_MASK) as usize]); } price = price.wrapping_add(get_len_price( - &raw const (*coder).match_len_encoder, + ::core::ptr::addr_of!((*coder).match_len_encoder), len, pos_state, )); @@ -164,14 +168,16 @@ extern "C" fn get_dist_len_price( unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { let mut dist_state: u32 = 0; while dist_state < DIST_STATES { - let dist_slot_prices: *mut u32 = &raw mut *(&raw mut (*coder).dist_slot_prices - as *mut [u32; 64]) - .offset(dist_state as isize) as *mut u32; + let dist_slot_prices: *mut u32 = + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).dist_slot_prices) + as *mut [u32; 64]) + .offset(dist_state as isize)) as *mut u32; let mut dist_slot: u32 = 0; while dist_slot < (*coder).dist_table_size { *dist_slot_prices.offset(dist_slot as isize) = rc_bittree_price( - &raw mut *(&raw mut (*coder).dist_slot as *mut [probability; 64]) - .offset(dist_state as isize) as *mut probability, + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).dist_slot) + as *mut [probability; 64]) + .offset(dist_state as isize)) as *mut probability, DIST_SLOT_BITS, dist_slot, ); @@ -199,7 +205,7 @@ unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { let footer_bits: u32 = (dist_slot_1 >> 1).wrapping_sub(1); let base: u32 = (2 | dist_slot_1 & 1) << footer_bits; let price: u32 = rc_bittree_reverse_price( - (&raw mut (*coder).dist_special as *mut probability) + (::core::ptr::addr_of_mut!((*coder).dist_special) as *mut probability) .offset(base as isize) .offset(-(dist_slot_1 as isize)) .offset(-1), @@ -221,7 +227,7 @@ unsafe extern "C" fn fill_align_prices(coder: *mut lzma_lzma1_encoder) { let mut i: u32 = 0; while i < ALIGN_SIZE { (*coder).align_prices[i as usize] = rc_bittree_reverse_price( - &raw mut (*coder).dist_align as *mut probability, + ::core::ptr::addr_of_mut!((*coder).dist_align) as *mut probability, ALIGN_BITS, i, ); @@ -251,8 +257,8 @@ unsafe extern "C" fn backward( loop { if (*coder).opts[cur as usize].prev_1_is_literal { make_literal( - (&raw mut (*coder).opts as *mut lzma_optimal).offset(pos_mem as isize) - as *mut lzma_optimal, + (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal) + .offset(pos_mem as isize) as *mut lzma_optimal, ); (*coder).opts[pos_mem as usize].pos_prev = pos_mem.wrapping_sub(1); if (*coder).opts[cur as usize].prev_2 { @@ -292,8 +298,8 @@ unsafe extern "C" fn helper1( if (*mf).read_ahead == 0 { len_main = lzma_mf_find( mf, - &raw mut matches_count, - &raw mut (*coder).matches as *mut lzma_match, + ::core::ptr::addr_of_mut!(matches_count), + ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, ); } else { len_main = (*coder).longest_match_length; @@ -359,7 +365,10 @@ unsafe extern "C" fn helper1( match_byte as u32, current_byte as u32, )); - make_literal((&raw mut (*coder).opts as *mut lzma_optimal).offset(1) as *mut lzma_optimal); + make_literal( + (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal).offset(1) + as *mut lzma_optimal, + ); let match_price: u32 = rc_bit_1_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) as u32; let rep_match_price: u32 = @@ -371,7 +380,8 @@ unsafe extern "C" fn helper1( if short_rep_price < (*coder).opts[1].price { (*coder).opts[1].price = short_rep_price; make_short_rep( - (&raw mut (*coder).opts as *mut lzma_optimal).offset(1) as *mut lzma_optimal + (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal).offset(1) + as *mut lzma_optimal, ); } } @@ -411,7 +421,7 @@ unsafe extern "C" fn helper1( ) as u32); loop { let cur_and_len_price: u32 = price.wrapping_add(get_len_price( - &raw mut (*coder).rep_len_encoder, + ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), rep_len, pos_state, ) as u32); @@ -597,8 +607,8 @@ unsafe extern "C" fn helper2( (*coder).opts[cur.wrapping_add(1) as usize].price = cur_and_1_price; (*coder).opts[cur.wrapping_add(1) as usize].pos_prev = cur; make_literal( - (&raw mut (*coder).opts as *mut lzma_optimal).offset(cur.wrapping_add(1) as isize) - as *mut lzma_optimal, + (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal) + .offset(cur.wrapping_add(1) as isize) as *mut lzma_optimal, ); next_is_literal = true; } @@ -616,8 +626,8 @@ unsafe extern "C" fn helper2( (*coder).opts[cur.wrapping_add(1) as usize].price = short_rep_price; (*coder).opts[cur.wrapping_add(1) as usize].pos_prev = cur; make_short_rep( - (&raw mut (*coder).opts as *mut lzma_optimal).offset(cur.wrapping_add(1) as isize) - as *mut lzma_optimal, + (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal) + .offset(cur.wrapping_add(1) as isize) as *mut lzma_optimal, ); next_is_literal = true; } @@ -691,7 +701,7 @@ unsafe extern "C" fn helper2( .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state) as u32); loop { let cur_and_len_price_0: u32 = price.wrapping_add(get_len_price( - &raw mut (*coder).rep_len_encoder, + ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), len_test_0, pos_state, ) as u32); @@ -733,7 +743,7 @@ unsafe extern "C" fn helper2( position.wrapping_add(len_test_0) & (*coder).pos_mask; let cur_and_len_literal_price: u32 = price .wrapping_add(get_len_price( - &raw mut (*coder).rep_len_encoder, + ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), len_test_0, pos_state, ) as u32) @@ -936,8 +946,8 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( } let mut reps: [u32; 4] = [0; 4]; core::ptr::copy_nonoverlapping( - &raw mut (*coder).reps as *const u8, - &raw mut reps as *mut u8, + ::core::ptr::addr_of_mut!((*coder).reps) as *const u8, + ::core::ptr::addr_of_mut!(reps) as *mut u8, core::mem::size_of::<[u32; 4]>(), ); let mut cur: u32 = 0; @@ -945,15 +955,15 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( while cur < len_end { (*coder).longest_match_length = lzma_mf_find( mf, - &raw mut (*coder).matches_count, - &raw mut (*coder).matches as *mut lzma_match, + ::core::ptr::addr_of_mut!((*coder).matches_count), + ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, ); if (*coder).longest_match_length >= (*mf).nice_len { break; } len_end = helper2( coder, - &raw mut reps as *mut u32, + ::core::ptr::addr_of_mut!(reps) as *mut u32, mf_ptr(mf).offset(-1), len_end, position.wrapping_add(cur), diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index 9d33e35f..0602d789 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_uint; pub const LZMA_LC_DEFAULT: u32 = 3; pub const LZMA_LP_DEFAULT: u32 = 0; pub const LZMA_PB_DEFAULT: u32 = 2; diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index 2d9b6e8b..4abb242f 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn arm_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index 2c153360..c6f73c2b 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn arm64_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index 7fd6c280..99527fde 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn armthumb_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index a481879e..8f29a609 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn ia64_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index 916cf2ab..bddf8673 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn powerpc_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index dc5f39b7..8f4b3b9c 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[inline] extern "C" fn read32be(buf: *const u8) -> u32 { return unsafe { diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index dd859d80..79a44d15 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn copy_or_code( coder: *mut lzma_simple_coder, allocator: *const lzma_allocator, @@ -68,8 +67,8 @@ unsafe extern "C" fn simple_code( } if (*coder).pos < (*coder).filtered { lzma_bufcpy( - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), (*coder).filtered, out, out_pos, @@ -89,7 +88,8 @@ unsafe extern "C" fn simple_code( let out_start: size_t = *out_pos; if buf_avail > 0 { core::ptr::copy_nonoverlapping( - (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const u8, + (::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8) + .offset((*coder).pos as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, buf_avail, ); @@ -116,14 +116,15 @@ unsafe extern "C" fn simple_code( *out_pos = (*out_pos).wrapping_sub(unfiltered); core::ptr::copy_nonoverlapping( out.offset(*out_pos as isize) as *const u8, - &raw mut (*coder).buffer as *mut u8, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, unfiltered, ); } } else if (*coder).pos > 0 { core::ptr::copy( - (&raw mut (*coder).buffer as *mut u8).offset((*coder).pos as isize) as *const u8, - &raw mut (*coder).buffer as *mut u8, + (::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8).offset((*coder).pos as isize) + as *const u8, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, buf_avail, ); (*coder).size = (*coder).size.wrapping_sub((*coder).pos); @@ -136,21 +137,25 @@ unsafe extern "C" fn simple_code( in_0, in_pos, in_size, - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).size, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).size), (*coder).allocated, action, ); if ret_0 != LZMA_OK { return ret_0; } - (*coder).filtered = call_filter(coder, &raw mut (*coder).buffer as *mut u8, (*coder).size); + (*coder).filtered = call_filter( + coder, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + (*coder).size, + ); if (*coder).end_was_reached { (*coder).filtered = (*coder).size; } lzma_bufcpy( - &raw mut (*coder).buffer as *mut u8, - &raw mut (*coder).pos, + ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, + ::core::ptr::addr_of_mut!((*coder).pos), (*coder).filtered, out, out_pos, @@ -164,7 +169,7 @@ unsafe extern "C" fn simple_code( } unsafe extern "C" fn simple_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; - lzma_next_end(&raw mut (*coder).next, allocator); + lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); lzma_free((*coder).simple, allocator); lzma_free(coder as *mut c_void, allocator); } @@ -176,7 +181,7 @@ unsafe extern "C" fn simple_coder_update( ) -> lzma_ret { let coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; lzma_next_filter_update( - &raw mut (*coder).next, + ::core::ptr::addr_of_mut!((*coder).next), allocator, reversed_filters.offset(1), ) @@ -266,5 +271,9 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*coder).pos = 0; (*coder).filtered = 0; (*coder).size = 0; - lzma_next_filter_init(&raw mut (*coder).next, allocator, filters.offset(1)) + lzma_next_filter_init( + ::core::ptr::addr_of_mut!((*coder).next), + allocator, + filters.offset(1), + ) } diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs index 30dce43d..fe3fa4ab 100644 --- a/liblzma-rs/src/simple/simple_decoder.rs +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_decode( options: *mut *mut c_void, diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index 8026a4d3..99a1094b 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[no_mangle] pub unsafe extern "C" fn lzma_simple_props_size( size: *mut u32, diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index f6b36ecf..fb8a1993 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; unsafe extern "C" fn sparc_code( _simple: *mut c_void, now_pos: u32, diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index 7c5acc42..a297ee1b 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -1,5 +1,4 @@ use crate::types::*; -use core::ffi::c_void; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_simple_x86 { @@ -137,7 +136,7 @@ pub unsafe extern "C" fn lzma_bcj_x86_encode( prev_pos: (-5_i32) as u32, }; x86_code( - &raw mut simple as *mut c_void, + ::core::ptr::addr_of_mut!(simple) as *mut c_void, start_offset, true, buf, @@ -163,7 +162,7 @@ pub unsafe extern "C" fn lzma_bcj_x86_decode( prev_pos: (-5_i32) as u32, }; x86_code( - &raw mut simple as *mut c_void, + ::core::ptr::addr_of_mut!(simple) as *mut c_void, start_offset, false, buf, diff --git a/liblzma-rs/src/tuklib/tuklib_physmem.rs b/liblzma-rs/src/tuklib/tuklib_physmem.rs index 4106e98a..a2d286a9 100644 --- a/liblzma-rs/src/tuklib/tuklib_physmem.rs +++ b/liblzma-rs/src/tuklib/tuklib_physmem.rs @@ -20,7 +20,6 @@ pub extern "C" fn tuklib_physmem() -> u64 { } 0 } - #[cfg(target_os = "linux")] { let pages = unsafe { libc::sysconf(libc::_SC_PHYS_PAGES) }; @@ -30,14 +29,10 @@ pub extern "C" fn tuklib_physmem() -> u64 { } 0 } - #[cfg(target_os = "windows")] { - // On Windows, use GetSystemInfo-based approach or return 0 - // Windows support would need winapi/windows-sys crate 0 } - #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))] { 0 diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 4f22f635..24d6b562 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -1,10 +1,12 @@ -use core::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; - -// Platform-dependent type aliases +pub use std::os::raw::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_ulonglong, c_void}; +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +pub type size_t = usize; +#[cfg(not(all(target_family = "wasm", target_os = "unknown")))] pub type size_t = libc::size_t; +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +pub type uintptr_t = usize; +#[cfg(not(all(target_family = "wasm", target_os = "unknown")))] pub type uintptr_t = libc::uintptr_t; - -// lzma type aliases pub type lzma_bool = c_uchar; pub type lzma_ret = c_uint; pub type lzma_action = c_uint; @@ -16,8 +18,6 @@ pub type lzma_match_finder = c_uint; pub type lzma_lzma_state = c_uint; pub type lzma_delta_type = c_uint; pub type probability = u16; - -// Common struct shared across all modules #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_allocator { @@ -25,14 +25,12 @@ pub struct lzma_allocator { pub free: Option ()>, pub opaque: *mut c_void, } - #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter { pub id: lzma_vli, pub options: *mut c_void, } - pub type lzma_end_function = Option ()>; pub type lzma_code_function = Option< unsafe extern "C" fn( @@ -69,7 +67,6 @@ pub struct lzma_next_coder_s { >, pub set_out_limit: Option lzma_ret>, } - pub type lzma_init_function = Option< unsafe extern "C" fn( *mut lzma_next_coder, @@ -85,7 +82,6 @@ pub struct lzma_filter_info_s { pub options: *mut c_void, } pub type lzma_filter_info = lzma_filter_info_s; - #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_lzma { @@ -114,8 +110,6 @@ pub struct lzma_options_lzma { pub reserved_ptr1: *mut c_void, pub reserved_ptr2: *mut c_void, } - -// lzma_internal sequence enum pub type lzma_internal_sequence = c_uint; pub const ISEQ_RUN: lzma_internal_sequence = 0; pub const ISEQ_SYNC_FLUSH: lzma_internal_sequence = 1; @@ -124,7 +118,6 @@ pub const ISEQ_FINISH: lzma_internal_sequence = 3; pub const ISEQ_FULL_BARRIER: lzma_internal_sequence = 4; pub const ISEQ_END: lzma_internal_sequence = 5; pub const ISEQ_ERROR: lzma_internal_sequence = 6; - #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_internal_s { @@ -135,7 +128,6 @@ pub struct lzma_internal_s { pub allow_buf_error: bool, } pub type lzma_internal = lzma_internal_s; - #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream { @@ -158,8 +150,6 @@ pub struct lzma_stream { pub reserved_enum1: lzma_reserved_enum, pub reserved_enum2: lzma_reserved_enum, } - -// lzma_ret constants pub const LZMA_OK: lzma_ret = 0; pub const LZMA_STREAM_END: lzma_ret = 1; pub const LZMA_NO_CHECK: lzma_ret = 2; @@ -181,49 +171,29 @@ pub const LZMA_RET_INTERNAL5: lzma_ret = 105; pub const LZMA_RET_INTERNAL6: lzma_ret = 106; pub const LZMA_RET_INTERNAL7: lzma_ret = 107; pub const LZMA_RET_INTERNAL8: lzma_ret = 108; - -// lzma_action constants pub const LZMA_RUN: lzma_action = 0; pub const LZMA_SYNC_FLUSH: lzma_action = 1; pub const LZMA_FULL_FLUSH: lzma_action = 2; pub const LZMA_FINISH: lzma_action = 3; pub const LZMA_FULL_BARRIER: lzma_action = 4; - -// lzma_check constants pub const LZMA_CHECK_NONE: lzma_check = 0; pub const LZMA_CHECK_CRC32: lzma_check = 1; pub const LZMA_CHECK_CRC64: lzma_check = 4; pub const LZMA_CHECK_SHA256: lzma_check = 10; - -// lzma_reserved_enum constant pub const LZMA_RESERVED_ENUM: lzma_reserved_enum = 0; - -// Integer max constants pub const UINT32_MAX: c_uint = u32::MAX; pub const UINT64_MAX: u64 = u64::MAX; - -// VLI constants pub const LZMA_VLI_MAX: lzma_vli = u64::MAX / 2; pub const LZMA_VLI_UNKNOWN: lzma_vli = u64::MAX; - -// lzma_match_finder constants pub const LZMA_MF_HC3: lzma_match_finder = 3; pub const LZMA_MF_HC4: lzma_match_finder = 4; pub const LZMA_MF_BT2: lzma_match_finder = 18; pub const LZMA_MF_BT3: lzma_match_finder = 19; pub const LZMA_MF_BT4: lzma_match_finder = 20; - -// lzma_mode constants pub const LZMA_MODE_FAST: lzma_mode = 1; pub const LZMA_MODE_NORMAL: lzma_mode = 2; - -// lzma_check additional constants pub const LZMA_CHECK_ID_MAX: lzma_check = 15; - -// lzma_delta_type constants pub const LZMA_DELTA_TYPE_BYTE: lzma_delta_type = 0; - -// LZMA filter IDs pub const LZMA_FILTER_DELTA: lzma_vli = 0x3; pub const LZMA_FILTER_X86: lzma_vli = 0x4; pub const LZMA_FILTER_POWERPC: lzma_vli = 0x5; @@ -237,22 +207,16 @@ pub const LZMA_FILTER_LZMA1: lzma_vli = 0x4000000000000001; pub const LZMA_FILTER_LZMA1EXT: lzma_vli = 0x4000000000000002; pub const LZMA_FILTER_LZMA2: lzma_vli = 0x21; pub const LZMA_FILTER_RESERVED_START: lzma_vli = 1 << 62; - -// Decoder flags pub const LZMA_TELL_NO_CHECK: c_uint = 0x1; pub const LZMA_TELL_UNSUPPORTED_CHECK: c_uint = 0x2; pub const LZMA_TELL_ANY_CHECK: c_uint = 0x4; pub const LZMA_CONCATENATED: c_uint = 0x8; pub const LZMA_IGNORE_CHECK: c_uint = 0x10; pub const LZMA_FAIL_FAST: c_uint = 0x20; - -// Stream/block size constants pub const LZMA_STREAM_HEADER_SIZE: u32 = 12; pub const LZMA_BLOCK_HEADER_SIZE_MAX: u32 = 1024; pub const LZMA_MEMUSAGE_BASE: u64 = 1 << 15; pub const LZMA_DICT_SIZE_MIN: c_uint = 4096; - -// lzma_lzma_state constants pub const STATE_LIT_LIT: lzma_lzma_state = 0; pub const STATE_MATCH_LIT_LIT: lzma_lzma_state = 1; pub const STATE_REP_LIT_LIT: lzma_lzma_state = 2; @@ -265,33 +229,19 @@ pub const STATE_LIT_LONGREP: lzma_lzma_state = 8; pub const STATE_LIT_SHORTREP: lzma_lzma_state = 9; pub const STATE_NONLIT_MATCH: lzma_lzma_state = 10; pub const STATE_NONLIT_REP: lzma_lzma_state = 11; - -// VLI encoding constants pub const LZMA_VLI_BYTES_MAX: u32 = 9; - -// Filter chain limit pub const LZMA_FILTERS_MAX: u32 = 4; - -// LZMA option limits pub const LZMA_LCLP_MAX: u32 = 4; pub const LZMA_PB_MAX: u32 = 4; - -// Delta filter pub const LZMA_DELTA_DIST_MAX: u32 = 256; - -// Stream flags pub const LZMA_BACKWARD_SIZE_MIN: u32 = 4; pub const LZMA_BACKWARD_SIZE_MAX: u64 = 1 << 34; - -// Decoder supported flags pub const LZMA_SUPPORTED_FLAGS: c_uint = LZMA_TELL_NO_CHECK | LZMA_TELL_UNSUPPORTED_CHECK | LZMA_TELL_ANY_CHECK | LZMA_IGNORE_CHECK | LZMA_CONCATENATED | LZMA_FAIL_FAST; - -// Common constants used across many modules pub const UINTPTR_MAX: c_ulong = uintptr_t::MAX as c_ulong; pub const SIZE_MAX: c_ulong = UINTPTR_MAX; pub const INDEX_INDICATOR: u8 = 0; @@ -300,8 +250,6 @@ pub const UNPADDED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX & !3; pub const LZMA_THREADS_MAX: u32 = 16384; pub const LZMA_DELTA_DIST_MIN: u32 = 1; pub const LZMA_LZMA1EXT_ALLOW_EOPM: c_uint = 0x1; - -// LZMA range coder and match constants pub const RC_BIT_MODEL_TOTAL_BITS: u32 = 11; pub const RC_BIT_MODEL_TOTAL: c_uint = 1u32 << RC_BIT_MODEL_TOTAL_BITS; pub const MATCH_LEN_MIN: u32 = 2; @@ -311,8 +259,6 @@ pub const FASTPOS_BITS: u32 = 13; pub const OPTS: u32 = 1 << 12; pub const LZ_DICT_REPEAT_MAX: u32 = 288; pub const LZ_DICT_INIT_POS: u32 = 2 * LZ_DICT_REPEAT_MAX; - -// LZMA encoder/decoder shared constants pub const ALIGN_BITS: u32 = 4; pub const ALIGN_SIZE: u32 = 1 << ALIGN_BITS; pub const ALIGN_MASK: u32 = ALIGN_SIZE - 1; @@ -337,37 +283,24 @@ pub const RC_TOP_VALUE: c_uint = 1u32 << RC_TOP_BITS; pub const RC_MOVE_REDUCING_BITS: u32 = 4; pub const LZMA2_CHUNK_MAX: c_uint = 1u32 << 16; pub const LZMA2_HEADER_UNCOMPRESSED: u32 = 3; - -// LZ encoder constants pub const HASH_2_SIZE: c_uint = 1u32 << 10; pub const HASH_3_SIZE: c_uint = 1u32 << 16; - -// Stream/block constants pub const LZMA_CHECK_SIZE_MAX: u32 = 64; pub const LZMA_STREAM_FLAGS_SIZE: u32 = 2; pub const LZMA_PRESET_EXTREME: c_uint = 1u32 << 31; pub const COMPRESSED_SIZE_MAX: c_ulonglong = LZMA_VLI_MAX .wrapping_sub(LZMA_BLOCK_HEADER_SIZE_MAX as u64) .wrapping_sub(LZMA_CHECK_SIZE_MAX as u64); - -// Thread-related constants pub const MYTHREAD_RET_VALUE: *mut c_void = core::ptr::null_mut(); pub const SIG_SETMASK: c_int = 3; - -// Type aliases used in multiple modules pub type worker_state = c_uint; pub type lzma_index_iter_mode = c_uint; - -// Worker state constants pub const THR_IDLE: worker_state = 0; pub const THR_RUN: worker_state = 1; - -// Index iterator mode constants pub const LZMA_INDEX_ITER_ANY: lzma_index_iter_mode = 0; pub const LZMA_INDEX_ITER_STREAM: lzma_index_iter_mode = 1; pub const LZMA_INDEX_ITER_BLOCK: lzma_index_iter_mode = 2; pub const LZMA_INDEX_ITER_NONEMPTY_BLOCK: lzma_index_iter_mode = 3; - #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_iter { @@ -422,8 +355,6 @@ pub struct lzma_index_iter_stream { pub reserved_vli3: lzma_vli, pub reserved_vli4: lzma_vli, } - -// lzma_block struct (shared across 12 modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_block { @@ -458,8 +389,6 @@ pub struct lzma_block { pub reserved_bool7: lzma_bool, pub reserved_bool8: lzma_bool, } - -// lzma_stream_flags struct (shared across 11 modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_flags { @@ -481,16 +410,12 @@ pub struct lzma_stream_flags { pub reserved_int1: u32, pub reserved_int2: u32, } - -// lzma_sha256_state struct (shared across check modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_sha256_state { pub state: [u32; 8], pub size: u64, } - -// lzma_check_state unions and struct (shared across check/block modules) #[derive(Copy, Clone)] #[repr(C)] pub union lzma_check_state_buffer { @@ -498,7 +423,6 @@ pub union lzma_check_state_buffer { pub u32_0: [u32; 16], pub u64_0: [u64; 8], } - #[derive(Copy, Clone)] #[repr(C)] pub union lzma_check_state_inner { @@ -506,15 +430,12 @@ pub union lzma_check_state_inner { pub crc64: u64, pub sha256: lzma_sha256_state, } - #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_check_state { pub buffer: lzma_check_state_buffer, pub state: lzma_check_state_inner, } - -// lzma_options_delta struct (shared across delta modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_delta { @@ -527,16 +448,12 @@ pub struct lzma_options_delta { pub reserved_ptr1: *mut c_void, pub reserved_ptr2: *mut c_void, } - -// lzma_options_easy struct (shared across easy modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_easy { pub filters: [lzma_filter; 5], pub opt_lzma: lzma_options_lzma, } - -// lzma_dict struct (shared across decoder modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_dict { @@ -548,8 +465,6 @@ pub struct lzma_dict { pub has_wrapped: bool, pub need_reset: bool, } - -// lzma_lz_decoder struct (shared across decoder modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_decoder { @@ -567,16 +482,12 @@ pub struct lzma_lz_decoder { pub set_uncompressed: Option ()>, pub end: Option ()>, } - -// lzma_match struct (shared across encoder modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_match { pub len: u32, pub dist: u32, } - -// lzma_mf_s struct (shared across encoder modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_mf_s { @@ -605,8 +516,6 @@ pub struct lzma_mf_s { pub sons_count: u32, } pub type lzma_mf = lzma_mf_s; - -// lzma_delta_coder struct (shared across delta modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_delta_coder { @@ -615,8 +524,6 @@ pub struct lzma_delta_coder { pub pos: u8, pub history: [u8; LZMA_DELTA_DIST_MAX as usize], } - -// lzma_lz_encoder struct (shared across encoder modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_encoder { @@ -628,8 +535,6 @@ pub struct lzma_lz_encoder { pub options_update: Option lzma_ret>, pub set_out_limit: Option lzma_ret>, } - -// lzma_outbuf_s struct (shared across mt modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_outbuf_s { @@ -645,8 +550,6 @@ pub struct lzma_outbuf_s { pub buf: [u8; 0], } pub type lzma_outbuf = lzma_outbuf_s; - -// lzma_outq struct (shared across mt modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_outq { @@ -660,20 +563,16 @@ pub struct lzma_outq { pub bufs_allocated: u32, pub bufs_limit: u32, } - -// Opaque struct forward declarations (used by files that only need pointer types) #[repr(C)] pub struct lzma_index_s { _opaque: [u8; 0], } pub type lzma_index = lzma_index_s; - #[repr(C)] pub struct lzma_index_hash_s { _opaque: [u8; 0], } pub type lzma_index_hash = lzma_index_hash_s; - #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma1_encoder_s { @@ -716,8 +615,6 @@ pub struct lzma_lzma1_encoder_s { pub opts: [lzma_optimal; OPTS as usize], } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; - -// Byte-order helper functions (shared across many modules) #[inline] pub extern "C" fn read32le(buf: *const u8) -> u32 { return unsafe { @@ -737,8 +634,6 @@ pub extern "C" fn write32le(buf: *mut u8, num: u32) { *buf.offset(3) = (num >> 24) as u8; } } - -// Darwin/pthread types (shared by stream_decoder_mt and stream_encoder_mt) pub type __uint32_t = u32; pub type __darwin_time_t = c_long; pub type __darwin_sigset_t = __uint32_t; @@ -824,8 +719,6 @@ pub struct mythread_cond { pub clk_id: clockid_t, } pub type mythread_condtime = timespec; - -// Shared inline helper functions (mythread wrappers, used by mt modules) #[inline] pub extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { let _ret: c_int = @@ -840,7 +733,11 @@ pub extern "C" fn mythread_create( let mut old: sigset_t = 0; let mut all: sigset_t = 0; all = !(0 as sigset_t); - mythread_sigmask(SIG_SETMASK, &raw mut all, &raw mut old); + mythread_sigmask( + SIG_SETMASK, + ::core::ptr::addr_of_mut!(all), + ::core::ptr::addr_of_mut!(old), + ); let ret: c_int = unsafe { pthread_create( thread as *mut pthread_t, @@ -849,7 +746,11 @@ pub extern "C" fn mythread_create( arg as *mut c_void, ) }; - mythread_sigmask(SIG_SETMASK, &raw mut old, core::ptr::null_mut()); + mythread_sigmask( + SIG_SETMASK, + ::core::ptr::addr_of_mut!(old), + core::ptr::null_mut(), + ); ret } #[inline] @@ -876,21 +777,25 @@ pub extern "C" fn mythread_mutex_unlock(mutex: *mut mythread_mutex) { pub extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { return unsafe { (*mycond).clk_id = _CLOCK_REALTIME; - pthread_cond_init(&raw mut (*mycond).cond, core::ptr::null()) + pthread_cond_init(::core::ptr::addr_of_mut!((*mycond).cond), core::ptr::null()) }; } #[inline] pub extern "C" fn mythread_cond_destroy(cond: *mut mythread_cond) { - let _ret: c_int = unsafe { pthread_cond_destroy(&raw mut (*cond).cond) }; + let _ret: c_int = unsafe { pthread_cond_destroy(::core::ptr::addr_of_mut!((*cond).cond)) }; } #[inline] pub extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { - let _ret: c_int = unsafe { pthread_cond_signal(&raw mut (*cond).cond) }; + let _ret: c_int = unsafe { pthread_cond_signal(::core::ptr::addr_of_mut!((*cond).cond)) }; } #[inline] pub extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { - let _ret: c_int = - unsafe { pthread_cond_wait(&raw mut (*cond).cond, mutex as *mut pthread_mutex_t) }; + let _ret: c_int = unsafe { + pthread_cond_wait( + ::core::ptr::addr_of_mut!((*cond).cond), + mutex as *mut pthread_mutex_t, + ) + }; } #[inline] pub extern "C" fn mythread_cond_timedwait( @@ -900,7 +805,7 @@ pub extern "C" fn mythread_cond_timedwait( ) -> c_int { let ret: c_int = unsafe { pthread_cond_timedwait( - &raw mut (*cond).cond, + ::core::ptr::addr_of_mut!((*cond).cond), mutex as *mut pthread_mutex_t, condtime as *const timespec, ) @@ -920,7 +825,7 @@ pub extern "C" fn mythread_condtime_set( tv_sec: 0, tv_nsec: 0, }; - let _ret: c_int = clock_gettime((*cond).clk_id, &raw mut now); + let _ret: c_int = clock_gettime((*cond).clk_id, ::core::ptr::addr_of_mut!(now)); (*condtime).tv_sec += now.tv_sec; (*condtime).tv_nsec += now.tv_nsec; if (*condtime).tv_nsec >= 1_000_000_000 { @@ -929,8 +834,6 @@ pub extern "C" fn mythread_condtime_set( } } } - -// Shared inline helpers (used by index, block, and mt modules) #[inline] pub extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { vli.wrapping_add(3) & !(3) @@ -949,8 +852,6 @@ pub extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { pub extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { unsafe { (*outq).bufs_in_use == 0 } } - -// Shared inline helpers (encoder match-finder and range coder) #[inline] pub unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { (*mf).buffer.offset((*mf).read_pos as isize) @@ -1028,8 +929,6 @@ pub unsafe extern "C" fn rc_bittree_price( } price } - -// Shared inline helpers (misc) #[inline] pub extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { match_finder as u32 & 0xf @@ -1068,16 +967,12 @@ pub extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { pub unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { *(buf as *const u32) } - -// Range coder symbol type and constants (shared across encoder modules) pub type rc_symbol = c_uint; pub const RC_FLUSH: rc_symbol = 4; pub const RC_DIRECT_1: rc_symbol = 3; pub const RC_DIRECT_0: rc_symbol = 2; pub const RC_BIT_1: rc_symbol = 1; pub const RC_BIT_0: rc_symbol = 0; - -// lzma_range_encoder struct (shared across encoder modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_range_encoder { @@ -1091,8 +986,6 @@ pub struct lzma_range_encoder { pub symbols: [rc_symbol; 53], pub probs: [*mut probability; 53], } - -// lzma_optimal struct (shared across encoder modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_optimal { @@ -1106,8 +999,6 @@ pub struct lzma_optimal { pub back_prev: u32, pub backs: [u32; 4], } - -// lzma_length_encoder struct (shared across encoder modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_length_encoder { @@ -1120,15 +1011,11 @@ pub struct lzma_length_encoder { pub table_size: u32, pub counters: [u32; 16], } - -// lzma_options_bcj struct (shared across simple/filter modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_options_bcj { pub start_offset: u32, } - -// lzma_mt struct (shared across mt modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_mt { @@ -1155,8 +1042,6 @@ pub struct lzma_mt { pub reserved_ptr3: *mut c_void, pub reserved_ptr4: *mut c_void, } - -// lzma_filter_coder struct (shared across filter modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_coder { @@ -1165,8 +1050,6 @@ pub struct lzma_filter_coder { pub memusage: Option u64>, } pub type lzma_filter_find = Option *const lzma_filter_coder>; - -// lzma_simple_coder struct (shared across simple modules) #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_simple_coder { @@ -1182,8 +1065,6 @@ pub struct lzma_simple_coder { pub size: size_t, pub buffer: [u8; 0], } - -// Common extern functions used across many modules extern "C" { pub fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; pub fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; @@ -1407,8 +1288,19 @@ extern "C" { pub fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> c_int; pub fn pthread_sigmask(_: c_int, _: *const sigset_t, _: *mut sigset_t) -> c_int; pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; + #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] pub fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn strlen(s: *const c_char) -> size_t; pub static lzma_rc_prices: [u8; 128]; pub static lzma_fastpos: [u8; 8192]; } + +#[cfg(all(target_family = "wasm", target_os = "unknown"))] +pub unsafe fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void { + let bytes = core::slice::from_raw_parts(s as *const u8, n); + let needle = c as u8; + match bytes.iter().position(|&byte| byte == needle) { + Some(index) => (s as *const u8).add(index) as *mut c_void, + None => core::ptr::null_mut(), + } +} diff --git a/liblzma-sys/Cargo.toml b/liblzma-sys/Cargo.toml index 3adf733c..de0881a0 100644 --- a/liblzma-sys/Cargo.toml +++ b/liblzma-sys/Cargo.toml @@ -17,7 +17,7 @@ High level Rust bindings are available in the `liblzma` crate. """ categories = ["external-ffi-bindings"] edition = "2021" -rust-version = "1.60" +rust-version = "1.63" exclude = ["xz/.github/", "xz/tests/files/*"] [dependencies] diff --git a/src/lib.rs b/src/lib.rs index d08daba9..2f2b874f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,13 +171,13 @@ pub fn uncompressed_size(mut source: R) -> io::Result { Ok(uncompressed_size) } -#[cfg(test)] +#[cfg(all(test, not(target_family = "wasm")))] mod tests { use super::*; + #[cfg(not(target_family = "wasm"))] use quickcheck::quickcheck; - #[cfg(all(target_family = "wasm", target_os = "unknown"))] - use wasm_bindgen_test::wasm_bindgen_test as test; + #[cfg(not(target_family = "wasm"))] #[test] fn all() { quickcheck(test as fn(_) -> _); @@ -189,6 +189,7 @@ mod tests { } } + #[cfg(not(target_family = "wasm"))] #[test] fn copy() { quickcheck(test as fn(_) -> _); @@ -202,6 +203,7 @@ mod tests { } } + #[cfg(not(target_family = "wasm"))] #[test] #[cfg(feature = "bindgen")] fn size() { diff --git a/src/read.rs b/src/read.rs index cea37de8..d550db0d 100644 --- a/src/read.rs +++ b/src/read.rs @@ -226,7 +226,10 @@ impl Write for XzDecoder { #[cfg(test)] mod tests { use super::*; - use crate::stream::{LzmaOptions, PRESET_EXTREME}; + #[cfg(not(target_family = "wasm"))] + use crate::stream::LzmaOptions; + use crate::stream::PRESET_EXTREME; + #[cfg(not(target_family = "wasm"))] use quickcheck::quickcheck; use rand::{thread_rng, Rng}; use std::iter; @@ -326,6 +329,7 @@ mod tests { assert_eq!(data, m); } + #[cfg(not(target_family = "wasm"))] #[test] fn qc_lzma1() { quickcheck(test as fn(_) -> _); @@ -341,6 +345,7 @@ mod tests { } } + #[cfg(not(target_family = "wasm"))] #[test] fn qc() { quickcheck(test as fn(_) -> _); @@ -354,6 +359,7 @@ mod tests { } } + #[cfg(not(target_family = "wasm"))] #[cfg(feature = "parallel")] #[test] fn qc_parallel_encode() { @@ -379,6 +385,7 @@ mod tests { assert_eq!(data, m); } + #[cfg(not(target_family = "wasm"))] #[cfg(feature = "parallel")] #[test] fn qc_parallel_decode() { diff --git a/src/write.rs b/src/write.rs index cb438255..ae24fab5 100644 --- a/src/write.rs +++ b/src/write.rs @@ -382,7 +382,10 @@ impl Drop for XzDecoder { #[cfg(test)] mod tests { use super::*; - use crate::stream::{LzmaOptions, PRESET_EXTREME}; + #[cfg(not(target_family = "wasm"))] + use crate::stream::LzmaOptions; + use crate::stream::PRESET_EXTREME; + #[cfg(not(target_family = "wasm"))] use quickcheck::quickcheck; use std::iter::repeat; #[cfg(all(target_family = "wasm", target_os = "unknown"))] @@ -420,6 +423,7 @@ mod tests { assert_eq!(data, input); } + #[cfg(not(target_family = "wasm"))] #[test] fn qc_lzma1() { quickcheck(test as fn(_) -> _); @@ -435,6 +439,7 @@ mod tests { } } + #[cfg(not(target_family = "wasm"))] #[test] fn qc() { quickcheck(test as fn(_) -> _); @@ -447,6 +452,7 @@ mod tests { } } + #[cfg(not(target_family = "wasm"))] #[cfg(feature = "parallel")] #[test] fn qc_parallel_encode() { @@ -460,6 +466,7 @@ mod tests { } } + #[cfg(not(target_family = "wasm"))] #[cfg(feature = "parallel")] #[test] fn qc_parallel_decode() { diff --git a/tests/sys_equivalence.rs b/tests/sys_equivalence.rs index ecf6a2c7..7192e1b8 100644 --- a/tests/sys_equivalence.rs +++ b/tests/sys_equivalence.rs @@ -1,3 +1,5 @@ +#![cfg(not(target_family = "wasm"))] + use std::collections::BTreeMap; use std::fs; use std::path::Path; From 61371c166ce5e72b23e32b951ada3d939400e56f Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sat, 14 Mar 2026 23:37:12 +0900 Subject: [PATCH 13/51] refactor: use Rust memchr in liblzma-rs --- liblzma-rs/Cargo.toml | 1 + liblzma-rs/src/common/common.rs | 39 +++++++++++++++++---------------- liblzma-rs/src/types.rs | 5 +---- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/liblzma-rs/Cargo.toml b/liblzma-rs/Cargo.toml index f53564c3..b8c718ac 100644 --- a/liblzma-rs/Cargo.toml +++ b/liblzma-rs/Cargo.toml @@ -10,3 +10,4 @@ default = [] [dependencies] libc = "0.2" +memchr = "2" diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index b59cbe15..6f55a2c8 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -15,38 +15,41 @@ const LZMA_ALLOC_ALIGN: usize = 16; const LZMA_ALLOC_HEADER_SIZE: usize = 16; #[cfg(all(target_family = "wasm", target_os = "unknown"))] -unsafe fn wasm_alloc_layout(size: size_t) -> Option { - let total_size = (size as usize).checked_add(LZMA_ALLOC_HEADER_SIZE)?; +unsafe fn rust_alloc_layout(size: usize) -> Option { + let total_size = size.checked_add(LZMA_ALLOC_HEADER_SIZE)?; Layout::from_size_align(total_size, LZMA_ALLOC_ALIGN).ok() } #[cfg(all(target_family = "wasm", target_os = "unknown"))] unsafe fn malloc(size: size_t) -> *mut c_void { - let Some(layout) = wasm_alloc_layout(size) else { - return core::ptr::null_mut(); + let layout = match rust_alloc_layout(size as usize) { + Some(layout) => layout, + None => return core::ptr::null_mut(), }; - let ptr = alloc(layout); - if ptr.is_null() { + let base = alloc(layout); + if base.is_null() { return core::ptr::null_mut(); } - *(ptr as *mut usize) = layout.size(); - ptr.add(LZMA_ALLOC_HEADER_SIZE) as *mut c_void + *(base as *mut usize) = layout.size(); + base.add(LZMA_ALLOC_HEADER_SIZE) as *mut c_void } #[cfg(all(target_family = "wasm", target_os = "unknown"))] unsafe fn calloc(count: size_t, size: size_t) -> *mut c_void { - let Some(total_size) = (count as usize).checked_mul(size as usize) else { - return core::ptr::null_mut(); + let size = match (count as usize).checked_mul(size as usize) { + Some(size) => size, + None => return core::ptr::null_mut(), }; - let Some(layout) = wasm_alloc_layout(total_size as size_t) else { - return core::ptr::null_mut(); + let layout = match rust_alloc_layout(size) { + Some(layout) => layout, + None => return core::ptr::null_mut(), }; - let ptr = alloc_zeroed(layout); - if ptr.is_null() { + let base = alloc_zeroed(layout); + if base.is_null() { return core::ptr::null_mut(); } - *(ptr as *mut usize) = layout.size(); - ptr.add(LZMA_ALLOC_HEADER_SIZE) as *mut c_void + *(base as *mut usize) = layout.size(); + base.add(LZMA_ALLOC_HEADER_SIZE) as *mut c_void } #[cfg(all(target_family = "wasm", target_os = "unknown"))] @@ -56,9 +59,7 @@ unsafe fn free(ptr: *mut c_void) { } let base = (ptr as *mut u8).sub(LZMA_ALLOC_HEADER_SIZE); let total_size = *(base as *const usize); - let Ok(layout) = Layout::from_size_align(total_size, LZMA_ALLOC_ALIGN) else { - return; - }; + let layout = Layout::from_size_align_unchecked(total_size, LZMA_ALLOC_ALIGN); dealloc(base, layout); } pub const LZMA_VERSION_MAJOR: u32 = 5; diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 24d6b562..294c3693 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -1288,18 +1288,15 @@ extern "C" { pub fn pthread_mutex_unlock(_: *mut pthread_mutex_t) -> c_int; pub fn pthread_sigmask(_: c_int, _: *const sigset_t, _: *mut sigset_t) -> c_int; pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; - #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] - pub fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn strlen(s: *const c_char) -> size_t; pub static lzma_rc_prices: [u8; 128]; pub static lzma_fastpos: [u8; 8192]; } -#[cfg(all(target_family = "wasm", target_os = "unknown"))] pub unsafe fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void { let bytes = core::slice::from_raw_parts(s as *const u8, n); let needle = c as u8; - match bytes.iter().position(|&byte| byte == needle) { + match ::memchr::memchr(needle, bytes) { Some(index) => (s as *const u8).add(index) as *mut c_void, None => core::ptr::null_mut(), } From 90c1615c8fe14a22ed684a25b923f6c3da28680c Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 15 Mar 2026 00:10:02 +0900 Subject: [PATCH 14/51] alloc: move internal memory to Rust allocator --- liblzma-rs/src/alloc.rs | 192 +++++++++++++++++++++ liblzma-rs/src/common/alone_decoder.rs | 5 +- liblzma-rs/src/common/alone_encoder.rs | 5 +- liblzma-rs/src/common/auto_decoder.rs | 5 +- liblzma-rs/src/common/block_decoder.rs | 5 +- liblzma-rs/src/common/block_encoder.rs | 5 +- liblzma-rs/src/common/common.rs | 5 +- liblzma-rs/src/common/file_info.rs | 5 +- liblzma-rs/src/common/index_decoder.rs | 5 +- liblzma-rs/src/common/index_encoder.rs | 5 +- liblzma-rs/src/common/lzip_decoder.rs | 5 +- liblzma-rs/src/common/microlzma_decoder.rs | 5 +- liblzma-rs/src/common/microlzma_encoder.rs | 5 +- liblzma-rs/src/common/outqueue.rs | 4 +- liblzma-rs/src/common/stream_decoder.rs | 5 +- liblzma-rs/src/common/stream_decoder_mt.rs | 24 +-- liblzma-rs/src/common/stream_encoder.rs | 5 +- liblzma-rs/src/common/stream_encoder_mt.rs | 23 ++- liblzma-rs/src/delta/delta_common.rs | 5 +- liblzma-rs/src/lib.rs | 1 + liblzma-rs/src/lz/lz_decoder.rs | 16 +- liblzma-rs/src/lz/lz_encoder.rs | 36 ++-- liblzma-rs/src/lzma/lzma2_decoder.rs | 7 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 7 +- liblzma-rs/src/lzma/lzma_decoder.rs | 3 +- liblzma-rs/src/lzma/lzma_encoder.rs | 3 +- liblzma-rs/src/simple/simple_coder.rs | 8 +- 27 files changed, 288 insertions(+), 111 deletions(-) create mode 100644 liblzma-rs/src/alloc.rs diff --git a/liblzma-rs/src/alloc.rs b/liblzma-rs/src/alloc.rs new file mode 100644 index 00000000..e20d9aeb --- /dev/null +++ b/liblzma-rs/src/alloc.rs @@ -0,0 +1,192 @@ +use crate::types::*; +use std::alloc::{alloc, alloc_zeroed, dealloc, Layout}; + +const RUST_ALLOC_ALIGN: usize = 16; + +#[derive(Copy, Clone)] +#[repr(C)] +struct RustAllocHeader { + total_size: usize, + align: usize, + offset: usize, +} + +const fn round_up(value: usize, align: usize) -> usize { + (value + (align - 1)) & !(align - 1) +} + +unsafe fn rust_alloc_impl(size: usize, align: usize, zeroed: bool) -> *mut c_void { + let size = if size == 0 { 1 } else { size }; + let align = align + .max(RUST_ALLOC_ALIGN) + .max(core::mem::align_of::()); + let header_size = core::mem::size_of::(); + let offset = match header_size.checked_add(align - 1) { + Some(value) => round_up(value, align), + None => return core::ptr::null_mut(), + }; + let total_size = match offset.checked_add(size) { + Some(total_size) => total_size, + None => return core::ptr::null_mut(), + }; + let layout = match Layout::from_size_align(total_size, align) { + Ok(layout) => layout, + Err(_) => return core::ptr::null_mut(), + }; + let base = if zeroed { alloc_zeroed(layout) } else { alloc(layout) }; + if base.is_null() { + return core::ptr::null_mut(); + } + let user_ptr = base.add(offset); + let header_ptr = user_ptr.sub(header_size) as *mut RustAllocHeader; + header_ptr.write(RustAllocHeader { + total_size, + align, + offset, + }); + user_ptr as *mut c_void +} + +unsafe fn rust_free_impl(ptr: *mut c_void) { + if ptr.is_null() { + return; + } + let header_size = core::mem::size_of::(); + let user_ptr = ptr as *mut u8; + let header_ptr = user_ptr.sub(header_size) as *const RustAllocHeader; + let header = header_ptr.read(); + let base = user_ptr.sub(header.offset); + let layout = Layout::from_size_align_unchecked(header.total_size, header.align); + dealloc(base, layout); +} + +pub unsafe extern "C" fn lzma_rust_alloc( + _opaque: *mut c_void, + nmemb: size_t, + size: size_t, +) -> *mut c_void { + let size = match (nmemb as usize).checked_mul(size as usize) { + Some(size) => size, + None => return core::ptr::null_mut(), + }; + rust_alloc_impl(size, RUST_ALLOC_ALIGN, false) +} + +pub unsafe extern "C" fn lzma_rust_free(_opaque: *mut c_void, ptr: *mut c_void) { + rust_free_impl(ptr); +} + +pub fn rust_allocator() -> lzma_allocator { + lzma_allocator { + alloc: Some(lzma_rust_alloc), + free: Some(lzma_rust_free), + opaque: core::ptr::null_mut(), + } +} + +pub(crate) unsafe fn internal_alloc_bytes( + size: size_t, + allocator: *const lzma_allocator, +) -> *mut c_void { + let size = if size == 0 { 1 } else { size }; + if !allocator.is_null() && (*allocator).alloc.is_some() { + (*allocator).alloc.unwrap()((*allocator).opaque, 1, size) + } else { + rust_alloc_impl(size as usize, RUST_ALLOC_ALIGN, false) + } +} + +pub(crate) unsafe fn internal_alloc_zeroed_bytes( + size: size_t, + allocator: *const lzma_allocator, +) -> *mut c_void { + let size = if size == 0 { 1 } else { size }; + if !allocator.is_null() && (*allocator).alloc.is_some() { + let ptr = (*allocator).alloc.unwrap()((*allocator).opaque, 1, size); + if !ptr.is_null() { + core::ptr::write_bytes(ptr as *mut u8, 0, size); + } + ptr + } else { + rust_alloc_impl(size as usize, RUST_ALLOC_ALIGN, true) + } +} + +pub(crate) unsafe fn internal_alloc_object(allocator: *const lzma_allocator) -> *mut T { + if !allocator.is_null() && (*allocator).alloc.is_some() { + return (*allocator).alloc.unwrap()( + (*allocator).opaque, + 1, + core::mem::size_of::() as size_t, + ) as *mut T; + } + rust_alloc_impl(core::mem::size_of::(), core::mem::align_of::(), false) as *mut T +} + +pub(crate) unsafe fn internal_alloc_array( + count: size_t, + allocator: *const lzma_allocator, +) -> *mut T { + let size = match (count as usize).checked_mul(core::mem::size_of::()) { + Some(size) => size, + None => return core::ptr::null_mut(), + }; + if !allocator.is_null() && (*allocator).alloc.is_some() { + return (*allocator).alloc.unwrap()((*allocator).opaque, 1, size as size_t) as *mut T; + } + rust_alloc_impl(size, core::mem::align_of::(), false) as *mut T +} + +pub(crate) unsafe fn internal_alloc_zeroed_array( + count: size_t, + allocator: *const lzma_allocator, +) -> *mut T { + let size = match (count as usize).checked_mul(core::mem::size_of::()) { + Some(size) => size, + None => return core::ptr::null_mut(), + }; + if !allocator.is_null() && (*allocator).alloc.is_some() { + let ptr = (*allocator).alloc.unwrap()((*allocator).opaque, 1, size as size_t) as *mut T; + if !ptr.is_null() { + core::ptr::write_bytes(ptr as *mut u8, 0, size); + } + return ptr; + } + rust_alloc_impl(size, core::mem::align_of::(), true) as *mut T +} + +pub(crate) unsafe fn internal_free(ptr: *mut c_void, allocator: *const lzma_allocator) { + if !allocator.is_null() && (*allocator).free.is_some() { + (*allocator).free.unwrap()((*allocator).opaque, ptr); + } else { + rust_free_impl(ptr); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn rust_allocator_round_trip() { + unsafe { + let allocator = rust_allocator(); + let ptr = allocator.alloc.unwrap()(allocator.opaque, 4, 8); + assert!(!ptr.is_null()); + allocator.free.unwrap()(allocator.opaque, ptr); + } + } + + #[test] + fn internal_object_allocation_respects_alignment() { + #[repr(align(32))] + struct Align32([u8; 32]); + + unsafe { + let ptr = internal_alloc_object::(core::ptr::null()); + assert!(!ptr.is_null()); + assert_eq!((ptr as usize) % core::mem::align_of::(), 0); + internal_free(ptr.cast(), core::ptr::null()); + } + } +} diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 45fe3f4c..7b3b9668 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -154,7 +154,7 @@ unsafe extern "C" fn alone_decode( unsafe extern "C" fn alone_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn alone_decoder_memconfig( coder_ptr: *mut c_void, @@ -223,8 +223,7 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( )); let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_alone_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index bb4be1d4..d3311934 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -60,7 +60,7 @@ unsafe extern "C" fn alone_encode( unsafe extern "C" fn alone_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_alone_coder = coder_ptr as *mut lzma_alone_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn alone_encoder_init( next: *mut lzma_next_coder, @@ -106,8 +106,7 @@ unsafe extern "C" fn alone_encoder_init( )); let mut coder: *mut lzma_alone_coder = (*next).coder as *mut lzma_alone_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_alone_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index edc1ba50..90629a12 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -107,7 +107,7 @@ unsafe extern "C" fn auto_decode( unsafe extern "C" fn auto_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_auto_coder = coder_ptr as *mut lzma_auto_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } extern "C" fn auto_decoder_get_check(coder_ptr: *const c_void) -> lzma_check { return unsafe { @@ -189,8 +189,7 @@ unsafe extern "C" fn auto_decoder_init( } let mut coder: *mut lzma_auto_coder = (*next).coder as *mut lzma_auto_coder; if coder.is_null() { - coder = - lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_auto_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 9e52f7cb..9d725c38 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -172,7 +172,7 @@ unsafe extern "C" fn block_decode( unsafe extern "C" fn block_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_block_decoder_init( @@ -225,8 +225,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( } let mut coder: *mut lzma_block_coder = (*next).coder as *mut lzma_block_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_block_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 41c85d90..b5429293 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -114,7 +114,7 @@ unsafe extern "C" fn block_encode( unsafe extern "C" fn block_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_block_coder = coder_ptr as *mut lzma_block_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn block_encoder_update( coder_ptr: *mut c_void, @@ -189,8 +189,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( } let mut coder: *mut lzma_block_coder = (*next).coder as *mut lzma_block_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_block_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index 6f55a2c8..a79dd275 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -216,8 +216,7 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { return LZMA_PROG_ERROR; } if (*strm).internal.is_null() { - (*strm).internal = lzma_alloc(core::mem::size_of::(), (*strm).allocator) - as *mut lzma_internal; + (*strm).internal = crate::alloc::internal_alloc_object::((*strm).allocator); if (*strm).internal.is_null() { return LZMA_MEM_ERROR; } @@ -389,7 +388,7 @@ pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { ::core::ptr::addr_of_mut!((*(*strm).internal).next), (*strm).allocator, ); - lzma_free((*strm).internal as *mut c_void, (*strm).allocator); + crate::alloc::internal_free((*strm).internal as *mut c_void, (*strm).allocator); (*strm).internal = core::ptr::null_mut(); } } diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index e83d1f9a..fdb125d7 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -555,7 +555,7 @@ unsafe extern "C" fn file_info_decoder_end( lzma_next_end(::core::ptr::addr_of_mut!((*coder).index_decoder), allocator); lzma_index_end((*coder).this_index, allocator); lzma_index_end((*coder).combined_index, allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma_file_info_decoder_init( next: *mut lzma_next_coder, @@ -619,8 +619,7 @@ unsafe extern "C" fn lzma_file_info_decoder_init( } let mut coder: *mut lzma_file_info_coder = (*next).coder as *mut lzma_file_info_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_file_info_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 301a22eb..7c857c55 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -188,7 +188,7 @@ unsafe extern "C" fn index_decode( unsafe extern "C" fn index_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_index_coder = coder_ptr as *mut lzma_index_coder; lzma_index_end((*coder).index, allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn index_decoder_memconfig( coder_ptr: *mut c_void, @@ -279,8 +279,7 @@ pub unsafe extern "C" fn lzma_index_decoder_init( } let mut coder: *mut lzma_index_coder = (*next).coder as *mut lzma_index_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_index_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index ab4353f4..a8800078 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -144,7 +144,7 @@ unsafe extern "C" fn index_encode( ret } unsafe extern "C" fn index_encoder_end(coder: *mut c_void, allocator: *const lzma_allocator) { - lzma_free(coder, allocator); + crate::alloc::internal_free(coder, allocator); } unsafe extern "C" fn index_encoder_reset(coder: *mut lzma_index_coder, i: *const lzma_index) { lzma_index_iter_init(::core::ptr::addr_of_mut!((*coder).iter), i); @@ -200,7 +200,8 @@ pub unsafe extern "C" fn lzma_index_encoder_init( return LZMA_PROG_ERROR; } if (*next).coder.is_null() { - (*next).coder = lzma_alloc(core::mem::size_of::(), allocator); + (*next).coder = + crate::alloc::internal_alloc_object::(allocator) as *mut c_void; if (*next).coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index f0ccadf1..9fef3c69 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -272,7 +272,7 @@ unsafe extern "C" fn lzip_decode( unsafe extern "C" fn lzip_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_lzip_coder = coder_ptr as *mut lzma_lzip_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).lzma_decoder), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } extern "C" fn lzip_decoder_get_check(_coder_ptr: *const c_void) -> lzma_check { LZMA_CHECK_CRC32 @@ -337,8 +337,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( } let mut coder: *mut lzma_lzip_coder = (*next).coder as *mut lzma_lzip_coder; if coder.is_null() { - coder = - lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_lzip_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index 3daf671c..f9886e77 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -153,7 +153,7 @@ unsafe extern "C" fn microlzma_decoder_end( ) { let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).lzma), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn microlzma_decoder_init( next: *mut lzma_next_coder, @@ -214,8 +214,7 @@ unsafe extern "C" fn microlzma_decoder_init( )); let mut coder: *mut lzma_microlzma_coder = (*next).coder as *mut lzma_microlzma_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_microlzma_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index edc9c6fc..0977a2a8 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -55,7 +55,7 @@ unsafe extern "C" fn microlzma_encoder_end( ) { let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).lzma), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn microlzma_encoder_init( next: *mut lzma_next_coder, @@ -101,8 +101,7 @@ unsafe extern "C" fn microlzma_encoder_init( )); let mut coder: *mut lzma_microlzma_coder = (*next).coder as *mut lzma_microlzma_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_microlzma_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index 7d316462..4c74b440 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -36,7 +36,7 @@ unsafe extern "C" fn free_one_cached_buffer( (*outq).mem_allocated = (*outq) .mem_allocated .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); - lzma_free(buf as *mut c_void, allocator); + crate::alloc::internal_free(buf as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_outq_clear_cache( @@ -104,7 +104,7 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( } let alloc_size: size_t = lzma_outq_outbuf_memusage(size) as size_t; lzma_outq_clear_cache(outq, allocator); - (*outq).cache = lzma_alloc(alloc_size, allocator) as *mut lzma_outbuf; + (*outq).cache = crate::alloc::internal_alloc_bytes(alloc_size, allocator) as *mut lzma_outbuf; if (*outq).cache.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 5e18045f..17f80343 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -333,7 +333,7 @@ unsafe extern "C" fn stream_decoder_end(coder_ptr: *mut c_void, allocator: *cons let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).block_decoder), allocator); lzma_index_hash_end((*coder).index_hash, allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } extern "C" fn stream_decoder_get_check(coder_ptr: *const c_void) -> lzma_check { return unsafe { @@ -401,8 +401,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( } let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_stream_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 1c0e2d25..834aab36 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -126,7 +126,7 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { } else { if (*thr).state == THR_EXIT { mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); - lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); + crate::alloc::internal_free((*thr).in_0 as *mut c_void, (*thr).allocator); lzma_next_end( ::core::ptr::addr_of_mut!((*thr).block_decoder), (*thr).allocator, @@ -211,7 +211,7 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { mythread_i_434 = 1; } if ret == LZMA_STREAM_END { - lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); + crate::alloc::internal_free((*thr).in_0 as *mut c_void, (*thr).allocator); (*thr).in_0 = core::ptr::null_mut(); } let mut mythread_i_458: c_uint = 0; @@ -293,7 +293,7 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); i_0 += 1; } - lzma_free((*coder).threads as *mut c_void, allocator); + crate::alloc::internal_free((*coder).threads as *mut c_void, allocator); (*coder).threads_initialized = 0; (*coder).threads = core::ptr::null_mut(); (*coder).threads_free = core::ptr::null_mut(); @@ -331,10 +331,10 @@ unsafe extern "C" fn initialize_new_thread( allocator: *const lzma_allocator, ) -> lzma_ret { if (*coder).threads.is_null() { - (*coder).threads = lzma_alloc( - ((*coder).threads_max as size_t).wrapping_mul(core::mem::size_of::()), + (*coder).threads = crate::alloc::internal_alloc_array::( + (*coder).threads_max as size_t, allocator, - ) as *mut worker_thread; + ); if (*coder).threads.is_null() { return LZMA_MEM_ERROR; } @@ -1186,7 +1186,8 @@ unsafe extern "C" fn stream_decode_mt( } else { (*(*coder).thr).in_size = (*coder).mem_next_in as size_t; (*(*coder).thr).in_0 = - lzma_alloc((*(*coder).thr).in_size, allocator) as *mut u8; + crate::alloc::internal_alloc_bytes((*(*coder).thr).in_size, allocator) + as *mut u8; if (*(*coder).thr).in_0.is_null() { threads_stop(coder); return LZMA_MEM_ERROR; @@ -1322,7 +1323,7 @@ unsafe extern "C" fn stream_decoder_mt_end( allocator, ); lzma_index_hash_end((*coder).index_hash, allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } extern "C" fn stream_decoder_mt_get_check(coder_ptr: *const c_void) -> lzma_check { return unsafe { @@ -1473,19 +1474,18 @@ unsafe extern "C" fn stream_decoder_mt_init( )); coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_stream_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } (*next).coder = coder as *mut c_void; if mythread_mutex_init(::core::ptr::addr_of_mut!((*coder).mutex)) != 0 { - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); return LZMA_MEM_ERROR; } if mythread_cond_init(::core::ptr::addr_of_mut!((*coder).cond)) != 0 { mythread_mutex_destroy(::core::ptr::addr_of_mut!((*coder).mutex)); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); return LZMA_MEM_ERROR; } (*next).code = Some( diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index c2f7c39b..9eaa91da 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -199,7 +199,7 @@ unsafe extern "C" fn stream_encoder_end(coder_ptr: *mut c_void, allocator: *cons ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, allocator, ); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn stream_encoder_update( coder_ptr: *mut c_void, @@ -324,8 +324,7 @@ unsafe extern "C" fn stream_encoder_init( } let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_stream_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 262d9022..85a11f8f 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -360,7 +360,7 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { ::core::ptr::addr_of_mut!((*thr).block_encoder), (*thr).allocator, ); - lzma_free((*thr).in_0 as *mut c_void, (*thr).allocator); + crate::alloc::internal_free((*thr).in_0 as *mut c_void, (*thr).allocator); MYTHREAD_RET_VALUE } unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_threads: bool) { @@ -457,7 +457,7 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons let _ret: c_int = mythread_join((*(*coder).threads.offset(i_0 as isize)).thread_id); i_0 += 1; } - lzma_free((*coder).threads as *mut c_void, allocator); + crate::alloc::internal_free((*coder).threads as *mut c_void, allocator); } unsafe extern "C" fn initialize_new_thread( coder: *mut lzma_stream_coder, @@ -467,7 +467,7 @@ unsafe extern "C" fn initialize_new_thread( .threads .offset((*coder).threads_initialized as isize) as *mut worker_thread; - (*thr).in_0 = lzma_alloc((*coder).block_size, allocator) as *mut u8; + (*thr).in_0 = crate::alloc::internal_alloc_bytes((*coder).block_size, allocator) as *mut u8; if (*thr).in_0.is_null() { return LZMA_MEM_ERROR; } @@ -506,7 +506,7 @@ unsafe extern "C" fn initialize_new_thread( } mythread_mutex_destroy(::core::ptr::addr_of_mut!((*thr).mutex)); } - lzma_free((*thr).in_0 as *mut c_void, allocator); + crate::alloc::internal_free((*thr).in_0 as *mut c_void, allocator); LZMA_MEM_ERROR } unsafe extern "C" fn get_thread( @@ -918,7 +918,7 @@ unsafe extern "C" fn stream_encoder_mt_end( lzma_index_end((*coder).index, allocator); mythread_cond_destroy(::core::ptr::addr_of_mut!((*coder).cond)); mythread_mutex_destroy(::core::ptr::addr_of_mut!((*coder).mutex)); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn stream_encoder_mt_update( coder_ptr: *mut c_void, @@ -1147,20 +1147,19 @@ unsafe extern "C" fn stream_encoder_mt_init( } let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_stream_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } (*next).coder = coder as *mut c_void; if mythread_mutex_init(::core::ptr::addr_of_mut!((*coder).mutex)) != 0 { - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); (*next).coder = core::ptr::null_mut(); return LZMA_MEM_ERROR; } if mythread_cond_init(::core::ptr::addr_of_mut!((*coder).cond)) != 0 { mythread_mutex_destroy(::core::ptr::addr_of_mut!((*coder).mutex)); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); (*next).coder = core::ptr::null_mut(); return LZMA_MEM_ERROR; } @@ -1227,10 +1226,10 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).threads_max = 0; (*coder).threads_initialized = 0; (*coder).threads_free = core::ptr::null_mut(); - (*coder).threads = lzma_alloc( - ((*options).threads as size_t).wrapping_mul(core::mem::size_of::()), + (*coder).threads = crate::alloc::internal_alloc_array::( + (*options).threads as size_t, allocator, - ) as *mut worker_thread; + ); if (*coder).threads.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index 3adb822b..0975f7b8 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -2,7 +2,7 @@ use crate::types::*; unsafe extern "C" fn delta_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_delta_coder_init( @@ -12,8 +12,7 @@ pub unsafe extern "C" fn lzma_delta_coder_init( ) -> lzma_ret { let mut coder: *mut lzma_delta_coder = (*next).coder as *mut lzma_delta_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_delta_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/lib.rs b/liblzma-rs/src/lib.rs index 20f38746..5f304142 100644 --- a/liblzma-rs/src/lib.rs +++ b/liblzma-rs/src/lib.rs @@ -13,6 +13,7 @@ macro_rules! c_str { concat!($s, "\0").as_ptr() as *const ::std::os::raw::c_char }; } +pub mod alloc; pub mod check; pub mod common; pub mod delta; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 7cc4636b..9ba4cea9 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -164,13 +164,13 @@ unsafe extern "C" fn lz_decode( unsafe extern "C" fn lz_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free((*coder).dict.buf as *mut c_void, allocator); + crate::alloc::internal_free((*coder).dict.buf as *mut c_void, allocator); if (*coder).lz.end.is_some() { (*coder).lz.end.unwrap()((*coder).lz.coder, allocator); } else { - lzma_free((*coder).lz.coder, allocator); + crate::alloc::internal_free((*coder).lz.coder, allocator); } - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } #[no_mangle] pub unsafe extern "C" fn lzma_lz_decoder_init( @@ -189,7 +189,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( ) -> lzma_ret { let mut coder: *mut lzma_coder = (*next).coder as *mut lzma_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } @@ -257,9 +257,11 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( .dict_size .wrapping_add((2 * LZ_DICT_REPEAT_MAX) as size_t); if (*coder).dict.size != alloc_size { - lzma_free((*coder).dict.buf as *mut c_void, allocator); - (*coder).dict.buf = - lzma_alloc(alloc_size.wrapping_add(LZ_DICT_EXTRA as size_t), allocator) as *mut u8; + crate::alloc::internal_free((*coder).dict.buf as *mut c_void, allocator); + (*coder).dict.buf = crate::alloc::internal_alloc_bytes( + alloc_size.wrapping_add(LZ_DICT_EXTRA as size_t), + allocator, + ) as *mut u8; if (*coder).dict.buf.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 3ba1486f..91ff1f28 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -177,7 +177,7 @@ unsafe extern "C" fn lz_encoder_prepare( .wrapping_add(reserve) .wrapping_add((*mf).keep_size_after); if !(*mf).buffer.is_null() && old_size != (*mf).size { - lzma_free((*mf).buffer as *mut c_void, allocator); + crate::alloc::internal_free((*mf).buffer as *mut c_void, allocator); (*mf).buffer = core::ptr::null_mut(); } (*mf).match_len_max = (*lz_options).match_len_max as u32; @@ -253,9 +253,9 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).sons_count = (*mf).sons_count.wrapping_mul(2); } if old_hash_count != (*mf).hash_count || old_sons_count != (*mf).sons_count { - lzma_free((*mf).hash as *mut c_void, allocator); + crate::alloc::internal_free((*mf).hash as *mut c_void, allocator); (*mf).hash = core::ptr::null_mut(); - lzma_free((*mf).son as *mut c_void, allocator); + crate::alloc::internal_free((*mf).son as *mut c_void, allocator); (*mf).son = core::ptr::null_mut(); } (*mf).depth = (*lz_options).depth; @@ -274,7 +274,7 @@ unsafe extern "C" fn lz_encoder_init( lz_options: *const lzma_lz_options, ) -> bool { if (*mf).buffer.is_null() { - (*mf).buffer = lzma_alloc( + (*mf).buffer = crate::alloc::internal_alloc_bytes( (*mf).size.wrapping_add(LZMA_MEMCMPLEN_EXTRA) as size_t, allocator, ) as *mut u8; @@ -294,18 +294,14 @@ unsafe extern "C" fn lz_encoder_init( (*mf).write_pos = 0; (*mf).pending = 0; if (*mf).hash.is_null() { - (*mf).hash = lzma_alloc_zero( - ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::()), - allocator, - ) as *mut u32; - (*mf).son = lzma_alloc( - ((*mf).sons_count as size_t).wrapping_mul(core::mem::size_of::()), - allocator, - ) as *mut u32; + (*mf).hash = + crate::alloc::internal_alloc_zeroed_array::((*mf).hash_count as size_t, allocator); + (*mf).son = + crate::alloc::internal_alloc_array::((*mf).sons_count as size_t, allocator); if (*mf).hash.is_null() || (*mf).son.is_null() { - lzma_free((*mf).hash as *mut c_void, allocator); + crate::alloc::internal_free((*mf).hash as *mut c_void, allocator); (*mf).hash = core::ptr::null_mut(); - lzma_free((*mf).son as *mut c_void, allocator); + crate::alloc::internal_free((*mf).son as *mut c_void, allocator); (*mf).son = core::ptr::null_mut(); return true; } @@ -376,15 +372,15 @@ pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) - unsafe extern "C" fn lz_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free((*coder).mf.son as *mut c_void, allocator); - lzma_free((*coder).mf.hash as *mut c_void, allocator); - lzma_free((*coder).mf.buffer as *mut c_void, allocator); + crate::alloc::internal_free((*coder).mf.son as *mut c_void, allocator); + crate::alloc::internal_free((*coder).mf.hash as *mut c_void, allocator); + crate::alloc::internal_free((*coder).mf.buffer as *mut c_void, allocator); if (*coder).lz.end.is_some() { (*coder).lz.end.unwrap()((*coder).lz.coder, allocator); } else { - lzma_free((*coder).lz.coder, allocator); + crate::alloc::internal_free((*coder).lz.coder, allocator); } - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lz_encoder_update( coder_ptr: *mut c_void, @@ -434,7 +430,7 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( ) -> lzma_ret { let mut coder: *mut lzma_coder = (*next).coder as *mut lzma_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index 0c37e6db..fe897df3 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -215,8 +215,8 @@ unsafe extern "C" fn lzma2_decode( } unsafe extern "C" fn lzma2_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; - lzma_free((*coder).lzma.coder, allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free((*coder).lzma.coder, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma2_decoder_init( lz: *mut lzma_lz_decoder, @@ -227,8 +227,7 @@ unsafe extern "C" fn lzma2_decoder_init( ) -> lzma_ret { let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_lzma2_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index ea6b89da..32a5d562 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -304,8 +304,8 @@ unsafe extern "C" fn lzma2_encode( } unsafe extern "C" fn lzma2_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_lzma2_coder = coder_ptr as *mut lzma_lzma2_coder; - lzma_free((*coder).lzma, allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free((*coder).lzma, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn lzma2_encoder_options_update( coder_ptr: *mut c_void, @@ -347,8 +347,7 @@ unsafe extern "C" fn lzma2_encoder_init( } let mut coder: *mut lzma_lzma2_coder = (*lz).coder as *mut lzma_lzma2_coder; if coder.is_null() { - coder = lzma_alloc(core::mem::size_of::(), allocator) - as *mut lzma_lzma2_coder; + coder = crate::alloc::internal_alloc_object::(allocator); if coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index f4c773bb..350b344a 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -3391,7 +3391,8 @@ pub unsafe extern "C" fn lzma_lzma_decoder_create( lz_options: *mut lzma_lz_options, ) -> lzma_ret { if (*lz).coder.is_null() { - (*lz).coder = lzma_alloc(core::mem::size_of::(), allocator); + (*lz).coder = + crate::alloc::internal_alloc_object::(allocator) as *mut c_void; if (*lz).coder.is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 22412945..b12858ff 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -980,7 +980,8 @@ pub unsafe extern "C" fn lzma_lzma_encoder_create( lz_options: *mut lzma_lz_options, ) -> lzma_ret { if (*coder_ptr).is_null() { - *coder_ptr = lzma_alloc(core::mem::size_of::(), allocator); + *coder_ptr = + crate::alloc::internal_alloc_object::(allocator) as *mut c_void; if (*coder_ptr).is_null() { return LZMA_MEM_ERROR; } diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 79a44d15..7f54d149 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -170,8 +170,8 @@ unsafe extern "C" fn simple_code( unsafe extern "C" fn simple_coder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_simple_coder = coder_ptr as *mut lzma_simple_coder; lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); - lzma_free((*coder).simple, allocator); - lzma_free(coder as *mut c_void, allocator); + crate::alloc::internal_free((*coder).simple, allocator); + crate::alloc::internal_free(coder as *mut c_void, allocator); } unsafe extern "C" fn simple_coder_update( coder_ptr: *mut c_void, @@ -199,7 +199,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( ) -> lzma_ret { let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; if coder.is_null() { - coder = lzma_alloc( + coder = crate::alloc::internal_alloc_bytes( (core::mem::size_of::()) .wrapping_add((2_usize).wrapping_mul(unfiltered_max)), allocator, @@ -249,7 +249,7 @@ pub unsafe extern "C" fn lzma_simple_coder_init( (*coder).filter = filter; (*coder).allocated = (2_usize).wrapping_mul(unfiltered_max); if simple_size > 0 { - (*coder).simple = lzma_alloc(simple_size, allocator); + (*coder).simple = crate::alloc::internal_alloc_bytes(simple_size, allocator); if (*coder).simple.is_null() { return LZMA_MEM_ERROR; } From 60a827398273e64952ee16e8f24120e8236aefdb Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 15 Mar 2026 17:36:45 +0900 Subject: [PATCH 15/51] Remove #[no_mangle] from liblzma-rs, replace extern "C" {} blocks with Rust use imports, add C ABI wrappers to liblzma-rs-sys - Remove all 167 #[no_mangle] attributes from 58 files in liblzma-rs - Replace 27 extern "C" {} import blocks with proper Rust use statements - Replace opaque struct definitions with re-exports from canonical modules - Remove duplicate lzma_lz_options struct definitions across 6 files - Add 46 new #[no_mangle] extern "C" wrapper functions to liblzma-rs-sys - Add 4 type re-exports (lzma_block, lzma_index_iter, lzma_index_iter_mode, lzma_index_hash) - Only 2 extern "C" {} blocks remain: types.rs (pthread/libc) and common.rs (malloc/calloc/free) --- liblzma-rs-sys/src/lib.rs | 493 ++++++++++++++++++ liblzma-rs/src/check/check.rs | 11 +- liblzma-rs/src/check/crc32_fast.rs | 1 - liblzma-rs/src/check/crc64_fast.rs | 1 - liblzma-rs/src/check/sha256.rs | 3 - liblzma-rs/src/common/alone_decoder.rs | 1 - liblzma-rs/src/common/auto_decoder.rs | 9 +- liblzma-rs/src/common/block_buffer_decoder.rs | 1 - liblzma-rs/src/common/block_buffer_encoder.rs | 4 - liblzma-rs/src/common/block_decoder.rs | 2 - liblzma-rs/src/common/block_encoder.rs | 2 - liblzma-rs/src/common/block_header_decoder.rs | 11 +- liblzma-rs/src/common/block_header_encoder.rs | 12 +- liblzma-rs/src/common/block_util.rs | 3 - liblzma-rs/src/common/common.rs | 8 - liblzma-rs/src/common/easy_buffer_encoder.rs | 13 +- liblzma-rs/src/common/easy_encoder.rs | 8 +- liblzma-rs/src/common/easy_preset.rs | 1 - liblzma-rs/src/common/file_info.rs | 23 +- liblzma-rs/src/common/filter_common.rs | 4 - liblzma-rs/src/common/filter_decoder.rs | 91 +--- liblzma-rs/src/common/filter_encoder.rs | 72 +-- liblzma-rs/src/common/filter_flags_decoder.rs | 10 +- liblzma-rs/src/common/filter_flags_encoder.rs | 7 +- liblzma-rs/src/common/index.rs | 21 - liblzma-rs/src/common/index_decoder.rs | 6 +- liblzma-rs/src/common/index_encoder.rs | 9 +- liblzma-rs/src/common/index_hash.rs | 5 - liblzma-rs/src/common/lzip_decoder.rs | 1 - liblzma-rs/src/common/microlzma_decoder.rs | 1 - liblzma-rs/src/common/microlzma_encoder.rs | 1 - liblzma-rs/src/common/outqueue.rs | 10 - .../src/common/stream_buffer_encoder.rs | 20 +- liblzma-rs/src/common/stream_decoder.rs | 1 - liblzma-rs/src/common/stream_decoder_mt.rs | 13 +- liblzma-rs/src/common/stream_encoder_mt.rs | 16 +- liblzma-rs/src/common/stream_flags_common.rs | 2 - liblzma-rs/src/common/stream_flags_decoder.rs | 5 +- liblzma-rs/src/common/stream_flags_encoder.rs | 5 +- liblzma-rs/src/common/string_conversion.rs | 7 +- liblzma-rs/src/delta/delta_common.rs | 2 - liblzma-rs/src/delta/delta_decoder.rs | 2 - liblzma-rs/src/delta/delta_encoder.rs | 2 - liblzma-rs/src/lz/lz_decoder.rs | 2 - liblzma-rs/src/lz/lz_encoder.rs | 15 +- liblzma-rs/src/lz/lz_encoder_mf.rs | 15 +- liblzma-rs/src/lzma/fastpos_table.rs | 1 - liblzma-rs/src/lzma/lzma2_decoder.rs | 34 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 54 +- liblzma-rs/src/lzma/lzma_decoder.rs | 31 +- liblzma-rs/src/lzma/lzma_encoder.rs | 54 +- .../src/lzma/lzma_encoder_optimum_fast.rs | 1 - .../src/lzma/lzma_encoder_optimum_normal.rs | 1 - liblzma-rs/src/rangecoder/price_table.rs | 1 - liblzma-rs/src/simple/arm.rs | 2 - liblzma-rs/src/simple/arm64.rs | 4 - liblzma-rs/src/simple/armthumb.rs | 2 - liblzma-rs/src/simple/ia64.rs | 2 - liblzma-rs/src/simple/powerpc.rs | 2 - liblzma-rs/src/simple/riscv.rs | 4 - liblzma-rs/src/simple/simple_coder.rs | 1 - liblzma-rs/src/simple/simple_decoder.rs | 1 - liblzma-rs/src/simple/simple_encoder.rs | 2 - liblzma-rs/src/simple/sparc.rs | 2 - liblzma-rs/src/simple/x86.rs | 4 - liblzma-rs/src/tuklib/tuklib_cpucores.rs | 1 - liblzma-rs/src/tuklib/tuklib_physmem.rs | 1 - liblzma-rs/src/types.rs | 244 ++------- 68 files changed, 582 insertions(+), 819 deletions(-) diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs index e0ee2ef8..417c2af2 100644 --- a/liblzma-rs-sys/src/lib.rs +++ b/liblzma-rs-sys/src/lib.rs @@ -50,6 +50,10 @@ pub use liblzma_rs::types::lzma_index; pub use liblzma_rs::types::lzma_options_lzma; pub use liblzma_rs::types::lzma_stream; pub use liblzma_rs::types::lzma_stream_flags; +pub use liblzma_rs::types::lzma_block; +pub use liblzma_rs::types::lzma_index_iter; +pub use liblzma_rs::types::lzma_index_iter_mode; +pub use liblzma_rs::common::index_hash::lzma_index_hash; #[repr(C)] pub struct lzma_options_bcj { @@ -630,6 +634,495 @@ pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lz liblzma_rs::common::index::lzma_index_end(i.cast(), allocator.cast()) } +// --- Block --- + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { + liblzma_rs::common::block_header_encoder::lzma_block_header_size(block.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_header_encode( + block: *const lzma_block, + out: *mut u8, +) -> lzma_ret { + liblzma_rs::common::block_header_encoder::lzma_block_header_encode(block.cast(), out) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_header_decode( + block: *mut lzma_block, + allocator: *const lzma_allocator, + input: *const u8, +) -> lzma_ret { + liblzma_rs::common::block_header_decoder::lzma_block_header_decode( + block.cast(), + allocator.cast(), + input, + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_compressed_size( + block: *mut lzma_block, + unpadded_size: lzma_vli, +) -> lzma_ret { + liblzma_rs::common::block_util::lzma_block_compressed_size(block.cast(), unpadded_size) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli { + liblzma_rs::common::block_util::lzma_block_unpadded_size(block.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_total_size(block: *const lzma_block) -> lzma_vli { + liblzma_rs::common::block_util::lzma_block_total_size(block.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_encoder( + strm: *mut lzma_stream, + block: *mut lzma_block, +) -> lzma_ret { + liblzma_rs::common::block_encoder::lzma_block_encoder(strm.cast(), block.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_decoder( + strm: *mut lzma_stream, + block: *mut lzma_block, +) -> lzma_ret { + liblzma_rs::common::block_decoder::lzma_block_decoder(strm.cast(), block.cast()) +} + +#[no_mangle] +pub extern "C" fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t { + liblzma_rs::common::block_buffer_encoder::lzma_block_buffer_bound(uncompressed_size) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_buffer_encode( + block: *mut lzma_block, + allocator: *const lzma_allocator, + input: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::block_buffer_encoder::lzma_block_buffer_encode( + block.cast(), + allocator.cast(), + input, + in_size, + out, + out_pos, + out_size, + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_uncomp_encode( + block: *mut lzma_block, + input: *const u8, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::block_buffer_encoder::lzma_block_uncomp_encode( + block.cast(), + input, + in_size, + out, + out_pos, + out_size, + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_block_buffer_decode( + block: *mut lzma_block, + allocator: *const lzma_allocator, + input: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::block_buffer_decoder::lzma_block_buffer_decode( + block.cast(), + allocator.cast(), + input, + in_pos, + in_size, + out, + out_pos, + out_size, + ) +} + +// --- Index (extended) --- + +#[no_mangle] +pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64 { + liblzma_rs::common::index::lzma_index_memusage(streams, blocks) +} + +#[no_mangle] +pub extern "C" fn lzma_index_memused(i: *const lzma_index) -> u64 { + liblzma_rs::common::index::lzma_index_memused(i.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_init( + allocator: *const lzma_allocator, +) -> *mut lzma_index { + liblzma_rs::common::index::lzma_index_init(allocator.cast()).cast() +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_append( + i: *mut lzma_index, + allocator: *const lzma_allocator, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, +) -> lzma_ret { + liblzma_rs::common::index::lzma_index_append( + i.cast(), + allocator.cast(), + unpadded_size, + uncompressed_size, + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_stream_flags( + i: *mut lzma_index, + stream_flags: *const lzma_stream_flags, +) -> lzma_ret { + liblzma_rs::common::index::lzma_index_stream_flags(i.cast(), stream_flags.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { + liblzma_rs::common::index::lzma_index_checks(i.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_stream_padding( + i: *mut lzma_index, + stream_padding: lzma_vli, +) -> lzma_ret { + liblzma_rs::common::index::lzma_index_stream_padding(i.cast(), stream_padding) +} + +#[no_mangle] +pub extern "C" fn lzma_index_stream_count(i: *const lzma_index) -> lzma_vli { + liblzma_rs::common::index::lzma_index_stream_count(i.cast()) +} + +#[no_mangle] +pub extern "C" fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli { + liblzma_rs::common::index::lzma_index_block_count(i.cast()) +} + +#[no_mangle] +pub extern "C" fn lzma_index_size(i: *const lzma_index) -> lzma_vli { + liblzma_rs::common::index::lzma_index_size(i.cast()) +} + +#[no_mangle] +pub extern "C" fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { + liblzma_rs::common::index::lzma_index_stream_size(i.cast()) +} + +#[no_mangle] +pub extern "C" fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { + liblzma_rs::common::index::lzma_index_total_size(i.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli { + liblzma_rs::common::index::lzma_index_file_size(i.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_iter_init( + iter: *mut lzma_index_iter, + i: *const lzma_index, +) { + liblzma_rs::common::index::lzma_index_iter_init(iter.cast(), i.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_iter_rewind(iter: *mut lzma_index_iter) { + liblzma_rs::common::index::lzma_index_iter_rewind(iter.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_iter_next( + iter: *mut lzma_index_iter, + mode: lzma_index_iter_mode, +) -> lzma_bool { + liblzma_rs::common::index::lzma_index_iter_next(iter.cast(), mode) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_iter_locate( + iter: *mut lzma_index_iter, + target: lzma_vli, +) -> lzma_bool { + liblzma_rs::common::index::lzma_index_iter_locate(iter.cast(), target) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_cat( + dest: *mut lzma_index, + src: *mut lzma_index, + allocator: *const lzma_allocator, +) -> lzma_ret { + liblzma_rs::common::index::lzma_index_cat(dest.cast(), src.cast(), allocator.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_dup( + i: *const lzma_index, + allocator: *const lzma_allocator, +) -> *mut lzma_index { + liblzma_rs::common::index::lzma_index_dup(i.cast(), allocator.cast()).cast() +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_encoder( + strm: *mut lzma_stream, + i: *const lzma_index, +) -> lzma_ret { + liblzma_rs::common::index_encoder::lzma_index_encoder(strm.cast(), i.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_decoder( + strm: *mut lzma_stream, + i: *mut *mut lzma_index, + memlimit: u64, +) -> lzma_ret { + liblzma_rs::common::index_decoder::lzma_index_decoder(strm.cast(), i.cast(), memlimit) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_buffer_encode( + i: *const lzma_index, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::index_encoder::lzma_index_buffer_encode( + i.cast(), + out, + out_pos, + out_size, + ) +} + +// --- Index hash --- + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_init( + index_hash: *mut lzma_index_hash, + allocator: *const lzma_allocator, +) -> *mut lzma_index_hash { + liblzma_rs::common::index_hash::lzma_index_hash_init(index_hash.cast(), allocator.cast()) + .cast() +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_end( + index_hash: *mut lzma_index_hash, + allocator: *const lzma_allocator, +) { + liblzma_rs::common::index_hash::lzma_index_hash_end(index_hash.cast(), allocator.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_append( + index_hash: *mut lzma_index_hash, + unpadded_size: lzma_vli, + uncompressed_size: lzma_vli, +) -> lzma_ret { + liblzma_rs::common::index_hash::lzma_index_hash_append( + index_hash.cast(), + unpadded_size, + uncompressed_size, + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_index_hash_decode( + index_hash: *mut lzma_index_hash, + input: *const u8, + in_pos: *mut size_t, + in_size: size_t, +) -> lzma_ret { + liblzma_rs::common::index_hash::lzma_index_hash_decode( + index_hash.cast(), + input, + in_pos, + in_size, + ) +} + +#[no_mangle] +pub extern "C" fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { + liblzma_rs::common::index_hash::lzma_index_hash_size(index_hash.cast()) +} + +// --- Filter flags/string --- + +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_flags_size( + size: *mut u32, + filter: *const lzma_filter, +) -> lzma_ret { + liblzma_rs::common::filter_flags_encoder::lzma_filter_flags_size(size, filter.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_flags_encode( + filter: *const lzma_filter, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + liblzma_rs::common::filter_flags_encoder::lzma_filter_flags_encode( + filter.cast(), + out, + out_pos, + out_size, + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_filter_flags_decode( + filter: *mut lzma_filter, + allocator: *const lzma_allocator, + input: *const u8, + in_pos: *mut size_t, + in_size: size_t, +) -> lzma_ret { + liblzma_rs::common::filter_flags_decoder::lzma_filter_flags_decode( + filter.cast(), + allocator.cast(), + input, + in_pos, + in_size, + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_filters_free( + filters: *mut lzma_filter, + allocator: *const lzma_allocator, +) { + liblzma_rs::common::filter_common::lzma_filters_free(filters.cast(), allocator.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_str_to_filters( + str_: *const c_char, + error_pos: *mut c_int, + filters: *mut lzma_filter, + flags: u32, + allocator: *const lzma_allocator, +) -> *const c_char { + liblzma_rs::common::string_conversion::lzma_str_to_filters( + str_, + error_pos, + filters.cast(), + flags, + allocator.cast(), + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_str_from_filters( + str_: *mut *mut c_char, + filters: *const lzma_filter, + flags: u32, + allocator: *const lzma_allocator, +) -> lzma_ret { + liblzma_rs::common::string_conversion::lzma_str_from_filters( + str_, + filters.cast(), + flags, + allocator.cast(), + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_str_list_filters( + str_: *mut *mut c_char, + filter_id: lzma_vli, + flags: u32, + allocator: *const lzma_allocator, +) -> lzma_ret { + liblzma_rs::common::string_conversion::lzma_str_list_filters( + str_, + filter_id, + flags, + allocator.cast(), + ) +} + +// --- Misc --- + +#[no_mangle] +pub extern "C" fn lzma_mode_is_supported(mode: lzma_mode) -> lzma_bool { + liblzma_rs::lzma::lzma_encoder::lzma_mode_is_supported(mode) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_microlzma_encoder( + strm: *mut lzma_stream, + options: *const lzma_options_lzma, +) -> lzma_ret { + liblzma_rs::common::microlzma_encoder::lzma_microlzma_encoder(strm.cast(), options.cast()) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_microlzma_decoder( + strm: *mut lzma_stream, + comp_size: u64, + uncomp_size: u64, + uncomp_size_is_exact: lzma_bool, + dict_size: u32, +) -> lzma_ret { + liblzma_rs::common::microlzma_decoder::lzma_microlzma_decoder( + strm.cast(), + comp_size, + uncomp_size, + uncomp_size_is_exact, + dict_size, + ) +} + +#[no_mangle] +pub unsafe extern "C" fn lzma_file_info_decoder( + strm: *mut lzma_stream, + i: *mut *mut lzma_index, + memlimit: u64, + file_size: u64, +) -> lzma_ret { + liblzma_rs::common::file_info::lzma_file_info_decoder( + strm.cast(), + i.cast(), + memlimit, + file_size, + ) +} + // ========================================================================= // Multithreaded API // ========================================================================= diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index 341ab9ad..b9b39678 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -1,10 +1,6 @@ use crate::types::*; -extern "C" { - fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64; - fn lzma_sha256_init(check: *mut lzma_check_state); - fn lzma_sha256_update(buf: *const u8, size: size_t, check: *mut lzma_check_state); - fn lzma_sha256_finish(check: *mut lzma_check_state); -} +use crate::check::crc64_fast::lzma_crc64; +use crate::check::sha256::{lzma_sha256_init, lzma_sha256_update, lzma_sha256_finish}; pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { if type_0 > LZMA_CHECK_ID_MAX { return false as lzma_bool; @@ -39,7 +35,6 @@ pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { ]; check_sizes[type_0 as usize] as u32 } -#[no_mangle] pub unsafe extern "C" fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check) { match type_0 { 1 => { @@ -54,7 +49,6 @@ pub unsafe extern "C" fn lzma_check_init(check: *mut lzma_check_state, type_0: l 0 | _ => {} }; } -#[no_mangle] pub unsafe extern "C" fn lzma_check_update( check: *mut lzma_check_state, type_0: lzma_check, @@ -74,7 +68,6 @@ pub unsafe extern "C" fn lzma_check_update( _ => {} }; } -#[no_mangle] pub unsafe extern "C" fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check) { match type_0 { 1 => { diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index 34234807..a3d23db2 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub static mut lzma_crc32_table: [[u32; 256]; 8] = [ [ 0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index b7c9c644..4823a475 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub static mut lzma_crc64_table: [[u64; 256]; 4] = [ [ 0, diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index 43699b5b..ce2704b7 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -531,7 +531,6 @@ unsafe extern "C" fn process(check: *mut lzma_check_state) { ::core::ptr::addr_of_mut!((*check).buffer.u32_0) as *const u32, ); } -#[no_mangle] pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { static mut s: [u32; 8] = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, @@ -544,7 +543,6 @@ pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { ); (*check).state.sha256.size = 0; } -#[no_mangle] pub unsafe extern "C" fn lzma_sha256_update( mut buf: *const u8, mut size: size_t, @@ -570,7 +568,6 @@ pub unsafe extern "C" fn lzma_sha256_update( } } } -#[no_mangle] pub unsafe extern "C" fn lzma_sha256_finish(check: *mut lzma_check_state) { let mut pos: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; (*check).buffer.u8_0[pos as usize] = 0x80 as u8; diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 7b3b9668..9cfb6499 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -173,7 +173,6 @@ unsafe extern "C" fn alone_decoder_memconfig( } LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_alone_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 90629a12..db8676fb 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -1,12 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_alone_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - memlimit: u64, - picky: bool, - ) -> lzma_ret; -} +use crate::common::alone_decoder::lzma_alone_decoder_init; pub type auto_decoder_seq = c_uint; pub const SEQ_FINISH: auto_decoder_seq = 2; pub const SEQ_CODE: auto_decoder_seq = 1; diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index 074587c9..c9d64911 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_decode( block: *mut lzma_block, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index ad2257c2..5097c9b9 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -16,7 +16,6 @@ extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { } uncompressed_size.wrapping_add(overhead) } -#[no_mangle] pub extern "C" fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { let mut lzma2_size: u64 = lzma2_bound(uncompressed_size); if lzma2_size == 0 { @@ -25,7 +24,6 @@ pub extern "C" fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { lzma2_size = lzma2_size.wrapping_add(3) & !(3); (HEADERS_BOUND as u64).wrapping_add(lzma2_size) } -#[no_mangle] pub extern "C" fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t { let ret: u64 = lzma_block_buffer_bound64(uncompressed_size as u64); ret as size_t @@ -270,7 +268,6 @@ unsafe extern "C" fn block_buffer_encode( } LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_block_buffer_encode( block: *mut lzma_block, allocator: *const lzma_allocator, @@ -284,7 +281,6 @@ pub unsafe extern "C" fn lzma_block_buffer_encode( block, allocator, in_0, in_size, out, out_pos, out_size, true, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_block_uncomp_encode( block: *mut lzma_block, in_0: *const u8, diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 9d725c38..049be186 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -174,7 +174,6 @@ unsafe extern "C" fn block_decoder_end(coder_ptr: *mut c_void, allocator: *const lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); crate::alloc::internal_free(coder as *mut c_void, allocator); } -#[no_mangle] pub unsafe extern "C" fn lzma_block_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -289,7 +288,6 @@ pub unsafe extern "C" fn lzma_block_decoder_init( (*block).filters, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_block_decoder( strm: *mut lzma_stream, block: *mut lzma_block, diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index b5429293..65ebf91e 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -132,7 +132,6 @@ unsafe extern "C" fn block_encoder_update( reversed_filters, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_block_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -245,7 +244,6 @@ pub unsafe extern "C" fn lzma_block_encoder_init( (*block).filters, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_block_encoder( strm: *mut lzma_stream, block: *mut lzma_block, diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index cf0929fe..75b95c0b 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -1,14 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_filter_flags_decode( - filter: *mut lzma_filter, - allocator: *const lzma_allocator, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; -} -#[no_mangle] +use crate::common::filter_flags_decoder::lzma_filter_flags_decode; pub unsafe extern "C" fn lzma_block_header_decode( block: *mut lzma_block, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 6a032d54..6155f26b 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,14 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_filter_flags_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret; - fn lzma_filter_flags_encode( - filter: *const lzma_filter, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; -} -#[no_mangle] +use crate::common::filter_flags_encoder::{lzma_filter_flags_size, lzma_filter_flags_encode}; pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { if (*block).version > 1 { return LZMA_OPTIONS_ERROR; @@ -50,7 +41,6 @@ pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ (*block).header_size = size.wrapping_add(3) & !(3); LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_block_header_encode( block: *const lzma_block, out: *mut u8, diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 7cfbe476..443de156 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -1,6 +1,5 @@ use crate::types::*; pub const LZMA_BLOCK_HEADER_SIZE_MIN: u32 = 8; -#[no_mangle] pub unsafe extern "C" fn lzma_block_compressed_size( block: *mut lzma_block, unpadded_size: lzma_vli, @@ -21,7 +20,6 @@ pub unsafe extern "C" fn lzma_block_compressed_size( (*block).compressed_size = compressed_size; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli { if block.is_null() || (*block).version > 1 @@ -47,7 +45,6 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> l } unpadded_size } -#[no_mangle] pub unsafe extern "C" fn lzma_block_total_size(block: *const lzma_block) -> lzma_vli { let mut unpadded_size: lzma_vli = lzma_block_unpadded_size(block); if unpadded_size != LZMA_VLI_UNKNOWN { diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index a79dd275..e3247266 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -79,7 +79,6 @@ pub extern "C" fn lzma_version_number() -> u32 { pub extern "C" fn lzma_version_string() -> *const c_char { crate::c_str!("5.8.2") } -#[no_mangle] pub unsafe extern "C" fn lzma_alloc( mut size: size_t, allocator: *const lzma_allocator, @@ -95,7 +94,6 @@ pub unsafe extern "C" fn lzma_alloc( } ptr } -#[no_mangle] pub unsafe extern "C" fn lzma_alloc_zero( mut size: size_t, allocator: *const lzma_allocator, @@ -114,7 +112,6 @@ pub unsafe extern "C" fn lzma_alloc_zero( } ptr } -#[no_mangle] pub unsafe extern "C" fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator) { if !allocator.is_null() && (*allocator).free.is_some() { (*allocator).free.unwrap()((*allocator).opaque, ptr); @@ -122,7 +119,6 @@ pub unsafe extern "C" fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allo free(ptr); }; } -#[no_mangle] pub unsafe extern "C" fn lzma_bufcpy( in_0: *const u8, in_pos: *mut size_t, @@ -149,7 +145,6 @@ pub unsafe extern "C" fn lzma_bufcpy( *out_pos = (*out_pos).wrapping_add(copy_size); copy_size } -#[no_mangle] pub unsafe extern "C" fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -166,7 +161,6 @@ pub unsafe extern "C" fn lzma_next_filter_init( (*filters).init.unwrap()(next, allocator, filters) } } -#[no_mangle] pub unsafe extern "C" fn lzma_next_filter_update( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -185,7 +179,6 @@ pub unsafe extern "C" fn lzma_next_filter_update( reversed_filters, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_next_end( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -210,7 +203,6 @@ pub unsafe extern "C" fn lzma_next_end( }; } } -#[no_mangle] pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { if strm.is_null() { return LZMA_PROG_ERROR; diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 457c734d..5414190b 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -1,16 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_stream_buffer_encode( - filters: *mut lzma_filter, - check: lzma_check, - allocator: *const lzma_allocator, - in_0: *const u8, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; -} +use crate::common::stream_buffer_encoder::lzma_stream_buffer_encode; pub unsafe extern "C" fn lzma_easy_buffer_encode( preset: u32, check: lzma_check, diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index 4c2a0a17..8bf5997a 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -1,11 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_stream_encoder( - strm: *mut lzma_stream, - filters: *const lzma_filter, - check: lzma_check, - ) -> lzma_ret; -} +use crate::common::stream_encoder::lzma_stream_encoder; pub unsafe extern "C" fn lzma_easy_encoder( strm: *mut lzma_stream, preset: u32, diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index 8bb9c2fe..5b0283d6 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_easy_preset(opt_easy: *mut lzma_options_easy, preset: u32) -> bool { if lzma_lzma_preset(::core::ptr::addr_of_mut!((*opt_easy).opt_lzma), preset) != 0 { return true; diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index fdb125d7..b6721e84 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -1,24 +1,6 @@ use crate::types::*; -extern "C" { - fn lzma_index_memused(i: *const lzma_index) -> u64; - fn lzma_index_stream_flags( - i: *mut lzma_index, - stream_flags: *const lzma_stream_flags, - ) -> lzma_ret; - fn lzma_index_stream_padding(i: *mut lzma_index, stream_padding: lzma_vli) -> lzma_ret; - fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli; - fn lzma_index_cat( - dest: *mut lzma_index, - src: *mut lzma_index, - allocator: *const lzma_allocator, - ) -> lzma_ret; - fn lzma_index_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - i: *mut *mut lzma_index, - memlimit: u64, - ) -> lzma_ret; -} +use crate::common::index::{lzma_index_memused, lzma_index_stream_flags, lzma_index_stream_padding, lzma_index_total_size, lzma_index_cat}; +use crate::common::index_decoder::lzma_index_decoder_init; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_file_info_coder { @@ -676,7 +658,6 @@ unsafe extern "C" fn lzma_file_info_decoder_init( (*coder).temp_size = LZMA_STREAM_HEADER_SIZE as size_t; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_file_info_decoder( strm: *mut lzma_stream, dest_index: *mut *mut lzma_index, diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 771ea8ff..a72e33ce 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -179,7 +179,6 @@ pub unsafe extern "C" fn lzma_filters_copy( } }; } -#[no_mangle] pub unsafe extern "C" fn lzma_filters_free( filters: *mut lzma_filter, allocator: *const lzma_allocator, @@ -198,7 +197,6 @@ pub unsafe extern "C" fn lzma_filters_free( i += 1; } } -#[no_mangle] pub unsafe extern "C" fn lzma_validate_chain( filters: *const lzma_filter, count: *mut size_t, @@ -237,7 +235,6 @@ pub unsafe extern "C" fn lzma_validate_chain( *count = i; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_raw_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -295,7 +292,6 @@ pub unsafe extern "C" fn lzma_raw_coder_init( } ret } -#[no_mangle] pub unsafe extern "C" fn lzma_raw_coder_memusage( coder_find: lzma_filter_find, filters: *const lzma_filter, diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 982ccfc8..a26589cf 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -1,82 +1,16 @@ use crate::types::*; -extern "C" { - fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64; - fn lzma_lzma_props_decode( - options: *mut *mut c_void, - allocator: *const lzma_allocator, - props: *const u8, - props_size: size_t, - ) -> lzma_ret; - fn lzma_lzma2_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_lzma2_decoder_memusage(options: *const c_void) -> u64; - fn lzma_lzma2_props_decode( - options: *mut *mut c_void, - allocator: *const lzma_allocator, - props: *const u8, - props_size: size_t, - ) -> lzma_ret; - fn lzma_simple_x86_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_powerpc_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_ia64_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_arm_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_armthumb_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_arm64_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_sparc_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_riscv_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_props_decode( - options: *mut *mut c_void, - allocator: *const lzma_allocator, - props: *const u8, - props_size: size_t, - ) -> lzma_ret; - fn lzma_delta_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_delta_props_decode( - options: *mut *mut c_void, - allocator: *const lzma_allocator, - props: *const u8, - props_size: size_t, - ) -> lzma_ret; -} +use crate::lzma::lzma_decoder::{lzma_lzma_decoder_memusage, lzma_lzma_props_decode}; +use crate::lzma::lzma2_decoder::{lzma_lzma2_decoder_init, lzma_lzma2_decoder_memusage, lzma_lzma2_props_decode}; +use crate::simple::x86::lzma_simple_x86_decoder_init; +use crate::simple::powerpc::lzma_simple_powerpc_decoder_init; +use crate::simple::ia64::lzma_simple_ia64_decoder_init; +use crate::simple::arm::lzma_simple_arm_decoder_init; +use crate::simple::armthumb::lzma_simple_armthumb_decoder_init; +use crate::simple::arm64::lzma_simple_arm64_decoder_init; +use crate::simple::sparc::lzma_simple_sparc_decoder_init; +use crate::simple::riscv::lzma_simple_riscv_decoder_init; +use crate::simple::simple_decoder::lzma_simple_props_decode; +use crate::delta::delta_decoder::{lzma_delta_decoder_init, lzma_delta_props_decode}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_decoder { @@ -365,7 +299,6 @@ extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { pub extern "C" fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { !decoder_find(id).is_null() as lzma_bool } -#[no_mangle] pub unsafe extern "C" fn lzma_raw_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index d3495838..b8792a44 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -1,63 +1,16 @@ use crate::types::*; -extern "C" { - fn lzma_lzma_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; - fn lzma_lzma2_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64; - fn lzma_lzma2_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; - fn lzma_lzma2_block_size(options: *const c_void) -> u64; - fn lzma_simple_x86_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_powerpc_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_ia64_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_arm_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_armthumb_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_arm64_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_sparc_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_riscv_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_simple_props_size(size: *mut u32, options: *const c_void) -> lzma_ret; - fn lzma_simple_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; - fn lzma_delta_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - fn lzma_delta_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret; -} +use crate::lzma::lzma_encoder::lzma_lzma_props_encode; +use crate::lzma::lzma2_encoder::{lzma_lzma2_encoder_init, lzma_lzma2_encoder_memusage, lzma_lzma2_props_encode, lzma_lzma2_block_size}; +use crate::simple::x86::lzma_simple_x86_encoder_init; +use crate::simple::powerpc::lzma_simple_powerpc_encoder_init; +use crate::simple::ia64::lzma_simple_ia64_encoder_init; +use crate::simple::arm::lzma_simple_arm_encoder_init; +use crate::simple::armthumb::lzma_simple_armthumb_encoder_init; +use crate::simple::arm64::lzma_simple_arm64_encoder_init; +use crate::simple::sparc::lzma_simple_sparc_encoder_init; +use crate::simple::riscv::lzma_simple_riscv_encoder_init; +use crate::simple::simple_encoder::{lzma_simple_props_size, lzma_simple_props_encode}; +use crate::delta::delta_encoder::{lzma_delta_encoder_init, lzma_delta_props_encode}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_encoder { @@ -354,7 +307,6 @@ pub unsafe extern "C" fn lzma_filters_update( ::core::ptr::addr_of_mut!(reversed_filters) as *mut lzma_filter, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_raw_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 5df0d1ac..5e7a38c3 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -1,13 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_properties_decode( - filter: *mut lzma_filter, - allocator: *const lzma_allocator, - props: *const u8, - props_size: size_t, - ) -> lzma_ret; -} -#[no_mangle] +use crate::common::filter_decoder::lzma_properties_decode; pub unsafe extern "C" fn lzma_filter_flags_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index 7c33235e..c1e63a6c 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -1,9 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret; - fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret; -} -#[no_mangle] +use crate::common::filter_encoder::{lzma_properties_size, lzma_properties_encode}; pub unsafe extern "C" fn lzma_filter_flags_size( size: *mut u32, filter: *const lzma_filter, @@ -19,7 +15,6 @@ pub unsafe extern "C" fn lzma_filter_flags_size( .wrapping_add(lzma_vli_size((*filter).id).wrapping_add(lzma_vli_size(*size as lzma_vli))); LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_filter_flags_encode( filter: *const lzma_filter, out: *mut u8, diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index f3bf95ad..76276b4d 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -228,7 +228,6 @@ unsafe extern "C" fn index_init_plain(allocator: *const lzma_allocator) -> *mut } i } -#[no_mangle] pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index { let i: *mut lzma_index = index_init_plain(allocator); if i.is_null() { @@ -257,14 +256,12 @@ pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lz lzma_free(i as *mut c_void, allocator); } } -#[no_mangle] pub unsafe extern "C" fn lzma_index_prealloc(i: *mut lzma_index, mut records: lzma_vli) { if records > PREALLOC_MAX as lzma_vli { records = PREALLOC_MAX as lzma_vli; } (*i).prealloc = records as size_t; } -#[no_mangle] pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64 { let alloc_overhead: size_t = (4_usize).wrapping_mul(core::mem::size_of::<*mut c_void>()); let stream_base: size_t = (core::mem::size_of::()) @@ -297,27 +294,21 @@ pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u6 .wrapping_add(streams_mem) .wrapping_add(groups_mem) } -#[no_mangle] pub extern "C" fn lzma_index_memused(i: *const lzma_index) -> u64 { unsafe { lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count) } } -#[no_mangle] pub extern "C" fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli { unsafe { (*i).record_count } } -#[no_mangle] pub extern "C" fn lzma_index_stream_count(i: *const lzma_index) -> lzma_vli { unsafe { (*i).streams.count as lzma_vli } } -#[no_mangle] pub extern "C" fn lzma_index_size(i: *const lzma_index) -> lzma_vli { unsafe { index_size((*i).record_count, (*i).index_list_size) } } -#[no_mangle] pub extern "C" fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { unsafe { (*i).total_size } } -#[no_mangle] pub extern "C" fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { unsafe { (LZMA_STREAM_HEADER_SIZE as lzma_vli) @@ -346,7 +337,6 @@ unsafe extern "C" fn index_file_size( } file_size } -#[no_mangle] pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli { let s: *const index_stream = (*i).streams.rightmost as *const index_stream; let g: *const index_group = (*s).groups.rightmost as *const index_group; @@ -367,7 +357,6 @@ pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli pub unsafe extern "C" fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { (*i).uncompressed_size } -#[no_mangle] pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { let mut checks: u32 = (*i).checks; let s: *const index_stream = (*i).streams.rightmost as *const index_stream; @@ -376,11 +365,9 @@ pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { } checks } -#[no_mangle] pub unsafe extern "C" fn lzma_index_padding_size(i: *const lzma_index) -> u32 { ((4_u64).wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) & 3) as u32 } -#[no_mangle] pub unsafe extern "C" fn lzma_index_stream_flags( i: *mut lzma_index, stream_flags: *const lzma_stream_flags, @@ -396,7 +383,6 @@ pub unsafe extern "C" fn lzma_index_stream_flags( (*s).stream_flags = *stream_flags; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_index_stream_padding( i: *mut lzma_index, stream_padding: lzma_vli, @@ -414,7 +400,6 @@ pub unsafe extern "C" fn lzma_index_stream_padding( (*s).stream_padding = stream_padding; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_index_append( i: *mut lzma_index, allocator: *const lzma_allocator, @@ -532,7 +517,6 @@ unsafe extern "C" fn index_cat_helper(info: *const index_cat_info, this: *mut in index_cat_helper(info, right); } } -#[no_mangle] pub unsafe extern "C" fn lzma_index_cat( dest: *mut lzma_index, src: *mut lzma_index, @@ -679,7 +663,6 @@ unsafe extern "C" fn index_dup_stream( ); dest } -#[no_mangle] pub unsafe extern "C" fn lzma_index_dup( src: *const lzma_index, allocator: *const lzma_allocator, @@ -812,19 +795,16 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { .wrapping_add((*iter).stream.uncompressed_offset); } } -#[no_mangle] pub unsafe extern "C" fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index) { (*iter).internal[ITER_INDEX as usize].p = i as *const c_void; lzma_index_iter_rewind(iter); } -#[no_mangle] pub unsafe extern "C" fn lzma_index_iter_rewind(iter: *mut lzma_index_iter) { (*iter).internal[ITER_STREAM as usize].p = core::ptr::null(); (*iter).internal[ITER_GROUP as usize].p = core::ptr::null(); (*iter).internal[ITER_RECORD as usize].s = 0; (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NORMAL as size_t; } -#[no_mangle] pub unsafe extern "C" fn lzma_index_iter_next( iter: *mut lzma_index_iter, mode: lzma_index_iter_mode, @@ -914,7 +894,6 @@ pub unsafe extern "C" fn lzma_index_iter_next( iter_set_info(iter); false as lzma_bool } -#[no_mangle] pub unsafe extern "C" fn lzma_index_iter_locate( iter: *mut lzma_index_iter, mut target: lzma_vli, diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 7c857c55..7bd2b69d 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -1,7 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_index_prealloc(i: *mut lzma_index, records: lzma_vli); -} +use crate::common::index::lzma_index_prealloc; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_coder { @@ -226,7 +224,6 @@ unsafe extern "C" fn index_decoder_reset( (*coder).crc32 = 0; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_index_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -311,7 +308,6 @@ pub unsafe extern "C" fn lzma_index_decoder_init( } index_decoder_reset(coder, allocator, i, memlimit) } -#[no_mangle] pub unsafe extern "C" fn lzma_index_decoder( strm: *mut lzma_stream, i: *mut *mut lzma_index, diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index a8800078..abea70ef 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -1,9 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli; - fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index); - fn lzma_index_iter_next(iter: *mut lzma_index_iter, mode: lzma_index_iter_mode) -> lzma_bool; -} +use crate::common::index::{lzma_index_block_count, lzma_index_iter_init, lzma_index_iter_next}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_coder { @@ -153,7 +149,6 @@ unsafe extern "C" fn index_encoder_reset(coder: *mut lzma_index_coder, i: *const (*coder).pos = 0; (*coder).crc32 = 0; } -#[no_mangle] pub unsafe extern "C" fn lzma_index_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -226,7 +221,6 @@ pub unsafe extern "C" fn lzma_index_encoder_init( index_encoder_reset((*next).coder as *mut lzma_index_coder, i); LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_index_encoder( strm: *mut lzma_stream, i: *const lzma_index, @@ -248,7 +242,6 @@ pub unsafe extern "C" fn lzma_index_encoder( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_index_buffer_encode( i: *const lzma_index, out: *mut u8, diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 49477dc4..815e723a 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -40,7 +40,6 @@ extern "C" fn index_stream_size( .wrapping_add(index_size(count, index_list_size)) .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) } -#[no_mangle] pub unsafe extern "C" fn lzma_index_hash_init( mut index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator, @@ -75,14 +74,12 @@ pub unsafe extern "C" fn lzma_index_hash_init( ); index_hash } -#[no_mangle] pub unsafe extern "C" fn lzma_index_hash_end( index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator, ) { lzma_free(index_hash as *mut c_void, allocator); } -#[no_mangle] pub extern "C" fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { unsafe { index_size( @@ -110,7 +107,6 @@ unsafe extern "C" fn hash_append( core::mem::size_of::<[lzma_vli; 2]>(), ); } -#[no_mangle] pub unsafe extern "C" fn lzma_index_hash_append( index_hash: *mut lzma_index_hash, unpadded_size: lzma_vli, @@ -145,7 +141,6 @@ pub unsafe extern "C" fn lzma_index_hash_append( } LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_index_hash_decode( index_hash: *mut lzma_index_hash, in_0: *const u8, diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 9fef3c69..5d839e14 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -294,7 +294,6 @@ unsafe extern "C" fn lzip_decoder_memconfig( } LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_lzip_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index f9886e77..b1ef102f 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -259,7 +259,6 @@ unsafe extern "C" fn microlzma_decoder_init( (*coder).props_decoded = false; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_microlzma_decoder( strm: *mut lzma_stream, comp_size: u64, diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index 0977a2a8..3a1edba1 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -164,7 +164,6 @@ unsafe extern "C" fn microlzma_encoder_init( ::core::ptr::addr_of!(filters) as *const lzma_filter_info, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_microlzma_encoder( strm: *mut lzma_stream, options: *const lzma_options_lzma, diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index 4c74b440..a4f00ab3 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { let limit: u64 = (UINT64_MAX) .wrapping_div((2 * 16384) as u64) @@ -38,7 +37,6 @@ unsafe extern "C" fn free_one_cached_buffer( .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); crate::alloc::internal_free(buf as *mut c_void, allocator); } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_clear_cache( outq: *mut lzma_outq, allocator: *const lzma_allocator, @@ -47,7 +45,6 @@ pub unsafe extern "C" fn lzma_outq_clear_cache( free_one_cached_buffer(outq, allocator); } } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_clear_cache2( outq: *mut lzma_outq, allocator: *const lzma_allocator, @@ -63,7 +60,6 @@ pub unsafe extern "C" fn lzma_outq_clear_cache2( free_one_cached_buffer(outq, allocator); } } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_init( outq: *mut lzma_outq, allocator: *const lzma_allocator, @@ -83,14 +79,12 @@ pub unsafe extern "C" fn lzma_outq_init( (*outq).read_pos = 0; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator) { while !(*outq).head.is_null() { move_head_to_cache(outq, allocator); } lzma_outq_clear_cache(outq, allocator); } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_prealloc_buf( outq: *mut lzma_outq, allocator: *const lzma_allocator, @@ -114,7 +108,6 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( (*outq).mem_allocated = (*outq).mem_allocated.wrapping_add(alloc_size as u64); LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_get_buf( outq: *mut lzma_outq, worker: *mut c_void, @@ -141,14 +134,12 @@ pub unsafe extern "C" fn lzma_outq_get_buf( .wrapping_add(lzma_outq_outbuf_memusage((*buf).allocated)); buf } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool { if (*outq).head.is_null() { return false; } (*outq).read_pos < (*(*outq).head).pos || (*(*outq).head).finished } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_read( outq: *mut lzma_outq, allocator: *const lzma_allocator, @@ -184,7 +175,6 @@ pub unsafe extern "C" fn lzma_outq_read( (*outq).read_pos = 0; finish_ret } -#[no_mangle] pub unsafe extern "C" fn lzma_outq_enable_partial_output( outq: *mut lzma_outq, enable_partial_output: Option ()>, diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 91676bd4..06862c5d 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -1,22 +1,6 @@ use crate::types::*; -extern "C" { - fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t; - fn lzma_block_buffer_encode( - block: *mut lzma_block, - allocator: *const lzma_allocator, - in_0: *const u8, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; - fn lzma_index_buffer_encode( - i: *const lzma_index, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; -} +use crate::common::block_buffer_encoder::{lzma_block_buffer_bound, lzma_block_buffer_encode}; +use crate::common::index_encoder::lzma_index_buffer_encode; pub const INDEX_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3 & !(3); pub const HEADERS_BOUND: u32 = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 17f80343..995e4575 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -358,7 +358,6 @@ unsafe extern "C" fn stream_decoder_memconfig( } LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_stream_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 834aab36..1be3e0a9 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -1,16 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_outq_clear_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator); - fn lzma_outq_clear_cache2( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - keep_size: size_t, - ); - fn lzma_outq_enable_partial_output( - outq: *mut lzma_outq, - enable_partial_output: Option ()>, - ); -} +use crate::common::outqueue::{lzma_outq_clear_cache, lzma_outq_clear_cache2, lzma_outq_enable_partial_output}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 85a11f8f..a7ac6f61 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -1,17 +1,7 @@ use crate::types::*; -extern "C" { - fn lzma_mt_block_size(filters: *const lzma_filter) -> u64; - fn lzma_block_uncomp_encode( - block: *mut lzma_block, - in_0: *const u8, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; - fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64; - fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64; -} +use crate::common::filter_encoder::lzma_mt_block_size; +use crate::common::block_buffer_encoder::{lzma_block_uncomp_encode, lzma_block_buffer_bound64}; +use crate::common::outqueue::lzma_outq_memusage; pub type worker_thread = worker_thread_s; #[derive(Copy, Clone)] #[repr(C)] diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index 280cdd1f..20cf7af6 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -1,9 +1,7 @@ use crate::types::*; -#[no_mangle] pub static mut lzma_header_magic: [u8; 6] = [ 0xfd as u8, 0x37 as u8, 0x7a as u8, 0x58 as u8, 0x5a as u8, 0, ]; -#[no_mangle] pub static mut lzma_footer_magic: [u8; 2] = [0x59 as u8, 0x5a as u8]; pub unsafe extern "C" fn lzma_stream_flags_compare( a: *const lzma_stream_flags, diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 957191ed..b875f4b7 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -1,8 +1,5 @@ use crate::types::*; -extern "C" { - static lzma_header_magic: [u8; 6]; - static lzma_footer_magic: [u8; 2]; -} +use crate::common::stream_flags_common::{lzma_header_magic, lzma_footer_magic}; extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> bool { return unsafe { if *in_0 != 0 || *in_0.offset(1) & 0xf0 != 0 { diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 58bb0727..6105b3aa 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -1,8 +1,5 @@ use crate::types::*; -extern "C" { - static lzma_header_magic: [u8; 6]; - static lzma_footer_magic: [u8; 2]; -} +use crate::common::stream_flags_common::{lzma_header_magic, lzma_footer_magic}; extern "C" fn stream_flags_encode(options: *const lzma_stream_flags, out: *mut u8) -> bool { return unsafe { if (*options).check > LZMA_CHECK_ID_MAX { diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 07a533bb..94c977ca 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -1,7 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_validate_chain(filters: *const lzma_filter, count: *mut size_t) -> lzma_ret; -} +use crate::common::filter_common::lzma_validate_chain; #[derive(Copy, Clone)] #[repr(C)] pub struct filter_codec_def { @@ -917,7 +915,6 @@ unsafe extern "C" fn str_to_filters( } errmsg } -#[no_mangle] pub unsafe extern "C" fn lzma_str_to_filters( str: *const c_char, error_pos: *mut c_int, @@ -1012,7 +1009,6 @@ unsafe extern "C" fn strfy_filter( i += 1; } } -#[no_mangle] pub unsafe extern "C" fn lzma_str_from_filters( output_str: *mut *mut c_char, filters: *const lzma_filter, @@ -1113,7 +1109,6 @@ pub unsafe extern "C" fn lzma_str_from_filters( } str_finish(output_str, ::core::ptr::addr_of_mut!(dest), allocator) } -#[no_mangle] pub unsafe extern "C" fn lzma_str_list_filters( output_str: *mut *mut c_char, filter_id: lzma_vli, diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index 0975f7b8..24a5f519 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -4,7 +4,6 @@ unsafe extern "C" fn delta_coder_end(coder_ptr: *mut c_void, allocator: *const l lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); crate::alloc::internal_free(coder as *mut c_void, allocator); } -#[no_mangle] pub unsafe extern "C" fn lzma_delta_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -49,7 +48,6 @@ pub unsafe extern "C" fn lzma_delta_coder_init( filters.offset(1), ) } -#[no_mangle] pub unsafe extern "C" fn lzma_delta_coder_memusage(options: *const c_void) -> u64 { let opt: *const lzma_options_delta = options as *const lzma_options_delta; if opt.is_null() diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 58c5aba1..ca50f877 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -41,7 +41,6 @@ unsafe extern "C" fn delta_decode( } ret } -#[no_mangle] pub unsafe extern "C" fn lzma_delta_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -63,7 +62,6 @@ pub unsafe extern "C" fn lzma_delta_decoder_init( ); lzma_delta_coder_init(next, allocator, filters) } -#[no_mangle] pub unsafe extern "C" fn lzma_delta_props_decode( options: *mut *mut c_void, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index 66ea3753..fb3bbdb4 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -97,7 +97,6 @@ unsafe extern "C" fn delta_encoder_update( reversed_filters.offset(1), ) } -#[no_mangle] pub unsafe extern "C" fn lzma_delta_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -128,7 +127,6 @@ pub unsafe extern "C" fn lzma_delta_encoder_init( ); lzma_delta_coder_init(next, allocator, filters) } -#[no_mangle] pub unsafe extern "C" fn lzma_delta_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { if lzma_delta_coder_memusage(options) == UINT64_MAX { return LZMA_PROG_ERROR; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 9ba4cea9..d53b659a 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -172,7 +172,6 @@ unsafe extern "C" fn lz_decoder_end(coder_ptr: *mut c_void, allocator: *const lz } crate::alloc::internal_free(coder as *mut c_void, allocator); } -#[no_mangle] pub unsafe extern "C" fn lzma_lz_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -293,7 +292,6 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( filters.offset(1), ) } -#[no_mangle] pub extern "C" fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64 { (core::mem::size_of::() as u64) .wrapping_add(dictionary_size as u64) diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 91ff1f28..9c8c20a3 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -1,16 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_mf_hc3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; - fn lzma_mf_hc3_skip(dict: *mut lzma_mf, amount: u32); - fn lzma_mf_hc4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; - fn lzma_mf_hc4_skip(dict: *mut lzma_mf, amount: u32); - fn lzma_mf_bt2_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; - fn lzma_mf_bt2_skip(dict: *mut lzma_mf, amount: u32); - fn lzma_mf_bt3_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; - fn lzma_mf_bt3_skip(dict: *mut lzma_mf, amount: u32); - fn lzma_mf_bt4_find(dict: *mut lzma_mf, matches: *mut lzma_match) -> u32; - fn lzma_mf_bt4_skip(dict: *mut lzma_mf, amount: u32); -} +use crate::lz::lz_encoder_mf::{lzma_mf_hc3_find, lzma_mf_hc3_skip, lzma_mf_hc4_find, lzma_mf_hc4_skip, lzma_mf_bt2_find, lzma_mf_bt2_skip, lzma_mf_bt3_find, lzma_mf_bt3_skip, lzma_mf_bt4_find, lzma_mf_bt4_skip}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -333,7 +322,6 @@ unsafe extern "C" fn lz_encoder_init( (*mf).action = LZMA_RUN; false } -#[no_mangle] pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> u64 { let mut mf: lzma_mf = lzma_mf_s { buffer: core::ptr::null_mut(), @@ -413,7 +401,6 @@ unsafe extern "C" fn lz_encoder_set_out_limit( } LZMA_OPTIONS_ERROR } -#[no_mangle] pub unsafe extern "C" fn lzma_lz_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 766d8011..21a2882c 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -1,12 +1,9 @@ use crate::types::*; -extern "C" { - static lzma_crc32_table: [[u32; 256]; 8]; -} +use crate::check::crc32_fast::lzma_crc32_table; pub const HASH_2_MASK: c_uint = HASH_2_SIZE.wrapping_sub(1); pub const HASH_3_MASK: c_uint = HASH_3_SIZE.wrapping_sub(1); pub const FIX_3_HASH_SIZE: c_uint = 1u32 << 10; pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); -#[no_mangle] pub unsafe extern "C" fn lzma_mf_find( mf: *mut lzma_mf, count_ptr: *mut u32, @@ -113,7 +110,6 @@ unsafe extern "C" fn hc_find_func( } } } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -164,7 +160,6 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { loop { if mf_avail(mf) < 3 { @@ -191,7 +186,6 @@ pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { } } } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -266,7 +260,6 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { loop { if mf_avail(mf) < 4 { @@ -412,7 +405,6 @@ unsafe extern "C" fn bt_skip_func( } } } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -443,7 +435,6 @@ pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_8: u64; loop { @@ -484,7 +475,6 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { } } } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -544,7 +534,6 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_9: u64; loop { @@ -592,7 +581,6 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { } } } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -676,7 +664,6 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } -#[no_mangle] pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_10: u64; loop { diff --git a/liblzma-rs/src/lzma/fastpos_table.rs b/liblzma-rs/src/lzma/fastpos_table.rs index 943e00e5..db50e825 100644 --- a/liblzma-rs/src/lzma/fastpos_table.rs +++ b/liblzma-rs/src/lzma/fastpos_table.rs @@ -1,4 +1,3 @@ -#[no_mangle] pub static mut lzma_fastpos: [u8; 8192] = [ 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index fe897df3..b7251b2f 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -1,33 +1,6 @@ use crate::types::*; -extern "C" { - fn lzma_lz_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - lz_init: Option< - unsafe extern "C" fn( - *mut lzma_lz_decoder, - *const lzma_allocator, - lzma_vli, - *const c_void, - *mut lzma_lz_options, - ) -> lzma_ret, - >, - ) -> lzma_ret; - fn lzma_lzma_decoder_create( - lz: *mut lzma_lz_decoder, - allocator: *const lzma_allocator, - opt: *const lzma_options_lzma, - lz_options: *mut lzma_lz_options, - ) -> lzma_ret; -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_lz_options { - pub dict_size: size_t, - pub preset_dict: *const u8, - pub preset_dict_size: size_t, -} +use crate::lz::lz_decoder::{lzma_lz_decoder_init, lzma_lz_options}; +use crate::lzma::lzma_decoder::lzma_lzma_decoder_create; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma2_coder { @@ -259,7 +232,6 @@ unsafe extern "C" fn lzma2_decoder_init( lz_options, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma2_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -281,12 +253,10 @@ pub unsafe extern "C" fn lzma_lzma2_decoder_init( ), ) } -#[no_mangle] pub extern "C" fn lzma_lzma2_decoder_memusage(options: *const c_void) -> u64 { (core::mem::size_of::() as u64) .wrapping_add(unsafe { lzma_lzma_decoder_memusage_nocheck(options) }) } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma2_props_decode( options: *mut *mut c_void, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 32a5d562..e43f44eb 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -1,52 +1,6 @@ use crate::types::*; -extern "C" { - fn lzma_lz_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - lz_init: Option< - unsafe extern "C" fn( - *mut lzma_lz_encoder, - *const lzma_allocator, - lzma_vli, - *const c_void, - *mut lzma_lz_options, - ) -> lzma_ret, - >, - ) -> lzma_ret; - fn lzma_lzma_encoder_create( - coder_ptr: *mut *mut c_void, - allocator: *const lzma_allocator, - id: lzma_vli, - options: *const lzma_options_lzma, - lz_options: *mut lzma_lz_options, - ) -> lzma_ret; - fn lzma_lzma_encoder_reset( - coder: *mut lzma_lzma1_encoder, - options: *const lzma_options_lzma, - ) -> lzma_ret; - fn lzma_lzma_encode( - coder: *mut lzma_lzma1_encoder, - mf: *mut lzma_mf, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - read_limit: u32, - ) -> lzma_ret; -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_lz_options { - pub before_size: size_t, - pub dict_size: size_t, - pub after_size: size_t, - pub match_len_max: size_t, - pub nice_len: size_t, - pub match_finder: lzma_match_finder, - pub depth: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, -} +use crate::lz::lz_encoder::{lzma_lz_encoder_init, lzma_lz_options}; +use crate::lzma::lzma_encoder::{lzma_lzma_encoder_create, lzma_lzma_encoder_reset, lzma_lzma_encode}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma2_coder { @@ -397,7 +351,6 @@ unsafe extern "C" fn lzma2_encoder_init( } LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma2_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -419,7 +372,6 @@ pub unsafe extern "C" fn lzma_lzma2_encoder_init( ), ) } -#[no_mangle] pub extern "C" fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64 { let lzma_mem: u64 = unsafe { lzma_lzma_encoder_memusage(options) } as u64; if lzma_mem == UINT64_MAX { @@ -427,7 +379,6 @@ pub extern "C" fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64 { } (core::mem::size_of::() as u64).wrapping_add(lzma_mem) } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; @@ -451,7 +402,6 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *m } LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma2_block_size(options: *const c_void) -> u64 { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; if (*opt).dict_size < LZMA_DICT_SIZE_MIN as u32 diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 350b344a..17a01bea 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -1,28 +1,5 @@ use crate::types::*; -extern "C" { - fn lzma_lz_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - lz_init: Option< - unsafe extern "C" fn( - *mut lzma_lz_decoder, - *const lzma_allocator, - lzma_vli, - *const c_void, - *mut lzma_lz_options, - ) -> lzma_ret, - >, - ) -> lzma_ret; - fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64; -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_lz_options { - pub dict_size: size_t, - pub preset_dict: *const u8, - pub preset_dict_size: size_t, -} +use crate::lz::lz_decoder::{lzma_lz_decoder_init, lzma_lz_decoder_memusage, lzma_lz_options}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma1_decoder { @@ -3383,7 +3360,6 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo (*coder).offset = 0; (*coder).len = 0; } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_decoder_create( lz: *mut lzma_lz_decoder, allocator: *const lzma_allocator, @@ -3452,7 +3428,6 @@ unsafe extern "C" fn lzma_decoder_init( lzma_decoder_uncompressed((*lz).coder, uncomp_size, allow_eopm); LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -3474,7 +3449,6 @@ pub unsafe extern "C" fn lzma_lzma_decoder_init( ), ) } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_lclppb_decode( options: *mut lzma_options_lzma, mut byte: u8, @@ -3488,7 +3462,6 @@ pub unsafe extern "C" fn lzma_lzma_lclppb_decode( (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9)); (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX } -#[no_mangle] pub extern "C" fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64 { return unsafe { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; @@ -3496,14 +3469,12 @@ pub extern "C" fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> .wrapping_add(lzma_lz_decoder_memusage((*opt).dict_size as size_t)) }; } -#[no_mangle] pub extern "C" fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64 { if !unsafe { is_lclppb_valid(options as *const lzma_options_lzma) } { return UINT64_MAX; } lzma_lzma_decoder_memusage_nocheck(options) } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_props_decode( options: *mut *mut c_void, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index b12858ff..bdf6e77f 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,47 +1,7 @@ use crate::types::*; -extern "C" { - fn lzma_lz_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - lz_init: Option< - unsafe extern "C" fn( - *mut lzma_lz_encoder, - *const lzma_allocator, - lzma_vli, - *const c_void, - *mut lzma_lz_options, - ) -> lzma_ret, - >, - ) -> lzma_ret; - fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> u64; - fn lzma_lzma_optimum_fast( - coder: *mut lzma_lzma1_encoder, - mf: *mut lzma_mf, - back_res: *mut u32, - len_res: *mut u32, - ); - fn lzma_lzma_optimum_normal( - coder: *mut lzma_lzma1_encoder, - mf: *mut lzma_mf, - back_res: *mut u32, - len_res: *mut u32, - position: u32, - ); -} -#[derive(Copy, Clone)] -#[repr(C)] -pub struct lzma_lz_options { - pub before_size: size_t, - pub dict_size: size_t, - pub after_size: size_t, - pub match_len_max: size_t, - pub nice_len: size_t, - pub match_finder: lzma_match_finder, - pub depth: u32, - pub preset_dict: *const u8, - pub preset_dict_size: u32, -} +use crate::lz::lz_encoder::{lzma_lz_encoder_init, lzma_lz_encoder_memusage, lzma_lz_options}; +use crate::lzma::lzma_encoder_optimum_fast::lzma_lzma_optimum_fast; +use crate::lzma::lzma_encoder_optimum_normal::lzma_lzma_optimum_normal; #[inline] unsafe extern "C" fn rc_reset(rc: *mut lzma_range_encoder) { (*rc).low = 0; @@ -713,7 +673,6 @@ unsafe extern "C" fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) match_0(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN); } pub const LOOP_INPUT_MAX: u32 = OPTS + 1; -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_encode( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, @@ -897,7 +856,6 @@ unsafe extern "C" fn length_encoder_reset( } } } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_reset( coder: *mut lzma_lzma1_encoder, options: *const lzma_options_lzma, @@ -971,7 +929,6 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( (*coder).opts_current_index = 0; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_create( coder_ptr: *mut *mut c_void, allocator: *const lzma_allocator, @@ -1059,7 +1016,6 @@ unsafe extern "C" fn lzma_encoder_init( lz_options, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -1081,7 +1037,6 @@ pub unsafe extern "C" fn lzma_lzma_encoder_init( ), ) } -#[no_mangle] pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { if !is_options_valid(options as *const lzma_options_lzma) { return UINT64_MAX; @@ -1108,7 +1063,6 @@ pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { } (core::mem::size_of::() as u64).wrapping_add(lz_memusage) } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_lclppb_encode( options: *const lzma_options_lzma, byte: *mut u8, @@ -1124,7 +1078,6 @@ pub unsafe extern "C" fn lzma_lzma_lclppb_encode( .wrapping_add((*options).lc) as u8; false } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { if options.is_null() { return LZMA_PROG_ERROR; @@ -1136,7 +1089,6 @@ pub unsafe extern "C" fn lzma_lzma_props_encode(options: *const c_void, out: *mu write32le(out.offset(1), (*opt).dict_size); LZMA_OK } -#[no_mangle] pub extern "C" fn lzma_mode_is_supported(mode: lzma_mode) -> lzma_bool { (mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL) as lzma_bool } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 682fe371..66e50a4f 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index c6bdd245..1b36d49a 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -916,7 +916,6 @@ unsafe extern "C" fn helper2( } len_end } -#[no_mangle] pub unsafe extern "C" fn lzma_lzma_optimum_normal( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, diff --git a/liblzma-rs/src/rangecoder/price_table.rs b/liblzma-rs/src/rangecoder/price_table.rs index 1f74ec81..10ce0f46 100644 --- a/liblzma-rs/src/rangecoder/price_table.rs +++ b/liblzma-rs/src/rangecoder/price_table.rs @@ -1,4 +1,3 @@ -#[no_mangle] pub static mut lzma_rc_prices: [u8; 128] = [ 128, 103, 91, 84, 78, 73, 69, 66, 63, 61, 58, 56, 54, 52, 51, 49, 48, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 34, 33, 32, 31, 31, 30, 29, 29, 28, 28, 27, 26, 26, 25, 25, 24, 24, diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index 4abb242f..894df6ef 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -54,7 +54,6 @@ extern "C" fn arm_coder_init( ) } } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_arm_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -62,7 +61,6 @@ pub unsafe extern "C" fn lzma_simple_arm_encoder_init( ) -> lzma_ret { arm_coder_init(next, allocator, filters, true) } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_arm_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index c6f73c2b..39f850a2 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -62,7 +62,6 @@ extern "C" fn arm64_coder_init( ) } } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -70,7 +69,6 @@ pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( ) -> lzma_ret { arm64_coder_init(next, allocator, filters, true) } -#[no_mangle] pub unsafe extern "C" fn lzma_bcj_arm64_encode( mut start_offset: u32, buf: *mut u8, @@ -79,7 +77,6 @@ pub unsafe extern "C" fn lzma_bcj_arm64_encode( start_offset = (start_offset & !3u32) as u32; arm64_code(core::ptr::null_mut(), start_offset, true, buf, size) } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -87,7 +84,6 @@ pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( ) -> lzma_ret { arm64_coder_init(next, allocator, filters, false) } -#[no_mangle] pub unsafe extern "C" fn lzma_bcj_arm64_decode( mut start_offset: u32, buf: *mut u8, diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index 99527fde..f82219ef 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -63,7 +63,6 @@ extern "C" fn armthumb_coder_init( ) } } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_armthumb_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -71,7 +70,6 @@ pub unsafe extern "C" fn lzma_simple_armthumb_encoder_init( ) -> lzma_ret { armthumb_coder_init(next, allocator, filters, true) } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_armthumb_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 8f29a609..94d26bc1 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -85,7 +85,6 @@ extern "C" fn ia64_coder_init( ) } } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_ia64_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -93,7 +92,6 @@ pub unsafe extern "C" fn lzma_simple_ia64_encoder_init( ) -> lzma_ret { ia64_coder_init(next, allocator, filters, true) } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_ia64_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index bddf8673..0bdefa93 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -56,7 +56,6 @@ extern "C" fn powerpc_coder_init( ) } } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_powerpc_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -64,7 +63,6 @@ pub unsafe extern "C" fn lzma_simple_powerpc_encoder_init( ) -> lzma_ret { powerpc_coder_init(next, allocator, filters, true) } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_powerpc_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 8f4b3b9c..4f7a2cce 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -95,7 +95,6 @@ unsafe extern "C" fn riscv_encode( } i } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -114,7 +113,6 @@ pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( true, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_bcj_riscv_encode( mut start_offset: u32, buf: *mut u8, @@ -197,7 +195,6 @@ unsafe extern "C" fn riscv_decode( } i } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -216,7 +213,6 @@ pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( false, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_bcj_riscv_decode( mut start_offset: u32, buf: *mut u8, diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 7f54d149..4e40c117 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -186,7 +186,6 @@ unsafe extern "C" fn simple_coder_update( reversed_filters.offset(1), ) } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/simple/simple_decoder.rs b/liblzma-rs/src/simple/simple_decoder.rs index fe3fa4ab..006ab061 100644 --- a/liblzma-rs/src/simple/simple_decoder.rs +++ b/liblzma-rs/src/simple/simple_decoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_simple_props_decode( options: *mut *mut c_void, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/simple/simple_encoder.rs b/liblzma-rs/src/simple/simple_encoder.rs index 99a1094b..4aca0cb1 100644 --- a/liblzma-rs/src/simple/simple_encoder.rs +++ b/liblzma-rs/src/simple/simple_encoder.rs @@ -1,5 +1,4 @@ use crate::types::*; -#[no_mangle] pub unsafe extern "C" fn lzma_simple_props_size( size: *mut u32, options: *const c_void, @@ -12,7 +11,6 @@ pub unsafe extern "C" fn lzma_simple_props_size( }) as u32; LZMA_OK } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_props_encode( options: *const c_void, out: *mut u8, diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index fb8a1993..f336eb13 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -60,7 +60,6 @@ extern "C" fn sparc_coder_init( ) } } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_sparc_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -68,7 +67,6 @@ pub unsafe extern "C" fn lzma_simple_sparc_encoder_init( ) -> lzma_ret { sparc_coder_init(next, allocator, filters, true) } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_sparc_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index a297ee1b..28cccdd6 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -117,7 +117,6 @@ extern "C" fn x86_coder_init( ret }; } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_x86_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -125,7 +124,6 @@ pub unsafe extern "C" fn lzma_simple_x86_encoder_init( ) -> lzma_ret { x86_coder_init(next, allocator, filters, true) } -#[no_mangle] pub unsafe extern "C" fn lzma_bcj_x86_encode( start_offset: u32, buf: *mut u8, @@ -143,7 +141,6 @@ pub unsafe extern "C" fn lzma_bcj_x86_encode( size, ) } -#[no_mangle] pub unsafe extern "C" fn lzma_simple_x86_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -151,7 +148,6 @@ pub unsafe extern "C" fn lzma_simple_x86_decoder_init( ) -> lzma_ret { x86_coder_init(next, allocator, filters, false) } -#[no_mangle] pub unsafe extern "C" fn lzma_bcj_x86_decode( start_offset: u32, buf: *mut u8, diff --git a/liblzma-rs/src/tuklib/tuklib_cpucores.rs b/liblzma-rs/src/tuklib/tuklib_cpucores.rs index cfb46237..3408c662 100644 --- a/liblzma-rs/src/tuklib/tuklib_cpucores.rs +++ b/liblzma-rs/src/tuklib/tuklib_cpucores.rs @@ -1,4 +1,3 @@ -#[no_mangle] pub extern "C" fn tuklib_cpucores() -> u32 { match std::thread::available_parallelism() { Ok(n) => n.get() as u32, diff --git a/liblzma-rs/src/tuklib/tuklib_physmem.rs b/liblzma-rs/src/tuklib/tuklib_physmem.rs index a2d286a9..6efe29d6 100644 --- a/liblzma-rs/src/tuklib/tuklib_physmem.rs +++ b/liblzma-rs/src/tuklib/tuklib_physmem.rs @@ -1,4 +1,3 @@ -#[no_mangle] pub extern "C" fn tuklib_physmem() -> u64 { #[cfg(target_os = "macos")] { diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 294c3693..a3f147bc 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -563,16 +563,8 @@ pub struct lzma_outq { pub bufs_allocated: u32, pub bufs_limit: u32, } -#[repr(C)] -pub struct lzma_index_s { - _opaque: [u8; 0], -} -pub type lzma_index = lzma_index_s; -#[repr(C)] -pub struct lzma_index_hash_s { - _opaque: [u8; 0], -} -pub type lzma_index_hash = lzma_index_hash_s; +pub use crate::common::index::{lzma_index_s, lzma_index}; +pub use crate::common::index_hash::{lzma_index_hash_s, lzma_index_hash}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma1_encoder_s { @@ -1065,206 +1057,38 @@ pub struct lzma_simple_coder { pub size: size_t, pub buffer: [u8; 0], } +pub use crate::common::common::{lzma_alloc, lzma_alloc_zero, lzma_free, lzma_next_end, lzma_next_filter_init, lzma_next_filter_update, lzma_strm_init, lzma_end, lzma_bufcpy}; +pub use crate::check::crc32_fast::lzma_crc32; +pub use crate::common::block_util::lzma_block_unpadded_size; +pub use crate::check::check::{lzma_check_is_supported, lzma_check_size, lzma_check_init, lzma_check_update, lzma_check_finish}; +pub use crate::common::vli_size::lzma_vli_size; +pub use crate::common::vli_decoder::lzma_vli_decode; +pub use crate::common::stream_flags_common::lzma_stream_flags_compare; +pub use crate::common::easy_preset::lzma_easy_preset; +pub use crate::common::filter_common::{lzma_filters_free, lzma_filters_copy, lzma_raw_coder_init, lzma_raw_coder_memusage}; +pub use crate::simple::simple_coder::lzma_simple_coder_init; +pub use crate::common::vli_encoder::lzma_vli_encode; +pub use crate::common::stream_flags_encoder::{lzma_stream_header_encode, lzma_stream_footer_encode}; +pub use crate::common::stream_flags_decoder::{lzma_stream_header_decode, lzma_stream_footer_decode}; +pub use crate::common::block_header_encoder::{lzma_block_header_size, lzma_block_header_encode}; +pub use crate::common::block_header_decoder::lzma_block_header_decode; +pub use crate::common::block_decoder::lzma_block_decoder_init; +pub use crate::common::block_encoder::lzma_block_encoder_init; +pub use crate::common::filter_encoder::{lzma_raw_encoder_init, lzma_raw_encoder_memusage}; +pub use crate::common::filter_decoder::{lzma_raw_decoder_memusage, lzma_raw_decoder_init}; +pub use crate::lzma::lzma_encoder::{lzma_lzma_encoder_init, lzma_lzma_lclppb_encode, lzma_lzma_encoder_memusage}; +pub use crate::lzma::lzma_decoder::{lzma_lzma_decoder_init, lzma_lzma_lclppb_decode, lzma_lzma_decoder_memusage_nocheck}; +pub use crate::delta::delta_common::{lzma_delta_coder_memusage, lzma_delta_coder_init}; +pub use crate::common::stream_decoder::lzma_stream_decoder_init; +pub use crate::lzma::lzma_encoder_presets::lzma_lzma_preset; +pub use crate::lz::lz_encoder_mf::lzma_mf_find; +pub use crate::common::index::{lzma_index_memusage, lzma_index_init, lzma_index_end, lzma_index_append, lzma_index_size, lzma_index_padding_size}; +pub use crate::common::index_encoder::lzma_index_encoder_init; +pub use crate::common::index_hash::{lzma_index_hash_init, lzma_index_hash_end, lzma_index_hash_append, lzma_index_hash_decode, lzma_index_hash_size}; +pub use crate::common::outqueue::{lzma_outq_init, lzma_outq_end, lzma_outq_prealloc_buf, lzma_outq_get_buf, lzma_outq_is_readable, lzma_outq_read}; +pub use crate::rangecoder::price_table::lzma_rc_prices; +pub use crate::lzma::fastpos_table::lzma_fastpos; extern "C" { - pub fn lzma_alloc(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - pub fn lzma_alloc_zero(size: size_t, allocator: *const lzma_allocator) -> *mut c_void; - pub fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allocator); - pub fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator); - pub fn lzma_next_filter_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - pub fn lzma_next_filter_update( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - reversed_filters: *const lzma_filter, - ) -> lzma_ret; - pub fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret; - pub fn lzma_end(strm: *mut lzma_stream); - pub fn lzma_bufcpy( - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> size_t; - pub fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32; - pub fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli; - pub fn lzma_check_is_supported(check: lzma_check) -> lzma_bool; - pub fn lzma_check_size(check: lzma_check) -> u32; - pub fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check); - pub fn lzma_check_update( - check: *mut lzma_check_state, - type_0: lzma_check, - buf: *const u8, - size: size_t, - ); - pub fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check); - pub fn lzma_vli_size(vli: lzma_vli) -> u32; - pub fn lzma_vli_decode( - vli: *mut lzma_vli, - vli_pos: *mut size_t, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; - pub fn lzma_stream_flags_compare( - a: *const lzma_stream_flags, - b: *const lzma_stream_flags, - ) -> lzma_ret; - pub fn lzma_easy_preset(easy: *mut lzma_options_easy, preset: u32) -> bool; - pub fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator); - pub fn lzma_simple_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - filter: Option size_t>, - simple_size: size_t, - unfiltered_max: size_t, - alignment: u32, - is_encoder: bool, - ) -> lzma_ret; - pub fn lzma_vli_encode( - vli: lzma_vli, - vli_pos: *mut size_t, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - ) -> lzma_ret; - pub fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; - pub fn lzma_stream_header_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; - pub fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret; - pub fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> lzma_ret; - pub fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret; - pub fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret; - pub fn lzma_block_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - block: *mut lzma_block, - ) -> lzma_ret; - pub fn lzma_raw_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter, - ) -> lzma_ret; - pub fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64; - pub fn lzma_lzma_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - pub fn lzma_lzma_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - pub fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool; - pub fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, byte: u8) -> bool; - pub fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64; - pub fn lzma_delta_coder_memusage(options: *const c_void) -> u64; - pub fn lzma_block_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - block: *mut lzma_block, - ) -> lzma_ret; - pub fn lzma_block_header_decode( - block: *mut lzma_block, - allocator: *const lzma_allocator, - in_0: *const u8, - ) -> lzma_ret; - pub fn lzma_filters_copy( - src: *const lzma_filter, - dest: *mut lzma_filter, - allocator: *const lzma_allocator, - ) -> lzma_ret; - pub fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64; - pub fn lzma_raw_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - options: *const lzma_filter, - ) -> lzma_ret; - pub fn lzma_raw_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter, - coder_find: lzma_filter_find, - is_encoder: bool, - ) -> lzma_ret; - pub fn lzma_raw_coder_memusage( - coder_find: lzma_filter_find, - filters: *const lzma_filter, - ) -> u64; - pub fn lzma_stream_decoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - memlimit: u64, - flags: u32, - ) -> lzma_ret; - pub fn lzma_delta_coder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - filters: *const lzma_filter_info, - ) -> lzma_ret; - pub fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64; - pub fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool; - pub fn lzma_mf_find(mf: *mut lzma_mf, count: *mut u32, matches: *mut lzma_match) -> u32; - pub fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64; - pub fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index; - pub fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator); - pub fn lzma_index_append( - i: *mut lzma_index, - allocator: *const lzma_allocator, - unpadded_size: lzma_vli, - uncompressed_size: lzma_vli, - ) -> lzma_ret; - pub fn lzma_index_size(i: *const lzma_index) -> lzma_vli; - pub fn lzma_index_padding_size(i: *const lzma_index) -> u32; - pub fn lzma_index_encoder_init( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, - i: *const lzma_index, - ) -> lzma_ret; - pub fn lzma_index_hash_init( - index_hash: *mut lzma_index_hash, - allocator: *const lzma_allocator, - ) -> *mut lzma_index_hash; - pub fn lzma_index_hash_end(index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator); - pub fn lzma_index_hash_append( - index_hash: *mut lzma_index_hash, - unpadded_size: lzma_vli, - uncompressed_size: lzma_vli, - ) -> lzma_ret; - pub fn lzma_index_hash_decode( - index_hash: *mut lzma_index_hash, - in_0: *const u8, - in_pos: *mut size_t, - in_size: size_t, - ) -> lzma_ret; - pub fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli; - pub fn lzma_outq_init( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - threads: u32, - ) -> lzma_ret; - pub fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator); - pub fn lzma_outq_prealloc_buf( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - size: size_t, - ) -> lzma_ret; - pub fn lzma_outq_get_buf(outq: *mut lzma_outq, worker: *mut c_void) -> *mut lzma_outbuf; - pub fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool; - pub fn lzma_outq_read( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, - out: *mut u8, - out_pos: *mut size_t, - out_size: size_t, - unpadded_size: *mut lzma_vli, - uncompressed_size: *mut lzma_vli, - ) -> lzma_ret; pub fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; pub fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; pub fn pthread_cond_init(_: *mut pthread_cond_t, _: *const pthread_condattr_t) -> c_int; @@ -1289,8 +1113,6 @@ extern "C" { pub fn pthread_sigmask(_: c_int, _: *const sigset_t, _: *mut sigset_t) -> c_int; pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; pub fn strlen(s: *const c_char) -> size_t; - pub static lzma_rc_prices: [u8; 128]; - pub static lzma_fastpos: [u8; 8192]; } pub unsafe fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void { From d8023d39939dfe507c1f041bbdb86f1fbd05c68d Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 15 Mar 2026 17:40:31 +0900 Subject: [PATCH 16/51] perf: simplify encoder hot paths and add #[inline] --- Cargo.toml | 29 ++--- benches/backend_comparison.rs | 2 +- liblzma-rs-sys/Cargo.toml | 16 +-- liblzma-rs-sys/src/lib.rs | 55 ++------- liblzma-rs/src/alloc.rs | 6 +- liblzma-rs/src/check/check.rs | 4 +- liblzma-rs/src/check/crc64_fast.rs | 9 +- liblzma-rs/src/common/auto_decoder.rs | 2 +- liblzma-rs/src/common/block_header_decoder.rs | 2 +- liblzma-rs/src/common/block_header_encoder.rs | 2 +- liblzma-rs/src/common/easy_buffer_encoder.rs | 2 +- liblzma-rs/src/common/easy_encoder.rs | 2 +- liblzma-rs/src/common/file_info.rs | 7 +- liblzma-rs/src/common/filter_decoder.rs | 18 +-- liblzma-rs/src/common/filter_encoder.rs | 21 ++-- liblzma-rs/src/common/filter_flags_decoder.rs | 2 +- liblzma-rs/src/common/filter_flags_encoder.rs | 2 +- liblzma-rs/src/common/index_decoder.rs | 2 +- liblzma-rs/src/common/index_encoder.rs | 2 +- .../src/common/stream_buffer_encoder.rs | 2 +- liblzma-rs/src/common/stream_decoder_mt.rs | 4 +- liblzma-rs/src/common/stream_encoder_mt.rs | 4 +- liblzma-rs/src/common/stream_flags_decoder.rs | 2 +- liblzma-rs/src/common/stream_flags_encoder.rs | 2 +- liblzma-rs/src/common/string_conversion.rs | 2 +- liblzma-rs/src/lz/lz_encoder.rs | 110 ++++++++---------- liblzma-rs/src/lz/lz_encoder_mf.rs | 19 ++- liblzma-rs/src/lzma/lzma2_decoder.rs | 2 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 6 +- liblzma-rs/src/lzma/lzma_decoder.rs | 2 +- liblzma-rs/src/lzma/lzma_encoder.rs | 2 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 103 ++++++++-------- liblzma-rs/src/types.rs | 76 +++++++----- 33 files changed, 262 insertions(+), 259 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4a057039..088c1a99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,10 @@ exclude = [".github/"] members = ["systest", "liblzma-rs", "liblzma-rs-sys"] [dependencies] -liblzma-sys = { package = "liblzma-rs-sys", path = "liblzma-rs-sys" } +# Rust backend (default) - pure Rust implementation +liblzma-sys = { package = "liblzma-rs-sys", path = "liblzma-rs-sys", optional = true } +# C backend - original liblzma C library via FFI +liblzma-c-sys = { package = "liblzma-sys", path = "liblzma-sys", version = "0.4.5", optional = true, default-features = false } num_cpus = { version = "1.16.0", optional = true } criterion = { version = "0.5", features = ["html_reports"], optional = true } @@ -39,24 +42,24 @@ getrandom = { version = "0.2", features = ["js"] } [target.'cfg(not(target_family = "wasm"))'.dev-dependencies] quickcheck = "=1.0.1" -liblzma-c-sys-test = { package = "liblzma-sys", path = "liblzma-sys", version = "0.4.5", default-features = false, features = ["bindgen"] } [target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dev-dependencies] wasm-bindgen-test = "0.3" [features] -default = ["bindgen"] -static = ["liblzma-sys/static"] -parallel = ["liblzma-sys/parallel", "num_cpus"] -bindgen = ["liblzma-sys/bindgen"] -wasm = ["liblzma-sys/wasm"] -uncheck_liblzma_version = ["liblzma-sys/uncheck_liblzma_version"] # Disables version checking for the system-installed liblzma. This is not recommended under normal circumstances. +default = ["rust-backend"] +rust-backend = ["liblzma-sys"] +c-backend = ["liblzma-c-sys/bindgen"] +static = ["liblzma-c-sys?/static"] +parallel = ["liblzma-sys?/parallel", "liblzma-c-sys?/parallel", "num_cpus"] +bindgen = ["liblzma-c-sys?/bindgen"] # ignored for rust-backend +wasm = ["liblzma-sys?/wasm", "liblzma-c-sys?/wasm"] +uncheck_liblzma_version = ["liblzma-c-sys?/uncheck_liblzma_version"] # ignored for rust-backend bench = ["criterion"] - -# These two are for cross-language LTO. -# Will only work if `clang` is used to build the C library. -fat-lto = ["liblzma-sys/fat-lto"] # Enable fat-lto, will override thin-lto if specified -thin-lto = ["liblzma-sys/thin-lto"] # Enable thin-lto, will fall back to fat-lto if not supported +# These two are for cross-language LTO with the C backend. +# Ignored for rust-backend. +fat-lto = ["liblzma-c-sys?/fat-lto"] +thin-lto = ["liblzma-c-sys?/thin-lto"] [package.metadata.docs.rs] features = ["parallel"] diff --git a/benches/backend_comparison.rs b/benches/backend_comparison.rs index 65c14d56..ee3c4130 100644 --- a/benches/backend_comparison.rs +++ b/benches/backend_comparison.rs @@ -4,7 +4,7 @@ use std::ptr; use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; -use liblzma_c_sys_test as c_sys; +use liblzma_c_sys as c_sys; use liblzma_sys as rs_sys; fn make_payload(size: usize) -> Vec { diff --git a/liblzma-rs-sys/Cargo.toml b/liblzma-rs-sys/Cargo.toml index 84ad32c1..13df0d8f 100644 --- a/liblzma-rs-sys/Cargo.toml +++ b/liblzma-rs-sys/Cargo.toml @@ -6,18 +6,20 @@ license = "MIT OR Apache-2.0" description = "liblzma-sys compatible API layer backed by pure Rust liblzma-rs" [lib] -crate-type = ["rlib", "staticlib"] +crate-type = ["rlib", "staticlib", "cdylib"] [features] default = ["bindgen"] -# Feature stubs matching liblzma-sys for smooth migration -static = [] +# The following features exist for compatibility with liblzma-sys. +# Since this crate is a pure Rust implementation, they are ignored. +static = [] # ignored: no C library to link statically +bindgen = [] # ignored: no C headers to generate bindings from +fat-lto = [] # ignored: no C object files for cross-language LTO +thin-lto = [] # ignored: no C object files for cross-language LTO +uncheck_liblzma_version = [] # ignored: no system liblzma to version-check +# These features have actual effects: parallel = [] -bindgen = [] wasm = ["static", "bindgen"] -uncheck_liblzma_version = [] -fat-lto = [] -thin-lto = [] [dependencies] liblzma-rs = { path = "../liblzma-rs" } diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs index 417c2af2..7f6b4454 100644 --- a/liblzma-rs-sys/src/lib.rs +++ b/liblzma-rs-sys/src/lib.rs @@ -44,16 +44,17 @@ pub type lzma_bool = c_uchar; pub type lzma_vli = u64; // === Canonical struct re-exports === +pub use liblzma_rs::common::index_hash::lzma_index_hash; pub use liblzma_rs::types::lzma_allocator; +pub use liblzma_rs::types::lzma_block; pub use liblzma_rs::types::lzma_filter; pub use liblzma_rs::types::lzma_index; +pub use liblzma_rs::types::lzma_index_iter; +pub use liblzma_rs::types::lzma_index_iter_mode; +pub use liblzma_rs::types::lzma_mt; pub use liblzma_rs::types::lzma_options_lzma; pub use liblzma_rs::types::lzma_stream; pub use liblzma_rs::types::lzma_stream_flags; -pub use liblzma_rs::types::lzma_block; -pub use liblzma_rs::types::lzma_index_iter; -pub use liblzma_rs::types::lzma_index_iter_mode; -pub use liblzma_rs::common::index_hash::lzma_index_hash; #[repr(C)] pub struct lzma_options_bcj { @@ -777,9 +778,7 @@ pub extern "C" fn lzma_index_memused(i: *const lzma_index) -> u64 { } #[no_mangle] -pub unsafe extern "C" fn lzma_index_init( - allocator: *const lzma_allocator, -) -> *mut lzma_index { +pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index { liblzma_rs::common::index::lzma_index_init(allocator.cast()).cast() } @@ -850,10 +849,7 @@ pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli } #[no_mangle] -pub unsafe extern "C" fn lzma_index_iter_init( - iter: *mut lzma_index_iter, - i: *const lzma_index, -) { +pub unsafe extern "C" fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index) { liblzma_rs::common::index::lzma_index_iter_init(iter.cast(), i.cast()) } @@ -919,12 +915,7 @@ pub unsafe extern "C" fn lzma_index_buffer_encode( out_pos: *mut size_t, out_size: size_t, ) -> lzma_ret { - liblzma_rs::common::index_encoder::lzma_index_buffer_encode( - i.cast(), - out, - out_pos, - out_size, - ) + liblzma_rs::common::index_encoder::lzma_index_buffer_encode(i.cast(), out, out_pos, out_size) } // --- Index hash --- @@ -934,8 +925,7 @@ pub unsafe extern "C" fn lzma_index_hash_init( index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator, ) -> *mut lzma_index_hash { - liblzma_rs::common::index_hash::lzma_index_hash_init(index_hash.cast(), allocator.cast()) - .cast() + liblzma_rs::common::index_hash::lzma_index_hash_init(index_hash.cast(), allocator.cast()).cast() } #[no_mangle] @@ -1127,33 +1117,6 @@ pub unsafe extern "C" fn lzma_file_info_decoder( // Multithreaded API // ========================================================================= -#[cfg(feature = "parallel")] -#[repr(C)] -pub struct lzma_mt { - pub flags: u32, - pub threads: u32, - pub block_size: u64, - pub timeout: u32, - pub preset: u32, - pub filters: *const lzma_filter, - pub check: lzma_check, - _reserved_enum1: __enum_ty, - _reserved_enum2: __enum_ty, - _reserved_enum3: __enum_ty, - _reserved_int1: u32, - _reserved_int2: u32, - _reserved_int3: u32, - _reserved_int4: u32, - pub memlimit_threading: u64, - pub memlimit_stop: u64, - _reserved_int7: u64, - _reserved_int8: u64, - _reserved_ptr1: *mut c_void, - _reserved_ptr2: *mut c_void, - _reserved_ptr3: *mut c_void, - _reserved_ptr4: *mut c_void, -} - #[cfg(feature = "parallel")] #[no_mangle] pub unsafe extern "C" fn lzma_stream_encoder_mt( diff --git a/liblzma-rs/src/alloc.rs b/liblzma-rs/src/alloc.rs index e20d9aeb..00f8a9ff 100644 --- a/liblzma-rs/src/alloc.rs +++ b/liblzma-rs/src/alloc.rs @@ -33,7 +33,11 @@ unsafe fn rust_alloc_impl(size: usize, align: usize, zeroed: bool) -> *mut c_voi Ok(layout) => layout, Err(_) => return core::ptr::null_mut(), }; - let base = if zeroed { alloc_zeroed(layout) } else { alloc(layout) }; + let base = if zeroed { + alloc_zeroed(layout) + } else { + alloc(layout) + }; if base.is_null() { return core::ptr::null_mut(); } diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index b9b39678..fe52f46b 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -1,6 +1,6 @@ -use crate::types::*; use crate::check::crc64_fast::lzma_crc64; -use crate::check::sha256::{lzma_sha256_init, lzma_sha256_update, lzma_sha256_finish}; +use crate::check::sha256::{lzma_sha256_finish, lzma_sha256_init, lzma_sha256_update}; +use crate::types::*; pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { if type_0 > LZMA_CHECK_ID_MAX { return false as lzma_bool; diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index 4823a475..891efc80 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1033,6 +1033,7 @@ pub static mut lzma_crc64_table: [[u64; 256]; 4] = [ 0x1e5cd90c6ec2440d, ], ]; +#[inline] unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mut crc: u64) -> u64 { crc = !crc; if size > 4 { @@ -1053,14 +1054,10 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu ^ lzma_crc64_table[0][(tmp >> 24) as usize]; } } - loop { - let old_size = size; - size = size.wrapping_sub(1); - if old_size == 0 { - break; - } + while size > 0 { crc = lzma_crc64_table[0][(*buf as u64 ^ crc & 0xff as u64) as usize] ^ crc >> 8; buf = buf.offset(1); + size -= 1; } !crc } diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index db8676fb..190ecb0a 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::common::alone_decoder::lzma_alone_decoder_init; +use crate::types::*; pub type auto_decoder_seq = c_uint; pub const SEQ_FINISH: auto_decoder_seq = 2; pub const SEQ_CODE: auto_decoder_seq = 1; diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 75b95c0b..0dc01adf 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::common::filter_flags_decoder::lzma_filter_flags_decode; +use crate::types::*; pub unsafe extern "C" fn lzma_block_header_decode( block: *mut lzma_block, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 6155f26b..8dea44fd 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,5 +1,5 @@ +use crate::common::filter_flags_encoder::{lzma_filter_flags_encode, lzma_filter_flags_size}; use crate::types::*; -use crate::common::filter_flags_encoder::{lzma_filter_flags_size, lzma_filter_flags_encode}; pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { if (*block).version > 1 { return LZMA_OPTIONS_ERROR; diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 5414190b..9f40a0a5 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::common::stream_buffer_encoder::lzma_stream_buffer_encode; +use crate::types::*; pub unsafe extern "C" fn lzma_easy_buffer_encode( preset: u32, check: lzma_check, diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index 8bf5997a..5d8cacc7 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::common::stream_encoder::lzma_stream_encoder; +use crate::types::*; pub unsafe extern "C" fn lzma_easy_encoder( strm: *mut lzma_stream, preset: u32, diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index b6721e84..38b67957 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -1,6 +1,9 @@ -use crate::types::*; -use crate::common::index::{lzma_index_memused, lzma_index_stream_flags, lzma_index_stream_padding, lzma_index_total_size, lzma_index_cat}; +use crate::common::index::{ + lzma_index_cat, lzma_index_memused, lzma_index_stream_flags, lzma_index_stream_padding, + lzma_index_total_size, +}; use crate::common::index_decoder::lzma_index_decoder_init; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_file_info_coder { diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index a26589cf..263dfdf0 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -1,16 +1,18 @@ -use crate::types::*; +use crate::delta::delta_decoder::{lzma_delta_decoder_init, lzma_delta_props_decode}; +use crate::lzma::lzma2_decoder::{ + lzma_lzma2_decoder_init, lzma_lzma2_decoder_memusage, lzma_lzma2_props_decode, +}; use crate::lzma::lzma_decoder::{lzma_lzma_decoder_memusage, lzma_lzma_props_decode}; -use crate::lzma::lzma2_decoder::{lzma_lzma2_decoder_init, lzma_lzma2_decoder_memusage, lzma_lzma2_props_decode}; -use crate::simple::x86::lzma_simple_x86_decoder_init; -use crate::simple::powerpc::lzma_simple_powerpc_decoder_init; -use crate::simple::ia64::lzma_simple_ia64_decoder_init; use crate::simple::arm::lzma_simple_arm_decoder_init; -use crate::simple::armthumb::lzma_simple_armthumb_decoder_init; use crate::simple::arm64::lzma_simple_arm64_decoder_init; -use crate::simple::sparc::lzma_simple_sparc_decoder_init; +use crate::simple::armthumb::lzma_simple_armthumb_decoder_init; +use crate::simple::ia64::lzma_simple_ia64_decoder_init; +use crate::simple::powerpc::lzma_simple_powerpc_decoder_init; use crate::simple::riscv::lzma_simple_riscv_decoder_init; use crate::simple::simple_decoder::lzma_simple_props_decode; -use crate::delta::delta_decoder::{lzma_delta_decoder_init, lzma_delta_props_decode}; +use crate::simple::sparc::lzma_simple_sparc_decoder_init; +use crate::simple::x86::lzma_simple_x86_decoder_init; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_decoder { diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index b8792a44..aaa74147 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -1,16 +1,19 @@ -use crate::types::*; +use crate::delta::delta_encoder::{lzma_delta_encoder_init, lzma_delta_props_encode}; +use crate::lzma::lzma2_encoder::{ + lzma_lzma2_block_size, lzma_lzma2_encoder_init, lzma_lzma2_encoder_memusage, + lzma_lzma2_props_encode, +}; use crate::lzma::lzma_encoder::lzma_lzma_props_encode; -use crate::lzma::lzma2_encoder::{lzma_lzma2_encoder_init, lzma_lzma2_encoder_memusage, lzma_lzma2_props_encode, lzma_lzma2_block_size}; -use crate::simple::x86::lzma_simple_x86_encoder_init; -use crate::simple::powerpc::lzma_simple_powerpc_encoder_init; -use crate::simple::ia64::lzma_simple_ia64_encoder_init; use crate::simple::arm::lzma_simple_arm_encoder_init; -use crate::simple::armthumb::lzma_simple_armthumb_encoder_init; use crate::simple::arm64::lzma_simple_arm64_encoder_init; -use crate::simple::sparc::lzma_simple_sparc_encoder_init; +use crate::simple::armthumb::lzma_simple_armthumb_encoder_init; +use crate::simple::ia64::lzma_simple_ia64_encoder_init; +use crate::simple::powerpc::lzma_simple_powerpc_encoder_init; use crate::simple::riscv::lzma_simple_riscv_encoder_init; -use crate::simple::simple_encoder::{lzma_simple_props_size, lzma_simple_props_encode}; -use crate::delta::delta_encoder::{lzma_delta_encoder_init, lzma_delta_props_encode}; +use crate::simple::simple_encoder::{lzma_simple_props_encode, lzma_simple_props_size}; +use crate::simple::sparc::lzma_simple_sparc_encoder_init; +use crate::simple::x86::lzma_simple_x86_encoder_init; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_filter_encoder { diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index 5e7a38c3..fa21ca7e 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::common::filter_decoder::lzma_properties_decode; +use crate::types::*; pub unsafe extern "C" fn lzma_filter_flags_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index c1e63a6c..399a9940 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -1,5 +1,5 @@ +use crate::common::filter_encoder::{lzma_properties_encode, lzma_properties_size}; use crate::types::*; -use crate::common::filter_encoder::{lzma_properties_size, lzma_properties_encode}; pub unsafe extern "C" fn lzma_filter_flags_size( size: *mut u32, filter: *const lzma_filter, diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 7bd2b69d..b1c94c65 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::common::index::lzma_index_prealloc; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_coder { diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index abea70ef..3d078f2b 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::common::index::{lzma_index_block_count, lzma_index_iter_init, lzma_index_iter_next}; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_index_coder { diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 06862c5d..d5a49e59 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -1,6 +1,6 @@ -use crate::types::*; use crate::common::block_buffer_encoder::{lzma_block_buffer_bound, lzma_block_buffer_encode}; use crate::common::index_encoder::lzma_index_buffer_encode; +use crate::types::*; pub const INDEX_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3 & !(3); pub const HEADERS_BOUND: u32 = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 1be3e0a9..fae7d6d8 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -1,5 +1,7 @@ +use crate::common::outqueue::{ + lzma_outq_clear_cache, lzma_outq_clear_cache2, lzma_outq_enable_partial_output, +}; use crate::types::*; -use crate::common::outqueue::{lzma_outq_clear_cache, lzma_outq_clear_cache2, lzma_outq_enable_partial_output}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_stream_coder { diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index a7ac6f61..f25331fc 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -1,7 +1,7 @@ -use crate::types::*; +use crate::common::block_buffer_encoder::{lzma_block_buffer_bound64, lzma_block_uncomp_encode}; use crate::common::filter_encoder::lzma_mt_block_size; -use crate::common::block_buffer_encoder::{lzma_block_uncomp_encode, lzma_block_buffer_bound64}; use crate::common::outqueue::lzma_outq_memusage; +use crate::types::*; pub type worker_thread = worker_thread_s; #[derive(Copy, Clone)] #[repr(C)] diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index b875f4b7..9657c072 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -1,5 +1,5 @@ +use crate::common::stream_flags_common::{lzma_footer_magic, lzma_header_magic}; use crate::types::*; -use crate::common::stream_flags_common::{lzma_header_magic, lzma_footer_magic}; extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const u8) -> bool { return unsafe { if *in_0 != 0 || *in_0.offset(1) & 0xf0 != 0 { diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index 6105b3aa..befb8896 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -1,5 +1,5 @@ +use crate::common::stream_flags_common::{lzma_footer_magic, lzma_header_magic}; use crate::types::*; -use crate::common::stream_flags_common::{lzma_header_magic, lzma_footer_magic}; extern "C" fn stream_flags_encode(options: *const lzma_stream_flags, out: *mut u8) -> bool { return unsafe { if (*options).check > LZMA_CHECK_ID_MAX { diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 94c977ca..c54edd08 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::common::filter_common::lzma_validate_chain; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct filter_codec_def { diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 9c8c20a3..bcf095c8 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -1,5 +1,8 @@ +use crate::lz::lz_encoder_mf::{ + lzma_mf_bt2_find, lzma_mf_bt2_skip, lzma_mf_bt3_find, lzma_mf_bt3_skip, lzma_mf_bt4_find, + lzma_mf_bt4_skip, lzma_mf_hc3_find, lzma_mf_hc3_skip, lzma_mf_hc4_find, lzma_mf_hc4_skip, +}; use crate::types::*; -use crate::lz::lz_encoder_mf::{lzma_mf_hc3_find, lzma_mf_hc3_skip, lzma_mf_hc4_find, lzma_mf_hc4_skip, lzma_mf_bt2_find, lzma_mf_bt2_skip, lzma_mf_bt3_find, lzma_mf_bt3_skip, lzma_mf_bt4_find, lzma_mf_bt4_skip}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lz_options { @@ -21,20 +24,23 @@ pub struct lzma_coder { pub next: lzma_next_coder, } pub const LZMA_MEMCMPLEN_EXTRA: u32 = 0; -unsafe extern "C" fn move_window(mf: *mut lzma_mf) { - let move_offset: u32 = (*mf).read_pos.wrapping_sub((*mf).keep_size_before) & !(15); - let move_size: size_t = (*mf).write_pos.wrapping_sub(move_offset) as size_t; +#[inline] +unsafe fn move_window(mf: *mut lzma_mf) { + debug_assert!((*mf).read_pos > (*mf).keep_size_before); + let move_offset: u32 = ((*mf).read_pos - (*mf).keep_size_before) & !15; + debug_assert!((*mf).write_pos > move_offset); + let move_size: size_t = ((*mf).write_pos - move_offset) as size_t; core::ptr::copy( (*mf).buffer.offset(move_offset as isize) as *const u8, (*mf).buffer as *mut u8, move_size, ); - (*mf).offset = (*mf).offset.wrapping_add(move_offset); - (*mf).read_pos = (*mf).read_pos.wrapping_sub(move_offset); - (*mf).read_limit = (*mf).read_limit.wrapping_sub(move_offset); - (*mf).write_pos = (*mf).write_pos.wrapping_sub(move_offset); + (*mf).offset += move_offset; + (*mf).read_pos -= move_offset; + (*mf).read_limit -= move_offset; + (*mf).write_pos -= move_offset; } -unsafe extern "C" fn fill_window( +unsafe fn fill_window( coder: *mut lzma_coder, allocator: *const lzma_allocator, in_0: *const u8, @@ -42,12 +48,12 @@ unsafe extern "C" fn fill_window( in_size: size_t, action: lzma_action, ) -> lzma_ret { - if (*coder).mf.read_pos >= (*coder).mf.size.wrapping_sub((*coder).mf.keep_size_after) { + debug_assert!((*coder).mf.read_pos <= (*coder).mf.write_pos); + if (*coder).mf.read_pos >= (*coder).mf.size - (*coder).mf.keep_size_after { move_window(::core::ptr::addr_of_mut!((*coder).mf)); } let mut write_pos: size_t = (*coder).mf.write_pos as size_t; - let mut ret: lzma_ret = LZMA_OK; - if (*coder).next.code.is_none() { + let mut ret = if (*coder).next.code.is_none() { lzma_bufcpy( in_0, in_pos, @@ -56,13 +62,13 @@ unsafe extern "C" fn fill_window( ::core::ptr::addr_of_mut!(write_pos), (*coder).mf.size as size_t, ); - ret = if action != LZMA_RUN && *in_pos == in_size { + if action != LZMA_RUN && *in_pos == in_size { LZMA_STREAM_END } else { LZMA_OK - }; + } } else { - ret = (*coder).next.code.unwrap()( + (*coder).next.code.unwrap()( (*coder).next.coder, allocator, in_0, @@ -72,8 +78,8 @@ unsafe extern "C" fn fill_window( ::core::ptr::addr_of_mut!(write_pos), (*coder).mf.size as size_t, action, - ); - } + ) + }; (*coder).mf.write_pos = write_pos as u32; core::ptr::write_bytes( (*coder).mf.buffer.offset(write_pos as isize) as *mut u8, @@ -85,15 +91,13 @@ unsafe extern "C" fn fill_window( (*coder).mf.action = action; (*coder).mf.read_limit = (*coder).mf.write_pos; } else if (*coder).mf.write_pos > (*coder).mf.keep_size_after { - (*coder).mf.read_limit = (*coder) - .mf - .write_pos - .wrapping_sub((*coder).mf.keep_size_after); + (*coder).mf.read_limit = (*coder).mf.write_pos - (*coder).mf.keep_size_after; } if (*coder).mf.pending > 0 && (*coder).mf.read_pos < (*coder).mf.read_limit { let pending: u32 = (*coder).mf.pending; (*coder).mf.pending = 0; - (*coder).mf.read_pos = (*coder).mf.read_pos.wrapping_sub(pending); + debug_assert!((*coder).mf.read_pos >= pending); + (*coder).mf.read_pos -= pending; (*coder).mf.skip.unwrap()(::core::ptr::addr_of_mut!((*coder).mf), pending); } ret @@ -131,47 +135,35 @@ unsafe extern "C" fn lz_encode( } LZMA_OK } -unsafe extern "C" fn lz_encoder_prepare( +unsafe fn lz_encoder_prepare( mf: *mut lzma_mf, allocator: *const lzma_allocator, lz_options: *const lzma_lz_options, ) -> bool { if (*lz_options).dict_size < LZMA_DICT_SIZE_MIN as size_t - || (*lz_options).dict_size > (1u32 << 30).wrapping_add(1u32 << 29) as size_t + || (*lz_options).dict_size > ((1u32 << 30) + (1u32 << 29)) as size_t || (*lz_options).nice_len > (*lz_options).match_len_max { return true; } - (*mf).keep_size_before = (*lz_options) - .before_size - .wrapping_add((*lz_options).dict_size) as u32; - (*mf).keep_size_after = (*lz_options) - .after_size - .wrapping_add((*lz_options).match_len_max) as u32; - let mut reserve: u32 = (*lz_options).dict_size.wrapping_div(2) as u32; + (*mf).keep_size_before = ((*lz_options).before_size + (*lz_options).dict_size) as u32; + (*mf).keep_size_after = ((*lz_options).after_size + (*lz_options).match_len_max) as u32; + let mut reserve: u32 = ((*lz_options).dict_size / 2) as u32; if reserve > 1 << 30 { - reserve = reserve.wrapping_div(2); + reserve /= 2; } - reserve = (reserve as size_t).wrapping_add( - (*lz_options) - .before_size - .wrapping_add((*lz_options).match_len_max) - .wrapping_add((*lz_options).after_size) - .wrapping_div(2) - .wrapping_add((1u32 << 19) as size_t), - ) as u32; + reserve += + (((*lz_options).before_size + (*lz_options).match_len_max + (*lz_options).after_size) / 2 + + (1u32 << 19) as size_t) as u32; let old_size: u32 = (*mf).size; - (*mf).size = (*mf) - .keep_size_before - .wrapping_add(reserve) - .wrapping_add((*mf).keep_size_after); + (*mf).size = (*mf).keep_size_before + reserve + (*mf).keep_size_after; if !(*mf).buffer.is_null() && old_size != (*mf).size { crate::alloc::internal_free((*mf).buffer as *mut c_void, allocator); (*mf).buffer = core::ptr::null_mut(); } (*mf).match_len_max = (*lz_options).match_len_max as u32; (*mf).nice_len = (*lz_options).nice_len as u32; - (*mf).cyclic_size = (*lz_options).dict_size.wrapping_add(1) as u32; + (*mf).cyclic_size = (*lz_options).dict_size as u32 + 1; match (*lz_options).match_finder { 3 => { (*mf).find = Some( @@ -211,7 +203,7 @@ unsafe extern "C" fn lz_encoder_prepare( if hash_bytes == 2 { hs = 0xffff; } else { - hs = (*lz_options).dict_size.wrapping_sub(1) as u32; + hs = (*lz_options).dict_size as u32 - 1; hs |= hs >> 1; hs |= hs >> 2; hs |= hs >> 4; @@ -220,7 +212,7 @@ unsafe extern "C" fn lz_encoder_prepare( hs |= 0xffff; if hs > 1 << 24 { if hash_bytes == 3 { - hs = (1u32 << 24).wrapping_sub(1) as u32; + hs = (1u32 << 24) - 1; } else { hs >>= 1; } @@ -229,17 +221,17 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).hash_mask = hs; hs += 1; if hash_bytes > 2 { - hs = hs.wrapping_add(HASH_2_SIZE); + hs += HASH_2_SIZE; } if hash_bytes > 3 { - hs = hs.wrapping_add(HASH_3_SIZE); + hs += HASH_3_SIZE; } let old_hash_count: u32 = (*mf).hash_count; let old_sons_count: u32 = (*mf).sons_count; (*mf).hash_count = hs; (*mf).sons_count = (*mf).cyclic_size; if is_bt { - (*mf).sons_count = (*mf).sons_count.wrapping_mul(2); + (*mf).sons_count *= 2; } if old_hash_count != (*mf).hash_count || old_sons_count != (*mf).sons_count { crate::alloc::internal_free((*mf).hash as *mut c_void, allocator); @@ -250,21 +242,21 @@ unsafe extern "C" fn lz_encoder_prepare( (*mf).depth = (*lz_options).depth; if (*mf).depth == 0 { if is_bt { - (*mf).depth = (16u32).wrapping_add((*mf).nice_len.wrapping_div(2)); + (*mf).depth = 16u32 + (*mf).nice_len / 2; } else { - (*mf).depth = (4u32).wrapping_add((*mf).nice_len.wrapping_div(4)); + (*mf).depth = 4u32 + (*mf).nice_len / 4; } } false } -unsafe extern "C" fn lz_encoder_init( +unsafe fn lz_encoder_init( mf: *mut lzma_mf, allocator: *const lzma_allocator, lz_options: *const lzma_lz_options, ) -> bool { if (*mf).buffer.is_null() { (*mf).buffer = crate::alloc::internal_alloc_bytes( - (*mf).size.wrapping_add(LZMA_MEMCMPLEN_EXTRA) as size_t, + ((*mf).size + LZMA_MEMCMPLEN_EXTRA) as size_t, allocator, ) as *mut u8; if (*mf).buffer.is_null() { @@ -298,7 +290,7 @@ unsafe extern "C" fn lz_encoder_init( core::ptr::write_bytes( (*mf).hash as *mut u8, 0 as u8, - ((*mf).hash_count as size_t).wrapping_mul(core::mem::size_of::()), + ((*mf).hash_count as size_t) * core::mem::size_of::(), ); } (*mf).cyclic_pos = 0; @@ -351,11 +343,9 @@ pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) - if unsafe { lz_encoder_prepare(::core::ptr::addr_of_mut!(mf), core::ptr::null(), lz_options) } { return UINT64_MAX; } - (mf.hash_count as u64) - .wrapping_add(mf.sons_count as u64) - .wrapping_mul(core::mem::size_of::() as u64) - .wrapping_add(mf.size as u64) - .wrapping_add(core::mem::size_of::() as u64) + ((mf.hash_count as u64) + (mf.sons_count as u64)) * core::mem::size_of::() as u64 + + mf.size as u64 + + core::mem::size_of::() as u64 } unsafe extern "C" fn lz_encoder_end(coder_ptr: *mut c_void, allocator: *const lzma_allocator) { let coder: *mut lzma_coder = coder_ptr as *mut lzma_coder; diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 21a2882c..96189b27 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -1,9 +1,10 @@ -use crate::types::*; use crate::check::crc32_fast::lzma_crc32_table; +use crate::types::*; pub const HASH_2_MASK: c_uint = HASH_2_SIZE.wrapping_sub(1); pub const HASH_3_MASK: c_uint = HASH_3_SIZE.wrapping_sub(1); pub const FIX_3_HASH_SIZE: c_uint = 1u32 << 10; pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); +#[inline] pub unsafe extern "C" fn lzma_mf_find( mf: *mut lzma_mf, count_ptr: *mut u32, @@ -31,6 +32,7 @@ pub unsafe extern "C" fn lzma_mf_find( } pub const EMPTY_HASH_VALUE: u32 = 0; pub const MUST_NORMALIZE_POS: c_uint = UINT32_MAX; +#[inline] unsafe extern "C" fn normalize(mf: *mut lzma_mf) { let subvalue: u32 = MUST_NORMALIZE_POS.wrapping_sub((*mf).cyclic_size); let mut i: u32 = 0; @@ -55,6 +57,7 @@ unsafe extern "C" fn normalize(mf: *mut lzma_mf) { } (*mf).offset = (*mf).offset.wrapping_sub(subvalue); } +#[inline(always)] unsafe extern "C" fn move_pos(mf: *mut lzma_mf) { (*mf).cyclic_pos = (*mf).cyclic_pos.wrapping_add(1); if (*mf).cyclic_pos == (*mf).cyclic_size { @@ -65,10 +68,12 @@ unsafe extern "C" fn move_pos(mf: *mut lzma_mf) { normalize(mf); } } +#[inline(always)] unsafe extern "C" fn move_pending(mf: *mut lzma_mf) { (*mf).read_pos = (*mf).read_pos.wrapping_add(1); (*mf).pending = (*mf).pending.wrapping_add(1); } +#[inline] unsafe extern "C" fn hc_find_func( len_limit: u32, pos: u32, @@ -110,6 +115,7 @@ unsafe extern "C" fn hc_find_func( } } } +#[inline] pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -160,6 +166,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } +#[inline] pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { loop { if mf_avail(mf) < 3 { @@ -186,6 +193,7 @@ pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { } } } +#[inline] pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -260,6 +268,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } +#[inline] pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { loop { if mf_avail(mf) < 4 { @@ -293,6 +302,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { } } } +#[inline] unsafe extern "C" fn bt_find_func( len_limit: u32, pos: u32, @@ -353,6 +363,7 @@ unsafe extern "C" fn bt_find_func( } } } +#[inline] unsafe extern "C" fn bt_skip_func( len_limit: u32, pos: u32, @@ -405,6 +416,7 @@ unsafe extern "C" fn bt_skip_func( } } } +#[inline] pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -435,6 +447,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } +#[inline] pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_8: u64; loop { @@ -475,6 +488,7 @@ pub unsafe extern "C" fn lzma_mf_bt2_skip(mf: *mut lzma_mf, mut amount: u32) { } } } +#[inline] pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -534,6 +548,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } +#[inline] pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_9: u64; loop { @@ -581,6 +596,7 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { } } } +#[inline] pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_match) -> u32 { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { @@ -664,6 +680,7 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m move_pos(mf); matches_count } +#[inline] pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { let mut current_block_10: u64; loop { diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index b7251b2f..5f081281 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -1,6 +1,6 @@ -use crate::types::*; use crate::lz::lz_decoder::{lzma_lz_decoder_init, lzma_lz_options}; use crate::lzma::lzma_decoder::lzma_lzma_decoder_create; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma2_coder { diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index e43f44eb..ca6505d5 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -1,6 +1,8 @@ -use crate::types::*; use crate::lz::lz_encoder::{lzma_lz_encoder_init, lzma_lz_options}; -use crate::lzma::lzma_encoder::{lzma_lzma_encoder_create, lzma_lzma_encoder_reset, lzma_lzma_encode}; +use crate::lzma::lzma_encoder::{ + lzma_lzma_encode, lzma_lzma_encoder_create, lzma_lzma_encoder_reset, +}; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma2_coder { diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 17a01bea..afc8dcb9 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -1,5 +1,5 @@ -use crate::types::*; use crate::lz::lz_decoder::{lzma_lz_decoder_init, lzma_lz_decoder_memusage, lzma_lz_options}; +use crate::types::*; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma1_decoder { diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index bdf6e77f..26614d39 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -1,7 +1,7 @@ -use crate::types::*; use crate::lz::lz_encoder::{lzma_lz_encoder_init, lzma_lz_encoder_memusage, lzma_lz_options}; use crate::lzma::lzma_encoder_optimum_fast::lzma_lzma_optimum_fast; use crate::lzma::lzma_encoder_optimum_normal::lzma_lzma_optimum_normal; +use crate::types::*; #[inline] unsafe extern "C" fn rc_reset(rc: *mut lzma_range_encoder) { (*rc).low = 0; diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 1b36d49a..d1176365 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -2,7 +2,7 @@ use crate::types::*; pub const RC_BIT_PRICE_SHIFT_BITS: u32 = 4; pub const RC_INFINITY_PRICE: c_uint = 1u32 << 30; #[inline] -unsafe extern "C" fn rc_bittree_reverse_price( +unsafe fn rc_bittree_reverse_price( probs: *const probability, mut bit_levels: u32, mut symbol: u32, @@ -12,8 +12,8 @@ unsafe extern "C" fn rc_bittree_reverse_price( loop { let bit: u32 = symbol & 1; symbol >>= 1; - price = price.wrapping_add(rc_bit_price(*probs.offset(model_index as isize), bit)); - model_index = (model_index << 1).wrapping_add(bit); + price += rc_bit_price(*probs.offset(model_index as isize), bit); + model_index = (model_index << 1) + bit; bit_levels -= 1; if bit_levels == 0 { break; @@ -22,23 +22,23 @@ unsafe extern "C" fn rc_bittree_reverse_price( price } #[inline] -extern "C" fn rc_direct_price(bits: u32) -> u32 { +fn rc_direct_price(bits: u32) -> u32 { bits << RC_BIT_PRICE_SHIFT_BITS } #[inline] -unsafe extern "C" fn get_dist_slot_2(dist: u32) -> u32 { +unsafe fn get_dist_slot_2(dist: u32) -> u32 { if dist < 1 << FASTPOS_BITS + (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1)) { return (lzma_fastpos[(dist >> 14 / 2 - 1 + 0 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1))) as u32); + + (2 * (14 / 2 - 1 + 0 * (FASTPOS_BITS - 1))) as u32; } if dist < 1 << FASTPOS_BITS + (14 / 2 - 1 + 1 * (FASTPOS_BITS - 1)) { return (lzma_fastpos[(dist >> 14 / 2 - 1 + 1 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (14 / 2 - 1 + 1 * (FASTPOS_BITS - 1))) as u32); + + (2 * (14 / 2 - 1 + 1 * (FASTPOS_BITS - 1))) as u32; } (lzma_fastpos[(dist >> 14 / 2 - 1 + 2 * (FASTPOS_BITS - 1)) as usize] as u32) - .wrapping_add((2 * (14 / 2 - 1 + 2 * (FASTPOS_BITS - 1))) as u32) + + (2 * (14 / 2 - 1 + 2 * (FASTPOS_BITS - 1))) as u32 } -unsafe extern "C" fn get_literal_price( +unsafe fn get_literal_price( coder: *const lzma_lzma1_encoder, pos: u32, prev_byte: u32, @@ -46,25 +46,23 @@ unsafe extern "C" fn get_literal_price( mut match_byte: u32, mut symbol: u32, ) -> u32 { - let subcoder: *const probability = (::core::ptr::addr_of!((*coder).literal) - as *const probability) - .offset((3u32).wrapping_mul( - ((pos << 8).wrapping_add(prev_byte) & (*coder).literal_mask) - << (*coder).literal_context_bits, - ) as isize); + let subcoder: *const probability = + (::core::ptr::addr_of!((*coder).literal) as *const probability).offset( + (3u32 * (((pos << 8) + prev_byte) & (*coder).literal_mask) + << (*coder).literal_context_bits) as isize, + ); let mut price: u32 = 0; if !match_mode { price = rc_bittree_price(subcoder, 8, symbol); } else { let mut offset: u32 = 0x100; - symbol = (symbol as u32).wrapping_add(1u32 << 8) as u32; + symbol += 1u32 << 8; loop { match_byte <<= 1; let match_bit: u32 = match_byte & offset; - let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol >> 8); + let subcoder_index: u32 = offset + match_bit + (symbol >> 8); let bit: u32 = symbol >> 7 & 1; - price = - price.wrapping_add(rc_bit_price(*subcoder.offset(subcoder_index as isize), bit)); + price += rc_bit_price(*subcoder.offset(subcoder_index as isize), bit); symbol <<= 1; offset &= !(match_byte ^ symbol); if symbol >= 1 << 16 { @@ -75,23 +73,23 @@ unsafe extern "C" fn get_literal_price( price } #[inline] -extern "C" fn get_len_price(lencoder: *const lzma_length_encoder, len: u32, pos_state: u32) -> u32 { - unsafe { (*lencoder).prices[pos_state as usize][len.wrapping_sub(MATCH_LEN_MIN) as usize] } +fn get_len_price(lencoder: *const lzma_length_encoder, len: u32, pos_state: u32) -> u32 { + debug_assert!(len >= MATCH_LEN_MIN); + unsafe { (*lencoder).prices[pos_state as usize][(len - MATCH_LEN_MIN) as usize] } } #[inline] -extern "C" fn get_short_rep_price( +fn get_short_rep_price( coder: *const lzma_lzma1_encoder, state: lzma_lzma_state, pos_state: u32, ) -> u32 { unsafe { - rc_bit_0_price((*coder).is_rep0[state as usize]).wrapping_add(rc_bit_0_price( - (*coder).is_rep0_long[state as usize][pos_state as usize], - )) + rc_bit_0_price((*coder).is_rep0[state as usize]) + + rc_bit_0_price((*coder).is_rep0_long[state as usize][pos_state as usize]) } } #[inline] -extern "C" fn get_pure_rep_price( +fn get_pure_rep_price( coder: *const lzma_lzma1_encoder, rep_index: u32, state: lzma_lzma_state, @@ -101,26 +99,22 @@ extern "C" fn get_pure_rep_price( let mut price: u32 = 0; if rep_index == 0 { price = rc_bit_0_price((*coder).is_rep0[state as usize]); - price = price.wrapping_add(rc_bit_1_price( - (*coder).is_rep0_long[state as usize][pos_state as usize], - )); + price += rc_bit_1_price((*coder).is_rep0_long[state as usize][pos_state as usize]); } else { price = rc_bit_1_price((*coder).is_rep0[state as usize]); if rep_index == 1 { - price = price.wrapping_add(rc_bit_0_price((*coder).is_rep1[state as usize])); + price += rc_bit_0_price((*coder).is_rep1[state as usize]); } else { - price = price.wrapping_add(rc_bit_1_price((*coder).is_rep1[state as usize])); - price = price.wrapping_add(rc_bit_price( - (*coder).is_rep2[state as usize], - rep_index.wrapping_sub(2), - )); + debug_assert!(rep_index >= 2); + price += rc_bit_1_price((*coder).is_rep1[state as usize]); + price += rc_bit_price((*coder).is_rep2[state as usize], rep_index - 2); } } price }; } #[inline] -extern "C" fn get_rep_price( +fn get_rep_price( coder: *const lzma_lzma1_encoder, rep_index: u32, len: u32, @@ -132,12 +126,11 @@ extern "C" fn get_rep_price( ::core::ptr::addr_of!((*coder).rep_len_encoder), len, pos_state, - ) - .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state)) + ) + get_pure_rep_price(coder, rep_index, state, pos_state) } } #[inline] -extern "C" fn get_dist_len_price( +fn get_dist_len_price( coder: *const lzma_lzma1_encoder, dist: u32, len: u32, @@ -145,7 +138,8 @@ extern "C" fn get_dist_len_price( ) -> u32 { return unsafe { let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN) + debug_assert!(len >= MATCH_LEN_MIN); + len - MATCH_LEN_MIN } else { (DIST_STATES - 1) as u32 }; @@ -155,17 +149,17 @@ extern "C" fn get_dist_len_price( } else { let dist_slot: u32 = get_dist_slot_2(dist) as u32; price = (*coder).dist_slot_prices[dist_state as usize][dist_slot as usize] - .wrapping_add((*coder).align_prices[(dist & ALIGN_MASK) as usize]); + + (*coder).align_prices[(dist & ALIGN_MASK) as usize]; } - price = price.wrapping_add(get_len_price( + price += get_len_price( ::core::ptr::addr_of!((*coder).match_len_encoder), len, pos_state, - )); + ); price }; } -unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { +unsafe fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { let mut dist_state: u32 = 0; while dist_state < DIST_STATES { let dist_slot_prices: *mut u32 = @@ -185,10 +179,8 @@ unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { } let mut dist_slot_0: u32 = DIST_MODEL_END; while dist_slot_0 < (*coder).dist_table_size { - *dist_slot_prices.offset(dist_slot_0 as isize) = - (*dist_slot_prices.offset(dist_slot_0 as isize)).wrapping_add(rc_direct_price( - (dist_slot_0 >> 1).wrapping_sub(1).wrapping_sub(ALIGN_BITS), - )); + *dist_slot_prices.offset(dist_slot_0 as isize) += + rc_direct_price(((dist_slot_0 >> 1) - 1) - ALIGN_BITS); dist_slot_0 += 1; } let mut i: u32 = 0; @@ -202,7 +194,7 @@ unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { let mut i_0: u32 = DIST_MODEL_START; while i_0 < FULL_DISTANCES { let dist_slot_1: u32 = get_dist_slot(i_0) as u32; - let footer_bits: u32 = (dist_slot_1 >> 1).wrapping_sub(1); + let footer_bits: u32 = (dist_slot_1 >> 1) - 1; let base: u32 = (2 | dist_slot_1 & 1) << footer_bits; let price: u32 = rc_bittree_reverse_price( (::core::ptr::addr_of_mut!((*coder).dist_special) as *mut probability) @@ -210,20 +202,19 @@ unsafe extern "C" fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { .offset(-(dist_slot_1 as isize)) .offset(-1), footer_bits, - i_0.wrapping_sub(base), + i_0 - base, ) as u32; let mut dist_state_0: u32 = 0; while dist_state_0 < DIST_STATES { - (*coder).dist_prices[dist_state_0 as usize][i_0 as usize] = price.wrapping_add( - (*coder).dist_slot_prices[dist_state_0 as usize][dist_slot_1 as usize], - ); + (*coder).dist_prices[dist_state_0 as usize][i_0 as usize] = + price + (*coder).dist_slot_prices[dist_state_0 as usize][dist_slot_1 as usize]; dist_state_0 += 1; } i_0 += 1; } (*coder).match_price_count = 0; } -unsafe extern "C" fn fill_align_prices(coder: *mut lzma_lzma1_encoder) { +unsafe fn fill_align_prices(coder: *mut lzma_lzma1_encoder) { let mut i: u32 = 0; while i < ALIGN_SIZE { (*coder).align_prices[i as usize] = rc_bittree_reverse_price( @@ -236,12 +227,12 @@ unsafe extern "C" fn fill_align_prices(coder: *mut lzma_lzma1_encoder) { (*coder).align_price_count = 0; } #[inline] -unsafe extern "C" fn make_literal(optimal: *mut lzma_optimal) { +unsafe fn make_literal(optimal: *mut lzma_optimal) { (*optimal).back_prev = UINT32_MAX; (*optimal).prev_1_is_literal = false; } #[inline] -unsafe extern "C" fn make_short_rep(optimal: *mut lzma_optimal) { +unsafe fn make_short_rep(optimal: *mut lzma_optimal) { (*optimal).back_prev = 0; (*optimal).prev_1_is_literal = false; } diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index a3f147bc..753721c5 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -563,8 +563,8 @@ pub struct lzma_outq { pub bufs_allocated: u32, pub bufs_limit: u32, } -pub use crate::common::index::{lzma_index_s, lzma_index}; -pub use crate::common::index_hash::{lzma_index_hash_s, lzma_index_hash}; +pub use crate::common::index::{lzma_index, lzma_index_s}; +pub use crate::common::index_hash::{lzma_index_hash, lzma_index_hash_s}; #[derive(Copy, Clone)] #[repr(C)] pub struct lzma_lzma1_encoder_s { @@ -1057,37 +1057,61 @@ pub struct lzma_simple_coder { pub size: size_t, pub buffer: [u8; 0], } -pub use crate::common::common::{lzma_alloc, lzma_alloc_zero, lzma_free, lzma_next_end, lzma_next_filter_init, lzma_next_filter_update, lzma_strm_init, lzma_end, lzma_bufcpy}; +pub use crate::check::check::{ + lzma_check_finish, lzma_check_init, lzma_check_is_supported, lzma_check_size, lzma_check_update, +}; pub use crate::check::crc32_fast::lzma_crc32; -pub use crate::common::block_util::lzma_block_unpadded_size; -pub use crate::check::check::{lzma_check_is_supported, lzma_check_size, lzma_check_init, lzma_check_update, lzma_check_finish}; -pub use crate::common::vli_size::lzma_vli_size; -pub use crate::common::vli_decoder::lzma_vli_decode; -pub use crate::common::stream_flags_common::lzma_stream_flags_compare; -pub use crate::common::easy_preset::lzma_easy_preset; -pub use crate::common::filter_common::{lzma_filters_free, lzma_filters_copy, lzma_raw_coder_init, lzma_raw_coder_memusage}; -pub use crate::simple::simple_coder::lzma_simple_coder_init; -pub use crate::common::vli_encoder::lzma_vli_encode; -pub use crate::common::stream_flags_encoder::{lzma_stream_header_encode, lzma_stream_footer_encode}; -pub use crate::common::stream_flags_decoder::{lzma_stream_header_decode, lzma_stream_footer_decode}; -pub use crate::common::block_header_encoder::{lzma_block_header_size, lzma_block_header_encode}; -pub use crate::common::block_header_decoder::lzma_block_header_decode; pub use crate::common::block_decoder::lzma_block_decoder_init; pub use crate::common::block_encoder::lzma_block_encoder_init; +pub use crate::common::block_header_decoder::lzma_block_header_decode; +pub use crate::common::block_header_encoder::{lzma_block_header_encode, lzma_block_header_size}; +pub use crate::common::block_util::lzma_block_unpadded_size; +pub use crate::common::common::{ + lzma_alloc, lzma_alloc_zero, lzma_bufcpy, lzma_end, lzma_free, lzma_next_end, + lzma_next_filter_init, lzma_next_filter_update, lzma_strm_init, +}; +pub use crate::common::easy_preset::lzma_easy_preset; +pub use crate::common::filter_common::{ + lzma_filters_copy, lzma_filters_free, lzma_raw_coder_init, lzma_raw_coder_memusage, +}; +pub use crate::common::filter_decoder::{lzma_raw_decoder_init, lzma_raw_decoder_memusage}; pub use crate::common::filter_encoder::{lzma_raw_encoder_init, lzma_raw_encoder_memusage}; -pub use crate::common::filter_decoder::{lzma_raw_decoder_memusage, lzma_raw_decoder_init}; -pub use crate::lzma::lzma_encoder::{lzma_lzma_encoder_init, lzma_lzma_lclppb_encode, lzma_lzma_encoder_memusage}; -pub use crate::lzma::lzma_decoder::{lzma_lzma_decoder_init, lzma_lzma_lclppb_decode, lzma_lzma_decoder_memusage_nocheck}; -pub use crate::delta::delta_common::{lzma_delta_coder_memusage, lzma_delta_coder_init}; +pub use crate::common::index::{ + lzma_index_append, lzma_index_end, lzma_index_init, lzma_index_memusage, + lzma_index_padding_size, lzma_index_size, +}; +pub use crate::common::index_encoder::lzma_index_encoder_init; +pub use crate::common::index_hash::{ + lzma_index_hash_append, lzma_index_hash_decode, lzma_index_hash_end, lzma_index_hash_init, + lzma_index_hash_size, +}; +pub use crate::common::outqueue::{ + lzma_outq_end, lzma_outq_get_buf, lzma_outq_init, lzma_outq_is_readable, + lzma_outq_prealloc_buf, lzma_outq_read, +}; pub use crate::common::stream_decoder::lzma_stream_decoder_init; -pub use crate::lzma::lzma_encoder_presets::lzma_lzma_preset; +pub use crate::common::stream_flags_common::lzma_stream_flags_compare; +pub use crate::common::stream_flags_decoder::{ + lzma_stream_footer_decode, lzma_stream_header_decode, +}; +pub use crate::common::stream_flags_encoder::{ + lzma_stream_footer_encode, lzma_stream_header_encode, +}; +pub use crate::common::vli_decoder::lzma_vli_decode; +pub use crate::common::vli_encoder::lzma_vli_encode; +pub use crate::common::vli_size::lzma_vli_size; +pub use crate::delta::delta_common::{lzma_delta_coder_init, lzma_delta_coder_memusage}; pub use crate::lz::lz_encoder_mf::lzma_mf_find; -pub use crate::common::index::{lzma_index_memusage, lzma_index_init, lzma_index_end, lzma_index_append, lzma_index_size, lzma_index_padding_size}; -pub use crate::common::index_encoder::lzma_index_encoder_init; -pub use crate::common::index_hash::{lzma_index_hash_init, lzma_index_hash_end, lzma_index_hash_append, lzma_index_hash_decode, lzma_index_hash_size}; -pub use crate::common::outqueue::{lzma_outq_init, lzma_outq_end, lzma_outq_prealloc_buf, lzma_outq_get_buf, lzma_outq_is_readable, lzma_outq_read}; -pub use crate::rangecoder::price_table::lzma_rc_prices; pub use crate::lzma::fastpos_table::lzma_fastpos; +pub use crate::lzma::lzma_decoder::{ + lzma_lzma_decoder_init, lzma_lzma_decoder_memusage_nocheck, lzma_lzma_lclppb_decode, +}; +pub use crate::lzma::lzma_encoder::{ + lzma_lzma_encoder_init, lzma_lzma_encoder_memusage, lzma_lzma_lclppb_encode, +}; +pub use crate::lzma::lzma_encoder_presets::lzma_lzma_preset; +pub use crate::rangecoder::price_table::lzma_rc_prices; +pub use crate::simple::simple_coder::lzma_simple_coder_init; extern "C" { pub fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> c_int; pub fn pthread_cond_destroy(_: *mut pthread_cond_t) -> c_int; From 00f31b8a5f7d21585db9dcb3c7030865b0553c15 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 15 Mar 2026 22:15:23 +0900 Subject: [PATCH 17/51] Add dual backend support (rust-backend/c-backend) with feature flags --- src/lib.rs | 12 ++++++++++-- src/stream.rs | 2 +- tests/sys_equivalence.rs | 8 ++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2f2b874f..994a4845 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,6 +52,14 @@ #![doc(html_root_url = "https://docs.rs/liblzma/0.4.6")] #![deny(missing_docs)] +#[cfg(not(any(feature = "rust-backend", feature = "c-backend")))] +compile_error!("Either `rust-backend` or `c-backend` feature must be enabled"); + +// When c-backend is active (without rust-backend), alias liblzma_c_sys +// so that internal `liblzma_sys::` references resolve to the C library. +#[cfg(all(feature = "c-backend", not(feature = "rust-backend")))] +extern crate liblzma_c_sys as liblzma_sys; + use std::io::{self, prelude::*}; pub mod stream; @@ -103,7 +111,7 @@ pub fn copy_decode(source: R, mut destination: W) -> io::Resu } /// Find the size in bytes of uncompressed data from xz file. -#[cfg(feature = "bindgen")] +#[cfg(any(feature = "rust-backend", feature = "bindgen"))] pub fn uncompressed_size(mut source: R) -> io::Result { use std::mem::MaybeUninit; let mut footer = [0u8; liblzma_sys::LZMA_STREAM_HEADER_SIZE as usize]; @@ -205,7 +213,7 @@ mod tests { #[cfg(not(target_family = "wasm"))] #[test] - #[cfg(feature = "bindgen")] + #[cfg(any(feature = "rust-backend", feature = "bindgen"))] fn size() { quickcheck(test as fn(_) -> _); diff --git a/src/stream.rs b/src/stream.rs index 24c4bdf8..1ae9551e 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -490,7 +490,7 @@ impl Stream { /// This is only supported if the underlying stream supports a memlimit. #[inline] pub fn memlimit(&self) -> u64 { - liblzma_sys::lzma_memlimit_get(&self.raw) + unsafe { liblzma_sys::lzma_memlimit_get(&self.raw) } } /// Set the current memory usage limit. diff --git a/tests/sys_equivalence.rs b/tests/sys_equivalence.rs index 7192e1b8..9c92e038 100644 --- a/tests/sys_equivalence.rs +++ b/tests/sys_equivalence.rs @@ -1,11 +1,15 @@ -#![cfg(not(target_family = "wasm"))] +#![cfg(all( + not(target_family = "wasm"), + feature = "rust-backend", + feature = "c-backend" +))] use std::collections::BTreeMap; use std::fs; use std::path::Path; use std::ptr; -use liblzma_c_sys_test as c_sys; +use liblzma_c_sys as c_sys; use liblzma_sys as rs_sys; fn parse_feature_table(cargo_toml: &str) -> BTreeMap> { From 0a127ea2fc5acb9b00d83d16c752fd34a4ce492b Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 15 Mar 2026 22:16:03 +0900 Subject: [PATCH 18/51] refactor: simplify encoder/decoder control flow --- liblzma-rs/src/common/stream_decoder.rs | 14 ++-- liblzma-rs/src/common/stream_encoder.rs | 58 +++++--------- .../src/lzma/lzma_encoder_optimum_normal.rs | 80 ++++++++----------- 3 files changed, 58 insertions(+), 94 deletions(-) diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 995e4575..7ef3bdfc 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -26,7 +26,7 @@ pub const SEQ_BLOCK_RUN: stream_decoder_seq = 3; pub const SEQ_BLOCK_INIT: stream_decoder_seq = 2; pub const SEQ_BLOCK_HEADER: stream_decoder_seq = 1; pub const SEQ_STREAM_HEADER: stream_decoder_seq = 0; -unsafe extern "C" fn stream_decoder_reset( +unsafe fn stream_decoder_reset( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { @@ -132,10 +132,8 @@ unsafe extern "C" fn stream_decode( (*coder).sequence = SEQ_INDEX; current_block_100 = 16789764818708874114; } else { - (*coder).block_options.header_size = (*in_0.offset(*in_pos as isize) - as u32) - .wrapping_add(1) - .wrapping_mul(4); + (*coder).block_options.header_size = + ((*in_0.offset(*in_pos as isize) as u32) + 1) * 4; current_block_100 = 13242334135786603907; } } else { @@ -238,11 +236,11 @@ unsafe extern "C" fn stream_decode( if *in_0.offset(*in_pos as isize) != 0 { break; } - *in_pos = (*in_pos).wrapping_add(1); - (*coder).pos = (*coder).pos.wrapping_add(1) & 3; + *in_pos += 1; + (*coder).pos = ((*coder).pos + 1) & 3; } if (*coder).pos != 0 { - *in_pos = (*in_pos).wrapping_add(1); + *in_pos += 1; return LZMA_DATA_ERROR; } let ret__2: lzma_ret = stream_decoder_reset(coder, allocator); diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 9eaa91da..be85eb3c 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -20,7 +20,7 @@ pub const SEQ_BLOCK_ENCODE: stream_encoder_seq = 3; pub const SEQ_BLOCK_HEADER: stream_encoder_seq = 2; pub const SEQ_BLOCK_INIT: stream_encoder_seq = 1; pub const SEQ_STREAM_HEADER: stream_encoder_seq = 0; -unsafe extern "C" fn block_encoder_init( +unsafe fn block_encoder_init( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { @@ -207,16 +207,16 @@ unsafe extern "C" fn stream_encoder_update( filters: *const lzma_filter, reversed_filters: *const lzma_filter, ) -> lzma_ret { - let current_block: u64; let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - let mut ret: lzma_ret = LZMA_OK; let mut temp: [lzma_filter; 5] = [lzma_filter { id: 0, options: core::ptr::null_mut(), }; 5]; + let temp_ptr = ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter; + let filters_ptr = ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter; let ret_: lzma_ret = lzma_filters_copy( filters, - ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter, + temp_ptr, allocator, ); if ret_ != LZMA_OK { @@ -224,53 +224,33 @@ unsafe extern "C" fn stream_encoder_update( } if (*coder).sequence <= SEQ_BLOCK_INIT { (*coder).block_encoder_is_initialized = false; - (*coder).block_options.filters = ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter; - ret = block_encoder_init(coder, allocator); - (*coder).block_options.filters = - ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter; + (*coder).block_options.filters = temp_ptr; + let ret = block_encoder_init(coder, allocator); + (*coder).block_options.filters = filters_ptr; if ret != LZMA_OK { - current_block = 9913398440939854562; - } else { - (*coder).block_encoder_is_initialized = true; - current_block = 8236137900636309791; + lzma_filters_free(temp_ptr, allocator); + return ret; } + (*coder).block_encoder_is_initialized = true; } else if (*coder).sequence <= SEQ_BLOCK_ENCODE { - ret = (*coder).block_encoder.update.unwrap()( + let ret = (*coder).block_encoder.update.unwrap()( (*coder).block_encoder.coder, allocator, filters, reversed_filters, ); if ret != LZMA_OK { - current_block = 9913398440939854562; - } else { - current_block = 8236137900636309791; + lzma_filters_free(temp_ptr, allocator); + return ret; } } else { - ret = LZMA_PROG_ERROR; - current_block = 9913398440939854562; + lzma_filters_free(temp_ptr, allocator); + return LZMA_PROG_ERROR; } - match current_block { - 9913398440939854562 => { - lzma_filters_free( - ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter, - allocator, - ); - return ret; - } - _ => { - lzma_filters_free( - ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, - allocator, - ); - core::ptr::copy_nonoverlapping( - ::core::ptr::addr_of_mut!(temp) as *const u8, - ::core::ptr::addr_of_mut!((*coder).filters) as *mut u8, - core::mem::size_of::<[lzma_filter; 5]>(), - ); - return LZMA_OK; - } - }; + + lzma_filters_free(filters_ptr, allocator); + (*coder).filters = temp; + LZMA_OK } unsafe extern "C" fn stream_encoder_init( next: *mut lzma_next_coder, diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index d1176365..b941d8b0 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -1,3 +1,4 @@ +use crate::lzma::lzma_encoder::MATCH_LEN_MAX; use crate::types::*; pub const RC_BIT_PRICE_SHIFT_BITS: u32 = 4; pub const RC_INFINITY_PRICE: c_uint = 1u32 << 30; @@ -236,7 +237,7 @@ unsafe fn make_short_rep(optimal: *mut lzma_optimal) { (*optimal).back_prev = 0; (*optimal).prev_1_is_literal = false; } -unsafe extern "C" fn backward( +unsafe fn backward( coder: *mut lzma_lzma1_encoder, len_res: *mut u32, back_res: *mut u32, @@ -251,12 +252,14 @@ unsafe extern "C" fn backward( (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal) .offset(pos_mem as isize) as *mut lzma_optimal, ); - (*coder).opts[pos_mem as usize].pos_prev = pos_mem.wrapping_sub(1); + debug_assert!(pos_mem > 0); + let literal_pos_prev = pos_mem - 1; + (*coder).opts[pos_mem as usize].pos_prev = literal_pos_prev; if (*coder).opts[cur as usize].prev_2 { - (*coder).opts[pos_mem.wrapping_sub(1) as usize].prev_1_is_literal = false; - (*coder).opts[pos_mem.wrapping_sub(1) as usize].pos_prev = + (*coder).opts[literal_pos_prev as usize].prev_1_is_literal = false; + (*coder).opts[literal_pos_prev as usize].pos_prev = (*coder).opts[cur as usize].pos_prev_2; - (*coder).opts[pos_mem.wrapping_sub(1) as usize].back_prev = + (*coder).opts[literal_pos_prev as usize].back_prev = (*coder).opts[cur as usize].back_prev_2; } } @@ -276,7 +279,7 @@ unsafe extern "C" fn backward( *back_res = (*coder).opts[0].back_prev; } #[inline] -unsafe extern "C" fn helper1( +unsafe fn helper1( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, back_res: *mut u32, @@ -293,15 +296,11 @@ unsafe extern "C" fn helper1( ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, ); } else { + debug_assert!((*mf).read_ahead == 1); len_main = (*coder).longest_match_length; matches_count = (*coder).matches_count; } - let buf_avail: u32 = - if mf_avail(mf).wrapping_add(1) < (2 + ((1 << 3) + (1 << 3) + (1 << 8)) - 1) as u32 { - (mf_avail(mf) as u32).wrapping_add(1) - } else { - (2 + ((1 << 3) + (1 << 3) + (1 << 8)) - 1) as u32 - }; + let buf_avail: u32 = core::cmp::min(mf_avail(mf) + 1, MATCH_LEN_MAX); if buf_avail < 2 { *back_res = UINT32_MAX; *len_res = 1; @@ -326,15 +325,14 @@ unsafe extern "C" fn helper1( if rep_lens[rep_max_index as usize] >= nice_len { *back_res = rep_max_index; *len_res = rep_lens[rep_max_index as usize]; - mf_skip(mf, (*len_res).wrapping_sub(1)); + mf_skip(mf, *len_res - 1); return UINT32_MAX; } if len_main >= nice_len { - *back_res = (*coder).matches[matches_count.wrapping_sub(1) as usize] - .dist - .wrapping_add(REPS); + debug_assert!(matches_count > 0); + *back_res = (*coder).matches[(matches_count - 1) as usize].dist + REPS; *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(1)); + mf_skip(mf, len_main - 1); return UINT32_MAX; } let current_byte: u8 = *buf; @@ -348,14 +346,14 @@ unsafe extern "C" fn helper1( let pos_state: u32 = position & (*coder).pos_mask; (*coder).opts[1].price = rc_bit_0_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) - .wrapping_add(get_literal_price( + + get_literal_price( coder, position, *buf.offset(-1) as u32, !(((*coder).state as u32) < LIT_STATES), match_byte as u32, current_byte as u32, - )); + ); make_literal( (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal).offset(1) as *mut lzma_optimal, @@ -363,11 +361,10 @@ unsafe extern "C" fn helper1( let match_price: u32 = rc_bit_1_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) as u32; let rep_match_price: u32 = - match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[(*coder).state as usize]) as u32); + match_price + rc_bit_1_price((*coder).is_rep[(*coder).state as usize]) as u32; if match_byte == current_byte { let short_rep_price: u32 = - rep_match_price - .wrapping_add(get_short_rep_price(coder, (*coder).state, pos_state) as u32); + rep_match_price + get_short_rep_price(coder, (*coder).state, pos_state) as u32; if short_rep_price < (*coder).opts[1].price { (*coder).opts[1].price = short_rep_price; make_short_rep( @@ -376,11 +373,7 @@ unsafe extern "C" fn helper1( ); } } - let len_end: u32 = if len_main > rep_lens[rep_max_index as usize] { - len_main - } else { - rep_lens[rep_max_index as usize] - }; + let len_end: u32 = core::cmp::max(len_main, rep_lens[rep_max_index as usize]); if len_end < 2 { *back_res = (*coder).opts[1].back_prev; *len_res = 1; @@ -404,18 +397,15 @@ unsafe extern "C" fn helper1( while i_1 < REPS { let mut rep_len: u32 = rep_lens[i_1 as usize]; if rep_len >= 2 { - let price: u32 = rep_match_price.wrapping_add(get_pure_rep_price( - coder, - i_1, - (*coder).state, - pos_state, - ) as u32); + let price: u32 = + rep_match_price + get_pure_rep_price(coder, i_1, (*coder).state, pos_state) as u32; loop { - let cur_and_len_price: u32 = price.wrapping_add(get_len_price( - ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), - rep_len, - pos_state, - ) as u32); + let cur_and_len_price: u32 = price + + get_len_price( + ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), + rep_len, + pos_state, + ) as u32; if cur_and_len_price < (*coder).opts[rep_len as usize].price { (*coder).opts[rep_len as usize].price = cur_and_len_price; (*coder).opts[rep_len as usize].pos_prev = 0; @@ -431,12 +421,8 @@ unsafe extern "C" fn helper1( i_1 += 1; } let normal_match_price: u32 = - match_price.wrapping_add(rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as u32); - len = if rep_lens[0] >= 2 { - rep_lens[0].wrapping_add(1) - } else { - 2 - }; + match_price + rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as u32; + len = if rep_lens[0] >= 2 { rep_lens[0] + 1 } else { 2 }; if len <= len_main { let mut i_2: u32 = 0; while len > (*coder).matches[i_2 as usize].len { @@ -444,12 +430,12 @@ unsafe extern "C" fn helper1( } loop { let dist: u32 = (*coder).matches[i_2 as usize].dist; - let cur_and_len_price_0: u32 = normal_match_price - .wrapping_add(get_dist_len_price(coder, dist, len, pos_state) as u32); + let cur_and_len_price_0: u32 = + normal_match_price + get_dist_len_price(coder, dist, len, pos_state) as u32; if cur_and_len_price_0 < (*coder).opts[len as usize].price { (*coder).opts[len as usize].price = cur_and_len_price_0; (*coder).opts[len as usize].pos_prev = 0; - (*coder).opts[len as usize].back_prev = dist.wrapping_add(REPS); + (*coder).opts[len as usize].back_prev = dist + REPS; (*coder).opts[len as usize].prev_1_is_literal = false; } if len == (*coder).matches[i_2 as usize].len { From 49169c9a68b5174a82e690a68e8a01500887aca4 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Tue, 17 Mar 2026 20:41:38 +0900 Subject: [PATCH 19/51] perf: optimize match finder and optimum normal paths --- liblzma-rs/src/lz/lz_encoder_mf.rs | 91 +++++---- .../src/lzma/lzma_encoder_optimum_normal.rs | 174 +++++++----------- liblzma-rs/src/types.rs | 17 ++ 3 files changed, 132 insertions(+), 150 deletions(-) diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 96189b27..aae4f0d6 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -32,8 +32,9 @@ pub unsafe extern "C" fn lzma_mf_find( } pub const EMPTY_HASH_VALUE: u32 = 0; pub const MUST_NORMALIZE_POS: c_uint = UINT32_MAX; -#[inline] -unsafe extern "C" fn normalize(mf: *mut lzma_mf) { +#[cold] +#[inline(never)] +unsafe fn normalize(mf: *mut lzma_mf) { let subvalue: u32 = MUST_NORMALIZE_POS.wrapping_sub((*mf).cyclic_size); let mut i: u32 = 0; while i < (*mf).hash_count { @@ -58,7 +59,7 @@ unsafe extern "C" fn normalize(mf: *mut lzma_mf) { (*mf).offset = (*mf).offset.wrapping_sub(subvalue); } #[inline(always)] -unsafe extern "C" fn move_pos(mf: *mut lzma_mf) { +unsafe fn move_pos(mf: *mut lzma_mf) { (*mf).cyclic_pos = (*mf).cyclic_pos.wrapping_add(1); if (*mf).cyclic_pos == (*mf).cyclic_size { (*mf).cyclic_pos = 0; @@ -69,12 +70,12 @@ unsafe extern "C" fn move_pos(mf: *mut lzma_mf) { } } #[inline(always)] -unsafe extern "C" fn move_pending(mf: *mut lzma_mf) { +unsafe fn move_pending(mf: *mut lzma_mf) { (*mf).read_pos = (*mf).read_pos.wrapping_add(1); (*mf).pending = (*mf).pending.wrapping_add(1); } #[inline] -unsafe extern "C" fn hc_find_func( +unsafe fn hc_find_func( len_limit: u32, pos: u32, cur: *const u8, @@ -303,7 +304,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { } } #[inline] -unsafe extern "C" fn bt_find_func( +unsafe fn bt_find_func( len_limit: u32, pos: u32, cur: *const u8, @@ -364,7 +365,7 @@ unsafe extern "C" fn bt_find_func( } } #[inline] -unsafe extern "C" fn bt_skip_func( +unsafe fn bt_skip_func( len_limit: u32, pos: u32, cur: *const u8, @@ -682,53 +683,49 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m } #[inline] pub unsafe extern "C" fn lzma_mf_bt4_skip(mf: *mut lzma_mf, mut amount: u32) { - let mut current_block_10: u64; + debug_assert!(amount > 0); loop { let mut len_limit: u32 = mf_avail(mf); if (*mf).nice_len <= len_limit { len_limit = (*mf).nice_len; - current_block_10 = 11875828834189669668; - } else if len_limit < 4 || true && (*mf).action == LZMA_SYNC_FLUSH { + } else if len_limit < 4 || (*mf).action == LZMA_SYNC_FLUSH { move_pending(mf); - current_block_10 = 18088007599891946824; - } else { - current_block_10 = 11875828834189669668; - } - match current_block_10 { - 11875828834189669668 => { - let cur: *const u8 = mf_ptr(mf); - let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); - let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; - let hash_2_value: u32 = temp & HASH_2_MASK as u32; - let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; - let hash_value: u32 = (temp - ^ (*cur.offset(2) as u32) << 8 - ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) - & (*mf).hash_mask; - let cur_match: u32 = *(*mf) - .hash - .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize); - *(*mf).hash.offset(hash_2_value as isize) = pos; - *(*mf) - .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize) = pos; - *(*mf) - .hash - .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; - bt_skip_func( - len_limit, - pos, - cur, - cur_match, - (*mf).depth, - (*mf).son, - (*mf).cyclic_pos, - (*mf).cyclic_size, - ); - move_pos(mf); + amount -= 1; + if amount == 0 { + break; } - _ => {} + continue; } + + let cur: *const u8 = mf_ptr(mf); + let pos: u32 = (*mf).read_pos.wrapping_add((*mf).offset); + let temp: u32 = lzma_crc32_table[0][*cur as usize] ^ *cur.offset(1) as u32; + let hash_2_value: u32 = temp & HASH_2_MASK as u32; + let hash_3_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & HASH_3_MASK as u32; + let hash_value: u32 = (temp + ^ (*cur.offset(2) as u32) << 8 + ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) + & (*mf).hash_mask; + let hash_3_index = FIX_3_HASH_SIZE as u32 + hash_3_value; + let hash_4_index = FIX_4_HASH_SIZE as u32 + hash_value; + let cur_match: u32 = *(*mf).hash.offset(hash_4_index as isize); + + *(*mf).hash.offset(hash_2_value as isize) = pos; + *(*mf).hash.offset(hash_3_index as isize) = pos; + *(*mf).hash.offset(hash_4_index as isize) = pos; + + bt_skip_func( + len_limit, + pos, + cur, + cur_match, + (*mf).depth, + (*mf).son, + (*mf).cyclic_pos, + (*mf).cyclic_size, + ); + move_pos(mf); + amount -= 1; if amount == 0 { break; diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index b941d8b0..03ba01ee 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -160,6 +160,48 @@ fn get_dist_len_price( price }; } +#[inline] +fn is_literal_state(state: lzma_lzma_state) -> bool { + state < LIT_STATES +} +#[inline] +fn update_literal_state(state: lzma_lzma_state) -> lzma_lzma_state { + if state <= STATE_SHORTREP_LIT_LIT { + STATE_LIT_LIT + } else if state <= STATE_LIT_SHORTREP { + state - 3 + } else { + state - 6 + } +} +#[inline] +fn update_match_state(state: lzma_lzma_state) -> lzma_lzma_state { + if is_literal_state(state) { + STATE_LIT_MATCH + } else { + STATE_NONLIT_MATCH + } +} +#[inline] +fn update_long_rep_state(state: lzma_lzma_state) -> lzma_lzma_state { + if is_literal_state(state) { + STATE_LIT_LONGREP + } else { + STATE_NONLIT_REP + } +} +#[inline] +fn update_short_rep_state(state: lzma_lzma_state) -> lzma_lzma_state { + if is_literal_state(state) { + STATE_LIT_SHORTREP + } else { + STATE_NONLIT_REP + } +} +#[inline] +unsafe fn not_equal_16(a: *const u8, b: *const u8) -> bool { + core::ptr::read_unaligned(a as *const u16) != core::ptr::read_unaligned(b as *const u16) +} unsafe fn fill_dist_prices(coder: *mut lzma_lzma1_encoder) { let mut dist_state: u32 = 0; while dist_state < DIST_STATES { @@ -312,7 +354,7 @@ unsafe fn helper1( let mut i: u32 = 0; while i < REPS { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); - if *buf != *buf_back || *buf.offset(1) != *buf_back.offset(1) { + if not_equal_16(buf, buf_back) { rep_lens[i as usize] = 0; } else { rep_lens[i as usize] = lzma_memcmplen(buf, buf_back, 2, buf_avail); @@ -450,7 +492,7 @@ unsafe fn helper1( len_end } #[inline] -unsafe extern "C" fn helper2( +unsafe fn helper2( coder: *mut lzma_lzma1_encoder, reps: *mut u32, buf: *const u8, @@ -469,71 +511,35 @@ unsafe extern "C" fn helper2( if (*coder).opts[cur as usize].prev_2 { state = (*coder).opts[(*coder).opts[cur as usize].pos_prev_2 as usize].state; if (*coder).opts[cur as usize].back_prev_2 < REPS { - state = (if (state as u32) < LIT_STATES { - STATE_LIT_LONGREP - } else { - STATE_NONLIT_REP - }) as lzma_lzma_state; + state = update_long_rep_state(state); } else { - state = (if (state as u32) < LIT_STATES { - STATE_LIT_MATCH - } else { - STATE_NONLIT_MATCH - }) as lzma_lzma_state; + state = update_match_state(state); } } else { state = (*coder).opts[pos_prev as usize].state; } - state = (if state <= STATE_SHORTREP_LIT_LIT { - STATE_LIT_LIT - } else if state <= STATE_LIT_SHORTREP { - (state as u32).wrapping_sub(3) - } else { - (state as u32).wrapping_sub(6) - }) as lzma_lzma_state; + state = update_literal_state(state); } else { state = (*coder).opts[pos_prev as usize].state; } if pos_prev == cur.wrapping_sub(1) { if (*coder).opts[cur as usize].back_prev == 0 { - state = (if (state as u32) < LIT_STATES { - STATE_LIT_SHORTREP - } else { - STATE_NONLIT_REP - }) as lzma_lzma_state; + state = update_short_rep_state(state); } else { - state = (if state <= STATE_SHORTREP_LIT_LIT { - STATE_LIT_LIT - } else if state <= STATE_LIT_SHORTREP { - (state as u32).wrapping_sub(3) - } else { - (state as u32).wrapping_sub(6) - }) as lzma_lzma_state; + state = update_literal_state(state); } } else { let mut pos: u32 = 0; if (*coder).opts[cur as usize].prev_1_is_literal && (*coder).opts[cur as usize].prev_2 { pos_prev = (*coder).opts[cur as usize].pos_prev_2; pos = (*coder).opts[cur as usize].back_prev_2; - state = (if (state as u32) < LIT_STATES { - STATE_LIT_LONGREP - } else { - STATE_NONLIT_REP - }) as lzma_lzma_state; + state = update_long_rep_state(state); } else { pos = (*coder).opts[cur as usize].back_prev; if pos < REPS { - state = (if (state as u32) < LIT_STATES { - STATE_LIT_LONGREP - } else { - STATE_NONLIT_REP - }) as lzma_lzma_state; + state = update_long_rep_state(state); } else { - state = (if (state as u32) < LIT_STATES { - STATE_LIT_MATCH - } else { - STATE_NONLIT_MATCH - }) as lzma_lzma_state; + state = update_match_state(state); } } if pos < REPS { @@ -575,18 +581,16 @@ unsafe extern "C" fn helper2( coder, position, *buf.offset(-1) as u32, - !((state as u32) < LIT_STATES), + !is_literal_state(state), match_byte as u32, current_byte as u32, ) as u32); + let next_opt = &mut (*coder).opts[cur.wrapping_add(1) as usize]; let mut next_is_literal: bool = false; - if cur_and_1_price < (*coder).opts[cur.wrapping_add(1) as usize].price { - (*coder).opts[cur.wrapping_add(1) as usize].price = cur_and_1_price; - (*coder).opts[cur.wrapping_add(1) as usize].pos_prev = cur; - make_literal( - (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal) - .offset(cur.wrapping_add(1) as isize) as *mut lzma_optimal, - ); + if cur_and_1_price < next_opt.price { + next_opt.price = cur_and_1_price; + next_opt.pos_prev = cur; + make_literal(next_opt); next_is_literal = true; } let match_price: u32 = cur_price @@ -594,18 +598,14 @@ unsafe extern "C" fn helper2( let rep_match_price: u32 = match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[state as usize]) as u32); if match_byte == current_byte - && !((*coder).opts[cur.wrapping_add(1) as usize].pos_prev < cur - && (*coder).opts[cur.wrapping_add(1) as usize].back_prev == 0) + && !(next_opt.pos_prev < cur && next_opt.back_prev == 0) { let short_rep_price: u32 = rep_match_price.wrapping_add(get_short_rep_price(coder, state, pos_state) as u32); - if short_rep_price <= (*coder).opts[cur.wrapping_add(1) as usize].price { - (*coder).opts[cur.wrapping_add(1) as usize].price = short_rep_price; - (*coder).opts[cur.wrapping_add(1) as usize].pos_prev = cur; - make_short_rep( - (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal) - .offset(cur.wrapping_add(1) as isize) as *mut lzma_optimal, - ); + if short_rep_price <= next_opt.price { + next_opt.price = short_rep_price; + next_opt.pos_prev = cur; + make_short_rep(next_opt); next_is_literal = true; } } @@ -625,15 +625,8 @@ unsafe extern "C" fn helper2( nice_len.wrapping_add(1) }; let len_test: u32 = (lzma_memcmplen(buf, buf_back, 1, limit) as u32).wrapping_sub(1); - if len_test >= 2 { - let mut state_2: lzma_lzma_state = state; - state_2 = (if state_2 <= STATE_SHORTREP_LIT_LIT { - STATE_LIT_LIT - } else if state_2 <= STATE_LIT_SHORTREP { - (state_2 as u32).wrapping_sub(3) - } else { - (state_2 as u32).wrapping_sub(6) - }) as lzma_lzma_state; + if len_test >= 2 { + let state_2: lzma_lzma_state = update_literal_state(state); let pos_state_next: u32 = position.wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price: u32 = cur_and_1_price .wrapping_add(rc_bit_1_price( @@ -667,7 +660,7 @@ unsafe extern "C" fn helper2( let buf_back_0: *const u8 = buf .offset(-(*reps.offset(rep_index as isize) as isize)) .offset(-1); - if *buf == *buf_back_0 && *buf.offset(1) == *buf_back_0.offset(1) { + if !not_equal_16(buf, buf_back_0) { let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2, buf_avail); while len_end < cur.wrapping_add(len_test_0) { len_end += 1; @@ -711,11 +704,7 @@ unsafe extern "C" fn helper2( len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1)); if len_test_2 >= 2 { let mut state_2_0: lzma_lzma_state = state; - state_2_0 = (if (state_2_0 as u32) < LIT_STATES { - STATE_LIT_LONGREP - } else { - STATE_NONLIT_REP - }) as lzma_lzma_state; + state_2_0 = update_long_rep_state(state_2_0); let mut pos_state_next_0: u32 = position.wrapping_add(len_test_0) & (*coder).pos_mask; let cur_and_len_literal_price: u32 = price @@ -735,13 +724,7 @@ unsafe extern "C" fn helper2( *buf_back_0.offset(len_test_0 as isize) as u32, *buf.offset(len_test_0 as isize) as u32, ) as u32); - state_2_0 = (if state_2_0 <= STATE_SHORTREP_LIT_LIT { - STATE_LIT_LIT - } else if state_2_0 <= STATE_LIT_SHORTREP { - (state_2_0 as u32).wrapping_sub(3) - } else { - (state_2_0 as u32).wrapping_sub(6) - }) as lzma_lzma_state; + state_2_0 = update_literal_state(state_2_0); pos_state_next_0 = position.wrapping_add(len_test_0).wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price_0: u32 = cur_and_len_literal_price @@ -825,11 +808,7 @@ unsafe extern "C" fn helper2( len_test_2_0 = len_test_2_0.wrapping_sub(len_test_1.wrapping_add(1)); if len_test_2_0 >= 2 { let mut state_2_1: lzma_lzma_state = state; - state_2_1 = (if (state_2_1 as u32) < LIT_STATES { - STATE_LIT_MATCH - } else { - STATE_NONLIT_MATCH - }) as lzma_lzma_state; + state_2_1 = update_match_state(state_2_1); let mut pos_state_next_1: u32 = position.wrapping_add(len_test_1) & (*coder).pos_mask; let cur_and_len_literal_price_0: u32 = cur_and_len_price_2 @@ -844,13 +823,7 @@ unsafe extern "C" fn helper2( *buf_back_1.offset(len_test_1 as isize) as u32, *buf.offset(len_test_1 as isize) as u32, ) as u32); - state_2_1 = (if state_2_1 <= STATE_SHORTREP_LIT_LIT { - STATE_LIT_LIT - } else if state_2_1 <= STATE_LIT_SHORTREP { - (state_2_1 as u32).wrapping_sub(3) - } else { - (state_2_1 as u32).wrapping_sub(6) - }) as lzma_lzma_state; + state_2_1 = update_literal_state(state_2_1); pos_state_next_1 = pos_state_next_1.wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price_1: u32 = cur_and_len_literal_price_0 .wrapping_add(rc_bit_1_price( @@ -920,12 +893,7 @@ pub unsafe extern "C" fn lzma_lzma_optimum_normal( if len_end == UINT32_MAX { return; } - let mut reps: [u32; 4] = [0; 4]; - core::ptr::copy_nonoverlapping( - ::core::ptr::addr_of_mut!((*coder).reps) as *const u8, - ::core::ptr::addr_of_mut!(reps) as *mut u8, - core::mem::size_of::<[u32; 4]>(), - ); + let mut reps: [u32; 4] = (*coder).reps; let mut cur: u32 = 0; cur = 1; while cur < len_end { diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 753721c5..53fe7b38 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -866,6 +866,23 @@ pub unsafe extern "C" fn lzma_memcmplen( mut len: u32, limit: u32, ) -> u32 { + debug_assert!(len <= limit); + debug_assert!(limit <= u32::MAX / 2); + + #[cfg(all( + target_endian = "little", + any(target_arch = "aarch64", target_arch = "x86_64") + ))] + while len + 8 <= limit { + let lhs = core::ptr::read_unaligned(buf1.add(len as usize) as *const u64); + let rhs = core::ptr::read_unaligned(buf2.add(len as usize) as *const u64); + let diff = lhs.wrapping_sub(rhs); + if diff != 0 { + return core::cmp::min(len + (diff.trailing_zeros() >> 3), limit); + } + len += 8; + } + while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { len += 1; } From a231b470525b648368b75041c38a266a3637334a Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Tue, 17 Mar 2026 21:49:10 +0900 Subject: [PATCH 20/51] review: guard wrapper callbacks and apply safety fixes --- liblzma-rs-sys/src/lib.rs | 2 +- liblzma-rs/src/check/check.rs | 32 +++++++++++++------ liblzma-rs/src/check/crc32_fast.rs | 2 +- liblzma-rs/src/common/auto_decoder.rs | 5 ++- liblzma-rs/src/common/block_buffer_decoder.rs | 6 +++- liblzma-rs/src/common/common.rs | 23 ++++++++++++- .../src/common/filter_buffer_decoder.rs | 8 +++-- .../src/common/filter_buffer_encoder.rs | 6 +++- liblzma-rs/src/common/filter_common.rs | 20 ++++++------ liblzma-rs/src/common/microlzma_encoder.rs | 10 ++++-- liblzma-rs/src/common/outqueue.rs | 6 +++- .../src/common/stream_buffer_decoder.rs | 12 +++++-- liblzma-rs/src/common/stream_encoder.rs | 10 ++---- liblzma-rs/src/common/string_conversion.rs | 9 ++---- liblzma-rs/src/lz/lz_decoder.rs | 8 ++++- liblzma-rs/src/lz/lz_encoder.rs | 8 ++++- .../src/lzma/lzma_encoder_optimum_normal.rs | 6 ++-- systest/Cargo.toml | 4 +-- 18 files changed, 122 insertions(+), 55 deletions(-) diff --git a/liblzma-rs-sys/src/lib.rs b/liblzma-rs-sys/src/lib.rs index 7f6b4454..dc0e191a 100644 --- a/liblzma-rs-sys/src/lib.rs +++ b/liblzma-rs-sys/src/lib.rs @@ -149,7 +149,7 @@ pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { } #[no_mangle] -pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { +pub unsafe extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { liblzma_rs::common::common::lzma_memlimit_get(strm.cast()) } diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index fe52f46b..0e0129f2 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -36,17 +36,21 @@ pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { check_sizes[type_0 as usize] as u32 } pub unsafe extern "C" fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check) { + if check.is_null() { + return; + } + match type_0 { - 1 => { + LZMA_CHECK_CRC32 => { (*check).state.crc32 = 0; } - 4 => { + LZMA_CHECK_CRC64 => { (*check).state.crc64 = 0; } - 10 => { + LZMA_CHECK_SHA256 => { lzma_sha256_init(check); } - 0 | _ => {} + LZMA_CHECK_NONE | _ => {} }; } pub unsafe extern "C" fn lzma_check_update( @@ -55,28 +59,36 @@ pub unsafe extern "C" fn lzma_check_update( buf: *const u8, size: size_t, ) { + if check.is_null() { + return; + } + match type_0 { - 1 => { + LZMA_CHECK_CRC32 => { (*check).state.crc32 = lzma_crc32(buf, size, (*check).state.crc32); } - 4 => { + LZMA_CHECK_CRC64 => { (*check).state.crc64 = lzma_crc64(buf, size, (*check).state.crc64); } - 10 => { + LZMA_CHECK_SHA256 => { lzma_sha256_update(buf, size, check); } _ => {} }; } pub unsafe extern "C" fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check) { + if check.is_null() { + return; + } + match type_0 { - 1 => { + LZMA_CHECK_CRC32 => { (*check).buffer.u32_0[0] = (*check).state.crc32; } - 4 => { + LZMA_CHECK_CRC64 => { (*check).buffer.u64_0[0] = (*check).state.crc64; } - 10 => { + LZMA_CHECK_SHA256 => { lzma_sha256_finish(check); } _ => {} diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index a3d23db2..36e387c7 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub static mut lzma_crc32_table: [[u32; 256]; 8] = [ +pub static lzma_crc32_table: [[u32; 256]; 8] = [ [ 0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0xedb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x9b64c2b, 0x7eb17cbd, 0xe7b82d07, diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 190ecb0a..0a70b471 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -70,7 +70,10 @@ unsafe extern "C" fn auto_decode( } match current_block_28 { 13935781298497728377 => { - let ret: lzma_ret = (*coder).next.code.unwrap()( + let Some(code) = (*coder).next.code else { + return LZMA_PROG_ERROR; + }; + let ret: lzma_ret = code( (*coder).next.coder, allocator, in_0, diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index c9d64911..9cb6b919 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -33,9 +33,13 @@ pub unsafe extern "C" fn lzma_block_buffer_decode( let mut ret: lzma_ret = lzma_block_decoder_init(::core::ptr::addr_of_mut!(block_decoder), allocator, block); if ret == LZMA_OK { + let Some(code) = block_decoder.code else { + lzma_next_end(::core::ptr::addr_of_mut!(block_decoder), allocator); + return LZMA_PROG_ERROR; + }; let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - ret = block_decoder.code.unwrap()( + ret = code( block_decoder.coder, allocator, in_0, diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index e3247266..94e9d826 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -127,6 +127,10 @@ pub unsafe extern "C" fn lzma_bufcpy( out_pos: *mut size_t, out_size: size_t, ) -> size_t { + if *in_pos > in_size || *out_pos > out_size { + return 0; + } + let in_avail: size_t = in_size.wrapping_sub(*in_pos); let out_avail: size_t = out_size.wrapping_sub(*out_pos); let copy_size: size_t = if in_avail < out_avail { @@ -172,7 +176,10 @@ pub unsafe extern "C" fn lzma_next_filter_update( if (*reversed_filters).id == LZMA_VLI_UNKNOWN { return LZMA_OK; } - (*next).update.unwrap()( + let Some(update) = (*next).update else { + return LZMA_PROG_ERROR; + }; + update( (*next).coder, allocator, core::ptr::null(), @@ -232,6 +239,7 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { ); (*(*strm).internal).sequence = ISEQ_RUN; (*(*strm).internal).allow_buf_error = false; + (*(*strm).internal).avail_in = 0; (*strm).total_in = 0; (*strm).total_out = 0; LZMA_OK @@ -389,6 +397,16 @@ pub unsafe extern "C" fn lzma_get_progress( progress_in: *mut u64, progress_out: *mut u64, ) { + if strm.is_null() || (*strm).internal.is_null() { + if !progress_in.is_null() { + *progress_in = 0; + } + if !progress_out.is_null() { + *progress_out = 0; + } + return; + } + if (*(*strm).internal).next.get_progress.is_some() { (*(*strm).internal).next.get_progress.unwrap()( (*(*strm).internal).next.coder, @@ -402,6 +420,9 @@ pub unsafe extern "C" fn lzma_get_progress( } pub extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { return unsafe { + if strm.is_null() || (*strm).internal.is_null() { + return LZMA_CHECK_NONE; + } if (*(*strm).internal).next.get_check.is_none() { return LZMA_CHECK_NONE; } diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index 6cdddee9..ad4c017b 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -34,9 +34,13 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( if ret_ != LZMA_OK { return ret_; } + let Some(code) = next.code else { + lzma_next_end(::core::ptr::addr_of_mut!(next), allocator); + return LZMA_PROG_ERROR; + }; let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - let mut ret: lzma_ret = next.code.unwrap()( + let mut ret: lzma_ret = code( next.coder, allocator, in_0, @@ -58,7 +62,7 @@ pub unsafe extern "C" fn lzma_raw_buffer_decode( } else { let mut tmp: [u8; 1] = [0; 1]; let mut tmp_pos: size_t = 0; - next.code.unwrap()( + code( next.coder, allocator, in_0, diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index dce2985a..477f0bb3 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -27,9 +27,13 @@ pub unsafe extern "C" fn lzma_raw_buffer_encode( if ret_ != LZMA_OK { return ret_; } + let Some(code) = next.code else { + lzma_next_end(::core::ptr::addr_of_mut!(next), allocator); + return LZMA_PROG_ERROR; + }; let out_start: size_t = *out_pos; let mut in_pos: size_t = 0; - let mut ret: lzma_ret = next.code.unwrap()( + let mut ret: lzma_ret = code( next.coder, allocator, in_0, diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index a72e33ce..26bedf30 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -8,7 +8,7 @@ pub struct filter_features { pub last_ok: bool, pub changes_size: bool, } -static mut features: [filter_features; 13] = [ +static FEATURES: [filter_features; 13] = [ filter_features { id: LZMA_FILTER_LZMA1, options_size: core::mem::size_of::(), @@ -133,8 +133,8 @@ pub unsafe extern "C" fn lzma_filters_copy( } else { let mut j: size_t = 0; j = 0; - while (*src.offset(i as isize)).id != features[j as usize].id { - if features[j as usize].id == LZMA_VLI_UNKNOWN { + while (*src.offset(i as isize)).id != FEATURES[j as usize].id { + if FEATURES[j as usize].id == LZMA_VLI_UNKNOWN { ret = LZMA_OPTIONS_ERROR; current_block = 6392083060350426025; break 's_15; @@ -142,7 +142,7 @@ pub unsafe extern "C" fn lzma_filters_copy( j += 1; } } - dest[i as usize].options = lzma_alloc(features[j as usize].options_size, allocator); + dest[i as usize].options = lzma_alloc(FEATURES[j as usize].options_size, allocator); if dest[i as usize].options.is_null() { ret = LZMA_MEM_ERROR; current_block = 6392083060350426025; @@ -151,7 +151,7 @@ pub unsafe extern "C" fn lzma_filters_copy( core::ptr::copy_nonoverlapping( (*src.offset(i as isize)).options as *const u8, dest[i as usize].options as *mut u8, - features[j as usize].options_size, + FEATURES[j as usize].options_size, ); } } @@ -211,8 +211,8 @@ pub unsafe extern "C" fn lzma_validate_chain( loop { let mut j: size_t = 0; j = 0; - while (*filters.offset(i as isize)).id != features[j as usize].id { - if features[j as usize].id == LZMA_VLI_UNKNOWN { + while (*filters.offset(i as isize)).id != FEATURES[j as usize].id { + if FEATURES[j as usize].id == LZMA_VLI_UNKNOWN { return LZMA_OPTIONS_ERROR; } j += 1; @@ -220,10 +220,10 @@ pub unsafe extern "C" fn lzma_validate_chain( if !non_last_ok { return LZMA_OPTIONS_ERROR; } - non_last_ok = features[j as usize].non_last_ok; - last_ok = features[j as usize].last_ok; + non_last_ok = FEATURES[j as usize].non_last_ok; + last_ok = FEATURES[j as usize].last_ok; changes_size_count = - changes_size_count.wrapping_add(features[j as usize].changes_size as size_t); + changes_size_count.wrapping_add(FEATURES[j as usize].changes_size as size_t); i += 1; if (*filters.offset(i as isize)).id == LZMA_VLI_UNKNOWN { break; diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index 3a1edba1..20ddcd52 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -20,7 +20,13 @@ unsafe extern "C" fn microlzma_encode( let out_start: size_t = *out_pos; let in_start: size_t = *in_pos; let mut uncomp_size: u64 = 0; - if (*coder).lzma.set_out_limit.unwrap()( + let Some(set_out_limit) = (*coder).lzma.set_out_limit else { + return LZMA_PROG_ERROR; + }; + let Some(code) = (*coder).lzma.code else { + return LZMA_PROG_ERROR; + }; + if set_out_limit( (*coder).lzma.coder, ::core::ptr::addr_of_mut!(uncomp_size), out_size.wrapping_sub(*out_pos) as u64, @@ -28,7 +34,7 @@ unsafe extern "C" fn microlzma_encode( { return LZMA_PROG_ERROR; } - let ret: lzma_ret = (*coder).lzma.code.unwrap()( + let ret: lzma_ret = code( (*coder).lzma.coder, allocator, in_0, diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index a4f00ab3..ecf15eab 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -179,8 +179,12 @@ pub unsafe extern "C" fn lzma_outq_enable_partial_output( outq: *mut lzma_outq, enable_partial_output: Option ()>, ) { + let Some(enable_partial_output) = enable_partial_output else { + return; + }; + if !(*outq).head.is_null() && !(*(*outq).head).finished && !(*(*outq).head).worker.is_null() { - enable_partial_output.unwrap()((*(*outq).head).worker); + enable_partial_output((*(*outq).head).worker); (*(*outq).head).worker = core::ptr::null_mut(); } } diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index dcfada7c..94d87b0d 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -41,9 +41,13 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( flags, ); if ret == LZMA_OK { + let Some(code) = stream_decoder.code else { + lzma_next_end(::core::ptr::addr_of_mut!(stream_decoder), allocator); + return LZMA_PROG_ERROR; + }; let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - ret = stream_decoder.code.unwrap()( + ret = code( stream_decoder.coder, allocator, in_0, @@ -67,7 +71,11 @@ pub unsafe extern "C" fn lzma_stream_buffer_decode( } } else if ret == LZMA_MEMLIMIT_ERROR { let mut memusage: u64 = 0; - stream_decoder.memconfig.unwrap()( + let Some(memconfig) = stream_decoder.memconfig else { + lzma_next_end(::core::ptr::addr_of_mut!(stream_decoder), allocator); + return LZMA_PROG_ERROR; + }; + memconfig( stream_decoder.coder, memlimit, ::core::ptr::addr_of_mut!(memusage), diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index be85eb3c..90919b91 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -106,7 +106,7 @@ unsafe extern "C" fn stream_encode( } } 3 => { - static mut convert: [lzma_action; 5] = [ + static CONVERT: [lzma_action; 5] = [ LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FINISH, @@ -122,7 +122,7 @@ unsafe extern "C" fn stream_encode( out, out_pos, out_size, - convert[action as usize], + CONVERT[action as usize], ); if ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH { return ret; @@ -214,11 +214,7 @@ unsafe extern "C" fn stream_encoder_update( }; 5]; let temp_ptr = ::core::ptr::addr_of_mut!(temp) as *mut lzma_filter; let filters_ptr = ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter; - let ret_: lzma_ret = lzma_filters_copy( - filters, - temp_ptr, - allocator, - ); + let ret_: lzma_ret = lzma_filters_copy(filters, temp_ptr, allocator); if ret_ != LZMA_OK { return ret_; } diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index c54edd08..6854227e 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -107,7 +107,7 @@ unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suf if v == 0 { str_append_str(str, crate::c_str!("0")); } else { - static mut suffixes: [[c_char; 4]; 4] = unsafe { + static SUFFIXES: [[c_char; 4]; 4] = unsafe { [ core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"\0\0\0\0"), core::mem::transmute::<[u8; 4], [c_char; 4]>(*b"KiB\0"), @@ -142,12 +142,7 @@ unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suf str, (::core::ptr::addr_of_mut!(buf) as *mut c_char).offset(pos as isize), ); - str_append_str( - str, - ::core::ptr::addr_of!( - *(::core::ptr::addr_of!(suffixes) as *const [c_char; 4]).offset(suf as isize) - ) as *const c_char, - ); + str_append_str(str, SUFFIXES[suf as usize].as_ptr()); }; } pub const NAME_LEN_MAX: u32 = 11; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index d53b659a..1c529a86 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -230,7 +230,10 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( preset_dict: core::ptr::null(), preset_dict_size: 0, }; - let ret_: lzma_ret = lz_init.unwrap()( + let Some(lz_init) = lz_init else { + return LZMA_PROG_ERROR; + }; + let ret_: lzma_ret = lz_init( ::core::ptr::addr_of_mut!((*coder).lz), allocator, (*filters).id, @@ -240,6 +243,9 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( if ret_ != LZMA_OK { return ret_; } + if (*coder).lz.code.is_none() { + return LZMA_PROG_ERROR; + } if lz_options.dict_size < 4096 { lz_options.dict_size = 4096; } diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index bcf095c8..7e7244d5 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -476,7 +476,10 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( preset_dict: core::ptr::null(), preset_dict_size: 0, }; - let ret_: lzma_ret = lz_init.unwrap()( + let Some(lz_init) = lz_init else { + return LZMA_PROG_ERROR; + }; + let ret_: lzma_ret = lz_init( ::core::ptr::addr_of_mut!((*coder).lz), allocator, (*filters).id, @@ -486,6 +489,9 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( if ret_ != LZMA_OK { return ret_; } + if (*coder).lz.code.is_none() { + return LZMA_PROG_ERROR; + } if lz_encoder_prepare( ::core::ptr::addr_of_mut!((*coder).mf), allocator, diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 03ba01ee..776893cc 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -597,9 +597,7 @@ unsafe fn helper2( .wrapping_add(rc_bit_1_price((*coder).is_match[state as usize][pos_state as usize]) as u32); let rep_match_price: u32 = match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[state as usize]) as u32); - if match_byte == current_byte - && !(next_opt.pos_prev < cur && next_opt.back_prev == 0) - { + if match_byte == current_byte && !(next_opt.pos_prev < cur && next_opt.back_prev == 0) { let short_rep_price: u32 = rep_match_price.wrapping_add(get_short_rep_price(coder, state, pos_state) as u32); if short_rep_price <= next_opt.price { @@ -625,7 +623,7 @@ unsafe fn helper2( nice_len.wrapping_add(1) }; let len_test: u32 = (lzma_memcmplen(buf, buf_back, 1, limit) as u32).wrapping_sub(1); - if len_test >= 2 { + if len_test >= 2 { let state_2: lzma_lzma_state = update_literal_state(state); let pos_state_next: u32 = position.wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price: u32 = cur_and_1_price diff --git a/systest/Cargo.toml b/systest/Cargo.toml index 46aedd25..6c2b8724 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -16,6 +16,6 @@ ctest2 = "0.4" [features] default = ["c-sys"] -c-sys = ["dep:liblzma-c-sys"] -rs-sys = ["dep:liblzma-rs-sys"] +c-sys = ["liblzma-c-sys"] +rs-sys = ["liblzma-rs-sys"] bindgen = ["c-sys", "liblzma-c-sys/bindgen"] From e8314cae1f32db9cb981b39a6aae25636b37950d Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Thu, 19 Mar 2026 20:17:19 +0900 Subject: [PATCH 21/51] remove extern "C" from internal functions not used as callbacks 193 pub unsafe extern "C" fn and 63 pub extern "C" fn converted. 53+5 kept for function pointer callback compatibility. --- liblzma-rs/src/check/check.rs | 10 +-- liblzma-rs/src/check/crc32_fast.rs | 2 +- liblzma-rs/src/check/crc64_fast.rs | 2 +- liblzma-rs/src/check/sha256.rs | 6 +- liblzma-rs/src/common/alone_decoder.rs | 2 +- liblzma-rs/src/common/alone_encoder.rs | 2 +- liblzma-rs/src/common/auto_decoder.rs | 2 +- liblzma-rs/src/common/block_buffer_decoder.rs | 2 +- liblzma-rs/src/common/block_buffer_encoder.rs | 8 +-- liblzma-rs/src/common/block_decoder.rs | 2 +- liblzma-rs/src/common/block_encoder.rs | 2 +- liblzma-rs/src/common/block_header_decoder.rs | 2 +- liblzma-rs/src/common/block_header_encoder.rs | 4 +- liblzma-rs/src/common/block_util.rs | 6 +- liblzma-rs/src/common/common.rs | 32 ++++----- liblzma-rs/src/common/easy_buffer_encoder.rs | 2 +- .../src/common/easy_decoder_memusage.rs | 2 +- liblzma-rs/src/common/easy_encoder.rs | 2 +- .../src/common/easy_encoder_memusage.rs | 2 +- liblzma-rs/src/common/easy_preset.rs | 2 +- liblzma-rs/src/common/file_info.rs | 2 +- .../src/common/filter_buffer_decoder.rs | 2 +- .../src/common/filter_buffer_encoder.rs | 2 +- liblzma-rs/src/common/filter_common.rs | 10 +-- liblzma-rs/src/common/filter_decoder.rs | 10 +-- liblzma-rs/src/common/filter_encoder.rs | 16 ++--- liblzma-rs/src/common/filter_flags_decoder.rs | 2 +- liblzma-rs/src/common/filter_flags_encoder.rs | 4 +- liblzma-rs/src/common/hardware_cputhreads.rs | 2 +- liblzma-rs/src/common/hardware_physmem.rs | 2 +- liblzma-rs/src/common/index.rs | 46 ++++++------ liblzma-rs/src/common/index_decoder.rs | 4 +- liblzma-rs/src/common/index_encoder.rs | 4 +- liblzma-rs/src/common/index_hash.rs | 10 +-- liblzma-rs/src/common/lzip_decoder.rs | 2 +- liblzma-rs/src/common/microlzma_decoder.rs | 2 +- liblzma-rs/src/common/microlzma_encoder.rs | 2 +- liblzma-rs/src/common/outqueue.rs | 20 +++--- .../src/common/stream_buffer_decoder.rs | 2 +- .../src/common/stream_buffer_encoder.rs | 6 +- liblzma-rs/src/common/stream_decoder.rs | 2 +- liblzma-rs/src/common/stream_decoder_mt.rs | 2 +- liblzma-rs/src/common/stream_encoder.rs | 2 +- liblzma-rs/src/common/stream_encoder_mt.rs | 4 +- liblzma-rs/src/common/stream_flags_common.rs | 2 +- liblzma-rs/src/common/stream_flags_decoder.rs | 4 +- liblzma-rs/src/common/stream_flags_encoder.rs | 4 +- liblzma-rs/src/common/string_conversion.rs | 6 +- liblzma-rs/src/common/vli_decoder.rs | 2 +- liblzma-rs/src/common/vli_encoder.rs | 2 +- liblzma-rs/src/common/vli_size.rs | 2 +- liblzma-rs/src/delta/delta_common.rs | 2 +- liblzma-rs/src/lz/lz_decoder.rs | 4 +- liblzma-rs/src/lz/lz_encoder.rs | 6 +- liblzma-rs/src/lz/lz_encoder_mf.rs | 2 +- liblzma-rs/src/lzma/lzma2_decoder.rs | 2 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 2 +- liblzma-rs/src/lzma/lzma_decoder.rs | 4 +- liblzma-rs/src/lzma/lzma_encoder.rs | 12 ++-- .../src/lzma/lzma_encoder_optimum_fast.rs | 2 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 2 +- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 2 +- liblzma-rs/src/simple/arm64.rs | 4 +- liblzma-rs/src/simple/riscv.rs | 4 +- liblzma-rs/src/simple/simple_coder.rs | 2 +- liblzma-rs/src/simple/x86.rs | 4 +- liblzma-rs/src/tuklib/tuklib_cpucores.rs | 2 +- liblzma-rs/src/tuklib/tuklib_physmem.rs | 2 +- liblzma-rs/src/types.rs | 72 +++++++++---------- 69 files changed, 203 insertions(+), 203 deletions(-) diff --git a/liblzma-rs/src/check/check.rs b/liblzma-rs/src/check/check.rs index 0e0129f2..7197ebb4 100644 --- a/liblzma-rs/src/check/check.rs +++ b/liblzma-rs/src/check/check.rs @@ -1,7 +1,7 @@ use crate::check::crc64_fast::lzma_crc64; use crate::check::sha256::{lzma_sha256_finish, lzma_sha256_init, lzma_sha256_update}; use crate::types::*; -pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { +pub fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { if type_0 > LZMA_CHECK_ID_MAX { return false as lzma_bool; } @@ -25,7 +25,7 @@ pub extern "C" fn lzma_check_is_supported(type_0: lzma_check) -> lzma_bool { ]; available_checks[type_0 as usize] } -pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { +pub fn lzma_check_size(type_0: lzma_check) -> u32 { if type_0 > LZMA_CHECK_ID_MAX { return UINT32_MAX; } @@ -35,7 +35,7 @@ pub extern "C" fn lzma_check_size(type_0: lzma_check) -> u32 { ]; check_sizes[type_0 as usize] as u32 } -pub unsafe extern "C" fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check) { +pub unsafe fn lzma_check_init(check: *mut lzma_check_state, type_0: lzma_check) { if check.is_null() { return; } @@ -53,7 +53,7 @@ pub unsafe extern "C" fn lzma_check_init(check: *mut lzma_check_state, type_0: l LZMA_CHECK_NONE | _ => {} }; } -pub unsafe extern "C" fn lzma_check_update( +pub unsafe fn lzma_check_update( check: *mut lzma_check_state, type_0: lzma_check, buf: *const u8, @@ -76,7 +76,7 @@ pub unsafe extern "C" fn lzma_check_update( _ => {} }; } -pub unsafe extern "C" fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check) { +pub unsafe fn lzma_check_finish(check: *mut lzma_check_state, type_0: lzma_check) { if check.is_null() { return; } diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index 36e387c7..0b784ed0 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -350,6 +350,6 @@ unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mu } !crc } -pub unsafe extern "C" fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32 { +pub unsafe fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32 { lzma_crc32_generic(buf, size, crc) } diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index 891efc80..07753301 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1061,6 +1061,6 @@ unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mu } !crc } -pub unsafe extern "C" fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64 { +pub unsafe fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64 { lzma_crc64_generic(buf, size, crc) } diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index ce2704b7..41cf9c8c 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -531,7 +531,7 @@ unsafe extern "C" fn process(check: *mut lzma_check_state) { ::core::ptr::addr_of_mut!((*check).buffer.u32_0) as *const u32, ); } -pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { +pub unsafe fn lzma_sha256_init(check: *mut lzma_check_state) { static mut s: [u32; 8] = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, @@ -543,7 +543,7 @@ pub unsafe extern "C" fn lzma_sha256_init(check: *mut lzma_check_state) { ); (*check).state.sha256.size = 0; } -pub unsafe extern "C" fn lzma_sha256_update( +pub unsafe fn lzma_sha256_update( mut buf: *const u8, mut size: size_t, check: *mut lzma_check_state, @@ -568,7 +568,7 @@ pub unsafe extern "C" fn lzma_sha256_update( } } } -pub unsafe extern "C" fn lzma_sha256_finish(check: *mut lzma_check_state) { +pub unsafe fn lzma_sha256_finish(check: *mut lzma_check_state) { let mut pos: size_t = ((*check).state.sha256.size & 0x3f as u64) as size_t; (*check).buffer.u8_0[pos as usize] = 0x80 as u8; pos += 1; diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 9cfb6499..4895cfb1 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -272,7 +272,7 @@ pub unsafe extern "C" fn lzma_alone_decoder_init( (*coder).memusage = LZMA_MEMUSAGE_BASE; LZMA_OK } -pub unsafe extern "C" fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { +pub unsafe fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index d3311934..90c2b357 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -197,7 +197,7 @@ unsafe extern "C" fn alone_encoder_init( ::core::ptr::addr_of!(filters) as *const lzma_filter_info, ) } -pub unsafe extern "C" fn lzma_alone_encoder( +pub unsafe fn lzma_alone_encoder( strm: *mut lzma_stream, options: *const lzma_options_lzma, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 0a70b471..457acd96 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -231,7 +231,7 @@ unsafe extern "C" fn auto_decoder_init( (*coder).sequence = SEQ_INIT; LZMA_OK } -pub unsafe extern "C" fn lzma_auto_decoder( +pub unsafe fn lzma_auto_decoder( strm: *mut lzma_stream, memlimit: u64, flags: u32, diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index 9cb6b919..fe1e2a7f 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub unsafe extern "C" fn lzma_block_buffer_decode( +pub unsafe fn lzma_block_buffer_decode( block: *mut lzma_block, allocator: *const lzma_allocator, in_0: *const u8, diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 5097c9b9..2d13ddd7 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -16,7 +16,7 @@ extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { } uncompressed_size.wrapping_add(overhead) } -pub extern "C" fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { +pub fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { let mut lzma2_size: u64 = lzma2_bound(uncompressed_size); if lzma2_size == 0 { return 0; @@ -24,7 +24,7 @@ pub extern "C" fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { lzma2_size = lzma2_size.wrapping_add(3) & !(3); (HEADERS_BOUND as u64).wrapping_add(lzma2_size) } -pub extern "C" fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t { +pub fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t { let ret: u64 = lzma_block_buffer_bound64(uncompressed_size as u64); ret as size_t } @@ -268,7 +268,7 @@ unsafe extern "C" fn block_buffer_encode( } LZMA_OK } -pub unsafe extern "C" fn lzma_block_buffer_encode( +pub unsafe fn lzma_block_buffer_encode( block: *mut lzma_block, allocator: *const lzma_allocator, in_0: *const u8, @@ -281,7 +281,7 @@ pub unsafe extern "C" fn lzma_block_buffer_encode( block, allocator, in_0, in_size, out, out_pos, out_size, true, ) } -pub unsafe extern "C" fn lzma_block_uncomp_encode( +pub unsafe fn lzma_block_uncomp_encode( block: *mut lzma_block, in_0: *const u8, in_size: size_t, diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 049be186..c202f1ec 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -288,7 +288,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( (*block).filters, ) } -pub unsafe extern "C" fn lzma_block_decoder( +pub unsafe fn lzma_block_decoder( strm: *mut lzma_stream, block: *mut lzma_block, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 65ebf91e..33590623 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -244,7 +244,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( (*block).filters, ) } -pub unsafe extern "C" fn lzma_block_encoder( +pub unsafe fn lzma_block_encoder( strm: *mut lzma_stream, block: *mut lzma_block, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 0dc01adf..080b3e86 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -1,6 +1,6 @@ use crate::common::filter_flags_decoder::lzma_filter_flags_decode; use crate::types::*; -pub unsafe extern "C" fn lzma_block_header_decode( +pub unsafe fn lzma_block_header_decode( block: *mut lzma_block, allocator: *const lzma_allocator, in_0: *const u8, diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 8dea44fd..21eeff33 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -1,6 +1,6 @@ use crate::common::filter_flags_encoder::{lzma_filter_flags_encode, lzma_filter_flags_size}; use crate::types::*; -pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { +pub unsafe fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { if (*block).version > 1 { return LZMA_OPTIONS_ERROR; } @@ -41,7 +41,7 @@ pub unsafe extern "C" fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ (*block).header_size = size.wrapping_add(3) & !(3); LZMA_OK } -pub unsafe extern "C" fn lzma_block_header_encode( +pub unsafe fn lzma_block_header_encode( block: *const lzma_block, out: *mut u8, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index 443de156..fce5b00c 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -1,6 +1,6 @@ use crate::types::*; pub const LZMA_BLOCK_HEADER_SIZE_MIN: u32 = 8; -pub unsafe extern "C" fn lzma_block_compressed_size( +pub unsafe fn lzma_block_compressed_size( block: *mut lzma_block, unpadded_size: lzma_vli, ) -> lzma_ret { @@ -20,7 +20,7 @@ pub unsafe extern "C" fn lzma_block_compressed_size( (*block).compressed_size = compressed_size; LZMA_OK } -pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli { +pub unsafe fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli { if block.is_null() || (*block).version > 1 || (*block).header_size < LZMA_BLOCK_HEADER_SIZE_MIN @@ -45,7 +45,7 @@ pub unsafe extern "C" fn lzma_block_unpadded_size(block: *const lzma_block) -> l } unpadded_size } -pub unsafe extern "C" fn lzma_block_total_size(block: *const lzma_block) -> lzma_vli { +pub unsafe fn lzma_block_total_size(block: *const lzma_block) -> lzma_vli { let mut unpadded_size: lzma_vli = lzma_block_unpadded_size(block); if unpadded_size != LZMA_VLI_UNKNOWN { unpadded_size = vli_ceil4(unpadded_size); diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index 94e9d826..903ccea5 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -73,13 +73,13 @@ pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR) .wrapping_add((LZMA_VERSION_PATCH).wrapping_mul(10)) .wrapping_add(LZMA_VERSION_STABILITY); pub const LZMA_TIMED_OUT: c_uint = 101; -pub extern "C" fn lzma_version_number() -> u32 { +pub fn lzma_version_number() -> u32 { LZMA_VERSION as u32 } -pub extern "C" fn lzma_version_string() -> *const c_char { +pub fn lzma_version_string() -> *const c_char { crate::c_str!("5.8.2") } -pub unsafe extern "C" fn lzma_alloc( +pub unsafe fn lzma_alloc( mut size: size_t, allocator: *const lzma_allocator, ) -> *mut c_void { @@ -94,7 +94,7 @@ pub unsafe extern "C" fn lzma_alloc( } ptr } -pub unsafe extern "C" fn lzma_alloc_zero( +pub unsafe fn lzma_alloc_zero( mut size: size_t, allocator: *const lzma_allocator, ) -> *mut c_void { @@ -119,7 +119,7 @@ pub unsafe extern "C" fn lzma_free(ptr: *mut c_void, allocator: *const lzma_allo free(ptr); }; } -pub unsafe extern "C" fn lzma_bufcpy( +pub unsafe fn lzma_bufcpy( in_0: *const u8, in_pos: *mut size_t, in_size: size_t, @@ -149,7 +149,7 @@ pub unsafe extern "C" fn lzma_bufcpy( *out_pos = (*out_pos).wrapping_add(copy_size); copy_size } -pub unsafe extern "C" fn lzma_next_filter_init( +pub unsafe fn lzma_next_filter_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, @@ -165,7 +165,7 @@ pub unsafe extern "C" fn lzma_next_filter_init( (*filters).init.unwrap()(next, allocator, filters) } } -pub unsafe extern "C" fn lzma_next_filter_update( +pub unsafe fn lzma_next_filter_update( next: *mut lzma_next_coder, allocator: *const lzma_allocator, reversed_filters: *const lzma_filter, @@ -186,7 +186,7 @@ pub unsafe extern "C" fn lzma_next_filter_update( reversed_filters, ) } -pub unsafe extern "C" fn lzma_next_end( +pub unsafe fn lzma_next_end( next: *mut lzma_next_coder, allocator: *const lzma_allocator, ) { @@ -210,7 +210,7 @@ pub unsafe extern "C" fn lzma_next_end( }; } } -pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { +pub unsafe fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { if strm.is_null() { return LZMA_PROG_ERROR; } @@ -244,7 +244,7 @@ pub unsafe extern "C" fn lzma_strm_init(strm: *mut lzma_stream) -> lzma_ret { (*strm).total_out = 0; LZMA_OK } -pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret { +pub unsafe fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret { if (*strm).next_in.is_null() && (*strm).avail_in != 0 || (*strm).next_out.is_null() && (*strm).avail_out != 0 || (*strm).internal.is_null() @@ -382,7 +382,7 @@ pub unsafe extern "C" fn lzma_code(strm: *mut lzma_stream, action: lzma_action) } ret } -pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { +pub unsafe fn lzma_end(strm: *mut lzma_stream) { if !strm.is_null() && !(*strm).internal.is_null() { lzma_next_end( ::core::ptr::addr_of_mut!((*(*strm).internal).next), @@ -392,7 +392,7 @@ pub unsafe extern "C" fn lzma_end(strm: *mut lzma_stream) { (*strm).internal = core::ptr::null_mut(); } } -pub unsafe extern "C" fn lzma_get_progress( +pub unsafe fn lzma_get_progress( strm: *mut lzma_stream, progress_in: *mut u64, progress_out: *mut u64, @@ -418,7 +418,7 @@ pub unsafe extern "C" fn lzma_get_progress( *progress_out = (*strm).total_out; }; } -pub extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { +pub fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { return unsafe { if strm.is_null() || (*strm).internal.is_null() { return LZMA_CHECK_NONE; @@ -429,7 +429,7 @@ pub extern "C" fn lzma_get_check(strm: *const lzma_stream) -> lzma_check { (*(*strm).internal).next.get_check.unwrap()((*(*strm).internal).next.coder) }; } -pub extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { +pub fn lzma_memusage(strm: *const lzma_stream) -> u64 { return unsafe { let mut memusage: u64 = 0; let mut old_memlimit: u64 = 0; @@ -448,7 +448,7 @@ pub extern "C" fn lzma_memusage(strm: *const lzma_stream) -> u64 { memusage }; } -pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { +pub fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { return unsafe { let mut old_memlimit: u64 = 0; let mut memusage: u64 = 0; @@ -467,7 +467,7 @@ pub extern "C" fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { old_memlimit }; } -pub unsafe extern "C" fn lzma_memlimit_set( +pub unsafe fn lzma_memlimit_set( strm: *mut lzma_stream, mut new_memlimit: u64, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/easy_buffer_encoder.rs b/liblzma-rs/src/common/easy_buffer_encoder.rs index 9f40a0a5..74863c48 100644 --- a/liblzma-rs/src/common/easy_buffer_encoder.rs +++ b/liblzma-rs/src/common/easy_buffer_encoder.rs @@ -1,6 +1,6 @@ use crate::common::stream_buffer_encoder::lzma_stream_buffer_encode; use crate::types::*; -pub unsafe extern "C" fn lzma_easy_buffer_encode( +pub unsafe fn lzma_easy_buffer_encode( preset: u32, check: lzma_check, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/easy_decoder_memusage.rs b/liblzma-rs/src/common/easy_decoder_memusage.rs index c28b952f..556efa9d 100644 --- a/liblzma-rs/src/common/easy_decoder_memusage.rs +++ b/liblzma-rs/src/common/easy_decoder_memusage.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub extern "C" fn lzma_easy_decoder_memusage(preset: u32) -> u64 { +pub fn lzma_easy_decoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, diff --git a/liblzma-rs/src/common/easy_encoder.rs b/liblzma-rs/src/common/easy_encoder.rs index 5d8cacc7..4ed491e4 100644 --- a/liblzma-rs/src/common/easy_encoder.rs +++ b/liblzma-rs/src/common/easy_encoder.rs @@ -1,6 +1,6 @@ use crate::common::stream_encoder::lzma_stream_encoder; use crate::types::*; -pub unsafe extern "C" fn lzma_easy_encoder( +pub unsafe fn lzma_easy_encoder( strm: *mut lzma_stream, preset: u32, check: lzma_check, diff --git a/liblzma-rs/src/common/easy_encoder_memusage.rs b/liblzma-rs/src/common/easy_encoder_memusage.rs index 06b0d369..029acdf3 100644 --- a/liblzma-rs/src/common/easy_encoder_memusage.rs +++ b/liblzma-rs/src/common/easy_encoder_memusage.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub extern "C" fn lzma_easy_encoder_memusage(preset: u32) -> u64 { +pub fn lzma_easy_encoder_memusage(preset: u32) -> u64 { let mut opt_easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, diff --git a/liblzma-rs/src/common/easy_preset.rs b/liblzma-rs/src/common/easy_preset.rs index 5b0283d6..fadc101d 100644 --- a/liblzma-rs/src/common/easy_preset.rs +++ b/liblzma-rs/src/common/easy_preset.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub unsafe extern "C" fn lzma_easy_preset(opt_easy: *mut lzma_options_easy, preset: u32) -> bool { +pub unsafe fn lzma_easy_preset(opt_easy: *mut lzma_options_easy, preset: u32) -> bool { if lzma_lzma_preset(::core::ptr::addr_of_mut!((*opt_easy).opt_lzma), preset) != 0 { return true; } diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 38b67957..d1c5594e 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -661,7 +661,7 @@ unsafe extern "C" fn lzma_file_info_decoder_init( (*coder).temp_size = LZMA_STREAM_HEADER_SIZE as size_t; LZMA_OK } -pub unsafe extern "C" fn lzma_file_info_decoder( +pub unsafe fn lzma_file_info_decoder( strm: *mut lzma_stream, dest_index: *mut *mut lzma_index, memlimit: u64, diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index ad4c017b..9df37a2d 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub unsafe extern "C" fn lzma_raw_buffer_decode( +pub unsafe fn lzma_raw_buffer_decode( filters: *const lzma_filter, allocator: *const lzma_allocator, in_0: *const u8, diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index 477f0bb3..6b0cb1c8 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub unsafe extern "C" fn lzma_raw_buffer_encode( +pub unsafe fn lzma_raw_buffer_encode( filters: *const lzma_filter, allocator: *const lzma_allocator, in_0: *const u8, diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 26bedf30..1fb8d6ec 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -101,7 +101,7 @@ static FEATURES: [filter_features; 13] = [ changes_size: false, }, ]; -pub unsafe extern "C" fn lzma_filters_copy( +pub unsafe fn lzma_filters_copy( src: *const lzma_filter, real_dest: *mut lzma_filter, allocator: *const lzma_allocator, @@ -179,7 +179,7 @@ pub unsafe extern "C" fn lzma_filters_copy( } }; } -pub unsafe extern "C" fn lzma_filters_free( +pub unsafe fn lzma_filters_free( filters: *mut lzma_filter, allocator: *const lzma_allocator, ) { @@ -197,7 +197,7 @@ pub unsafe extern "C" fn lzma_filters_free( i += 1; } } -pub unsafe extern "C" fn lzma_validate_chain( +pub unsafe fn lzma_validate_chain( filters: *const lzma_filter, count: *mut size_t, ) -> lzma_ret { @@ -235,7 +235,7 @@ pub unsafe extern "C" fn lzma_validate_chain( *count = i; LZMA_OK } -pub unsafe extern "C" fn lzma_raw_coder_init( +pub unsafe fn lzma_raw_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, options: *const lzma_filter, @@ -292,7 +292,7 @@ pub unsafe extern "C" fn lzma_raw_coder_init( } ret } -pub unsafe extern "C" fn lzma_raw_coder_memusage( +pub unsafe fn lzma_raw_coder_memusage( coder_find: lzma_filter_find, filters: *const lzma_filter, ) -> u64 { diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 263dfdf0..5aacfdbf 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -298,10 +298,10 @@ extern "C" fn decoder_find(id: lzma_vli) -> *const lzma_filter_decoder { extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { decoder_find(id) as *const lzma_filter_coder } -pub extern "C" fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { +pub fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool { !decoder_find(id).is_null() as lzma_bool } -pub unsafe extern "C" fn lzma_raw_decoder_init( +pub unsafe fn lzma_raw_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, options: *const lzma_filter, @@ -314,7 +314,7 @@ pub unsafe extern "C" fn lzma_raw_decoder_init( false, ) } -pub unsafe extern "C" fn lzma_raw_decoder( +pub unsafe fn lzma_raw_decoder( strm: *mut lzma_stream, options: *const lzma_filter, ) -> lzma_ret { @@ -335,13 +335,13 @@ pub unsafe extern "C" fn lzma_raw_decoder( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -pub unsafe extern "C" fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { +pub unsafe fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64 { lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, ) } -pub unsafe extern "C" fn lzma_properties_decode( +pub unsafe fn lzma_properties_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, props: *const u8, diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index aaa74147..13604a61 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -275,10 +275,10 @@ extern "C" fn encoder_find(id: lzma_vli) -> *const lzma_filter_encoder { extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { encoder_find(id) as *const lzma_filter_coder } -pub extern "C" fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { +pub fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { !encoder_find(id).is_null() as lzma_bool } -pub unsafe extern "C" fn lzma_filters_update( +pub unsafe fn lzma_filters_update( strm: *mut lzma_stream, filters: *const lzma_filter, ) -> lzma_ret { @@ -310,7 +310,7 @@ pub unsafe extern "C" fn lzma_filters_update( ::core::ptr::addr_of_mut!(reversed_filters) as *mut lzma_filter, ) } -pub unsafe extern "C" fn lzma_raw_encoder_init( +pub unsafe fn lzma_raw_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter, @@ -323,7 +323,7 @@ pub unsafe extern "C" fn lzma_raw_encoder_init( true, ) } -pub unsafe extern "C" fn lzma_raw_encoder( +pub unsafe fn lzma_raw_encoder( strm: *mut lzma_stream, filters: *const lzma_filter, ) -> lzma_ret { @@ -347,13 +347,13 @@ pub unsafe extern "C" fn lzma_raw_encoder( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -pub unsafe extern "C" fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64 { +pub unsafe fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64 { lzma_raw_coder_memusage( Some(coder_find as unsafe extern "C" fn(lzma_vli) -> *const lzma_filter_coder), filters, ) } -pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { +pub unsafe fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { if filters.is_null() { return UINT64_MAX; } @@ -379,7 +379,7 @@ pub unsafe extern "C" fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 max } } -pub unsafe extern "C" fn lzma_properties_size( +pub unsafe fn lzma_properties_size( size: *mut u32, filter: *const lzma_filter, ) -> lzma_ret { @@ -397,7 +397,7 @@ pub unsafe extern "C" fn lzma_properties_size( } (*fe).props_size_get.unwrap()(size, (*filter).options) } -pub unsafe extern "C" fn lzma_properties_encode( +pub unsafe fn lzma_properties_encode( filter: *const lzma_filter, props: *mut u8, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index fa21ca7e..e44b25f2 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -1,6 +1,6 @@ use crate::common::filter_decoder::lzma_properties_decode; use crate::types::*; -pub unsafe extern "C" fn lzma_filter_flags_decode( +pub unsafe fn lzma_filter_flags_decode( filter: *mut lzma_filter, allocator: *const lzma_allocator, in_0: *const u8, diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index 399a9940..d13c21d0 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -1,6 +1,6 @@ use crate::common::filter_encoder::{lzma_properties_encode, lzma_properties_size}; use crate::types::*; -pub unsafe extern "C" fn lzma_filter_flags_size( +pub unsafe fn lzma_filter_flags_size( size: *mut u32, filter: *const lzma_filter, ) -> lzma_ret { @@ -15,7 +15,7 @@ pub unsafe extern "C" fn lzma_filter_flags_size( .wrapping_add(lzma_vli_size((*filter).id).wrapping_add(lzma_vli_size(*size as lzma_vli))); LZMA_OK } -pub unsafe extern "C" fn lzma_filter_flags_encode( +pub unsafe fn lzma_filter_flags_encode( filter: *const lzma_filter, out: *mut u8, out_pos: *mut size_t, diff --git a/liblzma-rs/src/common/hardware_cputhreads.rs b/liblzma-rs/src/common/hardware_cputhreads.rs index 58217f8d..73fe4665 100644 --- a/liblzma-rs/src/common/hardware_cputhreads.rs +++ b/liblzma-rs/src/common/hardware_cputhreads.rs @@ -1,4 +1,4 @@ use crate::tuklib::tuklib_cpucores::tuklib_cpucores; -pub extern "C" fn lzma_cputhreads() -> u32 { +pub fn lzma_cputhreads() -> u32 { tuklib_cpucores() } diff --git a/liblzma-rs/src/common/hardware_physmem.rs b/liblzma-rs/src/common/hardware_physmem.rs index 44e8815c..9cf32319 100644 --- a/liblzma-rs/src/common/hardware_physmem.rs +++ b/liblzma-rs/src/common/hardware_physmem.rs @@ -1,4 +1,4 @@ use crate::tuklib::tuklib_physmem::tuklib_physmem; -pub extern "C" fn lzma_physmem() -> u64 { +pub fn lzma_physmem() -> u64 { tuklib_physmem() } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 76276b4d..0c87fd38 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -228,7 +228,7 @@ unsafe extern "C" fn index_init_plain(allocator: *const lzma_allocator) -> *mut } i } -pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index { +pub unsafe fn lzma_index_init(allocator: *const lzma_allocator) -> *mut lzma_index { let i: *mut lzma_index = index_init_plain(allocator); if i.is_null() { return core::ptr::null_mut(); @@ -244,7 +244,7 @@ pub unsafe extern "C" fn lzma_index_init(allocator: *const lzma_allocator) -> *m ); i } -pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { +pub unsafe fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator) { if !i.is_null() { index_tree_end( ::core::ptr::addr_of_mut!((*i).streams), @@ -256,13 +256,13 @@ pub unsafe extern "C" fn lzma_index_end(i: *mut lzma_index, allocator: *const lz lzma_free(i as *mut c_void, allocator); } } -pub unsafe extern "C" fn lzma_index_prealloc(i: *mut lzma_index, mut records: lzma_vli) { +pub unsafe fn lzma_index_prealloc(i: *mut lzma_index, mut records: lzma_vli) { if records > PREALLOC_MAX as lzma_vli { records = PREALLOC_MAX as lzma_vli; } (*i).prealloc = records as size_t; } -pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64 { +pub fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u64 { let alloc_overhead: size_t = (4_usize).wrapping_mul(core::mem::size_of::<*mut c_void>()); let stream_base: size_t = (core::mem::size_of::()) .wrapping_add(core::mem::size_of::()) @@ -294,22 +294,22 @@ pub extern "C" fn lzma_index_memusage(streams: lzma_vli, blocks: lzma_vli) -> u6 .wrapping_add(streams_mem) .wrapping_add(groups_mem) } -pub extern "C" fn lzma_index_memused(i: *const lzma_index) -> u64 { +pub fn lzma_index_memused(i: *const lzma_index) -> u64 { unsafe { lzma_index_memusage((*i).streams.count as lzma_vli, (*i).record_count) } } -pub extern "C" fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli { +pub fn lzma_index_block_count(i: *const lzma_index) -> lzma_vli { unsafe { (*i).record_count } } -pub extern "C" fn lzma_index_stream_count(i: *const lzma_index) -> lzma_vli { +pub fn lzma_index_stream_count(i: *const lzma_index) -> lzma_vli { unsafe { (*i).streams.count as lzma_vli } } -pub extern "C" fn lzma_index_size(i: *const lzma_index) -> lzma_vli { +pub fn lzma_index_size(i: *const lzma_index) -> lzma_vli { unsafe { index_size((*i).record_count, (*i).index_list_size) } } -pub extern "C" fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { +pub fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { unsafe { (*i).total_size } } -pub extern "C" fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { +pub fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { unsafe { (LZMA_STREAM_HEADER_SIZE as lzma_vli) .wrapping_add((*i).total_size) @@ -337,7 +337,7 @@ unsafe extern "C" fn index_file_size( } file_size } -pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli { +pub unsafe fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli { let s: *const index_stream = (*i).streams.rightmost as *const index_stream; let g: *const index_group = (*s).groups.rightmost as *const index_group; index_file_size( @@ -354,10 +354,10 @@ pub unsafe extern "C" fn lzma_index_file_size(i: *const lzma_index) -> lzma_vli (*s).stream_padding, ) } -pub unsafe extern "C" fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { +pub unsafe fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli { (*i).uncompressed_size } -pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { +pub unsafe fn lzma_index_checks(i: *const lzma_index) -> u32 { let mut checks: u32 = (*i).checks; let s: *const index_stream = (*i).streams.rightmost as *const index_stream; if (*s).stream_flags.version != UINT32_MAX { @@ -365,10 +365,10 @@ pub unsafe extern "C" fn lzma_index_checks(i: *const lzma_index) -> u32 { } checks } -pub unsafe extern "C" fn lzma_index_padding_size(i: *const lzma_index) -> u32 { +pub unsafe fn lzma_index_padding_size(i: *const lzma_index) -> u32 { ((4_u64).wrapping_sub(index_size_unpadded((*i).record_count, (*i).index_list_size)) & 3) as u32 } -pub unsafe extern "C" fn lzma_index_stream_flags( +pub unsafe fn lzma_index_stream_flags( i: *mut lzma_index, stream_flags: *const lzma_stream_flags, ) -> lzma_ret { @@ -383,7 +383,7 @@ pub unsafe extern "C" fn lzma_index_stream_flags( (*s).stream_flags = *stream_flags; LZMA_OK } -pub unsafe extern "C" fn lzma_index_stream_padding( +pub unsafe fn lzma_index_stream_padding( i: *mut lzma_index, stream_padding: lzma_vli, ) -> lzma_ret { @@ -400,7 +400,7 @@ pub unsafe extern "C" fn lzma_index_stream_padding( (*s).stream_padding = stream_padding; LZMA_OK } -pub unsafe extern "C" fn lzma_index_append( +pub unsafe fn lzma_index_append( i: *mut lzma_index, allocator: *const lzma_allocator, unpadded_size: lzma_vli, @@ -517,7 +517,7 @@ unsafe extern "C" fn index_cat_helper(info: *const index_cat_info, this: *mut in index_cat_helper(info, right); } } -pub unsafe extern "C" fn lzma_index_cat( +pub unsafe fn lzma_index_cat( dest: *mut lzma_index, src: *mut lzma_index, allocator: *const lzma_allocator, @@ -663,7 +663,7 @@ unsafe extern "C" fn index_dup_stream( ); dest } -pub unsafe extern "C" fn lzma_index_dup( +pub unsafe fn lzma_index_dup( src: *const lzma_index, allocator: *const lzma_allocator, ) -> *mut lzma_index { @@ -795,17 +795,17 @@ unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { .wrapping_add((*iter).stream.uncompressed_offset); } } -pub unsafe extern "C" fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index) { +pub unsafe fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index) { (*iter).internal[ITER_INDEX as usize].p = i as *const c_void; lzma_index_iter_rewind(iter); } -pub unsafe extern "C" fn lzma_index_iter_rewind(iter: *mut lzma_index_iter) { +pub unsafe fn lzma_index_iter_rewind(iter: *mut lzma_index_iter) { (*iter).internal[ITER_STREAM as usize].p = core::ptr::null(); (*iter).internal[ITER_GROUP as usize].p = core::ptr::null(); (*iter).internal[ITER_RECORD as usize].s = 0; (*iter).internal[ITER_METHOD as usize].s = ITER_METHOD_NORMAL as size_t; } -pub unsafe extern "C" fn lzma_index_iter_next( +pub unsafe fn lzma_index_iter_next( iter: *mut lzma_index_iter, mode: lzma_index_iter_mode, ) -> lzma_bool { @@ -894,7 +894,7 @@ pub unsafe extern "C" fn lzma_index_iter_next( iter_set_info(iter); false as lzma_bool } -pub unsafe extern "C" fn lzma_index_iter_locate( +pub unsafe fn lzma_index_iter_locate( iter: *mut lzma_index_iter, mut target: lzma_vli, ) -> lzma_bool { diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index b1c94c65..62905c15 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -308,7 +308,7 @@ pub unsafe extern "C" fn lzma_index_decoder_init( } index_decoder_reset(coder, allocator, i, memlimit) } -pub unsafe extern "C" fn lzma_index_decoder( +pub unsafe fn lzma_index_decoder( strm: *mut lzma_stream, i: *mut *mut lzma_index, memlimit: u64, @@ -334,7 +334,7 @@ pub unsafe extern "C" fn lzma_index_decoder( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -pub unsafe extern "C" fn lzma_index_buffer_decode( +pub unsafe fn lzma_index_buffer_decode( i: *mut *mut lzma_index, memlimit: *mut u64, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index 3d078f2b..8cf5801c 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -221,7 +221,7 @@ pub unsafe extern "C" fn lzma_index_encoder_init( index_encoder_reset((*next).coder as *mut lzma_index_coder, i); LZMA_OK } -pub unsafe extern "C" fn lzma_index_encoder( +pub unsafe fn lzma_index_encoder( strm: *mut lzma_stream, i: *const lzma_index, ) -> lzma_ret { @@ -242,7 +242,7 @@ pub unsafe extern "C" fn lzma_index_encoder( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -pub unsafe extern "C" fn lzma_index_buffer_encode( +pub unsafe fn lzma_index_buffer_encode( i: *const lzma_index, out: *mut u8, out_pos: *mut size_t, diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 815e723a..9d32b660 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -40,7 +40,7 @@ extern "C" fn index_stream_size( .wrapping_add(index_size(count, index_list_size)) .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) } -pub unsafe extern "C" fn lzma_index_hash_init( +pub unsafe fn lzma_index_hash_init( mut index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator, ) -> *mut lzma_index_hash { @@ -74,13 +74,13 @@ pub unsafe extern "C" fn lzma_index_hash_init( ); index_hash } -pub unsafe extern "C" fn lzma_index_hash_end( +pub unsafe fn lzma_index_hash_end( index_hash: *mut lzma_index_hash, allocator: *const lzma_allocator, ) { lzma_free(index_hash as *mut c_void, allocator); } -pub extern "C" fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { +pub fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { unsafe { index_size( (*index_hash).blocks.count, @@ -107,7 +107,7 @@ unsafe extern "C" fn hash_append( core::mem::size_of::<[lzma_vli; 2]>(), ); } -pub unsafe extern "C" fn lzma_index_hash_append( +pub unsafe fn lzma_index_hash_append( index_hash: *mut lzma_index_hash, unpadded_size: lzma_vli, uncompressed_size: lzma_vli, @@ -141,7 +141,7 @@ pub unsafe extern "C" fn lzma_index_hash_append( } LZMA_OK } -pub unsafe extern "C" fn lzma_index_hash_decode( +pub unsafe fn lzma_index_hash_decode( index_hash: *mut lzma_index_hash, in_0: *const u8, in_pos: *mut size_t, diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 5d839e14..075ec327 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -387,7 +387,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( (*coder).pos = 0; LZMA_OK } -pub unsafe extern "C" fn lzma_lzip_decoder( +pub unsafe fn lzma_lzip_decoder( strm: *mut lzma_stream, memlimit: u64, flags: u32, diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index b1ef102f..7c46979a 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -259,7 +259,7 @@ unsafe extern "C" fn microlzma_decoder_init( (*coder).props_decoded = false; LZMA_OK } -pub unsafe extern "C" fn lzma_microlzma_decoder( +pub unsafe fn lzma_microlzma_decoder( strm: *mut lzma_stream, comp_size: u64, uncomp_size: u64, diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index 20ddcd52..60f7c4a5 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -170,7 +170,7 @@ unsafe extern "C" fn microlzma_encoder_init( ::core::ptr::addr_of!(filters) as *const lzma_filter_info, ) } -pub unsafe extern "C" fn lzma_microlzma_encoder( +pub unsafe fn lzma_microlzma_encoder( strm: *mut lzma_stream, options: *const lzma_options_lzma, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index ecf15eab..a6cf5f8e 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub extern "C" fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { +pub fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { let limit: u64 = (UINT64_MAX) .wrapping_div((2 * 16384) as u64) .wrapping_div(2); @@ -37,7 +37,7 @@ unsafe extern "C" fn free_one_cached_buffer( .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); crate::alloc::internal_free(buf as *mut c_void, allocator); } -pub unsafe extern "C" fn lzma_outq_clear_cache( +pub unsafe fn lzma_outq_clear_cache( outq: *mut lzma_outq, allocator: *const lzma_allocator, ) { @@ -45,7 +45,7 @@ pub unsafe extern "C" fn lzma_outq_clear_cache( free_one_cached_buffer(outq, allocator); } } -pub unsafe extern "C" fn lzma_outq_clear_cache2( +pub unsafe fn lzma_outq_clear_cache2( outq: *mut lzma_outq, allocator: *const lzma_allocator, keep_size: size_t, @@ -60,7 +60,7 @@ pub unsafe extern "C" fn lzma_outq_clear_cache2( free_one_cached_buffer(outq, allocator); } } -pub unsafe extern "C" fn lzma_outq_init( +pub unsafe fn lzma_outq_init( outq: *mut lzma_outq, allocator: *const lzma_allocator, threads: u32, @@ -79,13 +79,13 @@ pub unsafe extern "C" fn lzma_outq_init( (*outq).read_pos = 0; LZMA_OK } -pub unsafe extern "C" fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator) { +pub unsafe fn lzma_outq_end(outq: *mut lzma_outq, allocator: *const lzma_allocator) { while !(*outq).head.is_null() { move_head_to_cache(outq, allocator); } lzma_outq_clear_cache(outq, allocator); } -pub unsafe extern "C" fn lzma_outq_prealloc_buf( +pub unsafe fn lzma_outq_prealloc_buf( outq: *mut lzma_outq, allocator: *const lzma_allocator, size: size_t, @@ -108,7 +108,7 @@ pub unsafe extern "C" fn lzma_outq_prealloc_buf( (*outq).mem_allocated = (*outq).mem_allocated.wrapping_add(alloc_size as u64); LZMA_OK } -pub unsafe extern "C" fn lzma_outq_get_buf( +pub unsafe fn lzma_outq_get_buf( outq: *mut lzma_outq, worker: *mut c_void, ) -> *mut lzma_outbuf { @@ -134,13 +134,13 @@ pub unsafe extern "C" fn lzma_outq_get_buf( .wrapping_add(lzma_outq_outbuf_memusage((*buf).allocated)); buf } -pub unsafe extern "C" fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool { +pub unsafe fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool { if (*outq).head.is_null() { return false; } (*outq).read_pos < (*(*outq).head).pos || (*(*outq).head).finished } -pub unsafe extern "C" fn lzma_outq_read( +pub unsafe fn lzma_outq_read( outq: *mut lzma_outq, allocator: *const lzma_allocator, out: *mut u8, @@ -175,7 +175,7 @@ pub unsafe extern "C" fn lzma_outq_read( (*outq).read_pos = 0; finish_ret } -pub unsafe extern "C" fn lzma_outq_enable_partial_output( +pub unsafe fn lzma_outq_enable_partial_output( outq: *mut lzma_outq, enable_partial_output: Option ()>, ) { diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index 94d87b0d..ba12cf7f 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub unsafe extern "C" fn lzma_stream_buffer_decode( +pub unsafe fn lzma_stream_buffer_decode( memlimit: *mut u64, flags: u32, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index d5a49e59..186fbf26 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -3,8 +3,8 @@ use crate::common::index_encoder::lzma_index_buffer_encode; use crate::types::*; pub const INDEX_BOUND: u32 = 1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3 & !(3); pub const HEADERS_BOUND: u32 = 2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND; -pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { - let block_bound: size_t = unsafe { lzma_block_buffer_bound(uncompressed_size) } as size_t; +pub fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { + let block_bound: size_t = lzma_block_buffer_bound(uncompressed_size) as size_t; if block_bound == 0 { return 0; } @@ -14,7 +14,7 @@ pub extern "C" fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t } block_bound.wrapping_add(HEADERS_BOUND as size_t) } -pub unsafe extern "C" fn lzma_stream_buffer_encode( +pub unsafe fn lzma_stream_buffer_encode( filters: *mut lzma_filter, check: lzma_check, allocator: *const lzma_allocator, diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 7ef3bdfc..97b7772d 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -450,7 +450,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( (*coder).first_stream = true; stream_decoder_reset(coder, allocator) } -pub unsafe extern "C" fn lzma_stream_decoder( +pub unsafe fn lzma_stream_decoder( strm: *mut lzma_stream, memlimit: u64, flags: u32, diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index fae7d6d8..553585a4 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -1578,7 +1578,7 @@ unsafe extern "C" fn stream_decoder_mt_init( } stream_decoder_reset(coder, allocator) } -pub unsafe extern "C" fn lzma_stream_decoder_mt( +pub unsafe fn lzma_stream_decoder_mt( strm: *mut lzma_stream, options: *const lzma_mt, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 90919b91..1e267dbe 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -396,7 +396,7 @@ unsafe extern "C" fn stream_encoder_init( (*coder).buffer_size = LZMA_STREAM_HEADER_SIZE as size_t; stream_encoder_update(coder as *mut c_void, allocator, filters, core::ptr::null()) } -pub unsafe extern "C" fn lzma_stream_encoder( +pub unsafe fn lzma_stream_encoder( strm: *mut lzma_stream, filters: *const lzma_filter, check: lzma_check, diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index f25331fc..3edf5b1d 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -1271,7 +1271,7 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).progress_out = LZMA_STREAM_HEADER_SIZE as u64; LZMA_OK } -pub unsafe extern "C" fn lzma_stream_encoder_mt( +pub unsafe fn lzma_stream_encoder_mt( strm: *mut lzma_stream, options: *const lzma_mt, ) -> lzma_ret { @@ -1294,7 +1294,7 @@ pub unsafe extern "C" fn lzma_stream_encoder_mt( (*(*strm).internal).supported_actions[LZMA_FINISH as usize] = true; LZMA_OK } -pub unsafe extern "C" fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64 { +pub unsafe fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64 { let mut easy: lzma_options_easy = lzma_options_easy { filters: [lzma_filter { id: 0, diff --git a/liblzma-rs/src/common/stream_flags_common.rs b/liblzma-rs/src/common/stream_flags_common.rs index 20cf7af6..be89bd00 100644 --- a/liblzma-rs/src/common/stream_flags_common.rs +++ b/liblzma-rs/src/common/stream_flags_common.rs @@ -3,7 +3,7 @@ pub static mut lzma_header_magic: [u8; 6] = [ 0xfd as u8, 0x37 as u8, 0x7a as u8, 0x58 as u8, 0x5a as u8, 0, ]; pub static mut lzma_footer_magic: [u8; 2] = [0x59 as u8, 0x5a as u8]; -pub unsafe extern "C" fn lzma_stream_flags_compare( +pub unsafe fn lzma_stream_flags_compare( a: *const lzma_stream_flags, b: *const lzma_stream_flags, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 9657c072..1ef5c4c2 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -10,7 +10,7 @@ extern "C" fn stream_flags_decode(options: *mut lzma_stream_flags, in_0: *const false }; } -pub unsafe extern "C" fn lzma_stream_header_decode( +pub unsafe fn lzma_stream_header_decode( options: *mut lzma_stream_flags, in_0: *const u8, ) -> lzma_ret { @@ -44,7 +44,7 @@ pub unsafe extern "C" fn lzma_stream_header_decode( (*options).backward_size = LZMA_VLI_UNKNOWN; LZMA_OK } -pub unsafe extern "C" fn lzma_stream_footer_decode( +pub unsafe fn lzma_stream_footer_decode( options: *mut lzma_stream_flags, in_0: *const u8, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/stream_flags_encoder.rs b/liblzma-rs/src/common/stream_flags_encoder.rs index befb8896..c9695e31 100644 --- a/liblzma-rs/src/common/stream_flags_encoder.rs +++ b/liblzma-rs/src/common/stream_flags_encoder.rs @@ -10,7 +10,7 @@ extern "C" fn stream_flags_encode(options: *const lzma_stream_flags, out: *mut u false }; } -pub unsafe extern "C" fn lzma_stream_header_encode( +pub unsafe fn lzma_stream_header_encode( options: *const lzma_stream_flags, out: *mut u8, ) -> lzma_ret { @@ -40,7 +40,7 @@ pub unsafe extern "C" fn lzma_stream_header_encode( ); LZMA_OK } -pub unsafe extern "C" fn lzma_stream_footer_encode( +pub unsafe fn lzma_stream_footer_encode( options: *const lzma_stream_flags, out: *mut u8, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 6854227e..a81e3a2a 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -910,7 +910,7 @@ unsafe extern "C" fn str_to_filters( } errmsg } -pub unsafe extern "C" fn lzma_str_to_filters( +pub unsafe fn lzma_str_to_filters( str: *const c_char, error_pos: *mut c_int, filters: *mut lzma_filter, @@ -1004,7 +1004,7 @@ unsafe extern "C" fn strfy_filter( i += 1; } } -pub unsafe extern "C" fn lzma_str_from_filters( +pub unsafe fn lzma_str_from_filters( output_str: *mut *mut c_char, filters: *const lzma_filter, flags: u32, @@ -1104,7 +1104,7 @@ pub unsafe extern "C" fn lzma_str_from_filters( } str_finish(output_str, ::core::ptr::addr_of_mut!(dest), allocator) } -pub unsafe extern "C" fn lzma_str_list_filters( +pub unsafe fn lzma_str_list_filters( output_str: *mut *mut c_char, filter_id: lzma_vli, flags: u32, diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index c4ec4ffb..96b1a9f9 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub unsafe extern "C" fn lzma_vli_decode( +pub unsafe fn lzma_vli_decode( vli: *mut lzma_vli, mut vli_pos: *mut size_t, in_0: *const u8, diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index 0e73f3e6..7dc86ab3 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub unsafe extern "C" fn lzma_vli_encode( +pub unsafe fn lzma_vli_encode( mut vli: lzma_vli, mut vli_pos: *mut size_t, out: *mut u8, diff --git a/liblzma-rs/src/common/vli_size.rs b/liblzma-rs/src/common/vli_size.rs index 184869ac..1106fe77 100644 --- a/liblzma-rs/src/common/vli_size.rs +++ b/liblzma-rs/src/common/vli_size.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub extern "C" fn lzma_vli_size(mut vli: lzma_vli) -> u32 { +pub fn lzma_vli_size(mut vli: lzma_vli) -> u32 { if vli > LZMA_VLI_MAX { return 0; } diff --git a/liblzma-rs/src/delta/delta_common.rs b/liblzma-rs/src/delta/delta_common.rs index 24a5f519..50321d75 100644 --- a/liblzma-rs/src/delta/delta_common.rs +++ b/liblzma-rs/src/delta/delta_common.rs @@ -4,7 +4,7 @@ unsafe extern "C" fn delta_coder_end(coder_ptr: *mut c_void, allocator: *const l lzma_next_end(::core::ptr::addr_of_mut!((*coder).next), allocator); crate::alloc::internal_free(coder as *mut c_void, allocator); } -pub unsafe extern "C" fn lzma_delta_coder_init( +pub unsafe fn lzma_delta_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index 1c529a86..fc757e8e 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -172,7 +172,7 @@ unsafe extern "C" fn lz_decoder_end(coder_ptr: *mut c_void, allocator: *const lz } crate::alloc::internal_free(coder as *mut c_void, allocator); } -pub unsafe extern "C" fn lzma_lz_decoder_init( +pub unsafe fn lzma_lz_decoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, @@ -298,7 +298,7 @@ pub unsafe extern "C" fn lzma_lz_decoder_init( filters.offset(1), ) } -pub extern "C" fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64 { +pub fn lzma_lz_decoder_memusage(dictionary_size: size_t) -> u64 { (core::mem::size_of::() as u64) .wrapping_add(dictionary_size as u64) .wrapping_add((2 * LZ_DICT_REPEAT_MAX) as u64) diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index 7e7244d5..ab355d65 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -314,7 +314,7 @@ unsafe fn lz_encoder_init( (*mf).action = LZMA_RUN; false } -pub extern "C" fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> u64 { +pub fn lzma_lz_encoder_memusage(lz_options: *const lzma_lz_options) -> u64 { let mut mf: lzma_mf = lzma_mf_s { buffer: core::ptr::null_mut(), size: 0, @@ -391,7 +391,7 @@ unsafe extern "C" fn lz_encoder_set_out_limit( } LZMA_OPTIONS_ERROR } -pub unsafe extern "C" fn lzma_lz_encoder_init( +pub unsafe fn lzma_lz_encoder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, @@ -512,7 +512,7 @@ pub unsafe extern "C" fn lzma_lz_encoder_init( filters.offset(1), ) } -pub extern "C" fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { +pub fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool { match mf { 3 => return true as lzma_bool, 4 => return true as lzma_bool, diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index aae4f0d6..52984618 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -5,7 +5,7 @@ pub const HASH_3_MASK: c_uint = HASH_3_SIZE.wrapping_sub(1); pub const FIX_3_HASH_SIZE: c_uint = 1u32 << 10; pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); #[inline] -pub unsafe extern "C" fn lzma_mf_find( +pub unsafe fn lzma_mf_find( mf: *mut lzma_mf, count_ptr: *mut u32, matches: *mut lzma_match, diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index 5f081281..c3fea7b3 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -255,7 +255,7 @@ pub unsafe extern "C" fn lzma_lzma2_decoder_init( } pub extern "C" fn lzma_lzma2_decoder_memusage(options: *const c_void) -> u64 { (core::mem::size_of::() as u64) - .wrapping_add(unsafe { lzma_lzma_decoder_memusage_nocheck(options) }) + .wrapping_add(lzma_lzma_decoder_memusage_nocheck(options)) } pub unsafe extern "C" fn lzma_lzma2_props_decode( options: *mut *mut c_void, diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index ca6505d5..282bbcd8 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -375,7 +375,7 @@ pub unsafe extern "C" fn lzma_lzma2_encoder_init( ) } pub extern "C" fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64 { - let lzma_mem: u64 = unsafe { lzma_lzma_encoder_memusage(options) } as u64; + let lzma_mem: u64 = lzma_lzma_encoder_memusage(options) as u64; if lzma_mem == UINT64_MAX { return UINT64_MAX; } diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index afc8dcb9..44a647ad 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -3360,7 +3360,7 @@ unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_vo (*coder).offset = 0; (*coder).len = 0; } -pub unsafe extern "C" fn lzma_lzma_decoder_create( +pub unsafe fn lzma_lzma_decoder_create( lz: *mut lzma_lz_decoder, allocator: *const lzma_allocator, options: *const lzma_options_lzma, @@ -3449,7 +3449,7 @@ pub unsafe extern "C" fn lzma_lzma_decoder_init( ), ) } -pub unsafe extern "C" fn lzma_lzma_lclppb_decode( +pub unsafe fn lzma_lzma_lclppb_decode( options: *mut lzma_options_lzma, mut byte: u8, ) -> bool { diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 26614d39..15ecd2e9 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -673,7 +673,7 @@ unsafe extern "C" fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) match_0(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN); } pub const LOOP_INPUT_MAX: u32 = OPTS + 1; -pub unsafe extern "C" fn lzma_lzma_encode( +pub unsafe fn lzma_lzma_encode( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, out: *mut u8, @@ -856,7 +856,7 @@ unsafe extern "C" fn length_encoder_reset( } } } -pub unsafe extern "C" fn lzma_lzma_encoder_reset( +pub unsafe fn lzma_lzma_encoder_reset( coder: *mut lzma_lzma1_encoder, options: *const lzma_options_lzma, ) -> lzma_ret { @@ -929,7 +929,7 @@ pub unsafe extern "C" fn lzma_lzma_encoder_reset( (*coder).opts_current_index = 0; LZMA_OK } -pub unsafe extern "C" fn lzma_lzma_encoder_create( +pub unsafe fn lzma_lzma_encoder_create( coder_ptr: *mut *mut c_void, allocator: *const lzma_allocator, id: lzma_vli, @@ -1057,13 +1057,13 @@ pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { options as *const lzma_options_lzma, ); let lz_memusage: u64 = - unsafe { lzma_lz_encoder_memusage(::core::ptr::addr_of_mut!(lz_options)) } as u64; + lzma_lz_encoder_memusage(::core::ptr::addr_of_mut!(lz_options)) as u64; if lz_memusage == UINT64_MAX { return UINT64_MAX; } (core::mem::size_of::() as u64).wrapping_add(lz_memusage) } -pub unsafe extern "C" fn lzma_lzma_lclppb_encode( +pub unsafe fn lzma_lzma_lclppb_encode( options: *const lzma_options_lzma, byte: *mut u8, ) -> bool { @@ -1089,6 +1089,6 @@ pub unsafe extern "C" fn lzma_lzma_props_encode(options: *const c_void, out: *mu write32le(out.offset(1), (*opt).dict_size); LZMA_OK } -pub extern "C" fn lzma_mode_is_supported(mode: lzma_mode) -> lzma_bool { +pub fn lzma_mode_is_supported(mode: lzma_mode) -> lzma_bool { (mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL) as lzma_bool } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 66e50a4f..3b35df44 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -1,5 +1,5 @@ use crate::types::*; -pub unsafe extern "C" fn lzma_lzma_optimum_fast( +pub unsafe fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, back_res: *mut u32, diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 776893cc..67dfdee0 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -864,7 +864,7 @@ unsafe fn helper2( } len_end } -pub unsafe extern "C" fn lzma_lzma_optimum_normal( +pub unsafe fn lzma_lzma_optimum_normal( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, back_res: *mut u32, diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index 0602d789..41643f43 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -3,7 +3,7 @@ pub const LZMA_LC_DEFAULT: u32 = 3; pub const LZMA_LP_DEFAULT: u32 = 0; pub const LZMA_PB_DEFAULT: u32 = 2; pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f; -pub unsafe extern "C" fn lzma_lzma_preset( +pub unsafe fn lzma_lzma_preset( options: *mut lzma_options_lzma, preset: u32, ) -> lzma_bool { diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index 39f850a2..f24baa9a 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -69,7 +69,7 @@ pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( ) -> lzma_ret { arm64_coder_init(next, allocator, filters, true) } -pub unsafe extern "C" fn lzma_bcj_arm64_encode( +pub unsafe fn lzma_bcj_arm64_encode( mut start_offset: u32, buf: *mut u8, size: size_t, @@ -84,7 +84,7 @@ pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( ) -> lzma_ret { arm64_coder_init(next, allocator, filters, false) } -pub unsafe extern "C" fn lzma_bcj_arm64_decode( +pub unsafe fn lzma_bcj_arm64_decode( mut start_offset: u32, buf: *mut u8, size: size_t, diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 4f7a2cce..1fbf8754 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -113,7 +113,7 @@ pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( true, ) } -pub unsafe extern "C" fn lzma_bcj_riscv_encode( +pub unsafe fn lzma_bcj_riscv_encode( mut start_offset: u32, buf: *mut u8, size: size_t, @@ -213,7 +213,7 @@ pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( false, ) } -pub unsafe extern "C" fn lzma_bcj_riscv_decode( +pub unsafe fn lzma_bcj_riscv_decode( mut start_offset: u32, buf: *mut u8, size: size_t, diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 4e40c117..d46b6212 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -186,7 +186,7 @@ unsafe extern "C" fn simple_coder_update( reversed_filters.offset(1), ) } -pub unsafe extern "C" fn lzma_simple_coder_init( +pub unsafe fn lzma_simple_coder_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, filters: *const lzma_filter_info, diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index 28cccdd6..2a6ab151 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -124,7 +124,7 @@ pub unsafe extern "C" fn lzma_simple_x86_encoder_init( ) -> lzma_ret { x86_coder_init(next, allocator, filters, true) } -pub unsafe extern "C" fn lzma_bcj_x86_encode( +pub unsafe fn lzma_bcj_x86_encode( start_offset: u32, buf: *mut u8, size: size_t, @@ -148,7 +148,7 @@ pub unsafe extern "C" fn lzma_simple_x86_decoder_init( ) -> lzma_ret { x86_coder_init(next, allocator, filters, false) } -pub unsafe extern "C" fn lzma_bcj_x86_decode( +pub unsafe fn lzma_bcj_x86_decode( start_offset: u32, buf: *mut u8, size: size_t, diff --git a/liblzma-rs/src/tuklib/tuklib_cpucores.rs b/liblzma-rs/src/tuklib/tuklib_cpucores.rs index 3408c662..b0db2196 100644 --- a/liblzma-rs/src/tuklib/tuklib_cpucores.rs +++ b/liblzma-rs/src/tuklib/tuklib_cpucores.rs @@ -1,4 +1,4 @@ -pub extern "C" fn tuklib_cpucores() -> u32 { +pub fn tuklib_cpucores() -> u32 { match std::thread::available_parallelism() { Ok(n) => n.get() as u32, Err(_) => 0, diff --git a/liblzma-rs/src/tuklib/tuklib_physmem.rs b/liblzma-rs/src/tuklib/tuklib_physmem.rs index 6efe29d6..587fa05a 100644 --- a/liblzma-rs/src/tuklib/tuklib_physmem.rs +++ b/liblzma-rs/src/tuklib/tuklib_physmem.rs @@ -1,4 +1,4 @@ -pub extern "C" fn tuklib_physmem() -> u64 { +pub fn tuklib_physmem() -> u64 { #[cfg(target_os = "macos")] { let mut memsize: u64 = 0; diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 53fe7b38..af16c498 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -608,7 +608,7 @@ pub struct lzma_lzma1_encoder_s { } pub type lzma_lzma1_encoder = lzma_lzma1_encoder_s; #[inline] -pub extern "C" fn read32le(buf: *const u8) -> u32 { +pub fn read32le(buf: *const u8) -> u32 { return unsafe { let mut num: u32 = *buf as u32; num |= (*buf.offset(1) as u32) << 8; @@ -618,7 +618,7 @@ pub extern "C" fn read32le(buf: *const u8) -> u32 { }; } #[inline] -pub extern "C" fn write32le(buf: *mut u8, num: u32) { +pub fn write32le(buf: *mut u8, num: u32) { unsafe { *buf = num as u8; *buf.offset(1) = (num >> 8) as u8; @@ -712,12 +712,12 @@ pub struct mythread_cond { } pub type mythread_condtime = timespec; #[inline] -pub extern "C" fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { +pub fn mythread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) { let _ret: c_int = unsafe { pthread_sigmask(how, set as *const sigset_t, oset as *mut sigset_t) }; } #[inline] -pub extern "C" fn mythread_create( +pub fn mythread_create( thread: *mut mythread, func: Option *mut c_void>, arg: *mut c_void, @@ -746,42 +746,42 @@ pub extern "C" fn mythread_create( ret } #[inline] -pub extern "C" fn mythread_join(thread: mythread) -> c_int { +pub fn mythread_join(thread: mythread) -> c_int { unsafe { pthread_join(thread as pthread_t, core::ptr::null_mut()) } } #[inline] -pub extern "C" fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { +pub fn mythread_mutex_init(mutex: *mut mythread_mutex) -> c_int { unsafe { pthread_mutex_init(mutex as *mut pthread_mutex_t, core::ptr::null()) } } #[inline] -pub extern "C" fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { +pub fn mythread_mutex_destroy(mutex: *mut mythread_mutex) { let _ret: c_int = unsafe { pthread_mutex_destroy(mutex as *mut pthread_mutex_t) }; } #[inline] -pub extern "C" fn mythread_mutex_lock(mutex: *mut mythread_mutex) { +pub fn mythread_mutex_lock(mutex: *mut mythread_mutex) { let _ret: c_int = unsafe { pthread_mutex_lock(mutex as *mut pthread_mutex_t) }; } #[inline] -pub extern "C" fn mythread_mutex_unlock(mutex: *mut mythread_mutex) { +pub fn mythread_mutex_unlock(mutex: *mut mythread_mutex) { let _ret: c_int = unsafe { pthread_mutex_unlock(mutex as *mut pthread_mutex_t) }; } #[inline] -pub extern "C" fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { +pub fn mythread_cond_init(mycond: *mut mythread_cond) -> c_int { return unsafe { (*mycond).clk_id = _CLOCK_REALTIME; pthread_cond_init(::core::ptr::addr_of_mut!((*mycond).cond), core::ptr::null()) }; } #[inline] -pub extern "C" fn mythread_cond_destroy(cond: *mut mythread_cond) { +pub fn mythread_cond_destroy(cond: *mut mythread_cond) { let _ret: c_int = unsafe { pthread_cond_destroy(::core::ptr::addr_of_mut!((*cond).cond)) }; } #[inline] -pub extern "C" fn mythread_cond_signal(cond: *mut mythread_cond) { +pub fn mythread_cond_signal(cond: *mut mythread_cond) { let _ret: c_int = unsafe { pthread_cond_signal(::core::ptr::addr_of_mut!((*cond).cond)) }; } #[inline] -pub extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { +pub fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythread_mutex) { let _ret: c_int = unsafe { pthread_cond_wait( ::core::ptr::addr_of_mut!((*cond).cond), @@ -790,7 +790,7 @@ pub extern "C" fn mythread_cond_wait(cond: *mut mythread_cond, mutex: *mut mythr }; } #[inline] -pub extern "C" fn mythread_cond_timedwait( +pub fn mythread_cond_timedwait( cond: *mut mythread_cond, mutex: *mut mythread_mutex, condtime: *const mythread_condtime, @@ -805,7 +805,7 @@ pub extern "C" fn mythread_cond_timedwait( ret } #[inline] -pub extern "C" fn mythread_condtime_set( +pub fn mythread_condtime_set( condtime: *mut mythread_condtime, cond: *const mythread_cond, timeout_ms: u32, @@ -827,40 +827,40 @@ pub extern "C" fn mythread_condtime_set( } } #[inline] -pub extern "C" fn vli_ceil4(vli: lzma_vli) -> lzma_vli { +pub fn vli_ceil4(vli: lzma_vli) -> lzma_vli { vli.wrapping_add(3) & !(3) } #[inline] -pub extern "C" fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { - (1u32.wrapping_add(unsafe { lzma_vli_size(count) }) as lzma_vli) +pub fn index_size_unpadded(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { + (1u32.wrapping_add(lzma_vli_size(count)) as lzma_vli) .wrapping_add(index_list_size) .wrapping_add(4) } #[inline] -pub extern "C" fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { +pub fn lzma_outq_has_buf(outq: *const lzma_outq) -> bool { unsafe { (*outq).bufs_in_use < (*outq).bufs_limit } } #[inline] -pub extern "C" fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { +pub fn lzma_outq_is_empty(outq: *const lzma_outq) -> bool { unsafe { (*outq).bufs_in_use == 0 } } #[inline] -pub unsafe extern "C" fn mf_ptr(mf: *const lzma_mf) -> *const u8 { +pub unsafe fn mf_ptr(mf: *const lzma_mf) -> *const u8 { (*mf).buffer.offset((*mf).read_pos as isize) } #[inline] -pub unsafe extern "C" fn mf_avail(mf: *const lzma_mf) -> u32 { +pub unsafe fn mf_avail(mf: *const lzma_mf) -> u32 { (*mf).write_pos.wrapping_sub((*mf).read_pos) } #[inline] -pub unsafe extern "C" fn mf_skip(mf: *mut lzma_mf, amount: u32) { +pub unsafe fn mf_skip(mf: *mut lzma_mf, amount: u32) { if amount != 0 { (*mf).skip.unwrap()(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } #[inline(always)] -pub unsafe extern "C" fn lzma_memcmplen( +pub unsafe fn lzma_memcmplen( buf1: *const u8, buf2: *const u8, mut len: u32, @@ -889,7 +889,7 @@ pub unsafe extern "C" fn lzma_memcmplen( len } #[inline] -pub unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { +pub unsafe fn get_dist_slot(dist: u32) -> u32 { if dist < 1 << FASTPOS_BITS + (0 + 0 * (FASTPOS_BITS - 1)) { return lzma_fastpos[dist as usize] as u32; } @@ -901,7 +901,7 @@ pub unsafe extern "C" fn get_dist_slot(dist: u32) -> u32 { .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) } #[inline] -pub extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { +pub fn rc_bit_price(prob: probability, bit: u32) -> u32 { unsafe { lzma_rc_prices[((prob as u32 ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) @@ -909,11 +909,11 @@ pub extern "C" fn rc_bit_price(prob: probability, bit: u32) -> u32 { } } #[inline] -pub extern "C" fn rc_bit_0_price(prob: probability) -> u32 { +pub fn rc_bit_0_price(prob: probability) -> u32 { unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 } } #[inline] -pub extern "C" fn rc_bit_1_price(prob: probability) -> u32 { +pub fn rc_bit_1_price(prob: probability) -> u32 { unsafe { lzma_rc_prices [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] @@ -921,7 +921,7 @@ pub extern "C" fn rc_bit_1_price(prob: probability) -> u32 { } } #[inline] -pub unsafe extern "C" fn rc_bittree_price( +pub unsafe fn rc_bittree_price( probs: *const probability, bit_levels: u32, mut symbol: u32, @@ -939,18 +939,18 @@ pub unsafe extern "C" fn rc_bittree_price( price } #[inline] -pub extern "C" fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { +pub fn mf_get_hash_bytes(match_finder: lzma_match_finder) -> u32 { match_finder as u32 & 0xf } #[inline] -pub unsafe extern "C" fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { +pub unsafe fn is_lclppb_valid(options: *const lzma_options_lzma) -> bool { (*options).lc <= LZMA_LCLP_MAX && (*options).lp <= LZMA_LCLP_MAX && (*options).lc.wrapping_add((*options).lp) <= LZMA_LCLP_MAX && (*options).pb <= LZMA_PB_MAX } #[inline] -pub unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) { +pub unsafe fn literal_init(probs: *mut probability, lc: u32, lp: u32) { let coders: size_t = (LITERAL_CODER_SIZE << lc.wrapping_add(lp)) as size_t; let mut i: size_t = 0; while i < coders { @@ -958,7 +958,7 @@ pub unsafe extern "C" fn literal_init(probs: *mut probability, lc: u32, lp: u32) i += 1; } } -pub extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { +pub fn is_backward_size_valid(options: *const lzma_stream_flags) -> bool { unsafe { (*options).backward_size >= LZMA_BACKWARD_SIZE_MIN as lzma_vli && (*options).backward_size <= LZMA_BACKWARD_SIZE_MAX @@ -966,14 +966,14 @@ pub extern "C" fn is_backward_size_valid(options: *const lzma_stream_flags) -> b } } #[inline] -pub extern "C" fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { +pub fn index_size(count: lzma_vli, index_list_size: lzma_vli) -> lzma_vli { vli_ceil4(index_size_unpadded(count, index_list_size)) } -pub extern "C" fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { +pub fn lzma_outq_outbuf_memusage(buf_size: size_t) -> u64 { (core::mem::size_of::()).wrapping_add(buf_size as usize) as u64 } #[inline] -pub unsafe extern "C" fn aligned_read32ne(buf: *const u8) -> u32 { +pub unsafe fn aligned_read32ne(buf: *const u8) -> u32 { *(buf as *const u32) } pub type rc_symbol = c_uint; From 15a05baa66c73b15f52e59ed835561d209ddd52b Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Thu, 19 Mar 2026 20:43:50 +0900 Subject: [PATCH 22/51] remove extern "C" from private internal functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are not callbacks — they are called directly and extern "C" prevents inlining. Matches C's static inline pattern. --- liblzma-rs/src/check/crc32_fast.rs | 2 +- liblzma-rs/src/check/crc64_fast.rs | 2 +- liblzma-rs/src/check/sha256.rs | 4 +- liblzma-rs/src/common/block_buffer_encoder.rs | 6 +-- liblzma-rs/src/common/file_info.rs | 10 ++--- liblzma-rs/src/common/index.rs | 24 +++++----- liblzma-rs/src/common/index_decoder.rs | 2 +- liblzma-rs/src/common/index_encoder.rs | 2 +- liblzma-rs/src/common/index_hash.rs | 2 +- liblzma-rs/src/common/outqueue.rs | 4 +- liblzma-rs/src/common/stream_decoder_mt.rs | 14 +++--- liblzma-rs/src/common/stream_encoder_mt.rs | 18 ++++---- liblzma-rs/src/common/string_conversion.rs | 24 +++++----- liblzma-rs/src/delta/delta_decoder.rs | 2 +- liblzma-rs/src/delta/delta_encoder.rs | 4 +- liblzma-rs/src/lz/lz_decoder.rs | 4 +- liblzma-rs/src/lzma/lzma2_decoder.rs | 4 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 8 ++-- liblzma-rs/src/lzma/lzma_decoder.rs | 14 +++--- liblzma-rs/src/lzma/lzma_encoder.rs | 44 +++++++++---------- liblzma-rs/src/simple/simple_coder.rs | 4 +- 21 files changed, 99 insertions(+), 99 deletions(-) diff --git a/liblzma-rs/src/check/crc32_fast.rs b/liblzma-rs/src/check/crc32_fast.rs index 0b784ed0..b27f1e92 100644 --- a/liblzma-rs/src/check/crc32_fast.rs +++ b/liblzma-rs/src/check/crc32_fast.rs @@ -313,7 +313,7 @@ pub static lzma_crc32_table: [[u32; 256]; 8] = [ 0x646e019b, 0xeae10678, 0x264b06e6, ], ]; -unsafe extern "C" fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mut crc: u32) -> u32 { +unsafe fn lzma_crc32_generic(mut buf: *const u8, mut size: size_t, mut crc: u32) -> u32 { crc = !crc; if size > 8 { while buf as uintptr_t & 7 as uintptr_t != 0 { diff --git a/liblzma-rs/src/check/crc64_fast.rs b/liblzma-rs/src/check/crc64_fast.rs index 07753301..16bef208 100644 --- a/liblzma-rs/src/check/crc64_fast.rs +++ b/liblzma-rs/src/check/crc64_fast.rs @@ -1034,7 +1034,7 @@ pub static mut lzma_crc64_table: [[u64; 256]; 4] = [ ], ]; #[inline] -unsafe extern "C" fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mut crc: u64) -> u64 { +unsafe fn lzma_crc64_generic(mut buf: *const u8, mut size: size_t, mut crc: u64) -> u64 { crc = !crc; if size > 4 { while buf as uintptr_t & 3 as uintptr_t != 0 { diff --git a/liblzma-rs/src/check/sha256.rs b/liblzma-rs/src/check/sha256.rs index 41cf9c8c..f9b8de44 100644 --- a/liblzma-rs/src/check/sha256.rs +++ b/liblzma-rs/src/check/sha256.rs @@ -13,7 +13,7 @@ static mut SHA256_K: [u32; 64] = [ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, ]; -unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { +unsafe fn transform(state: *mut u32, data: *const u32) { let mut W: [u32; 16] = [0; 16]; let mut T: [u32; 8] = [0; 8]; core::ptr::copy_nonoverlapping( @@ -525,7 +525,7 @@ unsafe extern "C" fn transform(state: *mut u32, data: *const u32) { *state.offset(i as isize) = (*state.offset(i as isize)).wrapping_add(T[i]); } } -unsafe extern "C" fn process(check: *mut lzma_check_state) { +unsafe fn process(check: *mut lzma_check_state) { transform( ::core::ptr::addr_of_mut!((*check).state.sha256.state) as *mut u32, ::core::ptr::addr_of_mut!((*check).buffer.u32_0) as *const u32, diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index 2d13ddd7..f5239327 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -28,7 +28,7 @@ pub fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t { let ret: u64 = lzma_block_buffer_bound64(uncompressed_size as u64); ret as size_t } -unsafe extern "C" fn block_encode_uncompressed( +unsafe fn block_encode_uncompressed( block: *mut lzma_block, in_0: *const u8, in_size: size_t, @@ -114,7 +114,7 @@ unsafe extern "C" fn block_encode_uncompressed( *out_pos += 1; LZMA_OK } -unsafe extern "C" fn block_encode_normal( +unsafe fn block_encode_normal( block: *mut lzma_block, allocator: *const lzma_allocator, in_0: *const u8, @@ -183,7 +183,7 @@ unsafe extern "C" fn block_encode_normal( } ret } -unsafe extern "C" fn block_buffer_encode( +unsafe fn block_buffer_encode( block: *mut lzma_block, allocator: *const lzma_allocator, in_0: *const u8, diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index d1c5594e..26513320 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -35,7 +35,7 @@ pub const SEQ_FOOTER: file_info_seq = 3; pub const SEQ_PADDING_DECODE: file_info_seq = 2; pub const SEQ_PADDING_SEEK: file_info_seq = 1; pub const SEQ_MAGIC_BYTES: file_info_seq = 0; -unsafe extern "C" fn fill_temp( +unsafe fn fill_temp( coder: *mut lzma_file_info_coder, in_0: *const u8, in_pos: *mut size_t, @@ -51,7 +51,7 @@ unsafe extern "C" fn fill_temp( ) as u64); (*coder).temp_pos < (*coder).temp_size } -unsafe extern "C" fn seek_to_pos( +unsafe fn seek_to_pos( coder: *mut lzma_file_info_coder, target_pos: u64, in_start: size_t, @@ -76,7 +76,7 @@ unsafe extern "C" fn seek_to_pos( (*coder).file_cur_pos = target_pos; external_seek_needed } -unsafe extern "C" fn reverse_seek( +unsafe fn reverse_seek( coder: *mut lzma_file_info_coder, in_start: size_t, in_pos: *mut size_t, @@ -110,7 +110,7 @@ unsafe extern "C" fn reverse_seek( } LZMA_OK } -unsafe extern "C" fn get_padding_size(buf: *const u8, mut buf_size: size_t) -> size_t { +unsafe fn get_padding_size(buf: *const u8, mut buf_size: size_t) -> size_t { let mut padding: size_t = 0; while buf_size > 0 && { buf_size -= 1; @@ -126,7 +126,7 @@ extern "C" fn hide_format_error(mut ret: lzma_ret) -> lzma_ret { } ret } -unsafe extern "C" fn decode_index( +unsafe fn decode_index( coder: *mut lzma_file_info_coder, allocator: *const lzma_allocator, in_0: *const u8, diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 0c87fd38..0df8debe 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -87,13 +87,13 @@ pub const INDEX_GROUP_SIZE: u32 = 512; pub const PREALLOC_MAX: usize = (SIZE_MAX as usize) .wrapping_sub(core::mem::size_of::()) .wrapping_div(core::mem::size_of::()); -unsafe extern "C" fn index_tree_init(tree: *mut index_tree) { +unsafe fn index_tree_init(tree: *mut index_tree) { (*tree).root = core::ptr::null_mut(); (*tree).leftmost = core::ptr::null_mut(); (*tree).rightmost = core::ptr::null_mut(); (*tree).count = 0; } -unsafe extern "C" fn index_tree_node_end( +unsafe fn index_tree_node_end( node: *mut index_tree_node, allocator: *const lzma_allocator, free_func: Option ()>, @@ -106,7 +106,7 @@ unsafe extern "C" fn index_tree_node_end( } free_func.unwrap()(node as *mut c_void, allocator); } -unsafe extern "C" fn index_tree_end( +unsafe fn index_tree_end( tree: *mut index_tree, allocator: *const lzma_allocator, free_func: Option ()>, @@ -115,7 +115,7 @@ unsafe extern "C" fn index_tree_end( index_tree_node_end((*tree).root, allocator, free_func); } } -unsafe extern "C" fn index_tree_append(tree: *mut index_tree, mut node: *mut index_tree_node) { +unsafe fn index_tree_append(tree: *mut index_tree, mut node: *mut index_tree_node) { (*node).parent = (*tree).rightmost; (*node).left = core::ptr::null_mut(); (*node).right = core::ptr::null_mut(); @@ -153,7 +153,7 @@ unsafe extern "C" fn index_tree_append(tree: *mut index_tree, mut node: *mut ind (*node).parent = pivot; } } -unsafe extern "C" fn index_tree_next(mut node: *const index_tree_node) -> *mut c_void { +unsafe fn index_tree_next(mut node: *const index_tree_node) -> *mut c_void { if !(*node).right.is_null() { node = (*node).right; while !(*node).left.is_null() { @@ -166,7 +166,7 @@ unsafe extern "C" fn index_tree_next(mut node: *const index_tree_node) -> *mut c } (*node).parent as *mut c_void } -unsafe extern "C" fn index_tree_locate(tree: *const index_tree, target: lzma_vli) -> *mut c_void { +unsafe fn index_tree_locate(tree: *const index_tree, target: lzma_vli) -> *mut c_void { let mut result: *const index_tree_node = core::ptr::null(); let mut node: *const index_tree_node = (*tree).root; while !node.is_null() { @@ -179,7 +179,7 @@ unsafe extern "C" fn index_tree_locate(tree: *const index_tree, target: lzma_vli } result as *mut c_void } -unsafe extern "C" fn index_stream_init( +unsafe fn index_stream_init( compressed_base: lzma_vli, uncompressed_base: lzma_vli, stream_number: u32, @@ -214,7 +214,7 @@ unsafe extern "C" fn index_stream_end(node: *mut c_void, allocator: *const lzma_ ); lzma_free(s as *mut c_void, allocator); } -unsafe extern "C" fn index_init_plain(allocator: *const lzma_allocator) -> *mut lzma_index { +unsafe fn index_init_plain(allocator: *const lzma_allocator) -> *mut lzma_index { let i: *mut lzma_index = lzma_alloc(core::mem::size_of::(), allocator) as *mut lzma_index; if !i.is_null() { @@ -317,7 +317,7 @@ pub fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) } } -unsafe extern "C" fn index_file_size( +unsafe fn index_file_size( compressed_base: lzma_vli, unpadded_sum: lzma_vli, record_count: lzma_vli, @@ -497,7 +497,7 @@ pub unsafe fn lzma_index_append( .wrapping_add(index_list_size_add as lzma_vli); LZMA_OK } -unsafe extern "C" fn index_cat_helper(info: *const index_cat_info, this: *mut index_stream) { +unsafe fn index_cat_helper(info: *const index_cat_info, this: *mut index_stream) { let left: *mut index_stream = (*this).node.left as *mut index_stream; let right: *mut index_stream = (*this).node.right as *mut index_stream; if !left.is_null() { @@ -598,7 +598,7 @@ pub unsafe fn lzma_index_cat( lzma_free(src as *mut c_void, allocator); LZMA_OK } -unsafe extern "C" fn index_dup_stream( +unsafe fn index_dup_stream( src: *const index_stream, allocator: *const lzma_allocator, ) -> *mut index_stream { @@ -694,7 +694,7 @@ pub unsafe fn lzma_index_dup( } dest } -unsafe extern "C" fn iter_set_info(iter: *mut lzma_index_iter) { +unsafe fn iter_set_info(iter: *mut lzma_index_iter) { let i: *const lzma_index = (*iter).internal[ITER_INDEX as usize].p as *const lzma_index; let stream: *const index_stream = (*iter).internal[ITER_STREAM as usize].p as *const index_stream; diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 62905c15..67bfa8e7 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -205,7 +205,7 @@ unsafe extern "C" fn index_decoder_memconfig( } LZMA_OK } -unsafe extern "C" fn index_decoder_reset( +unsafe fn index_decoder_reset( coder: *mut lzma_index_coder, allocator: *const lzma_allocator, i: *mut *mut lzma_index, diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index 8cf5801c..56194af6 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -142,7 +142,7 @@ unsafe extern "C" fn index_encode( unsafe extern "C" fn index_encoder_end(coder: *mut c_void, allocator: *const lzma_allocator) { crate::alloc::internal_free(coder, allocator); } -unsafe extern "C" fn index_encoder_reset(coder: *mut lzma_index_coder, i: *const lzma_index) { +unsafe fn index_encoder_reset(coder: *mut lzma_index_coder, i: *const lzma_index) { lzma_index_iter_init(::core::ptr::addr_of_mut!((*coder).iter), i); (*coder).sequence = SEQ_INDICATOR; (*coder).index = i; diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 9d32b660..7225cb6e 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -88,7 +88,7 @@ pub fn lzma_index_hash_size(index_hash: *const lzma_index_hash) -> lzma_vli { ) } } -unsafe extern "C" fn hash_append( +unsafe fn hash_append( info: *mut lzma_index_hash_info, unpadded_size: lzma_vli, uncompressed_size: lzma_vli, diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index a6cf5f8e..9aa1fd9c 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -9,7 +9,7 @@ pub fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { ((2u32).wrapping_mul(threads) as u64) .wrapping_mul(lzma_outq_outbuf_memusage(buf_size_max as size_t)) } -unsafe extern "C" fn move_head_to_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator) { +unsafe fn move_head_to_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator) { let buf: *mut lzma_outbuf = (*outq).head; (*outq).head = (*buf).next; if (*outq).head.is_null() { @@ -25,7 +25,7 @@ unsafe extern "C" fn move_head_to_cache(outq: *mut lzma_outq, allocator: *const .mem_in_use .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); } -unsafe extern "C" fn free_one_cached_buffer( +unsafe fn free_one_cached_buffer( outq: *mut lzma_outq, allocator: *const lzma_allocator, ) { diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index 553585a4..df957f08 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -251,7 +251,7 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { } } } -unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) { +unsafe fn threads_end(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) { let mut i: u32 = 0; while i < (*coder).threads_initialized { let mut mythread_i_502: c_uint = 0; @@ -291,7 +291,7 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons (*coder).mem_in_use = 0; (*coder).mem_cached = 0; } -unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder) { +unsafe fn threads_stop(coder: *mut lzma_stream_coder) { let mut i: u32 = 0; while i < (*coder).threads_initialized { let mut mythread_i_538: c_uint = 0; @@ -317,7 +317,7 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder) { i += 1; } } -unsafe extern "C" fn initialize_new_thread( +unsafe fn initialize_new_thread( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { @@ -372,7 +372,7 @@ unsafe extern "C" fn initialize_new_thread( } LZMA_MEM_ERROR } -unsafe extern "C" fn get_thread( +unsafe fn get_thread( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { @@ -413,7 +413,7 @@ unsafe extern "C" fn get_thread( (*(*coder).thr).partial_update_started = false; LZMA_OK } -unsafe extern "C" fn read_output_and_wait( +unsafe fn read_output_and_wait( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, out: *mut u8, @@ -540,7 +540,7 @@ unsafe extern "C" fn read_output_and_wait( } ret } -unsafe extern "C" fn decode_block_header( +unsafe fn decode_block_header( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, in_0: *const u8, @@ -594,7 +594,7 @@ extern "C" fn comp_blk_size(coder: *const lzma_stream_coder) -> size_t { extern "C" fn is_direct_mode_needed(size: lzma_vli) -> bool { size == LZMA_VLI_UNKNOWN || size > SIZE_MAX.wrapping_div(3 as c_ulong) as lzma_vli } -unsafe extern "C" fn stream_decoder_reset( +unsafe fn stream_decoder_reset( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 3edf5b1d..49260e59 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -58,7 +58,7 @@ pub const THR_EXIT: worker_state = 4; pub const THR_STOP: worker_state = 3; pub const THR_FINISH: worker_state = 2; pub const BLOCK_SIZE_MAX: c_ulonglong = UINT64_MAX.wrapping_div(LZMA_THREADS_MAX as u64); -unsafe extern "C" fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { +unsafe fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { let mut mythread_i_207: c_uint = 0; while if mythread_i_207 != 0 { mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*thr).coder).mutex)); @@ -79,7 +79,7 @@ unsafe extern "C" fn worker_error(thr: *mut worker_thread, ret: lzma_ret) { mythread_i_207 = 1; } } -unsafe extern "C" fn worker_encode( +unsafe fn worker_encode( thr: *mut worker_thread, out_pos: *mut size_t, mut state: worker_state, @@ -353,7 +353,7 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { crate::alloc::internal_free((*thr).in_0 as *mut c_void, (*thr).allocator); MYTHREAD_RET_VALUE } -unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_threads: bool) { +unsafe fn threads_stop(coder: *mut lzma_stream_coder, wait_for_threads: bool) { let mut i: u32 = 0; while i < (*coder).threads_initialized { let mut mythread_i_449: c_uint = 0; @@ -414,7 +414,7 @@ unsafe extern "C" fn threads_stop(coder: *mut lzma_stream_coder, wait_for_thread i_0 += 1; } } -unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) { +unsafe fn threads_end(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) { let mut i: u32 = 0; while i < (*coder).threads_initialized { let mut mythread_i_477: c_uint = 0; @@ -449,7 +449,7 @@ unsafe extern "C" fn threads_end(coder: *mut lzma_stream_coder, allocator: *cons } crate::alloc::internal_free((*coder).threads as *mut c_void, allocator); } -unsafe extern "C" fn initialize_new_thread( +unsafe fn initialize_new_thread( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { @@ -499,7 +499,7 @@ unsafe extern "C" fn initialize_new_thread( crate::alloc::internal_free((*thr).in_0 as *mut c_void, allocator); LZMA_MEM_ERROR } -unsafe extern "C" fn get_thread( +unsafe fn get_thread( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, ) -> lzma_ret { @@ -586,7 +586,7 @@ unsafe extern "C" fn get_thread( } LZMA_OK } -unsafe extern "C" fn stream_encode_in( +unsafe fn stream_encode_in( coder: *mut lzma_stream_coder, allocator: *const lzma_allocator, in_0: *const u8, @@ -663,7 +663,7 @@ unsafe extern "C" fn stream_encode_in( } LZMA_OK } -unsafe extern "C" fn wait_for_work( +unsafe fn wait_for_work( coder: *mut lzma_stream_coder, wait_abs: *mut mythread_condtime, has_blocked: *mut bool, @@ -953,7 +953,7 @@ unsafe extern "C" fn stream_encoder_mt_update( ); LZMA_OK } -unsafe extern "C" fn get_options( +unsafe fn get_options( options: *const lzma_mt, opt_easy: *mut lzma_options_easy, filters: *mut *const lzma_filter, diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index a81e3a2a..635e2240 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -64,7 +64,7 @@ pub const LZMA_LCLP_MIN: u32 = 0; pub const LZMA_PB_MIN: u32 = 0; pub const LZMA_PRESET_DEFAULT: c_uint = 6; pub const STR_ALLOC_SIZE: u32 = 800; -unsafe extern "C" fn str_init(str: *mut lzma_str, allocator: *const lzma_allocator) -> lzma_ret { +unsafe fn str_init(str: *mut lzma_str, allocator: *const lzma_allocator) -> lzma_ret { (*str).buf = lzma_alloc(STR_ALLOC_SIZE as size_t, allocator) as *mut c_char; if (*str).buf.is_null() { return LZMA_MEM_ERROR; @@ -72,13 +72,13 @@ unsafe extern "C" fn str_init(str: *mut lzma_str, allocator: *const lzma_allocat (*str).pos = 0; LZMA_OK } -unsafe extern "C" fn str_free(str: *mut lzma_str, allocator: *const lzma_allocator) { +unsafe fn str_free(str: *mut lzma_str, allocator: *const lzma_allocator) { lzma_free((*str).buf as *mut c_void, allocator); } -unsafe extern "C" fn str_is_full(str: *const lzma_str) -> bool { +unsafe fn str_is_full(str: *const lzma_str) -> bool { (*str).pos == (STR_ALLOC_SIZE - 1) as size_t } -unsafe extern "C" fn str_finish( +unsafe fn str_finish( dest: *mut *mut c_char, str: *mut lzma_str, allocator: *const lzma_allocator, @@ -92,7 +92,7 @@ unsafe extern "C" fn str_finish( *dest = (*str).buf; LZMA_OK } -unsafe extern "C" fn str_append_str(str: *mut lzma_str, s: *const c_char) { +unsafe fn str_append_str(str: *mut lzma_str, s: *const c_char) { let len: size_t = strlen(s) as size_t; let limit: size_t = ((STR_ALLOC_SIZE - 1) as size_t).wrapping_sub((*str).pos); let copy_size: size_t = if len < limit { len } else { limit }; @@ -103,7 +103,7 @@ unsafe extern "C" fn str_append_str(str: *mut lzma_str, s: *const c_char) { ); (*str).pos = (*str).pos.wrapping_add(copy_size); } -unsafe extern "C" fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) { +unsafe fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) { if v == 0 { str_append_str(str, crate::c_str!("0")); } else { @@ -214,7 +214,7 @@ extern "C" fn parse_delta( } pub const LZMA12_PRESET_STR: [c_char; 7] = unsafe { core::mem::transmute::<[u8; 7], [c_char; 7]>(*b"0-9[e]\0") }; -unsafe extern "C" fn parse_lzma12_preset( +unsafe fn parse_lzma12_preset( str: *mut *const c_char, str_end: *const c_char, preset: *mut u32, @@ -239,7 +239,7 @@ unsafe extern "C" fn parse_lzma12_preset( } core::ptr::null() } -unsafe extern "C" fn set_lzma12_preset( +unsafe fn set_lzma12_preset( str: *mut *const c_char, str_end: *const c_char, filter_options: *mut c_void, @@ -522,7 +522,7 @@ static mut filter_name_map: [filter_codec_def; 11] = unsafe { }, ] }; -unsafe extern "C" fn parse_options( +unsafe fn parse_options( str: *mut *const c_char, str_end: *const c_char, filter_options: *mut c_void, @@ -693,7 +693,7 @@ unsafe extern "C" fn parse_options( } core::ptr::null() } -unsafe extern "C" fn parse_filter( +unsafe fn parse_filter( str: *mut *const c_char, str_end: *const c_char, filter: *mut lzma_filter, @@ -756,7 +756,7 @@ unsafe extern "C" fn parse_filter( } crate::c_str!("Unknown filter name") } -unsafe extern "C" fn str_to_filters( +unsafe fn str_to_filters( str: *mut *const c_char, filters: *mut lzma_filter, flags: u32, @@ -941,7 +941,7 @@ pub unsafe fn lzma_str_to_filters( } errmsg } -unsafe extern "C" fn strfy_filter( +unsafe fn strfy_filter( dest: *mut lzma_str, mut delimiter: *const c_char, optmap: *const option_map, diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index ca50f877..3c3d1733 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -unsafe extern "C" fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { +unsafe fn decode_buffer(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { let distance: size_t = (*coder).distance; let mut i: size_t = 0; while i < size { diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index fb3bbdb4..e402d25c 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -1,5 +1,5 @@ use crate::types::*; -unsafe extern "C" fn copy_and_encode( +unsafe fn copy_and_encode( coder: *mut lzma_delta_coder, in_0: *const u8, out: *mut u8, @@ -16,7 +16,7 @@ unsafe extern "C" fn copy_and_encode( i += 1; } } -unsafe extern "C" fn encode_in_place(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { +unsafe fn encode_in_place(coder: *mut lzma_delta_coder, buffer: *mut u8, size: size_t) { let distance: size_t = (*coder).distance; let mut i: size_t = 0; while i < size { diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index fc757e8e..c42acca2 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -32,14 +32,14 @@ pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { set_uncompressed: None, end: None, }; -unsafe extern "C" fn lz_decoder_reset(coder: *mut lzma_coder) { +unsafe fn lz_decoder_reset(coder: *mut lzma_coder) { (*coder).dict.pos = LZ_DICT_INIT_POS as size_t; (*coder).dict.full = 0; *(*coder).dict.buf.offset((LZ_DICT_INIT_POS - 1) as isize) = '\0' as i32 as u8; (*coder).dict.has_wrapped = false; (*coder).dict.need_reset = false; } -unsafe extern "C" fn decode_buffer( +unsafe fn decode_buffer( coder: *mut lzma_coder, in_0: *const u8, in_pos: *mut size_t, diff --git a/liblzma-rs/src/lzma/lzma2_decoder.rs b/liblzma-rs/src/lzma/lzma2_decoder.rs index c3fea7b3..8c2efd29 100644 --- a/liblzma-rs/src/lzma/lzma2_decoder.rs +++ b/liblzma-rs/src/lzma/lzma2_decoder.rs @@ -30,7 +30,7 @@ pub const LZMA_LZ_DECODER_INIT: lzma_lz_decoder = lzma_lz_decoder { end: None, }; #[inline] -unsafe extern "C" fn dict_write( +unsafe fn dict_write( dict: *mut lzma_dict, in_0: *const u8, in_pos: *mut size_t, @@ -53,7 +53,7 @@ unsafe extern "C" fn dict_write( } } #[inline] -unsafe extern "C" fn dict_reset(dict: *mut lzma_dict) { +unsafe fn dict_reset(dict: *mut lzma_dict) { (*dict).need_reset = true; } unsafe extern "C" fn lzma2_decode( diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 282bbcd8..5db83958 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -24,14 +24,14 @@ pub const SEQ_LZMA_COPY: lzma2_encoder_seq = 2; pub const SEQ_LZMA_ENCODE: lzma2_encoder_seq = 1; pub const SEQ_INIT: lzma2_encoder_seq = 0; #[inline] -unsafe extern "C" fn mf_unencoded(mf: *const lzma_mf) -> u32 { +unsafe fn mf_unencoded(mf: *const lzma_mf) -> u32 { (*mf) .write_pos .wrapping_sub((*mf).read_pos) .wrapping_add((*mf).read_ahead) } #[inline] -unsafe extern "C" fn mf_read( +unsafe fn mf_read( mf: *mut lzma_mf, out: *mut u8, out_pos: *mut size_t, @@ -53,7 +53,7 @@ unsafe extern "C" fn mf_read( } pub const LZMA2_UNCOMPRESSED_MAX: c_uint = 1u32 << 21; pub const LZMA2_HEADER_MAX: u32 = 6; -unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { +unsafe fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { let mut pos: size_t = 0; if (*coder).need_properties { pos = 0; @@ -97,7 +97,7 @@ unsafe extern "C" fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { .compressed_size .wrapping_add(LZMA2_HEADER_MAX as size_t); } -unsafe extern "C" fn lzma2_header_uncompressed(coder: *mut lzma_lzma2_coder) { +unsafe fn lzma2_header_uncompressed(coder: *mut lzma_lzma2_coder) { if (*coder).need_dictionary_reset { (*coder).buf[0] = 1; } else { diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 44a647ad..246c82d0 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -74,7 +74,7 @@ pub struct lzma_length_decoder { pub high: [probability; 256], } #[inline] -unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { +unsafe fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { *(*dict).buf.offset( (*dict) .pos @@ -88,15 +88,15 @@ unsafe extern "C" fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { ) } #[inline] -unsafe extern "C" fn dict_get0(dict: *const lzma_dict) -> u8 { +unsafe fn dict_get0(dict: *const lzma_dict) -> u8 { *(*dict).buf.offset((*dict).pos.wrapping_sub(1) as isize) } #[inline] -unsafe extern "C" fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bool { +unsafe fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bool { (*dict).full > distance } #[inline] -unsafe extern "C" fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut u32) -> bool { +unsafe fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut u32) -> bool { let dict_avail: size_t = (*dict).limit.wrapping_sub((*dict).pos); let mut left: u32 = (if dict_avail < *len as size_t { dict_avail @@ -132,7 +132,7 @@ unsafe extern "C" fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut *len != 0 } #[inline] -unsafe extern "C" fn dict_put(dict: *mut lzma_dict, byte: u8) { +unsafe fn dict_put(dict: *mut lzma_dict, byte: u8) { *(*dict).buf.offset((*dict).pos as isize) = byte; (*dict).pos = (*dict).pos.wrapping_add(1); if !(*dict).has_wrapped { @@ -140,7 +140,7 @@ unsafe extern "C" fn dict_put(dict: *mut lzma_dict, byte: u8) { } } #[inline] -unsafe extern "C" fn dict_put_safe(dict: *mut lzma_dict, byte: u8) -> bool { +unsafe fn dict_put_safe(dict: *mut lzma_dict, byte: u8) -> bool { if (*dict).pos == (*dict).limit { return true; } @@ -149,7 +149,7 @@ unsafe extern "C" fn dict_put_safe(dict: *mut lzma_dict, byte: u8) -> bool { } pub const DIST_SLOTS: u32 = 1 << DIST_SLOT_BITS; #[inline] -unsafe extern "C" fn rc_read_init( +unsafe fn rc_read_init( rc: *mut lzma_range_decoder, in_0: *const u8, in_pos: *mut size_t, diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 15ecd2e9..b96989fa 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -3,7 +3,7 @@ use crate::lzma::lzma_encoder_optimum_fast::lzma_lzma_optimum_fast; use crate::lzma::lzma_encoder_optimum_normal::lzma_lzma_optimum_normal; use crate::types::*; #[inline] -unsafe extern "C" fn rc_reset(rc: *mut lzma_range_encoder) { +unsafe fn rc_reset(rc: *mut lzma_range_encoder) { (*rc).low = 0; (*rc).cache_size = 1; (*rc).range = UINT32_MAX; @@ -13,17 +13,17 @@ unsafe extern "C" fn rc_reset(rc: *mut lzma_range_encoder) { (*rc).pos = 0; } #[inline] -unsafe extern "C" fn rc_forget(rc: *mut lzma_range_encoder) { +unsafe fn rc_forget(rc: *mut lzma_range_encoder) { (*rc).count = 0; } #[inline] -unsafe extern "C" fn rc_bit(rc: *mut lzma_range_encoder, prob: *mut probability, bit: u32) { +unsafe fn rc_bit(rc: *mut lzma_range_encoder, prob: *mut probability, bit: u32) { (*rc).symbols[(*rc).count as usize] = bit as rc_symbol; (*rc).probs[(*rc).count as usize] = prob; (*rc).count = (*rc).count.wrapping_add(1); } #[inline] -unsafe extern "C" fn rc_bittree( +unsafe fn rc_bittree( rc: *mut lzma_range_encoder, probs: *mut probability, mut bit_count: u32, @@ -45,7 +45,7 @@ unsafe extern "C" fn rc_bittree( } } #[inline] -unsafe extern "C" fn rc_bittree_reverse( +unsafe fn rc_bittree_reverse( rc: *mut lzma_range_encoder, probs: *mut probability, mut bit_count: u32, @@ -68,7 +68,7 @@ unsafe extern "C" fn rc_bittree_reverse( } } #[inline] -unsafe extern "C" fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) { +unsafe fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) { loop { bit_count -= 1; (*rc).symbols[(*rc).count as usize] = @@ -80,7 +80,7 @@ unsafe extern "C" fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_ } } #[inline] -unsafe extern "C" fn rc_flush(rc: *mut lzma_range_encoder) { +unsafe fn rc_flush(rc: *mut lzma_range_encoder) { let mut i: size_t = 0; while i < 5 { (*rc).symbols[(*rc).count as usize] = RC_FLUSH; @@ -89,7 +89,7 @@ unsafe extern "C" fn rc_flush(rc: *mut lzma_range_encoder) { } } #[inline] -unsafe extern "C" fn rc_shift_low( +unsafe fn rc_shift_low( rc: *mut lzma_range_encoder, out: *mut u8, out_pos: *mut size_t, @@ -116,7 +116,7 @@ unsafe extern "C" fn rc_shift_low( false } #[inline] -unsafe extern "C" fn rc_shift_low_dummy( +unsafe fn rc_shift_low_dummy( low: *mut u64, cache_size: *mut u64, cache: *mut u8, @@ -142,7 +142,7 @@ unsafe extern "C" fn rc_shift_low_dummy( false } #[inline] -unsafe extern "C" fn rc_encode( +unsafe fn rc_encode( rc: *mut lzma_range_encoder, out: *mut u8, out_pos: *mut size_t, @@ -203,7 +203,7 @@ unsafe extern "C" fn rc_encode( false } #[inline] -unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u64) -> bool { +unsafe fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u64) -> bool { let mut low: u64 = (*rc).low; let mut cache_size: u64 = (*rc).cache_size; let mut range: u32 = (*rc).range; @@ -264,13 +264,13 @@ unsafe extern "C" fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u false } #[inline] -unsafe extern "C" fn rc_pending(rc: *const lzma_range_encoder) -> u64 { +unsafe fn rc_pending(rc: *const lzma_range_encoder) -> u64 { (*rc).cache_size.wrapping_add(5).wrapping_sub(1) } pub const LEN_SYMBOLS: u32 = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS; pub const MATCH_LEN_MAX: u32 = MATCH_LEN_MIN + LEN_SYMBOLS - 1; #[inline] -unsafe extern "C" fn literal_matched( +unsafe fn literal_matched( rc: *mut lzma_range_encoder, subcoder: *mut probability, mut match_byte: u32, @@ -296,7 +296,7 @@ unsafe extern "C" fn literal_matched( } } #[inline] -unsafe extern "C" fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u32) { +unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u32) { let cur_byte: u8 = *(*mf) .buffer .offset((*mf).read_pos.wrapping_sub((*mf).read_ahead) as isize); @@ -347,7 +347,7 @@ unsafe extern "C" fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, p ); }; } -unsafe extern "C" fn length_update_prices(lc: *mut lzma_length_encoder, pos_state: u32) { +unsafe fn length_update_prices(lc: *mut lzma_length_encoder, pos_state: u32) { let table_size: u32 = (*lc).table_size; (*lc).counters[pos_state as usize] = table_size; let a0: u32 = rc_bit_0_price((*lc).choice) as u32; @@ -390,7 +390,7 @@ unsafe extern "C" fn length_update_prices(lc: *mut lzma_length_encoder, pos_stat } } #[inline] -unsafe extern "C" fn length( +unsafe fn length( rc: *mut lzma_range_encoder, lc: *mut lzma_length_encoder, pos_state: u32, @@ -440,7 +440,7 @@ unsafe extern "C" fn length( } } #[inline] -unsafe extern "C" fn match_0( +unsafe fn match_0( coder: *mut lzma_lzma1_encoder, pos_state: u32, distance: u32, @@ -508,7 +508,7 @@ unsafe extern "C" fn match_0( (*coder).match_price_count = (*coder).match_price_count.wrapping_add(1); } #[inline] -unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, rep: u32, len: u32) { +unsafe fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, rep: u32, len: u32) { if rep == 0 { rc_bit( ::core::ptr::addr_of_mut!((*coder).rc), @@ -581,7 +581,7 @@ unsafe extern "C" fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, r }) as lzma_lzma_state; }; } -unsafe extern "C" fn encode_symbol( +unsafe fn encode_symbol( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, back: u32, @@ -628,7 +628,7 @@ unsafe extern "C" fn encode_symbol( } (*mf).read_ahead = (*mf).read_ahead.wrapping_sub(len); } -unsafe extern "C" fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool { +unsafe fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool { if (*mf).read_pos == (*mf).read_limit { if (*mf).action == LZMA_RUN { return false; @@ -654,7 +654,7 @@ unsafe extern "C" fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_m (*coder).is_initialized = true; true } -unsafe extern "C" fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) { +unsafe fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) { let pos_state: u32 = position & (*coder).pos_mask; rc_bit( ::core::ptr::addr_of_mut!((*coder).rc), @@ -820,7 +820,7 @@ extern "C" fn set_lz_options(lz_options: *mut lzma_lz_options, options: *const l (*lz_options).preset_dict_size = (*options).preset_dict_size; } } -unsafe extern "C" fn length_encoder_reset( +unsafe fn length_encoder_reset( lencoder: *mut lzma_length_encoder, num_pos_states: u32, fast_mode: bool, diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index d46b6212..931ee9bb 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -1,5 +1,5 @@ use crate::types::*; -unsafe extern "C" fn copy_or_code( +unsafe fn copy_or_code( coder: *mut lzma_simple_coder, allocator: *const lzma_allocator, in_0: *const u8, @@ -35,7 +35,7 @@ unsafe extern "C" fn copy_or_code( } LZMA_OK } -unsafe extern "C" fn call_filter( +unsafe fn call_filter( coder: *mut lzma_simple_coder, buffer: *mut u8, size: size_t, From 0ddd0289d9e498c36b1a96e9f0deabd58784d41a Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Thu, 19 Mar 2026 21:04:36 +0900 Subject: [PATCH 23/51] perf: trim optimum normal and bt match finder hot paths --- liblzma-rs/src/lz/lz_encoder_mf.rs | 44 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 443 ++++++++++-------- 2 files changed, 276 insertions(+), 211 deletions(-) diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 52984618..506f5a2e 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -321,28 +321,27 @@ unsafe fn bt_find_func( let mut len0: u32 = 0; let mut len1: u32 = 0; loop { - let delta: u32 = pos.wrapping_sub(cur_match); - let old_depth = depth; - depth = depth.wrapping_sub(1); - if old_depth == 0 || delta >= cyclic_size { + let delta: u32 = pos - cur_match; + if depth == 0 || delta >= cyclic_size { *ptr0 = EMPTY_HASH_VALUE; *ptr1 = EMPTY_HASH_VALUE; return matches; } - let pair: *mut u32 = son.offset( - (cyclic_pos - .wrapping_sub(delta) - .wrapping_add(if delta > cyclic_pos { cyclic_size } else { 0 }) - << 1) as isize, - ); + depth -= 1; + let pair_index = if delta > cyclic_pos { + cyclic_pos + cyclic_size - delta + } else { + cyclic_pos - delta + }; + let pair: *mut u32 = son.offset((pair_index << 1) as isize); let pb: *const u8 = cur.offset(-(delta as isize)); let mut len: u32 = if len0 < len1 { len0 } else { len1 }; if *pb.offset(len as isize) == *cur.offset(len as isize) { - len = lzma_memcmplen(pb, cur, len.wrapping_add(1), len_limit); + len = lzma_memcmplen(pb, cur, len + 1, len_limit); if len_best < len { len_best = len; (*matches).len = len; - (*matches).dist = delta.wrapping_sub(1); + (*matches).dist = delta - 1; matches = matches.offset(1); if len == len_limit { *ptr1 = *pair; @@ -380,24 +379,23 @@ unsafe fn bt_skip_func( let mut len0: u32 = 0; let mut len1: u32 = 0; loop { - let delta: u32 = pos.wrapping_sub(cur_match); - let old_depth = depth; - depth = depth.wrapping_sub(1); - if old_depth == 0 || delta >= cyclic_size { + let delta: u32 = pos - cur_match; + if depth == 0 || delta >= cyclic_size { *ptr0 = EMPTY_HASH_VALUE; *ptr1 = EMPTY_HASH_VALUE; return; } - let pair: *mut u32 = son.offset( - (cyclic_pos - .wrapping_sub(delta) - .wrapping_add(if delta > cyclic_pos { cyclic_size } else { 0 }) - << 1) as isize, - ); + depth -= 1; + let pair_index = if delta > cyclic_pos { + cyclic_pos + cyclic_size - delta + } else { + cyclic_pos - delta + }; + let pair: *mut u32 = son.offset((pair_index << 1) as isize); let pb: *const u8 = cur.offset(-(delta as isize)); let mut len: u32 = if len0 < len1 { len0 } else { len1 }; if *pb.offset(len as isize) == *cur.offset(len as isize) { - len = lzma_memcmplen(pb, cur, len.wrapping_add(1), len_limit); + len = lzma_memcmplen(pb, cur, len + 1, len_limit); if len == len_limit { *ptr1 = *pair; *ptr0 = *pair.offset(1); diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 67dfdee0..b9cd78f7 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -76,7 +76,11 @@ unsafe fn get_literal_price( #[inline] fn get_len_price(lencoder: *const lzma_length_encoder, len: u32, pos_state: u32) -> u32 { debug_assert!(len >= MATCH_LEN_MIN); - unsafe { (*lencoder).prices[pos_state as usize][(len - MATCH_LEN_MIN) as usize] } + unsafe { + let prices = ::core::ptr::addr_of!((*lencoder).prices) as *const [u32; 272]; + let row = prices.add(pos_state as usize) as *const u32; + *row.add((len - MATCH_LEN_MIN) as usize) + } } #[inline] fn get_short_rep_price( @@ -85,8 +89,8 @@ fn get_short_rep_price( pos_state: u32, ) -> u32 { unsafe { - rc_bit_0_price((*coder).is_rep0[state as usize]) - + rc_bit_0_price((*coder).is_rep0_long[state as usize][pos_state as usize]) + rc_bit_0_price(rep0_prob(coder, state)) + + rc_bit_0_price(rep0_long_prob(coder, state, pos_state)) } } #[inline] @@ -99,16 +103,16 @@ fn get_pure_rep_price( return unsafe { let mut price: u32 = 0; if rep_index == 0 { - price = rc_bit_0_price((*coder).is_rep0[state as usize]); - price += rc_bit_1_price((*coder).is_rep0_long[state as usize][pos_state as usize]); + price = rc_bit_0_price(rep0_prob(coder, state)); + price += rc_bit_1_price(rep0_long_prob(coder, state, pos_state)); } else { - price = rc_bit_1_price((*coder).is_rep0[state as usize]); + price = rc_bit_1_price(rep0_prob(coder, state)); if rep_index == 1 { - price += rc_bit_0_price((*coder).is_rep1[state as usize]); + price += rc_bit_0_price(rep1_prob(coder, state)); } else { debug_assert!(rep_index >= 2); - price += rc_bit_1_price((*coder).is_rep1[state as usize]); - price += rc_bit_price((*coder).is_rep2[state as usize], rep_index - 2); + price += rc_bit_1_price(rep1_prob(coder, state)); + price += rc_bit_price(rep2_prob(coder, state), rep_index - 2); } } price @@ -146,11 +150,11 @@ fn get_dist_len_price( }; let mut price: u32 = 0; if dist < FULL_DISTANCES { - price = (*coder).dist_prices[dist_state as usize][dist as usize]; + price = dist_price(coder, dist_state, dist); } else { let dist_slot: u32 = get_dist_slot_2(dist) as u32; - price = (*coder).dist_slot_prices[dist_state as usize][dist_slot as usize] - + (*coder).align_prices[(dist & ALIGN_MASK) as usize]; + price = dist_slot_price(coder, dist_state, dist_slot) + + align_price(coder, dist & ALIGN_MASK); } price += get_len_price( ::core::ptr::addr_of!((*coder).match_len_encoder), @@ -269,6 +273,74 @@ unsafe fn fill_align_prices(coder: *mut lzma_lzma1_encoder) { } (*coder).align_price_count = 0; } +#[inline(always)] +unsafe fn opts_ptr(coder: *mut lzma_lzma1_encoder) -> *mut lzma_optimal { + ::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal +} +#[inline(always)] +unsafe fn matches_ptr(coder: *mut lzma_lzma1_encoder) -> *mut lzma_match { + ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match +} +#[inline(always)] +unsafe fn optimal_backs_ptr(optimal: *mut lzma_optimal) -> *mut u32 { + ::core::ptr::addr_of_mut!((*optimal).backs) as *mut u32 +} +#[inline(always)] +unsafe fn match_prob( + coder: *const lzma_lzma1_encoder, + state: lzma_lzma_state, + pos_state: u32, +) -> probability { + let row = (::core::ptr::addr_of!((*coder).is_match) as *const [probability; 16]) + .add(state as usize) as *const probability; + *row.add(pos_state as usize) +} +#[inline(always)] +unsafe fn rep0_prob(coder: *const lzma_lzma1_encoder, state: lzma_lzma_state) -> probability { + *((::core::ptr::addr_of!((*coder).is_rep0) as *const probability).add(state as usize)) +} +#[inline(always)] +unsafe fn is_rep_prob(coder: *const lzma_lzma1_encoder, state: lzma_lzma_state) -> probability { + *((::core::ptr::addr_of!((*coder).is_rep) as *const probability).add(state as usize)) +} +#[inline(always)] +unsafe fn rep0_long_prob( + coder: *const lzma_lzma1_encoder, + state: lzma_lzma_state, + pos_state: u32, +) -> probability { + let row = (::core::ptr::addr_of!((*coder).is_rep0_long) as *const [probability; 16]) + .add(state as usize) as *const probability; + *row.add(pos_state as usize) +} +#[inline(always)] +unsafe fn rep1_prob(coder: *const lzma_lzma1_encoder, state: lzma_lzma_state) -> probability { + *((::core::ptr::addr_of!((*coder).is_rep1) as *const probability).add(state as usize)) +} +#[inline(always)] +unsafe fn rep2_prob(coder: *const lzma_lzma1_encoder, state: lzma_lzma_state) -> probability { + *((::core::ptr::addr_of!((*coder).is_rep2) as *const probability).add(state as usize)) +} +#[inline(always)] +unsafe fn dist_slot_price( + coder: *const lzma_lzma1_encoder, + dist_state: u32, + dist_slot: u32, +) -> u32 { + let row = (::core::ptr::addr_of!((*coder).dist_slot_prices) as *const [u32; 64]) + .add(dist_state as usize) as *const u32; + *row.add(dist_slot as usize) +} +#[inline(always)] +unsafe fn dist_price(coder: *const lzma_lzma1_encoder, dist_state: u32, dist: u32) -> u32 { + let row = (::core::ptr::addr_of!((*coder).dist_prices) as *const [u32; 128]) + .add(dist_state as usize) as *const u32; + *row.add(dist as usize) +} +#[inline(always)] +unsafe fn align_price(coder: *const lzma_lzma1_encoder, index: u32) -> u32 { + *((::core::ptr::addr_of!((*coder).align_prices) as *const u32).add(index as usize)) +} #[inline] unsafe fn make_literal(optimal: *mut lzma_optimal) { (*optimal).back_prev = UINT32_MAX; @@ -285,40 +357,38 @@ unsafe fn backward( back_res: *mut u32, mut cur: u32, ) { + let opts = opts_ptr(coder); (*coder).opts_end_index = cur; - let mut pos_mem: u32 = (*coder).opts[cur as usize].pos_prev; - let mut back_mem: u32 = (*coder).opts[cur as usize].back_prev; + let mut pos_mem: u32 = (*opts.add(cur as usize)).pos_prev; + let mut back_mem: u32 = (*opts.add(cur as usize)).back_prev; loop { - if (*coder).opts[cur as usize].prev_1_is_literal { - make_literal( - (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal) - .offset(pos_mem as isize) as *mut lzma_optimal, - ); + if (*opts.add(cur as usize)).prev_1_is_literal { + make_literal(opts.add(pos_mem as usize)); debug_assert!(pos_mem > 0); let literal_pos_prev = pos_mem - 1; - (*coder).opts[pos_mem as usize].pos_prev = literal_pos_prev; - if (*coder).opts[cur as usize].prev_2 { - (*coder).opts[literal_pos_prev as usize].prev_1_is_literal = false; - (*coder).opts[literal_pos_prev as usize].pos_prev = - (*coder).opts[cur as usize].pos_prev_2; - (*coder).opts[literal_pos_prev as usize].back_prev = - (*coder).opts[cur as usize].back_prev_2; + (*opts.add(pos_mem as usize)).pos_prev = literal_pos_prev; + if (*opts.add(cur as usize)).prev_2 { + (*opts.add(literal_pos_prev as usize)).prev_1_is_literal = false; + (*opts.add(literal_pos_prev as usize)).pos_prev = + (*opts.add(cur as usize)).pos_prev_2; + (*opts.add(literal_pos_prev as usize)).back_prev = + (*opts.add(cur as usize)).back_prev_2; } } let pos_prev: u32 = pos_mem; let back_cur: u32 = back_mem; - back_mem = (*coder).opts[pos_prev as usize].back_prev; - pos_mem = (*coder).opts[pos_prev as usize].pos_prev; - (*coder).opts[pos_prev as usize].back_prev = back_cur; - (*coder).opts[pos_prev as usize].pos_prev = cur; + back_mem = (*opts.add(pos_prev as usize)).back_prev; + pos_mem = (*opts.add(pos_prev as usize)).pos_prev; + (*opts.add(pos_prev as usize)).back_prev = back_cur; + (*opts.add(pos_prev as usize)).pos_prev = cur; cur = pos_prev; if cur == 0 { break; } } - (*coder).opts_current_index = (*coder).opts[0].pos_prev; - *len_res = (*coder).opts[0].pos_prev; - *back_res = (*coder).opts[0].back_prev; + (*coder).opts_current_index = (*opts).pos_prev; + *len_res = (*opts).pos_prev; + *back_res = (*opts).back_prev; } #[inline] unsafe fn helper1( @@ -328,15 +398,13 @@ unsafe fn helper1( len_res: *mut u32, position: u32, ) -> u32 { + let opts = opts_ptr(coder); + let matches = matches_ptr(coder); let nice_len: u32 = (*mf).nice_len; let mut len_main: u32 = 0; let mut matches_count: u32 = 0; if (*mf).read_ahead == 0 { - len_main = lzma_mf_find( - mf, - ::core::ptr::addr_of_mut!(matches_count), - ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, - ); + len_main = lzma_mf_find(mf, ::core::ptr::addr_of_mut!(matches_count), matches); } else { debug_assert!((*mf).read_ahead == 1); len_main = (*coder).longest_match_length; @@ -350,86 +418,79 @@ unsafe fn helper1( } let buf: *const u8 = mf_ptr(mf).offset(-1); let mut rep_lens: [u32; 4] = [0; 4]; + let rep_lens_ptr = rep_lens.as_mut_ptr(); let mut rep_max_index: u32 = 0; let mut i: u32 = 0; while i < REPS { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); if not_equal_16(buf, buf_back) { - rep_lens[i as usize] = 0; + *rep_lens_ptr.add(i as usize) = 0; } else { - rep_lens[i as usize] = lzma_memcmplen(buf, buf_back, 2, buf_avail); - if rep_lens[i as usize] > rep_lens[rep_max_index as usize] { + *rep_lens_ptr.add(i as usize) = lzma_memcmplen(buf, buf_back, 2, buf_avail); + if *rep_lens_ptr.add(i as usize) > *rep_lens_ptr.add(rep_max_index as usize) { rep_max_index = i; } } i += 1; } - if rep_lens[rep_max_index as usize] >= nice_len { + if *rep_lens_ptr.add(rep_max_index as usize) >= nice_len { *back_res = rep_max_index; - *len_res = rep_lens[rep_max_index as usize]; + *len_res = *rep_lens_ptr.add(rep_max_index as usize); mf_skip(mf, *len_res - 1); return UINT32_MAX; } if len_main >= nice_len { debug_assert!(matches_count > 0); - *back_res = (*coder).matches[(matches_count - 1) as usize].dist + REPS; + *back_res = (*matches.add((matches_count - 1) as usize)).dist + REPS; *len_res = len_main; mf_skip(mf, len_main - 1); return UINT32_MAX; } let current_byte: u8 = *buf; let match_byte: u8 = *buf.offset(-((*coder).reps[0] as isize)).offset(-1); - if len_main < 2 && current_byte != match_byte && rep_lens[rep_max_index as usize] < 2 { + if len_main < 2 && current_byte != match_byte && *rep_lens_ptr.add(rep_max_index as usize) < 2 { *back_res = UINT32_MAX; *len_res = 1; return UINT32_MAX; } - (*coder).opts[0].state = (*coder).state; + (*opts).state = (*coder).state; let pos_state: u32 = position & (*coder).pos_mask; - (*coder).opts[1].price = - rc_bit_0_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) - + get_literal_price( - coder, - position, - *buf.offset(-1) as u32, - !(((*coder).state as u32) < LIT_STATES), - match_byte as u32, - current_byte as u32, - ); - make_literal( - (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal).offset(1) - as *mut lzma_optimal, - ); - let match_price: u32 = - rc_bit_1_price((*coder).is_match[(*coder).state as usize][pos_state as usize]) as u32; + (*opts.add(1)).price = rc_bit_0_price(match_prob(coder, (*coder).state, pos_state)) + + get_literal_price( + coder, + position, + *buf.offset(-1) as u32, + !(((*coder).state as u32) < LIT_STATES), + match_byte as u32, + current_byte as u32, + ); + make_literal(opts.add(1)); + let match_price: u32 = rc_bit_1_price(match_prob(coder, (*coder).state, pos_state)) as u32; let rep_match_price: u32 = - match_price + rc_bit_1_price((*coder).is_rep[(*coder).state as usize]) as u32; + match_price + rc_bit_1_price(is_rep_prob(coder, (*coder).state)) as u32; if match_byte == current_byte { let short_rep_price: u32 = rep_match_price + get_short_rep_price(coder, (*coder).state, pos_state) as u32; - if short_rep_price < (*coder).opts[1].price { - (*coder).opts[1].price = short_rep_price; - make_short_rep( - (::core::ptr::addr_of_mut!((*coder).opts) as *mut lzma_optimal).offset(1) - as *mut lzma_optimal, - ); + if short_rep_price < (*opts.add(1)).price { + (*opts.add(1)).price = short_rep_price; + make_short_rep(opts.add(1)); } } - let len_end: u32 = core::cmp::max(len_main, rep_lens[rep_max_index as usize]); + let len_end: u32 = core::cmp::max(len_main, *rep_lens_ptr.add(rep_max_index as usize)); if len_end < 2 { - *back_res = (*coder).opts[1].back_prev; + *back_res = (*opts.add(1)).back_prev; *len_res = 1; return UINT32_MAX; } - (*coder).opts[1].pos_prev = 0; + (*opts.add(1)).pos_prev = 0; let mut i_0: u32 = 0; while i_0 < REPS { - (*coder).opts[0].backs[i_0 as usize] = (*coder).reps[i_0 as usize]; + (*opts).backs[i_0 as usize] = (*coder).reps[i_0 as usize]; i_0 += 1; } let mut len: u32 = len_end; loop { - (*coder).opts[len as usize].price = RC_INFINITY_PRICE as u32; + (*opts.add(len as usize)).price = RC_INFINITY_PRICE as u32; len -= 1; if len < 2 { break; @@ -437,7 +498,7 @@ unsafe fn helper1( } let mut i_1: u32 = 0; while i_1 < REPS { - let mut rep_len: u32 = rep_lens[i_1 as usize]; + let mut rep_len: u32 = *rep_lens_ptr.add(i_1 as usize); if rep_len >= 2 { let price: u32 = rep_match_price + get_pure_rep_price(coder, i_1, (*coder).state, pos_state) as u32; @@ -448,11 +509,11 @@ unsafe fn helper1( rep_len, pos_state, ) as u32; - if cur_and_len_price < (*coder).opts[rep_len as usize].price { - (*coder).opts[rep_len as usize].price = cur_and_len_price; - (*coder).opts[rep_len as usize].pos_prev = 0; - (*coder).opts[rep_len as usize].back_prev = i_1; - (*coder).opts[rep_len as usize].prev_1_is_literal = false; + if cur_and_len_price < (*opts.add(rep_len as usize)).price { + (*opts.add(rep_len as usize)).price = cur_and_len_price; + (*opts.add(rep_len as usize)).pos_prev = 0; + (*opts.add(rep_len as usize)).back_prev = i_1; + (*opts.add(rep_len as usize)).prev_1_is_literal = false; } rep_len -= 1; if rep_len < 2 { @@ -463,24 +524,28 @@ unsafe fn helper1( i_1 += 1; } let normal_match_price: u32 = - match_price + rc_bit_0_price((*coder).is_rep[(*coder).state as usize]) as u32; - len = if rep_lens[0] >= 2 { rep_lens[0] + 1 } else { 2 }; + match_price + rc_bit_0_price(is_rep_prob(coder, (*coder).state)) as u32; + len = if *rep_lens_ptr >= 2 { + *rep_lens_ptr + 1 + } else { + 2 + }; if len <= len_main { let mut i_2: u32 = 0; - while len > (*coder).matches[i_2 as usize].len { + while len > (*matches.add(i_2 as usize)).len { i_2 += 1; } loop { - let dist: u32 = (*coder).matches[i_2 as usize].dist; + let dist: u32 = (*matches.add(i_2 as usize)).dist; let cur_and_len_price_0: u32 = normal_match_price + get_dist_len_price(coder, dist, len, pos_state) as u32; - if cur_and_len_price_0 < (*coder).opts[len as usize].price { - (*coder).opts[len as usize].price = cur_and_len_price_0; - (*coder).opts[len as usize].pos_prev = 0; - (*coder).opts[len as usize].back_prev = dist + REPS; - (*coder).opts[len as usize].prev_1_is_literal = false; + if cur_and_len_price_0 < (*opts.add(len as usize)).price { + (*opts.add(len as usize)).price = cur_and_len_price_0; + (*opts.add(len as usize)).pos_prev = 0; + (*opts.add(len as usize)).back_prev = dist + REPS; + (*opts.add(len as usize)).prev_1_is_literal = false; } - if len == (*coder).matches[i_2 as usize].len { + if len == (*matches.add(i_2 as usize)).len { i_2 += 1; if i_2 == matches_count { break; @@ -502,40 +567,42 @@ unsafe fn helper2( nice_len: u32, buf_avail_full: u32, ) -> u32 { + let opts = opts_ptr(coder); + let matches = matches_ptr(coder); let mut matches_count: u32 = (*coder).matches_count; let mut new_len: u32 = (*coder).longest_match_length; - let mut pos_prev: u32 = (*coder).opts[cur as usize].pos_prev; + let mut pos_prev: u32 = (*opts.add(cur as usize)).pos_prev; let mut state: lzma_lzma_state = STATE_LIT_LIT; - if (*coder).opts[cur as usize].prev_1_is_literal { + if (*opts.add(cur as usize)).prev_1_is_literal { pos_prev -= 1; - if (*coder).opts[cur as usize].prev_2 { - state = (*coder).opts[(*coder).opts[cur as usize].pos_prev_2 as usize].state; - if (*coder).opts[cur as usize].back_prev_2 < REPS { + if (*opts.add(cur as usize)).prev_2 { + state = (*opts.add((*opts.add(cur as usize)).pos_prev_2 as usize)).state; + if (*opts.add(cur as usize)).back_prev_2 < REPS { state = update_long_rep_state(state); } else { state = update_match_state(state); } } else { - state = (*coder).opts[pos_prev as usize].state; + state = (*opts.add(pos_prev as usize)).state; } state = update_literal_state(state); } else { - state = (*coder).opts[pos_prev as usize].state; + state = (*opts.add(pos_prev as usize)).state; } if pos_prev == cur.wrapping_sub(1) { - if (*coder).opts[cur as usize].back_prev == 0 { + if (*opts.add(cur as usize)).back_prev == 0 { state = update_short_rep_state(state); } else { state = update_literal_state(state); } } else { let mut pos: u32 = 0; - if (*coder).opts[cur as usize].prev_1_is_literal && (*coder).opts[cur as usize].prev_2 { - pos_prev = (*coder).opts[cur as usize].pos_prev_2; - pos = (*coder).opts[cur as usize].back_prev_2; + if (*opts.add(cur as usize)).prev_1_is_literal && (*opts.add(cur as usize)).prev_2 { + pos_prev = (*opts.add(cur as usize)).pos_prev_2; + pos = (*opts.add(cur as usize)).back_prev_2; state = update_long_rep_state(state); } else { - pos = (*coder).opts[cur as usize].back_prev; + pos = (*opts.add(cur as usize)).back_prev; if pos < REPS { state = update_long_rep_state(state); } else { @@ -543,40 +610,41 @@ unsafe fn helper2( } } if pos < REPS { - *reps = (*coder).opts[pos_prev as usize].backs[pos as usize]; + let prev_backs = optimal_backs_ptr(opts.add(pos_prev as usize)); + *reps = *prev_backs.add(pos as usize); let mut i: u32 = 0; i = 1; while i <= pos { - *reps.offset(i as isize) = - (*coder).opts[pos_prev as usize].backs[i.wrapping_sub(1) as usize]; + *reps.offset(i as isize) = *prev_backs.add(i.wrapping_sub(1) as usize); i += 1; } while i < REPS { - *reps.offset(i as isize) = (*coder).opts[pos_prev as usize].backs[i as usize]; + *reps.offset(i as isize) = *prev_backs.add(i as usize); i += 1; } } else { *reps = pos.wrapping_sub(REPS); + let prev_backs = optimal_backs_ptr(opts.add(pos_prev as usize)); let mut i_0: u32 = 1; while i_0 < REPS { - *reps.offset(i_0 as isize) = - (*coder).opts[pos_prev as usize].backs[i_0.wrapping_sub(1) as usize]; + *reps.offset(i_0 as isize) = *prev_backs.add(i_0.wrapping_sub(1) as usize); i_0 += 1; } } } - (*coder).opts[cur as usize].state = state; + (*opts.add(cur as usize)).state = state; + let cur_backs = optimal_backs_ptr(opts.add(cur as usize)); let mut i_1: u32 = 0; while i_1 < REPS { - (*coder).opts[cur as usize].backs[i_1 as usize] = *reps.offset(i_1 as isize); + *cur_backs.add(i_1 as usize) = *reps.offset(i_1 as isize); i_1 += 1; } - let cur_price: u32 = (*coder).opts[cur as usize].price; + let cur_price: u32 = (*opts.add(cur as usize)).price; let current_byte: u8 = *buf; let match_byte: u8 = *buf.offset(-(*reps as isize)).offset(-1); let pos_state: u32 = position & (*coder).pos_mask; let cur_and_1_price: u32 = cur_price - .wrapping_add(rc_bit_0_price((*coder).is_match[state as usize][pos_state as usize]) as u32) + .wrapping_add(rc_bit_0_price(match_prob(coder, state, pos_state)) as u32) .wrapping_add(get_literal_price( coder, position, @@ -585,7 +653,7 @@ unsafe fn helper2( match_byte as u32, current_byte as u32, ) as u32); - let next_opt = &mut (*coder).opts[cur.wrapping_add(1) as usize]; + let next_opt = &mut *opts.add(cur.wrapping_add(1) as usize); let mut next_is_literal: bool = false; if cur_and_1_price < next_opt.price { next_opt.price = cur_and_1_price; @@ -593,10 +661,10 @@ unsafe fn helper2( make_literal(next_opt); next_is_literal = true; } - let match_price: u32 = cur_price - .wrapping_add(rc_bit_1_price((*coder).is_match[state as usize][pos_state as usize]) as u32); + let match_price: u32 = + cur_price.wrapping_add(rc_bit_1_price(match_prob(coder, state, pos_state)) as u32); let rep_match_price: u32 = - match_price.wrapping_add(rc_bit_1_price((*coder).is_rep[state as usize]) as u32); + match_price.wrapping_add(rc_bit_1_price(is_rep_prob(coder, state)) as u32); if match_byte == current_byte && !(next_opt.pos_prev < cur && next_opt.back_prev == 0) { let short_rep_price: u32 = rep_match_price.wrapping_add(get_short_rep_price(coder, state, pos_state) as u32); @@ -627,14 +695,12 @@ unsafe fn helper2( let state_2: lzma_lzma_state = update_literal_state(state); let pos_state_next: u32 = position.wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price: u32 = cur_and_1_price - .wrapping_add(rc_bit_1_price( - (*coder).is_match[state_2 as usize][pos_state_next as usize], - ) as u32) - .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2 as usize]) as u32); + .wrapping_add(rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32) + .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2)) as u32); let offset: u32 = cur.wrapping_add(1u32).wrapping_add(len_test); while len_end < offset { len_end += 1; - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; + (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } let cur_and_len_price: u32 = next_rep_match_price.wrapping_add(get_rep_price( coder, @@ -643,12 +709,13 @@ unsafe fn helper2( state_2, pos_state_next, ) as u32); - if cur_and_len_price < (*coder).opts[offset as usize].price { - (*coder).opts[offset as usize].price = cur_and_len_price; - (*coder).opts[offset as usize].pos_prev = cur.wrapping_add(1); - (*coder).opts[offset as usize].back_prev = 0; - (*coder).opts[offset as usize].prev_1_is_literal = true; - (*coder).opts[offset as usize].prev_2 = false; + let opt = opts.add(offset as usize); + if cur_and_len_price < (*opt).price { + (*opt).price = cur_and_len_price; + (*opt).pos_prev = cur.wrapping_add(1); + (*opt).back_prev = 0; + (*opt).prev_1_is_literal = true; + (*opt).prev_2 = false; } } } @@ -662,7 +729,7 @@ unsafe fn helper2( let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2, buf_avail); while len_end < cur.wrapping_add(len_test_0) { len_end += 1; - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; + (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } let len_test_temp: u32 = len_test_0; let price: u32 = rep_match_price @@ -673,13 +740,12 @@ unsafe fn helper2( len_test_0, pos_state, ) as u32); - if cur_and_len_price_0 < (*coder).opts[cur.wrapping_add(len_test_0) as usize].price - { - (*coder).opts[cur.wrapping_add(len_test_0) as usize].price = - cur_and_len_price_0; - (*coder).opts[cur.wrapping_add(len_test_0) as usize].pos_prev = cur; - (*coder).opts[cur.wrapping_add(len_test_0) as usize].back_prev = rep_index; - (*coder).opts[cur.wrapping_add(len_test_0) as usize].prev_1_is_literal = false; + let opt = opts.add(cur.wrapping_add(len_test_0) as usize); + if cur_and_len_price_0 < (*opt).price { + (*opt).price = cur_and_len_price_0; + (*opt).pos_prev = cur; + (*opt).back_prev = rep_index; + (*opt).prev_1_is_literal = false; } len_test_0 -= 1; if len_test_0 < 2 { @@ -711,9 +777,9 @@ unsafe fn helper2( len_test_0, pos_state, ) as u32) - .wrapping_add(rc_bit_0_price( - (*coder).is_match[state_2_0 as usize][pos_state_next_0 as usize], - ) as u32) + .wrapping_add( + rc_bit_0_price(match_prob(coder, state_2_0, pos_state_next_0)) as u32, + ) .wrapping_add(get_literal_price( coder, position.wrapping_add(len_test_0), @@ -726,17 +792,17 @@ unsafe fn helper2( pos_state_next_0 = position.wrapping_add(len_test_0).wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price_0: u32 = cur_and_len_literal_price - .wrapping_add(rc_bit_1_price( - (*coder).is_match[state_2_0 as usize][pos_state_next_0 as usize], - ) as u32) - .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2_0 as usize]) as u32); + .wrapping_add( + rc_bit_1_price(match_prob(coder, state_2_0, pos_state_next_0)) as u32, + ) + .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2_0)) as u32); let offset_0: u32 = cur .wrapping_add(len_test_0) .wrapping_add(1) .wrapping_add(len_test_2); while len_end < offset_0 { len_end += 1; - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; + (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } let cur_and_len_price_1: u32 = next_rep_match_price_0.wrapping_add(get_rep_price( coder, @@ -746,15 +812,15 @@ unsafe fn helper2( pos_state_next_0, ) as u32); - if cur_and_len_price_1 < (*coder).opts[offset_0 as usize].price { - (*coder).opts[offset_0 as usize].price = cur_and_len_price_1; - (*coder).opts[offset_0 as usize].pos_prev = - cur.wrapping_add(len_test_0).wrapping_add(1); - (*coder).opts[offset_0 as usize].back_prev = 0; - (*coder).opts[offset_0 as usize].prev_1_is_literal = true; - (*coder).opts[offset_0 as usize].prev_2 = true; - (*coder).opts[offset_0 as usize].pos_prev_2 = cur; - (*coder).opts[offset_0 as usize].back_prev_2 = rep_index; + let opt = opts.add(offset_0 as usize); + if cur_and_len_price_1 < (*opt).price { + (*opt).price = cur_and_len_price_1; + (*opt).pos_prev = cur.wrapping_add(len_test_0).wrapping_add(1); + (*opt).back_prev = 0; + (*opt).prev_1_is_literal = true; + (*opt).prev_2 = true; + (*opt).pos_prev_2 = cur; + (*opt).back_prev_2 = rep_index; } } } @@ -763,36 +829,36 @@ unsafe fn helper2( if new_len > buf_avail { new_len = buf_avail; matches_count = 0; - while new_len > (*coder).matches[matches_count as usize].len { + while new_len > (*matches.add(matches_count as usize)).len { matches_count += 1; } - (*coder).matches[matches_count as usize].len = new_len; + (*matches.add(matches_count as usize)).len = new_len; matches_count += 1; } if new_len >= start_len { let normal_match_price: u32 = - match_price.wrapping_add(rc_bit_0_price((*coder).is_rep[state as usize]) as u32); + match_price.wrapping_add(rc_bit_0_price(is_rep_prob(coder, state)) as u32); while len_end < cur.wrapping_add(new_len) { len_end += 1; - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; + (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } let mut i_2: u32 = 0; - while start_len > (*coder).matches[i_2 as usize].len { + while start_len > (*matches.add(i_2 as usize)).len { i_2 += 1; } let mut len_test_1: u32 = start_len; loop { - let cur_back: u32 = (*coder).matches[i_2 as usize].dist; + let cur_back: u32 = (*matches.add(i_2 as usize)).dist; let mut cur_and_len_price_2: u32 = normal_match_price .wrapping_add(get_dist_len_price(coder, cur_back, len_test_1, pos_state)); - if cur_and_len_price_2 < (*coder).opts[cur.wrapping_add(len_test_1) as usize].price { - (*coder).opts[cur.wrapping_add(len_test_1) as usize].price = cur_and_len_price_2; - (*coder).opts[cur.wrapping_add(len_test_1) as usize].pos_prev = cur; - (*coder).opts[cur.wrapping_add(len_test_1) as usize].back_prev = - cur_back.wrapping_add(REPS); - (*coder).opts[cur.wrapping_add(len_test_1) as usize].prev_1_is_literal = false; + let opt = opts.add(cur.wrapping_add(len_test_1) as usize); + if cur_and_len_price_2 < (*opt).price { + (*opt).price = cur_and_len_price_2; + (*opt).pos_prev = cur; + (*opt).back_prev = cur_back.wrapping_add(REPS); + (*opt).prev_1_is_literal = false; } - if len_test_1 == (*coder).matches[i_2 as usize].len { + if len_test_1 == (*matches.add(i_2 as usize)).len { let buf_back_1: *const u8 = buf.offset(-(cur_back as isize)).offset(-1); let mut len_test_2_0: u32 = len_test_1.wrapping_add(1); let limit_1: u32 = if buf_avail_full < len_test_2_0.wrapping_add(nice_len) { @@ -810,9 +876,9 @@ unsafe fn helper2( let mut pos_state_next_1: u32 = position.wrapping_add(len_test_1) & (*coder).pos_mask; let cur_and_len_literal_price_0: u32 = cur_and_len_price_2 - .wrapping_add(rc_bit_0_price( - (*coder).is_match[state_2_1 as usize][pos_state_next_1 as usize], - ) as u32) + .wrapping_add( + rc_bit_0_price(match_prob(coder, state_2_1, pos_state_next_1)) as u32, + ) .wrapping_add(get_literal_price( coder, position.wrapping_add(len_test_1), @@ -824,17 +890,17 @@ unsafe fn helper2( state_2_1 = update_literal_state(state_2_1); pos_state_next_1 = pos_state_next_1.wrapping_add(1) & (*coder).pos_mask; let next_rep_match_price_1: u32 = cur_and_len_literal_price_0 - .wrapping_add(rc_bit_1_price( - (*coder).is_match[state_2_1 as usize][pos_state_next_1 as usize], - ) as u32) - .wrapping_add(rc_bit_1_price((*coder).is_rep[state_2_1 as usize]) as u32); + .wrapping_add( + rc_bit_1_price(match_prob(coder, state_2_1, pos_state_next_1)) as u32, + ) + .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2_1)) as u32); let offset_1: u32 = cur .wrapping_add(len_test_1) .wrapping_add(1) .wrapping_add(len_test_2_0); while len_end < offset_1 { len_end += 1; - (*coder).opts[len_end as usize].price = RC_INFINITY_PRICE as u32; + (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } cur_and_len_price_2 = next_rep_match_price_1.wrapping_add(get_rep_price( coder, @@ -843,15 +909,15 @@ unsafe fn helper2( state_2_1, pos_state_next_1, )); - if cur_and_len_price_2 < (*coder).opts[offset_1 as usize].price { - (*coder).opts[offset_1 as usize].price = cur_and_len_price_2; - (*coder).opts[offset_1 as usize].pos_prev = - cur.wrapping_add(len_test_1).wrapping_add(1); - (*coder).opts[offset_1 as usize].back_prev = 0; - (*coder).opts[offset_1 as usize].prev_1_is_literal = true; - (*coder).opts[offset_1 as usize].prev_2 = true; - (*coder).opts[offset_1 as usize].pos_prev_2 = cur; - (*coder).opts[offset_1 as usize].back_prev_2 = cur_back.wrapping_add(REPS); + let opt = opts.add(offset_1 as usize); + if cur_and_len_price_2 < (*opt).price { + (*opt).price = cur_and_len_price_2; + (*opt).pos_prev = cur.wrapping_add(len_test_1).wrapping_add(1); + (*opt).back_prev = 0; + (*opt).prev_1_is_literal = true; + (*opt).prev_2 = true; + (*opt).pos_prev_2 = cur; + (*opt).back_prev_2 = cur_back.wrapping_add(REPS); } } i_2 += 1; @@ -871,12 +937,13 @@ pub unsafe fn lzma_lzma_optimum_normal( len_res: *mut u32, position: u32, ) { + let opts = opts_ptr(coder); + let matches = matches_ptr(coder); if (*coder).opts_end_index != (*coder).opts_current_index { - *len_res = (*coder).opts[(*coder).opts_current_index as usize] - .pos_prev - .wrapping_sub((*coder).opts_current_index); - *back_res = (*coder).opts[(*coder).opts_current_index as usize].back_prev; - (*coder).opts_current_index = (*coder).opts[(*coder).opts_current_index as usize].pos_prev; + let opt = opts.add((*coder).opts_current_index as usize); + *len_res = (*opt).pos_prev.wrapping_sub((*coder).opts_current_index); + *back_res = (*opt).back_prev; + (*coder).opts_current_index = (*opt).pos_prev; return; } if (*mf).read_ahead == 0 { @@ -898,7 +965,7 @@ pub unsafe fn lzma_lzma_optimum_normal( (*coder).longest_match_length = lzma_mf_find( mf, ::core::ptr::addr_of_mut!((*coder).matches_count), - ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, + matches, ); if (*coder).longest_match_length >= (*mf).nice_len { break; From 55aa151cf86b4b87d9e700dd66587145a2114f9b Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 05:04:46 +0900 Subject: [PATCH 24/51] perf: outline cold optimum-normal branches --- .../src/lzma/lzma_encoder_optimum_normal.rs | 252 +++++++++++------- 1 file changed, 152 insertions(+), 100 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index b9cd78f7..7c1971ff 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -767,61 +767,21 @@ unsafe fn helper2( } len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1)); if len_test_2 >= 2 { - let mut state_2_0: lzma_lzma_state = state; - state_2_0 = update_long_rep_state(state_2_0); - let mut pos_state_next_0: u32 = - position.wrapping_add(len_test_0) & (*coder).pos_mask; - let cur_and_len_literal_price: u32 = price - .wrapping_add(get_len_price( - ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), - len_test_0, - pos_state, - ) as u32) - .wrapping_add( - rc_bit_0_price(match_prob(coder, state_2_0, pos_state_next_0)) as u32, - ) - .wrapping_add(get_literal_price( - coder, - position.wrapping_add(len_test_0), - *buf.offset(len_test_0.wrapping_sub(1) as isize) as u32, - true, - *buf_back_0.offset(len_test_0 as isize) as u32, - *buf.offset(len_test_0 as isize) as u32, - ) as u32); - state_2_0 = update_literal_state(state_2_0); - pos_state_next_0 = - position.wrapping_add(len_test_0).wrapping_add(1) & (*coder).pos_mask; - let next_rep_match_price_0: u32 = cur_and_len_literal_price - .wrapping_add( - rc_bit_1_price(match_prob(coder, state_2_0, pos_state_next_0)) as u32, - ) - .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2_0)) as u32); - let offset_0: u32 = cur - .wrapping_add(len_test_0) - .wrapping_add(1) - .wrapping_add(len_test_2); - while len_end < offset_0 { - len_end += 1; - (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; - } - let cur_and_len_price_1: u32 = next_rep_match_price_0.wrapping_add(get_rep_price( + consider_literal_after_rep( coder, - 0, + opts, + ::core::ptr::addr_of_mut!(len_end), + buf, + buf_back_0, + position, + cur, + len_test_0, len_test_2, - state_2_0, - pos_state_next_0, - ) - as u32); - let opt = opts.add(offset_0 as usize); - if cur_and_len_price_1 < (*opt).price { - (*opt).price = cur_and_len_price_1; - (*opt).pos_prev = cur.wrapping_add(len_test_0).wrapping_add(1); - (*opt).back_prev = 0; - (*opt).prev_1_is_literal = true; - (*opt).prev_2 = true; - (*opt).pos_prev_2 = cur; - (*opt).back_prev_2 = rep_index; - } + price, + state, + pos_state, + rep_index, + ); } } rep_index += 1; @@ -849,7 +809,7 @@ unsafe fn helper2( let mut len_test_1: u32 = start_len; loop { let cur_back: u32 = (*matches.add(i_2 as usize)).dist; - let mut cur_and_len_price_2: u32 = normal_match_price + let cur_and_len_price_2: u32 = normal_match_price .wrapping_add(get_dist_len_price(coder, cur_back, len_test_1, pos_state)); let opt = opts.add(cur.wrapping_add(len_test_1) as usize); if cur_and_len_price_2 < (*opt).price { @@ -871,54 +831,20 @@ unsafe fn helper2( } len_test_2_0 = len_test_2_0.wrapping_sub(len_test_1.wrapping_add(1)); if len_test_2_0 >= 2 { - let mut state_2_1: lzma_lzma_state = state; - state_2_1 = update_match_state(state_2_1); - let mut pos_state_next_1: u32 = - position.wrapping_add(len_test_1) & (*coder).pos_mask; - let cur_and_len_literal_price_0: u32 = cur_and_len_price_2 - .wrapping_add( - rc_bit_0_price(match_prob(coder, state_2_1, pos_state_next_1)) as u32, - ) - .wrapping_add(get_literal_price( - coder, - position.wrapping_add(len_test_1), - *buf.offset(len_test_1.wrapping_sub(1) as isize) as u32, - true, - *buf_back_1.offset(len_test_1 as isize) as u32, - *buf.offset(len_test_1 as isize) as u32, - ) as u32); - state_2_1 = update_literal_state(state_2_1); - pos_state_next_1 = pos_state_next_1.wrapping_add(1) & (*coder).pos_mask; - let next_rep_match_price_1: u32 = cur_and_len_literal_price_0 - .wrapping_add( - rc_bit_1_price(match_prob(coder, state_2_1, pos_state_next_1)) as u32, - ) - .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2_1)) as u32); - let offset_1: u32 = cur - .wrapping_add(len_test_1) - .wrapping_add(1) - .wrapping_add(len_test_2_0); - while len_end < offset_1 { - len_end += 1; - (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; - } - cur_and_len_price_2 = next_rep_match_price_1.wrapping_add(get_rep_price( + consider_literal_after_match( coder, - 0, + opts, + ::core::ptr::addr_of_mut!(len_end), + buf, + buf_back_1, + position, + cur, + len_test_1, len_test_2_0, - state_2_1, - pos_state_next_1, - )); - let opt = opts.add(offset_1 as usize); - if cur_and_len_price_2 < (*opt).price { - (*opt).price = cur_and_len_price_2; - (*opt).pos_prev = cur.wrapping_add(len_test_1).wrapping_add(1); - (*opt).back_prev = 0; - (*opt).prev_1_is_literal = true; - (*opt).prev_2 = true; - (*opt).pos_prev_2 = cur; - (*opt).back_prev_2 = cur_back.wrapping_add(REPS); - } + cur_and_len_price_2, + state, + cur_back, + ); } i_2 += 1; if i_2 == matches_count { @@ -930,6 +856,132 @@ unsafe fn helper2( } len_end } +#[cold] +#[inline(never)] +unsafe fn consider_literal_after_rep( + coder: *mut lzma_lzma1_encoder, + opts: *mut lzma_optimal, + len_end: *mut u32, + buf: *const u8, + buf_back: *const u8, + position: u32, + cur: u32, + len_test: u32, + len_test_2: u32, + price: u32, + state: lzma_lzma_state, + pos_state: u32, + rep_index: u32, +) { + let mut state_2: lzma_lzma_state = state; + state_2 = update_long_rep_state(state_2); + let mut pos_state_next: u32 = position.wrapping_add(len_test) & (*coder).pos_mask; + let cur_and_len_literal_price: u32 = price + .wrapping_add(get_len_price( + ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), + len_test, + pos_state, + ) as u32) + .wrapping_add(rc_bit_0_price(match_prob(coder, state_2, pos_state_next)) as u32) + .wrapping_add(get_literal_price( + coder, + position.wrapping_add(len_test), + *buf.offset(len_test.wrapping_sub(1) as isize) as u32, + true, + *buf_back.offset(len_test as isize) as u32, + *buf.offset(len_test as isize) as u32, + ) as u32); + state_2 = update_literal_state(state_2); + pos_state_next = position.wrapping_add(len_test).wrapping_add(1) & (*coder).pos_mask; + let next_rep_match_price: u32 = cur_and_len_literal_price + .wrapping_add(rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32) + .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2)) as u32); + let offset: u32 = cur + .wrapping_add(len_test) + .wrapping_add(1) + .wrapping_add(len_test_2); + while *len_end < offset { + *len_end += 1; + (*opts.add(*len_end as usize)).price = RC_INFINITY_PRICE as u32; + } + let cur_and_len_price: u32 = next_rep_match_price.wrapping_add(get_rep_price( + coder, + 0, + len_test_2, + state_2, + pos_state_next, + ) as u32); + let opt = opts.add(offset as usize); + if cur_and_len_price < (*opt).price { + (*opt).price = cur_and_len_price; + (*opt).pos_prev = cur.wrapping_add(len_test).wrapping_add(1); + (*opt).back_prev = 0; + (*opt).prev_1_is_literal = true; + (*opt).prev_2 = true; + (*opt).pos_prev_2 = cur; + (*opt).back_prev_2 = rep_index; + } +} +#[cold] +#[inline(never)] +unsafe fn consider_literal_after_match( + coder: *mut lzma_lzma1_encoder, + opts: *mut lzma_optimal, + len_end: *mut u32, + buf: *const u8, + buf_back: *const u8, + position: u32, + cur: u32, + len_test: u32, + len_test_2: u32, + cur_and_len_price: u32, + state: lzma_lzma_state, + cur_back: u32, +) { + let mut state_2: lzma_lzma_state = state; + state_2 = update_match_state(state_2); + let mut pos_state_next: u32 = position.wrapping_add(len_test) & (*coder).pos_mask; + let cur_and_len_literal_price: u32 = cur_and_len_price + .wrapping_add(rc_bit_0_price(match_prob(coder, state_2, pos_state_next)) as u32) + .wrapping_add(get_literal_price( + coder, + position.wrapping_add(len_test), + *buf.offset(len_test.wrapping_sub(1) as isize) as u32, + true, + *buf_back.offset(len_test as isize) as u32, + *buf.offset(len_test as isize) as u32, + ) as u32); + state_2 = update_literal_state(state_2); + pos_state_next = pos_state_next.wrapping_add(1) & (*coder).pos_mask; + let next_rep_match_price: u32 = cur_and_len_literal_price + .wrapping_add(rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32) + .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2)) as u32); + let offset: u32 = cur + .wrapping_add(len_test) + .wrapping_add(1) + .wrapping_add(len_test_2); + while *len_end < offset { + *len_end += 1; + (*opts.add(*len_end as usize)).price = RC_INFINITY_PRICE as u32; + } + let cur_and_len_price = next_rep_match_price.wrapping_add(get_rep_price( + coder, + 0, + len_test_2, + state_2, + pos_state_next, + )); + let opt = opts.add(offset as usize); + if cur_and_len_price < (*opt).price { + (*opt).price = cur_and_len_price; + (*opt).pos_prev = cur.wrapping_add(len_test).wrapping_add(1); + (*opt).back_prev = 0; + (*opt).prev_1_is_literal = true; + (*opt).prev_2 = true; + (*opt).pos_prev_2 = cur; + (*opt).back_prev_2 = cur_back.wrapping_add(REPS); + } +} pub unsafe fn lzma_lzma_optimum_normal( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, From 2af70191db072e5393ec08bd3b688a7fb5b46b62 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 17:01:37 +0900 Subject: [PATCH 25/51] perf: simplify bt4 find header arithmetic --- liblzma-rs/src/lz/lz_encoder_mf.rs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 506f5a2e..40f5892d 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -613,38 +613,30 @@ pub unsafe extern "C" fn lzma_mf_bt4_find(mf: *mut lzma_mf, matches: *mut lzma_m let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8 ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) & (*mf).hash_mask; - let mut delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); - let delta3: u32 = pos.wrapping_sub( - *(*mf) - .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize), - ); - let cur_match: u32 = *(*mf) - .hash - .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize); + let hash_3_index = FIX_3_HASH_SIZE as u32 + hash_3_value; + let hash_4_index = FIX_4_HASH_SIZE as u32 + hash_value; + let mut delta2: u32 = pos - *(*mf).hash.offset(hash_2_value as isize); + let delta3: u32 = pos - *(*mf).hash.offset(hash_3_index as isize); + let cur_match: u32 = *(*mf).hash.offset(hash_4_index as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; - *(*mf) - .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize) = pos; - *(*mf) - .hash - .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + *(*mf).hash.offset(hash_3_index as isize) = pos; + *(*mf).hash.offset(hash_4_index as isize) = pos; let mut len_best: u32 = 1; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = 2; (*matches).len = 2; - (*matches).dist = delta2.wrapping_sub(1); + (*matches).dist = delta2 - 1; matches_count = 1; } if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) == *cur { len_best = 3; - (*matches.offset(matches_count as isize)).dist = delta3.wrapping_sub(1); + (*matches.offset(matches_count as isize)).dist = delta3 - 1; matches_count += 1; delta2 = delta3; } if matches_count != 0 { len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); - (*matches.offset(matches_count.wrapping_sub(1) as isize)).len = len_best; + (*matches.offset((matches_count - 1) as isize)).len = len_best; if len_best == len_limit { bt_skip_func( len_limit, From 76a3ed817f928452f51cc4560abfa8f5e63f0361 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 17:18:15 +0900 Subject: [PATCH 26/51] perf: shrink lzma encode hot path --- liblzma-rs/src/lzma/lzma_encoder.rs | 229 +++++++++++----------------- 1 file changed, 91 insertions(+), 138 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index b96989fa..19583bf5 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -347,45 +347,56 @@ unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u3 ); }; } +#[inline(always)] +unsafe fn length_prices_row(lc: *mut lzma_length_encoder, pos_state: u32) -> *mut u32 { + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).prices) as *mut [u32; 272]) + .add(pos_state as usize)) as *mut u32 +} +#[inline(always)] +unsafe fn length_low_probs(lc: *mut lzma_length_encoder, pos_state: u32) -> *mut probability { + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).low) as *mut [probability; 8]) + .add(pos_state as usize)) as *mut probability +} +#[inline(always)] +unsafe fn length_mid_probs(lc: *mut lzma_length_encoder, pos_state: u32) -> *mut probability { + ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).mid) as *mut [probability; 8]) + .add(pos_state as usize)) as *mut probability +} +#[inline(always)] +unsafe fn is_match_prob(coder: *mut lzma_lzma1_encoder, pos_state: u32) -> *mut probability { + (::core::ptr::addr_of_mut!( + *(::core::ptr::addr_of_mut!((*coder).is_match) as *mut [probability; 16]) + .add((*coder).state as usize) + ) as *mut probability) + .add(pos_state as usize) +} +#[inline(always)] +unsafe fn is_rep_prob(coder: *mut lzma_lzma1_encoder) -> *mut probability { + (::core::ptr::addr_of_mut!((*coder).is_rep) as *mut probability).add((*coder).state as usize) +} unsafe fn length_update_prices(lc: *mut lzma_length_encoder, pos_state: u32) { let table_size: u32 = (*lc).table_size; (*lc).counters[pos_state as usize] = table_size; let a0: u32 = rc_bit_0_price((*lc).choice) as u32; let a1: u32 = rc_bit_1_price((*lc).choice) as u32; - let b0: u32 = a1.wrapping_add(rc_bit_0_price((*lc).choice2) as u32); - let b1: u32 = a1.wrapping_add(rc_bit_1_price((*lc).choice2) as u32); - let prices: *mut u32 = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).prices) - as *mut [u32; 272]) - .offset(pos_state as isize)) as *mut u32; + let b0: u32 = a1 + rc_bit_0_price((*lc).choice2) as u32; + let b1: u32 = a1 + rc_bit_1_price((*lc).choice2) as u32; + let prices: *mut u32 = length_prices_row(lc, pos_state); + let low: *mut probability = length_low_probs(lc, pos_state); + let mid: *mut probability = length_mid_probs(lc, pos_state); + let high: *mut probability = ::core::ptr::addr_of_mut!((*lc).high) as *mut probability; let mut i: u32 = 0; - i = 0; while i < table_size && i < LEN_LOW_SYMBOLS { - *prices.offset(i as isize) = a0.wrapping_add(rc_bittree_price( - ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).low) - as *mut [probability; 8]) - .offset(pos_state as isize)) as *mut probability, - LEN_LOW_BITS, - i, - )); + *prices.add(i as usize) = a0 + rc_bittree_price(low, LEN_LOW_BITS, i); i += 1; } - while i < table_size && i < (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS) as u32 { - *prices.offset(i as isize) = b0.wrapping_add(rc_bittree_price( - ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).mid) - as *mut [probability; 8]) - .offset(pos_state as isize)) as *mut probability, - LEN_MID_BITS, - i.wrapping_sub(LEN_LOW_SYMBOLS), - )); + while i < table_size && i < LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS { + *prices.add(i as usize) = b0 + rc_bittree_price(mid, LEN_MID_BITS, i - LEN_LOW_SYMBOLS); i += 1; } while i < table_size { - *prices.offset(i as isize) = b1.wrapping_add(rc_bittree_price( - ::core::ptr::addr_of_mut!((*lc).high) as *mut probability, - LEN_HIGH_BITS, - i.wrapping_sub(LEN_LOW_SYMBOLS) - .wrapping_sub(LEN_MID_SYMBOLS), - )); + *prices.add(i as usize) = + b1 + rc_bittree_price(high, LEN_HIGH_BITS, i - LEN_LOW_SYMBOLS - LEN_MID_SYMBOLS); i += 1; } } @@ -397,33 +408,19 @@ unsafe fn length( mut len: u32, fast_mode: bool, ) { - len = len.wrapping_sub(MATCH_LEN_MIN); + len -= MATCH_LEN_MIN; if len < LEN_LOW_SYMBOLS { rc_bit(rc, ::core::ptr::addr_of_mut!((*lc).choice), 0); - rc_bittree( - rc, - ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).low) - as *mut [probability; 8]) - .offset(pos_state as isize)) as *mut probability, - LEN_LOW_BITS, - len, - ); + rc_bittree(rc, length_low_probs(lc, pos_state), LEN_LOW_BITS, len); } else { rc_bit(rc, ::core::ptr::addr_of_mut!((*lc).choice), 1); - len = len.wrapping_sub(LEN_LOW_SYMBOLS); + len -= LEN_LOW_SYMBOLS; if len < LEN_MID_SYMBOLS { rc_bit(rc, ::core::ptr::addr_of_mut!((*lc).choice2), 0); - rc_bittree( - rc, - ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).mid) - as *mut [probability; 8]) - .offset(pos_state as isize)) as *mut probability, - LEN_MID_BITS, - len, - ); + rc_bittree(rc, length_mid_probs(lc, pos_state), LEN_MID_BITS, len); } else { rc_bit(rc, ::core::ptr::addr_of_mut!((*lc).choice2), 1); - len = len.wrapping_sub(LEN_MID_SYMBOLS); + len -= LEN_MID_SYMBOLS; rc_bittree( rc, ::core::ptr::addr_of_mut!((*lc).high) as *mut probability, @@ -433,7 +430,7 @@ unsafe fn length( } } if !fast_mode { - (*lc).counters[pos_state as usize] = (*lc).counters[pos_state as usize].wrapping_sub(1); + (*lc).counters[pos_state as usize] -= 1; if (*lc).counters[pos_state as usize] == 0 { length_update_prices(lc, pos_state); } @@ -590,43 +587,19 @@ unsafe fn encode_symbol( ) { let pos_state: u32 = position & (*coder).pos_mask; if back == UINT32_MAX { - rc_bit( - ::core::ptr::addr_of_mut!((*coder).rc), - (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_match) - as *mut [probability; 16]) - .offset((*coder).state as isize)) as *mut probability) - .offset(pos_state as isize) as *mut probability, - 0, - ); + rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_match_prob(coder, pos_state), 0); literal(coder, mf, position); } else { - rc_bit( - ::core::ptr::addr_of_mut!((*coder).rc), - (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_match) - as *mut [probability; 16]) - .offset((*coder).state as isize)) as *mut probability) - .offset(pos_state as isize) as *mut probability, - 1, - ); + rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_match_prob(coder, pos_state), 1); if back < REPS { - rc_bit( - ::core::ptr::addr_of_mut!((*coder).rc), - (::core::ptr::addr_of_mut!((*coder).is_rep) as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 1, - ); + rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_rep_prob(coder), 1); rep_match(coder, pos_state, back, len); } else { - rc_bit( - ::core::ptr::addr_of_mut!((*coder).rc), - (::core::ptr::addr_of_mut!((*coder).is_rep) as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 0, - ); - match_0(coder, pos_state, back.wrapping_sub(REPS), len); + rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_rep_prob(coder), 0); + match_0(coder, pos_state, back - REPS, len); } } - (*mf).read_ahead = (*mf).read_ahead.wrapping_sub(len); + (*mf).read_ahead -= len; } unsafe fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool { if (*mf).read_pos == (*mf).read_limit { @@ -636,13 +609,7 @@ unsafe fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool } else { mf_skip(mf, 1); (*mf).read_ahead = 0; - rc_bit( - ::core::ptr::addr_of_mut!((*coder).rc), - (::core::ptr::addr_of_mut!( - *(::core::ptr::addr_of_mut!((*coder).is_match) as *mut [probability; 16]) - ) as *mut probability) as *mut probability, - 0, - ); + rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_match_prob(coder, 0), 0); rc_bittree( ::core::ptr::addr_of_mut!((*coder).rc), ::core::ptr::addr_of_mut!((*coder).literal) as *mut probability, @@ -656,23 +623,33 @@ unsafe fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool } unsafe fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) { let pos_state: u32 = position & (*coder).pos_mask; - rc_bit( - ::core::ptr::addr_of_mut!((*coder).rc), - (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_match) - as *mut [probability; 16]) - .offset((*coder).state as isize)) as *mut probability) - .offset(pos_state as isize) as *mut probability, - 1, - ); - rc_bit( - ::core::ptr::addr_of_mut!((*coder).rc), - (::core::ptr::addr_of_mut!((*coder).is_rep) as *mut probability) - .offset((*coder).state as isize) as *mut probability, - 0, - ); + rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_match_prob(coder, pos_state), 1); + rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_rep_prob(coder), 0); match_0(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN); } pub const LOOP_INPUT_MAX: u32 = OPTS + 1; +#[cold] +#[inline(never)] +unsafe fn finish_lzma_stream( + coder: *mut lzma_lzma1_encoder, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + let rc = ::core::ptr::addr_of_mut!((*coder).rc); + if !(*coder).uncomp_size_ptr.is_null() { + *(*coder).uncomp_size_ptr = (*coder).uncomp_size; + } + if (*coder).use_eopm { + encode_eopm(coder, (*coder).uncomp_size as u32); + } + rc_flush(rc); + if rc_encode(rc, out, out_pos, out_size) { + (*coder).is_flushed = true; + return LZMA_OK; + } + LZMA_STREAM_END +} pub unsafe fn lzma_lzma_encode( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, @@ -681,25 +658,23 @@ pub unsafe fn lzma_lzma_encode( out_size: size_t, limit: u32, ) -> lzma_ret { + let rc = ::core::ptr::addr_of_mut!((*coder).rc); if !(*coder).is_initialized && !encode_init(coder, mf) { return LZMA_OK; } - if rc_encode( - ::core::ptr::addr_of_mut!((*coder).rc), - out, - out_pos, - out_size, - ) { + if rc_encode(rc, out, out_pos, out_size) { return LZMA_OK; } if (*coder).is_flushed { return LZMA_STREAM_END; } - while !(limit != UINT32_MAX - && ((*mf).read_pos.wrapping_sub((*mf).read_ahead) >= limit - || (*out_pos as u64).wrapping_add(rc_pending(::core::ptr::addr_of_mut!((*coder).rc))) - >= LZMA2_CHUNK_MAX.wrapping_sub(LOOP_INPUT_MAX) as u64)) - { + loop { + if limit != UINT32_MAX + && ((*mf).read_pos - (*mf).read_ahead >= limit + || (*out_pos as u64) + rc_pending(rc) >= (LZMA2_CHUNK_MAX - LOOP_INPUT_MAX) as u64) + { + break; + } if (*mf).read_pos >= (*mf).read_limit { if (*mf).action == LZMA_RUN { return LZMA_OK; @@ -728,39 +703,17 @@ pub unsafe fn lzma_lzma_encode( } encode_symbol(coder, mf, back, len, (*coder).uncomp_size as u32); if (*coder).out_limit != 0 - && rc_encode_dummy(::core::ptr::addr_of_mut!((*coder).rc), (*coder).out_limit) + && rc_encode_dummy(rc, (*coder).out_limit) { - rc_forget(::core::ptr::addr_of_mut!((*coder).rc)); + rc_forget(rc); break; - } else { - (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(len as u64); - if rc_encode( - ::core::ptr::addr_of_mut!((*coder).rc), - out, - out_pos, - out_size, - ) { - return LZMA_OK; - } + } + (*coder).uncomp_size += len as u64; + if rc_encode(rc, out, out_pos, out_size) { + return LZMA_OK; } } - if !(*coder).uncomp_size_ptr.is_null() { - *(*coder).uncomp_size_ptr = (*coder).uncomp_size; - } - if (*coder).use_eopm { - encode_eopm(coder, (*coder).uncomp_size as u32); - } - rc_flush(::core::ptr::addr_of_mut!((*coder).rc)); - if rc_encode( - ::core::ptr::addr_of_mut!((*coder).rc), - out, - out_pos, - out_size, - ) { - (*coder).is_flushed = true; - return LZMA_OK; - } - LZMA_STREAM_END + finish_lzma_stream(coder, out, out_pos, out_size) } unsafe extern "C" fn lzma_encode( coder: *mut c_void, From b55c05c645a76559f2241fb067f388f4ce888cce Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 17:25:55 +0900 Subject: [PATCH 27/51] Replace unnecessary wrapping arithmetic with plain ops in delta, simple, and common modules --- liblzma-rs/src/common/alone_decoder.rs | 14 ++--- liblzma-rs/src/common/alone_encoder.rs | 2 +- liblzma-rs/src/common/block_decoder.rs | 50 ++++++---------- liblzma-rs/src/common/block_encoder.rs | 13 ++-- liblzma-rs/src/common/block_header_decoder.rs | 6 +- liblzma-rs/src/common/block_header_encoder.rs | 16 ++--- liblzma-rs/src/common/block_util.rs | 13 ++-- liblzma-rs/src/common/common.rs | 21 ++++--- liblzma-rs/src/common/filter_common.rs | 14 ++--- liblzma-rs/src/common/filter_decoder.rs | 6 +- liblzma-rs/src/common/filter_encoder.rs | 8 +-- liblzma-rs/src/common/filter_flags_decoder.rs | 4 +- liblzma-rs/src/common/filter_flags_encoder.rs | 7 +-- liblzma-rs/src/common/index_decoder.rs | 12 ++-- liblzma-rs/src/common/index_encoder.rs | 16 ++--- liblzma-rs/src/common/index_hash.rs | 12 ++-- liblzma-rs/src/common/lzip_decoder.rs | 21 +++---- liblzma-rs/src/common/microlzma_decoder.rs | 18 +++--- liblzma-rs/src/common/microlzma_encoder.rs | 4 +- liblzma-rs/src/common/outqueue.rs | 33 ++++------ .../src/common/stream_buffer_encoder.rs | 12 ++-- liblzma-rs/src/common/stream_flags_decoder.rs | 8 +-- liblzma-rs/src/common/vli_decoder.rs | 8 +-- liblzma-rs/src/common/vli_encoder.rs | 10 ++-- liblzma-rs/src/delta/delta_decoder.rs | 5 +- liblzma-rs/src/delta/delta_encoder.rs | 16 +++-- liblzma-rs/src/simple/arm.rs | 12 ++-- liblzma-rs/src/simple/arm64.rs | 4 +- liblzma-rs/src/simple/armthumb.rs | 22 +++---- liblzma-rs/src/simple/ia64.rs | 17 +++--- liblzma-rs/src/simple/powerpc.rs | 20 +++---- liblzma-rs/src/simple/riscv.rs | 60 +++++++++---------- liblzma-rs/src/simple/simple_coder.rs | 23 ++++--- liblzma-rs/src/simple/sparc.rs | 18 +++--- liblzma-rs/src/simple/x86.rs | 20 +++---- 35 files changed, 256 insertions(+), 289 deletions(-) diff --git a/liblzma-rs/src/common/alone_decoder.rs b/liblzma-rs/src/common/alone_decoder.rs index 4895cfb1..31de9d99 100644 --- a/liblzma-rs/src/common/alone_decoder.rs +++ b/liblzma-rs/src/common/alone_decoder.rs @@ -40,14 +40,14 @@ unsafe extern "C" fn alone_decode( return LZMA_FORMAT_ERROR; } (*coder).sequence = SEQ_DICTIONARY_SIZE; - *in_pos = (*in_pos).wrapping_add(1); + *in_pos += 1; current_block_42 = 11048769245176032998; } 1 => { (*coder).options.dict_size = ((*coder).options.dict_size as size_t - | (*in_0.offset(*in_pos as isize) as size_t) << (*coder).pos.wrapping_mul(8)) + | (*in_0.offset(*in_pos as isize) as size_t) << ((*coder).pos * 8)) as u32; - (*coder).pos = (*coder).pos.wrapping_add(1); + (*coder).pos += 1; if (*coder).pos == 4 { if (*coder).picky && (*coder).options.dict_size != UINT32_MAX { let mut d: u32 = (*coder).options.dict_size.wrapping_sub(1); @@ -64,14 +64,14 @@ unsafe extern "C" fn alone_decode( (*coder).pos = 0; (*coder).sequence = SEQ_UNCOMPRESSED_SIZE; } - *in_pos = (*in_pos).wrapping_add(1); + *in_pos += 1; current_block_42 = 11048769245176032998; } 2 => { (*coder).uncompressed_size |= - (*in_0.offset(*in_pos as isize) as lzma_vli) << (*coder).pos.wrapping_mul(8); - *in_pos = (*in_pos).wrapping_add(1); - (*coder).pos = (*coder).pos.wrapping_add(1); + (*in_0.offset(*in_pos as isize) as lzma_vli) << ((*coder).pos * 8); + *in_pos += 1; + (*coder).pos += 1; if (*coder).pos < 8 { current_block_42 = 11048769245176032998; } else { diff --git a/liblzma-rs/src/common/alone_encoder.rs b/liblzma-rs/src/common/alone_encoder.rs index 90c2b357..921236a8 100644 --- a/liblzma-rs/src/common/alone_encoder.rs +++ b/liblzma-rs/src/common/alone_encoder.rs @@ -152,7 +152,7 @@ unsafe extern "C" fn alone_encoder_init( if (*options).dict_size < LZMA_DICT_SIZE_MIN as u32 { return LZMA_OPTIONS_ERROR; } - let mut d: u32 = (*options).dict_size.wrapping_sub(1); + let mut d: u32 = (*options).dict_size - 1; d |= d >> 2; d |= d >> 3; d |= d >> 4; diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index c202f1ec..21fb8792 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -37,32 +37,22 @@ unsafe extern "C" fn block_decode( 0 => { let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - let in_stop: size_t = (*in_pos).wrapping_add( - (if (in_size.wrapping_sub(*in_pos) as lzma_vli) - < (*coder) - .compressed_limit - .wrapping_sub((*coder).compressed_size) + let in_stop: size_t = *in_pos + + (if ((in_size - *in_pos) as lzma_vli) + < (*coder).compressed_limit - (*coder).compressed_size { - in_size.wrapping_sub(*in_pos) as lzma_vli + (in_size - *in_pos) as lzma_vli } else { - (*coder) - .compressed_limit - .wrapping_sub((*coder).compressed_size) - }) as size_t, - ); - let out_stop: size_t = (*out_pos).wrapping_add( - (if (out_size.wrapping_sub(*out_pos) as lzma_vli) - < (*coder) - .uncompressed_limit - .wrapping_sub((*coder).uncompressed_size) + (*coder).compressed_limit - (*coder).compressed_size + }) as size_t; + let out_stop: size_t = *out_pos + + (if ((out_size - *out_pos) as lzma_vli) + < (*coder).uncompressed_limit - (*coder).uncompressed_size { - out_size.wrapping_sub(*out_pos) as lzma_vli + (out_size - *out_pos) as lzma_vli } else { - (*coder) - .uncompressed_limit - .wrapping_sub((*coder).uncompressed_size) - }) as size_t, - ); + (*coder).uncompressed_limit - (*coder).uncompressed_size + }) as size_t; let ret: lzma_ret = (*coder).next.code.unwrap()( (*coder).next.coder, allocator, @@ -74,12 +64,10 @@ unsafe extern "C" fn block_decode( out_stop, action, ); - let in_used: size_t = (*in_pos).wrapping_sub(in_start); - let out_used: size_t = (*out_pos).wrapping_sub(out_start); - (*coder).compressed_size = (*coder).compressed_size.wrapping_add(in_used as lzma_vli); - (*coder).uncompressed_size = (*coder) - .uncompressed_size - .wrapping_add(out_used as lzma_vli); + let in_used: size_t = *in_pos - in_start; + let out_used: size_t = *out_pos - out_start; + (*coder).compressed_size += in_used as lzma_vli; + (*coder).uncompressed_size += out_used as lzma_vli; if ret == LZMA_OK { let comp_done: bool = (*coder).compressed_size == (*(*coder).block).compressed_size; let uncomp_done: bool = @@ -127,7 +115,7 @@ unsafe extern "C" fn block_decode( if *in_pos >= in_size { return LZMA_OK; } - (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); + (*coder).compressed_size += 1; let byte = *in_0.offset(*in_pos as isize); *in_pos += 1; if byte != 0 { @@ -265,8 +253,8 @@ pub unsafe extern "C" fn lzma_block_decoder_init( (*coder).uncompressed_size = 0; (*coder).compressed_limit = if (*block).compressed_size == LZMA_VLI_UNKNOWN { (LZMA_VLI_MAX & !(3)) - .wrapping_sub((*block).header_size as lzma_vli) - .wrapping_sub(lzma_check_size((*block).check) as lzma_vli) + - (*block).header_size as lzma_vli + - lzma_check_size((*block).check) as lzma_vli } else { (*block).compressed_size }; diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index 33590623..f6adb42a 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -46,14 +46,13 @@ unsafe extern "C" fn block_encode( out_size, action, ); - let in_used: size_t = (*in_pos).wrapping_sub(in_start); - let out_used: size_t = (*out_pos).wrapping_sub(out_start); + let in_used: size_t = *in_pos - in_start; + let out_used: size_t = *out_pos - out_start; if (COMPRESSED_SIZE_MAX).wrapping_sub((*coder).compressed_size) < out_used as lzma_vli { return LZMA_DATA_ERROR; } - (*coder).compressed_size = (*coder).compressed_size.wrapping_add(out_used as lzma_vli); - (*coder).uncompressed_size = - (*coder).uncompressed_size.wrapping_add(in_used as lzma_vli); + (*coder).compressed_size += out_used as lzma_vli; + (*coder).uncompressed_size += in_used as lzma_vli; if in_used > 0 { lzma_check_update( ::core::ptr::addr_of_mut!((*coder).check), @@ -80,8 +79,8 @@ unsafe extern "C" fn block_encode( return LZMA_OK; } *out.offset(*out_pos as isize) = 0; - *out_pos = (*out_pos).wrapping_add(1); - (*coder).compressed_size = (*coder).compressed_size.wrapping_add(1); + *out_pos += 1; + (*coder).compressed_size += 1; } if (*(*coder).block).check == LZMA_CHECK_NONE { return LZMA_STREAM_END; diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 080b3e86..10bf695a 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -18,12 +18,12 @@ pub unsafe fn lzma_block_header_decode( (*block).version = 1; } (*block).ignore_check = false as lzma_bool; - if (*in_0 as u32).wrapping_add(1).wrapping_mul(4) != (*block).header_size + if (*in_0 as u32 + 1) * 4 != (*block).header_size || (*block).check > LZMA_CHECK_ID_MAX { return LZMA_PROG_ERROR; } - let in_size: size_t = (*block).header_size.wrapping_sub(4) as size_t; + let in_size: size_t = ((*block).header_size - 4) as size_t; if lzma_crc32(in_0, in_size, 0) != read32le(in_0.offset(in_size as isize)) { return LZMA_DATA_ERROR; } @@ -62,7 +62,7 @@ pub unsafe fn lzma_block_header_decode( } else { (*block).uncompressed_size = LZMA_VLI_UNKNOWN; } - let filter_count: size_t = (u32::from(*in_0.offset(1)) & 3).wrapping_add(1) as size_t; + let filter_count: size_t = ((u32::from(*in_0.offset(1)) & 3) + 1) as size_t; let mut i_0: size_t = 0; while i_0 < filter_count { let ret: lzma_ret = lzma_filter_flags_decode( diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 21eeff33..9a286490 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -10,14 +10,14 @@ pub unsafe fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { if add == 0 || (*block).compressed_size == 0 { return LZMA_PROG_ERROR; } - size = size.wrapping_add(add); + size += add; } if (*block).uncompressed_size != LZMA_VLI_UNKNOWN { let add_0: u32 = lzma_vli_size((*block).uncompressed_size) as u32; if add_0 == 0 { return LZMA_PROG_ERROR; } - size = size.wrapping_add(add_0); + size += add_0; } if (*block).filters.is_null() || (*(*block).filters).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; @@ -35,10 +35,10 @@ pub unsafe fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { if ret_ != LZMA_OK { return ret_; } - size = size.wrapping_add(add_1); + size += add_1; i += 1; } - (*block).header_size = size.wrapping_add(3) & !(3); + (*block).header_size = (size + 3) & !(3); LZMA_OK } pub unsafe fn lzma_block_header_encode( @@ -51,8 +51,8 @@ pub unsafe fn lzma_block_header_encode( { return LZMA_PROG_ERROR; } - let out_size: size_t = (*block).header_size.wrapping_sub(4) as size_t; - *out = out_size.wrapping_div(4) as u8; + let out_size: size_t = ((*block).header_size - 4) as size_t; + *out = (out_size / 4) as u8; *out.offset(1) = 0; let mut out_pos: size_t = 2; if (*block).compressed_size != LZMA_VLI_UNKNOWN { @@ -103,11 +103,11 @@ pub unsafe fn lzma_block_header_encode( break; } } - *out.offset(1) |= filter_count.wrapping_sub(1) as u8; + *out.offset(1) |= (filter_count - 1) as u8; core::ptr::write_bytes( out.offset(out_pos as isize) as *mut u8, 0 as u8, - out_size.wrapping_sub(out_pos), + out_size - out_pos, ); write32le(out.offset(out_size as isize), lzma_crc32(out, out_size, 0)); LZMA_OK diff --git a/liblzma-rs/src/common/block_util.rs b/liblzma-rs/src/common/block_util.rs index fce5b00c..6b47061f 100644 --- a/liblzma-rs/src/common/block_util.rs +++ b/liblzma-rs/src/common/block_util.rs @@ -7,13 +7,11 @@ pub unsafe fn lzma_block_compressed_size( if lzma_block_unpadded_size(block) == 0 { return LZMA_PROG_ERROR; } - let container_size: u32 = (*block) - .header_size - .wrapping_add(lzma_check_size((*block).check) as u32); + let container_size: u32 = (*block).header_size + lzma_check_size((*block).check) as u32; if unpadded_size <= container_size as lzma_vli { return LZMA_DATA_ERROR; } - let compressed_size: lzma_vli = unpadded_size.wrapping_sub(container_size as lzma_vli); + let compressed_size: lzma_vli = unpadded_size - container_size as lzma_vli; if (*block).compressed_size != LZMA_VLI_UNKNOWN && (*block).compressed_size != compressed_size { return LZMA_DATA_ERROR; } @@ -36,10 +34,9 @@ pub unsafe fn lzma_block_unpadded_size(block: *const lzma_block) -> lzma_vli { if (*block).compressed_size == LZMA_VLI_UNKNOWN { return LZMA_VLI_UNKNOWN; } - let unpadded_size: lzma_vli = (*block) - .compressed_size - .wrapping_add((*block).header_size as lzma_vli) - .wrapping_add(lzma_check_size((*block).check) as lzma_vli); + let unpadded_size: lzma_vli = (*block).compressed_size + + (*block).header_size as lzma_vli + + lzma_check_size((*block).check) as lzma_vli; if unpadded_size > UNPADDED_SIZE_MAX { return 0; } diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index 903ccea5..bdae8801 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -67,11 +67,10 @@ pub const LZMA_VERSION_MINOR: u32 = 8; pub const LZMA_VERSION_PATCH: u32 = 2; pub const LZMA_VERSION_STABILITY: u32 = LZMA_VERSION_STABILITY_STABLE; pub const LZMA_VERSION_STABILITY_STABLE: u32 = 2; -pub const LZMA_VERSION: c_uint = (LZMA_VERSION_MAJOR) - .wrapping_mul(10000000) - .wrapping_add((LZMA_VERSION_MINOR).wrapping_mul(10000)) - .wrapping_add((LZMA_VERSION_PATCH).wrapping_mul(10)) - .wrapping_add(LZMA_VERSION_STABILITY); +pub const LZMA_VERSION: c_uint = LZMA_VERSION_MAJOR * 10000000 + + LZMA_VERSION_MINOR * 10000 + + LZMA_VERSION_PATCH * 10 + + LZMA_VERSION_STABILITY; pub const LZMA_TIMED_OUT: c_uint = 101; pub fn lzma_version_number() -> u32 { LZMA_VERSION as u32 @@ -131,8 +130,8 @@ pub unsafe fn lzma_bufcpy( return 0; } - let in_avail: size_t = in_size.wrapping_sub(*in_pos); - let out_avail: size_t = out_size.wrapping_sub(*out_pos); + let in_avail: size_t = in_size - *in_pos; + let out_avail: size_t = out_size - *out_pos; let copy_size: size_t = if in_avail < out_avail { in_avail } else { @@ -145,8 +144,8 @@ pub unsafe fn lzma_bufcpy( copy_size, ); } - *in_pos = (*in_pos).wrapping_add(copy_size); - *out_pos = (*out_pos).wrapping_add(copy_size); + *in_pos += copy_size; + *out_pos += copy_size; copy_size } pub unsafe fn lzma_next_filter_init( @@ -320,12 +319,12 @@ pub unsafe fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret ); if in_pos > 0 { (*strm).next_in = (*strm).next_in.offset(in_pos as isize); - (*strm).avail_in = (*strm).avail_in.wrapping_sub(in_pos); + (*strm).avail_in -= in_pos; (*strm).total_in = (*strm).total_in.wrapping_add(in_pos as u64); } if out_pos > 0 { (*strm).next_out = (*strm).next_out.offset(out_pos as isize); - (*strm).avail_out = (*strm).avail_out.wrapping_sub(out_pos); + (*strm).avail_out -= out_pos; (*strm).total_out = (*strm).total_out.wrapping_add(out_pos as u64); } (*(*strm).internal).avail_in = (*strm).avail_in; diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 1fb8d6ec..41d7cf9b 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -172,8 +172,7 @@ pub unsafe fn lzma_filters_copy( core::ptr::copy_nonoverlapping( ::core::ptr::addr_of_mut!(dest) as *const u8, real_dest as *mut u8, - i.wrapping_add(1) - .wrapping_mul(core::mem::size_of::()), + (i + 1) * core::mem::size_of::(), ); return LZMA_OK; } @@ -222,8 +221,7 @@ pub unsafe fn lzma_validate_chain( } non_last_ok = FEATURES[j as usize].non_last_ok; last_ok = FEATURES[j as usize].last_ok; - changes_size_count = - changes_size_count.wrapping_add(FEATURES[j as usize].changes_size as size_t); + changes_size_count += FEATURES[j as usize].changes_size as size_t; i += 1; if (*filters.offset(i as isize)).id == LZMA_VLI_UNKNOWN { break; @@ -255,7 +253,7 @@ pub unsafe fn lzma_raw_coder_init( if is_encoder { let mut i: size_t = 0; while i < count { - let j: size_t = count.wrapping_sub(i).wrapping_sub(1); + let j: size_t = count - i - 1; let fc: *const lzma_filter_coder = coder_find.unwrap()((*options.offset(i as isize)).id) as *const lzma_filter_coder; if fc.is_null() || (*fc).init.is_none() { @@ -309,18 +307,18 @@ pub unsafe fn lzma_raw_coder_memusage( return UINT64_MAX; } if (*fc).memusage.is_none() { - total = total.wrapping_add(1024); + total += 1024; } else { let usage: u64 = (*fc).memusage.unwrap()((*filters.offset(i as isize)).options) as u64; if usage == UINT64_MAX { return UINT64_MAX; } - total = total.wrapping_add(usage); + total += usage; } i += 1; if (*filters.offset(i as isize)).id == LZMA_VLI_UNKNOWN { break; } } - total.wrapping_add(LZMA_MEMUSAGE_BASE) + total + LZMA_MEMUSAGE_BASE } diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index 5aacfdbf..e27cc17b 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -285,11 +285,11 @@ static decoders: [lzma_filter_decoder; 12] = [ extern "C" fn decoder_find(id: lzma_vli) -> *const lzma_filter_decoder { let mut i: size_t = 0; while i - < (core::mem::size_of::<[lzma_filter_decoder; 12]>()) - .wrapping_div(core::mem::size_of::()) + < core::mem::size_of::<[lzma_filter_decoder; 12]>() + / core::mem::size_of::() { if decoders[i as usize].id == id { - return decoders.as_ptr().wrapping_add(i as usize); + return &decoders[i as usize]; } i += 1; } diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index 13604a61..78fd092f 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -262,11 +262,11 @@ static encoders: [lzma_filter_encoder; 12] = [ extern "C" fn encoder_find(id: lzma_vli) -> *const lzma_filter_encoder { let mut i: size_t = 0; while i - < (core::mem::size_of::<[lzma_filter_encoder; 12]>()) - .wrapping_div(core::mem::size_of::()) + < core::mem::size_of::<[lzma_filter_encoder; 12]>() + / core::mem::size_of::() { if encoders[i as usize].id == id { - return encoders.as_ptr().wrapping_add(i as usize); + return &encoders[i as usize]; } i += 1; } @@ -298,7 +298,7 @@ pub unsafe fn lzma_filters_update( }; 5]; let mut i: size_t = 0; while i < count { - reversed_filters[count.wrapping_sub(i).wrapping_sub(1) as usize] = + reversed_filters[count - i - 1] = *filters.offset(i as isize); i += 1; } diff --git a/liblzma-rs/src/common/filter_flags_decoder.rs b/liblzma-rs/src/common/filter_flags_decoder.rs index e44b25f2..926b5345 100644 --- a/liblzma-rs/src/common/filter_flags_decoder.rs +++ b/liblzma-rs/src/common/filter_flags_decoder.rs @@ -32,7 +32,7 @@ pub unsafe fn lzma_filter_flags_decode( if ret__0 != LZMA_OK { return ret__0; } - if (in_size.wrapping_sub(*in_pos) as lzma_vli) < props_size { + if ((in_size - *in_pos) as lzma_vli) < props_size { return LZMA_DATA_ERROR; } let ret: lzma_ret = lzma_properties_decode( @@ -41,6 +41,6 @@ pub unsafe fn lzma_filter_flags_decode( in_0.offset(*in_pos as isize), props_size as size_t, ); - *in_pos = (*in_pos as lzma_vli).wrapping_add(props_size) as size_t; + *in_pos = (*in_pos as lzma_vli + props_size) as size_t; ret } diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index d13c21d0..6a5d02ac 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -11,8 +11,7 @@ pub unsafe fn lzma_filter_flags_size( if ret_ != LZMA_OK { return ret_; } - *size = (*size) - .wrapping_add(lzma_vli_size((*filter).id).wrapping_add(lzma_vli_size(*size as lzma_vli))); + *size += lzma_vli_size((*filter).id) + lzma_vli_size(*size as lzma_vli); LZMA_OK } pub unsafe fn lzma_filter_flags_encode( @@ -44,13 +43,13 @@ pub unsafe fn lzma_filter_flags_encode( if ret__1 != LZMA_OK { return ret__1; } - if out_size.wrapping_sub(*out_pos) < props_size as size_t { + if out_size - *out_pos < props_size as size_t { return LZMA_PROG_ERROR; } let ret__2: lzma_ret = lzma_properties_encode(filter, out.offset(*out_pos as isize)); if ret__2 != LZMA_OK { return ret__2; } - *out_pos = (*out_pos).wrapping_add(props_size as size_t); + *out_pos += props_size as size_t; LZMA_OK } diff --git a/liblzma-rs/src/common/index_decoder.rs b/liblzma-rs/src/common/index_decoder.rs index 67bfa8e7..99950371 100644 --- a/liblzma-rs/src/common/index_decoder.rs +++ b/liblzma-rs/src/common/index_decoder.rs @@ -101,7 +101,7 @@ unsafe extern "C" fn index_decode( if ret_ != LZMA_OK { return ret_; } - (*coder).count = (*coder).count.wrapping_sub(1); + (*coder).count -= 1; (*coder).sequence = (if (*coder).count == 0 { SEQ_PADDING_INIT } else { @@ -126,7 +126,7 @@ unsafe extern "C" fn index_decode( match current_block { 8340016495055110192 => { if (*coder).pos > 0 { - (*coder).pos = (*coder).pos.wrapping_sub(1); + (*coder).pos -= 1; let byte = *in_0.offset(*in_pos as isize); *in_pos += 1; if byte != 0 { @@ -136,7 +136,7 @@ unsafe extern "C" fn index_decode( } else { (*coder).crc32 = lzma_crc32( in_0.offset(in_start as isize), - (*in_pos).wrapping_sub(in_start), + *in_pos - in_start, (*coder).crc32, ); (*coder).sequence = SEQ_CRC32; @@ -165,10 +165,10 @@ unsafe extern "C" fn index_decode( } let val = *in_0.offset(*in_pos as isize); *in_pos += 1; - if (*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff != val as u32 { + if (*coder).crc32 >> ((*coder).pos * 8) & 0xff != val as u32 { return LZMA_DATA_ERROR; } - (*coder).pos = (*coder).pos.wrapping_add(1); + (*coder).pos += 1; if (*coder).pos >= 4 { break; } @@ -177,7 +177,7 @@ unsafe extern "C" fn index_decode( (*coder).index = core::ptr::null_mut(); return LZMA_STREAM_END; } - let in_used: size_t = (*in_pos).wrapping_sub(in_start); + let in_used: size_t = *in_pos - in_start; if in_used > 0 { (*coder).crc32 = lzma_crc32(in_0.offset(in_start as isize), in_used, (*coder).crc32); } diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index 56194af6..494bf5fd 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -36,7 +36,7 @@ unsafe extern "C" fn index_encode( match (*coder).sequence { 0 => { *out.offset(*out_pos as isize) = INDEX_INDICATOR; - *out_pos = (*out_pos).wrapping_add(1); + *out_pos += 1; (*coder).sequence = SEQ_COUNT; continue; } @@ -76,14 +76,14 @@ unsafe extern "C" fn index_encode( } 5 => { if (*coder).pos > 0 { - (*coder).pos = (*coder).pos.wrapping_sub(1); + (*coder).pos -= 1; *out.offset(*out_pos as isize) = 0; *out_pos += 1; continue; } else { (*coder).crc32 = lzma_crc32( out.offset(out_start as isize), - (*out_pos).wrapping_sub(out_start), + *out_pos - out_start, (*coder).crc32, ); (*coder).sequence = SEQ_CRC32; @@ -122,9 +122,9 @@ unsafe extern "C" fn index_encode( return LZMA_OK; } *out.offset(*out_pos as isize) = - ((*coder).crc32 >> (*coder).pos.wrapping_mul(8) & 0xff) as u8; - *out_pos = (*out_pos).wrapping_add(1); - (*coder).pos = (*coder).pos.wrapping_add(1); + ((*coder).crc32 >> ((*coder).pos * 8) & 0xff) as u8; + *out_pos += 1; + (*coder).pos += 1; if (*coder).pos >= 4 { break; } @@ -133,7 +133,7 @@ unsafe extern "C" fn index_encode( } } } - let out_used: size_t = (*out_pos).wrapping_sub(out_start); + let out_used: size_t = *out_pos - out_start; if out_used > 0 { (*coder).crc32 = lzma_crc32(out.offset(out_start as isize), out_used, (*coder).crc32); } @@ -251,7 +251,7 @@ pub unsafe fn lzma_index_buffer_encode( if i.is_null() || out.is_null() || out_pos.is_null() || *out_pos > out_size { return LZMA_PROG_ERROR; } - if (out_size.wrapping_sub(*out_pos) as lzma_vli) < lzma_index_size(i) { + if ((out_size - *out_pos) as lzma_vli) < lzma_index_size(i) { return LZMA_BUF_ERROR; } let mut coder: lzma_index_coder = lzma_index_coder { diff --git a/liblzma-rs/src/common/index_hash.rs b/liblzma-rs/src/common/index_hash.rs index 7225cb6e..c75d4389 100644 --- a/liblzma-rs/src/common/index_hash.rs +++ b/liblzma-rs/src/common/index_hash.rs @@ -226,7 +226,7 @@ pub unsafe fn lzma_index_hash_decode( { return LZMA_DATA_ERROR; } - (*index_hash).remaining = (*index_hash).remaining.wrapping_sub(1); + (*index_hash).remaining -= 1; (*index_hash).sequence = (if (*index_hash).remaining == 0 { SEQ_PADDING_INIT } else { @@ -254,7 +254,7 @@ pub unsafe fn lzma_index_hash_decode( match current_block { 12753679906265593574 => { if (*index_hash).pos > 0 { - (*index_hash).pos = (*index_hash).pos.wrapping_sub(1); + (*index_hash).pos -= 1; let byte = *in_0.offset(*in_pos as isize); *in_pos += 1; if byte != 0 { @@ -290,7 +290,7 @@ pub unsafe fn lzma_index_hash_decode( } (*index_hash).crc32 = lzma_crc32( in_0.offset(in_start as isize), - (*in_pos).wrapping_sub(in_start), + *in_pos - in_start, (*index_hash).crc32, ); (*index_hash).sequence = SEQ_CRC32; @@ -304,17 +304,17 @@ pub unsafe fn lzma_index_hash_decode( } let val = *in_0.offset(*in_pos as isize); *in_pos += 1; - if (*index_hash).crc32 >> (*index_hash).pos.wrapping_mul(8) & 0xff != val as u32 { + if (*index_hash).crc32 >> ((*index_hash).pos * 8) & 0xff != val as u32 { return LZMA_DATA_ERROR; } - (*index_hash).pos = (*index_hash).pos.wrapping_add(1); + (*index_hash).pos += 1; if (*index_hash).pos >= 4 { break; } } return LZMA_STREAM_END; } - let in_used: size_t = (*in_pos).wrapping_sub(in_start); + let in_used: size_t = *in_pos - in_start; if in_used > 0 { (*index_hash).crc32 = lzma_crc32(in_0.offset(in_start as isize), in_used, (*index_hash).crc32); diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 075ec327..3d2ed156 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -76,8 +76,8 @@ unsafe extern "C" fn lzip_decode( LZMA_FORMAT_ERROR }; } - *in_pos = (*in_pos).wrapping_add(1); - (*coder).pos = (*coder).pos.wrapping_add(1); + *in_pos += 1; + (*coder).pos += 1; } (*coder).pos = 0; (*coder).crc32 = 0; @@ -113,7 +113,7 @@ unsafe extern "C" fn lzip_decode( if (*coder).version > 1 { return LZMA_OPTIONS_ERROR; } - (*coder).member_size = (*coder).member_size.wrapping_add(1); + (*coder).member_size += 1; (*coder).sequence = SEQ_DICT_SIZE; if (*coder).tell_any_check { return LZMA_GET_CHECK; @@ -129,14 +129,14 @@ unsafe extern "C" fn lzip_decode( } let ds: u32 = *in_0.offset(*in_pos as isize) as u32; *in_pos += 1; - (*coder).member_size = (*coder).member_size.wrapping_add(1); + (*coder).member_size += 1; let b2log: u32 = ds & 0x1f; let fracnum: u32 = ds >> 5; if b2log < 12 || b2log > 29 || b2log == 12 && fracnum > 0 { return LZMA_DATA_ERROR; } (*coder).options.dict_size = - (1u32 << b2log).wrapping_sub(fracnum << b2log.wrapping_sub(4)); + (1u32 << b2log) - (fracnum << (b2log - 4)); (*coder).options.preset_dict = core::ptr::null(); (*coder).options.lc = LZIP_LC; (*coder).options.lp = LZIP_LP; @@ -205,12 +205,9 @@ unsafe extern "C" fn lzip_decode( out_size, action, ); - let out_used: size_t = (*out_pos).wrapping_sub(out_start); - (*coder).member_size = (*coder) - .member_size - .wrapping_add((*in_pos).wrapping_sub(in_start) as u64); - (*coder).uncompressed_size = - (*coder).uncompressed_size.wrapping_add(out_used as u64); + let out_used: size_t = *out_pos - out_start; + (*coder).member_size += (*in_pos - in_start) as u64; + (*coder).uncompressed_size += out_used as u64; if !(*coder).ignore_check && out_used > 0 { (*coder).crc32 = lzma_crc32(out.offset(out_start as isize), out_used, (*coder).crc32); @@ -239,7 +236,7 @@ unsafe extern "C" fn lzip_decode( return LZMA_OK; } (*coder).pos = 0; - (*coder).member_size = (*coder).member_size.wrapping_add(footer_size as u64); + (*coder).member_size += footer_size as u64; if !(*coder).ignore_check && (*coder).crc32 != read32le((::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8) as *mut u8) diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index 7c46979a..e879c688 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -23,13 +23,13 @@ unsafe extern "C" fn microlzma_decode( let coder: *mut lzma_microlzma_coder = coder_ptr as *mut lzma_microlzma_coder; let in_start: size_t = *in_pos; let out_start: size_t = *out_pos; - if in_size.wrapping_sub(*in_pos) as u64 > (*coder).comp_size { - in_size = (*in_pos).wrapping_add((*coder).comp_size as size_t); + if (in_size - *in_pos) as u64 > (*coder).comp_size { + in_size = *in_pos + (*coder).comp_size as size_t; } if !(*coder).uncomp_size_is_exact - && out_size.wrapping_sub(*out_pos) as lzma_vli > (*coder).uncomp_size + && (out_size - *out_pos) as lzma_vli > (*coder).uncomp_size { - out_size = (*out_pos).wrapping_add((*coder).uncomp_size as size_t); + out_size = *out_pos + (*coder).uncomp_size as size_t; } if !(*coder).props_decoded { if *in_pos >= in_size { @@ -71,7 +71,7 @@ unsafe extern "C" fn microlzma_decode( ) { return LZMA_OPTIONS_ERROR; } - *in_pos = (*in_pos).wrapping_add(1); + *in_pos += 1; let mut filters: [lzma_filter_info; 2] = [ lzma_filter_info_s { id: LZMA_FILTER_LZMA1EXT, @@ -128,17 +128,13 @@ unsafe extern "C" fn microlzma_decode( out_size, action, ); - (*coder).comp_size = (*coder) - .comp_size - .wrapping_sub((*in_pos).wrapping_sub(in_start) as u64); + (*coder).comp_size -= (*in_pos - in_start) as u64; if (*coder).uncomp_size_is_exact { if ret == LZMA_STREAM_END && (*coder).comp_size != 0 { ret = LZMA_DATA_ERROR; } } else { - (*coder).uncomp_size = (*coder) - .uncomp_size - .wrapping_sub((*out_pos).wrapping_sub(out_start) as lzma_vli); + (*coder).uncomp_size -= (*out_pos - out_start) as lzma_vli; if ret == LZMA_STREAM_END { ret = LZMA_DATA_ERROR; } else if (*coder).uncomp_size == 0 { diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index 60f7c4a5..0e2e670f 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -29,7 +29,7 @@ unsafe extern "C" fn microlzma_encode( if set_out_limit( (*coder).lzma.coder, ::core::ptr::addr_of_mut!(uncomp_size), - out_size.wrapping_sub(*out_pos) as u64, + (out_size - *out_pos) as u64, ) != LZMA_OK { return LZMA_PROG_ERROR; @@ -52,7 +52,7 @@ unsafe extern "C" fn microlzma_encode( return ret; } *out.offset(out_start as isize) = !(*coder).props; - *in_pos = in_start.wrapping_add(uncomp_size as size_t); + *in_pos = in_start + uncomp_size as size_t; ret } unsafe extern "C" fn microlzma_encoder_end( diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index 9aa1fd9c..c73286d3 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -1,13 +1,10 @@ use crate::types::*; pub fn lzma_outq_memusage(buf_size_max: u64, threads: u32) -> u64 { - let limit: u64 = (UINT64_MAX) - .wrapping_div((2 * 16384) as u64) - .wrapping_div(2); + let limit: u64 = UINT64_MAX / (2 * 16384) as u64 / 2; if threads > LZMA_THREADS_MAX || buf_size_max > limit { return UINT64_MAX; } - ((2u32).wrapping_mul(threads) as u64) - .wrapping_mul(lzma_outq_outbuf_memusage(buf_size_max as size_t)) + (2u32 * threads) as u64 * lzma_outq_outbuf_memusage(buf_size_max as size_t) } unsafe fn move_head_to_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator) { let buf: *mut lzma_outbuf = (*outq).head; @@ -20,10 +17,8 @@ unsafe fn move_head_to_cache(outq: *mut lzma_outq, allocator: *const lzma_alloca } (*buf).next = (*outq).cache; (*outq).cache = buf; - (*outq).bufs_in_use = (*outq).bufs_in_use.wrapping_sub(1); - (*outq).mem_in_use = (*outq) - .mem_in_use - .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); + (*outq).bufs_in_use -= 1; + (*outq).mem_in_use -= lzma_outq_outbuf_memusage((*buf).allocated); } unsafe fn free_one_cached_buffer( outq: *mut lzma_outq, @@ -31,10 +26,8 @@ unsafe fn free_one_cached_buffer( ) { let buf: *mut lzma_outbuf = (*outq).cache; (*outq).cache = (*buf).next; - (*outq).bufs_allocated = (*outq).bufs_allocated.wrapping_sub(1); - (*outq).mem_allocated = (*outq) - .mem_allocated - .wrapping_sub(lzma_outq_outbuf_memusage((*buf).allocated)); + (*outq).bufs_allocated -= 1; + (*outq).mem_allocated -= lzma_outq_outbuf_memusage((*buf).allocated); crate::alloc::internal_free(buf as *mut c_void, allocator); } pub unsafe fn lzma_outq_clear_cache( @@ -68,7 +61,7 @@ pub unsafe fn lzma_outq_init( if threads > LZMA_THREADS_MAX { return LZMA_OPTIONS_ERROR; } - let bufs_limit: u32 = (2u32).wrapping_mul(threads); + let bufs_limit: u32 = 2u32 * threads; while !(*outq).head.is_null() { move_head_to_cache(outq, allocator); } @@ -93,7 +86,7 @@ pub unsafe fn lzma_outq_prealloc_buf( if !(*outq).cache.is_null() && (*(*outq).cache).allocated == size { return LZMA_OK; } - if size > (SIZE_MAX as usize).wrapping_sub(core::mem::size_of::()) { + if size > (SIZE_MAX as usize) - core::mem::size_of::() { return LZMA_MEM_ERROR; } let alloc_size: size_t = lzma_outq_outbuf_memusage(size) as size_t; @@ -104,8 +97,8 @@ pub unsafe fn lzma_outq_prealloc_buf( } (*(*outq).cache).next = core::ptr::null_mut(); (*(*outq).cache).allocated = size; - (*outq).bufs_allocated = (*outq).bufs_allocated.wrapping_add(1); - (*outq).mem_allocated = (*outq).mem_allocated.wrapping_add(alloc_size as u64); + (*outq).bufs_allocated += 1; + (*outq).mem_allocated += alloc_size as u64; LZMA_OK } pub unsafe fn lzma_outq_get_buf( @@ -128,10 +121,8 @@ pub unsafe fn lzma_outq_get_buf( (*buf).decoder_in_pos = 0; (*buf).unpadded_size = 0; (*buf).uncompressed_size = 0; - (*outq).bufs_in_use = (*outq).bufs_in_use.wrapping_add(1); - (*outq).mem_in_use = (*outq) - .mem_in_use - .wrapping_add(lzma_outq_outbuf_memusage((*buf).allocated)); + (*outq).bufs_in_use += 1; + (*outq).mem_in_use += lzma_outq_outbuf_memusage((*buf).allocated); buf } pub unsafe fn lzma_outq_is_readable(outq: *const lzma_outq) -> bool { diff --git a/liblzma-rs/src/common/stream_buffer_encoder.rs b/liblzma-rs/src/common/stream_buffer_encoder.rs index 186fbf26..b89031b8 100644 --- a/liblzma-rs/src/common/stream_buffer_encoder.rs +++ b/liblzma-rs/src/common/stream_buffer_encoder.rs @@ -9,10 +9,10 @@ pub fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t { return 0; } let stream_bound_max: size_t = core::cmp::min(size_t::MAX, LZMA_VLI_MAX as size_t); - if stream_bound_max.wrapping_sub(block_bound) < HEADERS_BOUND as size_t { + if stream_bound_max - block_bound < HEADERS_BOUND as size_t { return 0; } - block_bound.wrapping_add(HEADERS_BOUND as size_t) + block_bound + HEADERS_BOUND as size_t } pub unsafe fn lzma_stream_buffer_encode( filters: *mut lzma_filter, @@ -37,10 +37,10 @@ pub unsafe fn lzma_stream_buffer_encode( return LZMA_UNSUPPORTED_CHECK; } let mut out_pos: size_t = *out_pos_ptr; - if out_size.wrapping_sub(out_pos) <= (2 * LZMA_STREAM_HEADER_SIZE) as size_t { + if out_size - out_pos <= (2 * LZMA_STREAM_HEADER_SIZE) as size_t { return LZMA_BUF_ERROR; } - out_size = out_size.wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); + out_size -= LZMA_STREAM_HEADER_SIZE as size_t; let mut stream_flags: lzma_stream_flags = lzma_stream_flags { version: 0, backward_size: 0, @@ -67,7 +67,7 @@ pub unsafe fn lzma_stream_buffer_encode( { return LZMA_PROG_ERROR; } - out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); + out_pos += LZMA_STREAM_HEADER_SIZE as size_t; let mut block: lzma_block = lzma_block { version: 0, header_size: 0, @@ -142,7 +142,7 @@ pub unsafe fn lzma_stream_buffer_encode( { return LZMA_PROG_ERROR; } - out_pos = out_pos.wrapping_add(LZMA_STREAM_HEADER_SIZE as size_t); + out_pos += LZMA_STREAM_HEADER_SIZE as size_t; *out_pos_ptr = out_pos; LZMA_OK } diff --git a/liblzma-rs/src/common/stream_flags_decoder.rs b/liblzma-rs/src/common/stream_flags_decoder.rs index 1ef5c4c2..a43b6933 100644 --- a/liblzma-rs/src/common/stream_flags_decoder.rs +++ b/liblzma-rs/src/common/stream_flags_decoder.rs @@ -49,7 +49,7 @@ pub unsafe fn lzma_stream_footer_decode( in_0: *const u8, ) -> lzma_ret { if memcmp( - in_0.offset((core::mem::size_of::()).wrapping_mul(2) as isize) + in_0.offset((core::mem::size_of::() * 2) as isize) .offset(LZMA_STREAM_FLAGS_SIZE as isize) as *const c_void, ::core::ptr::addr_of!(lzma_footer_magic) as *const c_void, core::mem::size_of::<[u8; 2]>(), @@ -59,7 +59,7 @@ pub unsafe fn lzma_stream_footer_decode( } let crc: u32 = lzma_crc32( in_0.offset(core::mem::size_of::() as isize), - (core::mem::size_of::()).wrapping_add(LZMA_STREAM_FLAGS_SIZE as size_t), + core::mem::size_of::() + LZMA_STREAM_FLAGS_SIZE as size_t, 0, ) as u32; if crc != read32le(in_0) { @@ -67,12 +67,12 @@ pub unsafe fn lzma_stream_footer_decode( } if stream_flags_decode( options, - in_0.offset((core::mem::size_of::()).wrapping_mul(2) as isize), + in_0.offset((core::mem::size_of::() * 2) as isize), ) { return LZMA_OPTIONS_ERROR; } (*options).backward_size = read32le(in_0.offset(core::mem::size_of::() as isize)) as lzma_vli; - (*options).backward_size = (*options).backward_size.wrapping_add(1).wrapping_mul(4); + (*options).backward_size = ((*options).backward_size + 1) * 4; LZMA_OK } diff --git a/liblzma-rs/src/common/vli_decoder.rs b/liblzma-rs/src/common/vli_decoder.rs index 96b1a9f9..96fa2606 100644 --- a/liblzma-rs/src/common/vli_decoder.rs +++ b/liblzma-rs/src/common/vli_decoder.rs @@ -17,7 +17,7 @@ pub unsafe fn lzma_vli_decode( if *vli_pos == 0 { *vli = 0; } - if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || *vli >> (*vli_pos).wrapping_mul(7) != 0 { + if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || *vli >> (*vli_pos * 7) != 0 { return LZMA_PROG_ERROR; } if *in_pos >= in_size { @@ -26,9 +26,9 @@ pub unsafe fn lzma_vli_decode( } loop { let byte: u8 = *in_0.offset(*in_pos as isize); - *in_pos = (*in_pos).wrapping_add(1); - *vli = (*vli).wrapping_add(((byte & 0x7f) as lzma_vli) << (*vli_pos).wrapping_mul(7)); - *vli_pos = (*vli_pos).wrapping_add(1); + *in_pos += 1; + *vli += ((byte & 0x7f) as lzma_vli) << (*vli_pos * 7); + *vli_pos += 1; if byte & 0x80 == 0 { if byte == 0 && *vli_pos > 1 { return LZMA_DATA_ERROR; diff --git a/liblzma-rs/src/common/vli_encoder.rs b/liblzma-rs/src/common/vli_encoder.rs index 7dc86ab3..f343feec 100644 --- a/liblzma-rs/src/common/vli_encoder.rs +++ b/liblzma-rs/src/common/vli_encoder.rs @@ -18,12 +18,12 @@ pub unsafe fn lzma_vli_encode( if *vli_pos >= LZMA_VLI_BYTES_MAX as size_t || vli > LZMA_VLI_MAX { return LZMA_PROG_ERROR; } - vli >>= (*vli_pos).wrapping_mul(7); + vli >>= *vli_pos * 7; while vli >= 0x80 { - *vli_pos = (*vli_pos).wrapping_add(1); + *vli_pos += 1; *out.offset(*out_pos as isize) = vli as u8 | 0x80; vli >>= 7; - *out_pos = (*out_pos).wrapping_add(1); + *out_pos += 1; if *out_pos == out_size { return if vli_pos == ::core::ptr::addr_of_mut!(vli_pos_internal) { LZMA_PROG_ERROR @@ -33,8 +33,8 @@ pub unsafe fn lzma_vli_encode( } } *out.offset(*out_pos as isize) = vli as u8; - *out_pos = (*out_pos).wrapping_add(1); - *vli_pos = (*vli_pos).wrapping_add(1); + *out_pos += 1; + *vli_pos += 1; if vli_pos == ::core::ptr::addr_of_mut!(vli_pos_internal) { LZMA_OK } else { diff --git a/liblzma-rs/src/delta/delta_decoder.rs b/liblzma-rs/src/delta/delta_decoder.rs index 3c3d1733..eb6f25bf 100644 --- a/liblzma-rs/src/delta/delta_decoder.rs +++ b/liblzma-rs/src/delta/delta_decoder.rs @@ -35,7 +35,8 @@ unsafe extern "C" fn delta_decode( out_size, action, ); - let size: size_t = (*out_pos).wrapping_sub(out_start); + debug_assert!(*out_pos >= out_start); + let size: size_t = *out_pos - out_start; if size > 0 { decode_buffer(coder, out.offset(out_start as isize), size); } @@ -78,7 +79,7 @@ pub unsafe extern "C" fn lzma_delta_props_decode( return LZMA_MEM_ERROR; } (*opt).type_0 = LZMA_DELTA_TYPE_BYTE; - (*opt).dist = u32::from(*props).wrapping_add(1); + (*opt).dist = u32::from(*props) + 1; *options = opt as *mut c_void; LZMA_OK } diff --git a/liblzma-rs/src/delta/delta_encoder.rs b/liblzma-rs/src/delta/delta_encoder.rs index e402d25c..a50640d1 100644 --- a/liblzma-rs/src/delta/delta_encoder.rs +++ b/liblzma-rs/src/delta/delta_encoder.rs @@ -42,8 +42,10 @@ unsafe extern "C" fn delta_encode( let coder: *mut lzma_delta_coder = coder_ptr as *mut lzma_delta_coder; let mut ret: lzma_ret = LZMA_OK; if (*coder).next.code.is_none() { - let in_avail: size_t = in_size.wrapping_sub(*in_pos); - let out_avail: size_t = out_size.wrapping_sub(*out_pos); + debug_assert!(in_size >= *in_pos); + debug_assert!(out_size >= *out_pos); + let in_avail: size_t = in_size - *in_pos; + let out_avail: size_t = out_size - *out_pos; let size: size_t = if in_avail < out_avail { in_avail } else { @@ -57,8 +59,8 @@ unsafe extern "C" fn delta_encode( size, ); } - *in_pos = (*in_pos).wrapping_add(size); - *out_pos = (*out_pos).wrapping_add(size); + *in_pos += size; + *out_pos += size; ret = if action != LZMA_RUN && *in_pos == in_size { LZMA_STREAM_END } else { @@ -77,7 +79,8 @@ unsafe extern "C" fn delta_encode( out_size, action, ); - let size_0: size_t = (*out_pos).wrapping_sub(out_start); + debug_assert!(*out_pos >= out_start); + let size_0: size_t = *out_pos - out_start; if size_0 > 0 { encode_in_place(coder, out.offset(out_start as isize), size_0); } @@ -132,6 +135,7 @@ pub unsafe extern "C" fn lzma_delta_props_encode(options: *const c_void, out: *m return LZMA_PROG_ERROR; } let opt: *const lzma_options_delta = options as *const lzma_options_delta; - *out = (*opt).dist.wrapping_sub(LZMA_DELTA_DIST_MIN) as u8; + debug_assert!((*opt).dist >= LZMA_DELTA_DIST_MIN); + *out = ((*opt).dist - LZMA_DELTA_DIST_MIN) as u8; LZMA_OK } diff --git a/liblzma-rs/src/simple/arm.rs b/liblzma-rs/src/simple/arm.rs index 894df6ef..bb184fdc 100644 --- a/liblzma-rs/src/simple/arm.rs +++ b/liblzma-rs/src/simple/arm.rs @@ -10,9 +10,9 @@ unsafe extern "C" fn arm_code( let mut i: size_t = 0; i = 0; while i < size { - if *buffer.offset(i.wrapping_add(3) as isize) == 0xeb { - let mut src: u32 = (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16 - | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8 + if *buffer.offset((i + 3) as isize) == 0xeb { + let mut src: u32 = (*buffer.offset((i + 2) as isize) as u32) << 16 + | (*buffer.offset((i + 1) as isize) as u32) << 8 | *buffer.offset(i as isize) as u32; src <<= 2; let mut dest: u32 = 0; @@ -25,11 +25,11 @@ unsafe extern "C" fn arm_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(8)); } dest >>= 2; - *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 16) as u8; - *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 8) as u8; + *buffer.offset((i + 2) as isize) = (dest >> 16) as u8; + *buffer.offset((i + 1) as isize) = (dest >> 8) as u8; *buffer.offset(i as isize) = dest as u8; } - i = i.wrapping_add(4); + i += 4; } i } diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index f24baa9a..c24d1339 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -10,7 +10,7 @@ unsafe extern "C" fn arm64_code( let mut i: size_t = 0; i = 0; while i < size { - let mut pc: u32 = (now_pos as size_t).wrapping_add(i) as u32; + let mut pc: u32 = (now_pos as size_t + i) as u32; let mut instr: u32 = read32le(buffer.offset(i as isize)); if instr >> 26 == 0x25 { let src: u32 = instr; @@ -36,7 +36,7 @@ unsafe extern "C" fn arm64_code( write32le(buffer.offset(i as isize), instr); } } - i = i.wrapping_add(4); + i += 4; } i } diff --git a/liblzma-rs/src/simple/armthumb.rs b/liblzma-rs/src/simple/armthumb.rs index f82219ef..f17a4b0b 100644 --- a/liblzma-rs/src/simple/armthumb.rs +++ b/liblzma-rs/src/simple/armthumb.rs @@ -9,17 +9,17 @@ unsafe extern "C" fn armthumb_code( if size < 4 { return 0; } - size = size.wrapping_sub(4); + size -= 4; let mut i: size_t = 0; i = 0; while i <= size { - if *buffer.offset(i.wrapping_add(1) as isize) & 0xf8 == 0xf0 - && *buffer.offset(i.wrapping_add(3) as isize) & 0xf8 == 0xf8 + if *buffer.offset((i + 1) as isize) & 0xf8 == 0xf0 + && *buffer.offset((i + 3) as isize) & 0xf8 == 0xf8 { - let mut src: u32 = (*buffer.offset(i.wrapping_add(1) as isize) as u32 & 7) << 19 + let mut src: u32 = (*buffer.offset((i + 1) as isize) as u32 & 7) << 19 | (*buffer.offset(i as isize) as u32) << 11 - | (*buffer.offset(i.wrapping_add(3) as isize) as u32 & 7) << 8 - | *buffer.offset(i.wrapping_add(2) as isize) as u32; + | (*buffer.offset((i + 3) as isize) as u32 & 7) << 8 + | *buffer.offset((i + 2) as isize) as u32; src <<= 1; let mut dest: u32 = 0; if is_encoder { @@ -31,13 +31,13 @@ unsafe extern "C" fn armthumb_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32).wrapping_add(4)); } dest >>= 1; - *buffer.offset(i.wrapping_add(1) as isize) = (0xf0 | dest >> 19 & 0x7) as u8; + *buffer.offset((i + 1) as isize) = (0xf0 | dest >> 19 & 0x7) as u8; *buffer.offset(i as isize) = (dest >> 11) as u8; - *buffer.offset(i.wrapping_add(3) as isize) = (0xf8 | dest >> 8 & 0x7) as u8; - *buffer.offset(i.wrapping_add(2) as isize) = dest as u8; - i = i.wrapping_add(2); + *buffer.offset((i + 3) as isize) = (0xf8 | dest >> 8 & 0x7) as u8; + *buffer.offset((i + 2) as isize) = dest as u8; + i += 2; } - i = i.wrapping_add(2); + i += 2; } i } diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 94d26bc1..3f41e62c 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -25,10 +25,9 @@ unsafe extern "C" fn ia64_code( let mut instruction: u64 = 0; let mut j: size_t = 0; while j < 6 { - instruction = instruction.wrapping_add( - (*buffer.offset(i.wrapping_add(j).wrapping_add(byte_pos) as isize) as u64) - << (8_usize).wrapping_mul(j), - ); + instruction += + (*buffer.offset((i + j + byte_pos) as isize) as u64) + << (8 * j); j += 1; } let mut inst_norm: u64 = instruction >> bit_res; @@ -46,20 +45,20 @@ unsafe extern "C" fn ia64_code( inst_norm &= !((0x8fffff as u64) << 13); inst_norm |= ((dest & 0xfffff) as u64) << 13; inst_norm |= ((dest & 0x100000) as u64) << 36 - 20; - instruction &= (1u32 << bit_res).wrapping_sub(1) as u64; + instruction &= ((1u32 << bit_res) - 1) as u64; instruction |= inst_norm << bit_res; let mut j_0: size_t = 0; while j_0 < 6 { - *buffer.offset(i.wrapping_add(j_0).wrapping_add(byte_pos) as isize) = - (instruction >> (8_usize).wrapping_mul(j_0)) as u8; + *buffer.offset((i + j_0 + byte_pos) as isize) = + (instruction >> (8 * j_0)) as u8; j_0 += 1; } } } slot += 1; - bit_pos = bit_pos.wrapping_add(41); + bit_pos += 41; } - i = i.wrapping_add(16); + i += 16; } i } diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index 0bdefa93..b4cf4a58 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -11,12 +11,12 @@ unsafe extern "C" fn powerpc_code( i = 0; while i < size { if *buffer.offset(i as isize) >> 2 == 0x12 - && *buffer.offset(i.wrapping_add(3) as isize) & 3 == 1 + && *buffer.offset((i + 3) as isize) & 3 == 1 { let src: u32 = (*buffer.offset(i as isize) as u32 & 3) << 24 - | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 16 - | (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 8 - | *buffer.offset(i.wrapping_add(3) as isize) as u32 & !(3); + | (*buffer.offset((i + 1) as isize) as u32) << 16 + | (*buffer.offset((i + 2) as isize) as u32) << 8 + | *buffer.offset((i + 3) as isize) as u32 & !(3); let mut dest: u32 = 0; if is_encoder { dest = now_pos.wrapping_add(i as u32).wrapping_add(src); @@ -24,13 +24,13 @@ unsafe extern "C" fn powerpc_code( dest = src.wrapping_sub(now_pos.wrapping_add(i as u32)); } *buffer.offset(i as isize) = (0x48 | dest >> 24 & 0x3) as u8; - *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 16) as u8; - *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 8) as u8; - *buffer.offset(i.wrapping_add(3) as isize) &= 0x3; - *buffer.offset(i.wrapping_add(3) as isize) = - (*buffer.offset(i.wrapping_add(3) as isize) as u32 | dest) as u8; + *buffer.offset((i + 1) as isize) = (dest >> 16) as u8; + *buffer.offset((i + 2) as isize) = (dest >> 8) as u8; + *buffer.offset((i + 3) as isize) &= 0x3; + *buffer.offset((i + 3) as isize) = + (*buffer.offset((i + 3) as isize) as u32 | dest) as u8; } - i = i.wrapping_add(4); + i += 4; } i } diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 1fbf8754..514cac08 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -28,17 +28,17 @@ unsafe extern "C" fn riscv_encode( if size < 8 { return 0; } - size = size.wrapping_sub(8); + size -= 8; let mut i: size_t = 0; let mut current_block_22: u64; i = 0; while i <= size { let mut inst: u32 = *buffer.offset(i as isize) as u32; if inst == 0xef { - let b1: u32 = *buffer.offset(i.wrapping_add(1) as isize) as u32; + let b1: u32 = *buffer.offset((i + 1) as isize) as u32; if b1 & 0xd == 0 { - let b2: u32 = *buffer.offset(i.wrapping_add(2) as isize) as u32; - let b3: u32 = *buffer.offset(i.wrapping_add(3) as isize) as u32; + let b2: u32 = *buffer.offset((i + 2) as isize) as u32; + let b3: u32 = *buffer.offset((i + 3) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); let mut addr: u32 = (b1 & 0xf0) << 8 | (b2 & 0xf) << 16 @@ -47,19 +47,19 @@ unsafe extern "C" fn riscv_encode( | (b3 & 0x7f) << 4 | (b3 & 0x80) << 13; addr = addr.wrapping_add(pc); - *buffer.offset(i.wrapping_add(1) as isize) = (b1 & 0xf | addr >> 13 & 0xf0) as u8; - *buffer.offset(i.wrapping_add(2) as isize) = (addr >> 9) as u8; - *buffer.offset(i.wrapping_add(3) as isize) = (addr >> 1) as u8; - i = i.wrapping_add((4 - 2) as size_t); + *buffer.offset((i + 1) as isize) = (b1 & 0xf | addr >> 13 & 0xf0) as u8; + *buffer.offset((i + 2) as isize) = (addr >> 9) as u8; + *buffer.offset((i + 3) as isize) = (addr >> 1) as u8; + i += 4 - 2; } } else if inst & 0x7f == 0x17 { - inst |= (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8; - inst |= (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16; - inst |= (*buffer.offset(i.wrapping_add(3) as isize) as u32) << 24; + inst |= (*buffer.offset((i + 1) as isize) as u32) << 8; + inst |= (*buffer.offset((i + 2) as isize) as u32) << 16; + inst |= (*buffer.offset((i + 3) as isize) as u32) << 24; if inst & 0xe80 != 0 { let inst2: u32 = read32le(buffer.offset(i as isize).offset(4)); if (inst << 8 ^ inst2.wrapping_sub(3)) & 0xf8003 != 0 { - i = i.wrapping_add((6 - 2) as size_t); + i += 6 - 2; current_block_22 = 12517898123489920830; } else { let mut addr_0: u32 = inst & 0xfffff000; @@ -73,7 +73,7 @@ unsafe extern "C" fn riscv_encode( } else { let fake_rs1: u32 = inst >> 27; if inst.wrapping_sub(0x3117) << 18 >= fake_rs1 & 0x1d { - i = i.wrapping_add((4 - 2) as size_t); + i += 4 - 2; current_block_22 = 12517898123489920830; } else { let fake_addr: u32 = read32le(buffer.offset(i as isize).offset(4)) as u32; @@ -87,11 +87,11 @@ unsafe extern "C" fn riscv_encode( match current_block_22 { 12517898123489920830 => {} _ => { - i = i.wrapping_add((8 - 2) as size_t); + i += 8 - 2; } } } - i = i.wrapping_add(2); + i += 2; } i } @@ -131,36 +131,36 @@ unsafe extern "C" fn riscv_decode( if size < 8 { return 0; } - size = size.wrapping_sub(8); + size -= 8; let mut i: size_t = 0; let mut current_block_23: u64; i = 0; while i <= size { let mut inst: u32 = *buffer.offset(i as isize) as u32; if inst == 0xef { - let b1: u32 = *buffer.offset(i.wrapping_add(1) as isize) as u32; + let b1: u32 = *buffer.offset((i + 1) as isize) as u32; if b1 & 0xd == 0 { - let b2: u32 = *buffer.offset(i.wrapping_add(2) as isize) as u32; - let b3: u32 = *buffer.offset(i.wrapping_add(3) as isize) as u32; + let b2: u32 = *buffer.offset((i + 2) as isize) as u32; + let b3: u32 = *buffer.offset((i + 3) as isize) as u32; let pc: u32 = now_pos.wrapping_add(i as u32); let mut addr: u32 = (b1 & 0xf0) << 13 | b2 << 9 | b3 << 1; addr = addr.wrapping_sub(pc); - *buffer.offset(i.wrapping_add(1) as isize) = (b1 & 0xf | addr >> 8 & 0xf0) as u8; - *buffer.offset(i.wrapping_add(2) as isize) = + *buffer.offset((i + 1) as isize) = (b1 & 0xf | addr >> 8 & 0xf0) as u8; + *buffer.offset((i + 2) as isize) = (addr >> 16 & 0xf | addr >> 7 & 0x10 | addr << 4 & 0xe0) as u8; - *buffer.offset(i.wrapping_add(3) as isize) = + *buffer.offset((i + 3) as isize) = (addr >> 4 & 0x7f | addr >> 13 & 0x80) as u8; - i = i.wrapping_add((4 - 2) as size_t); + i += 4 - 2; } } else if inst & 0x7f == 0x17 { let mut inst2: u32 = 0; - inst |= (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 8; - inst |= (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 16; - inst |= (*buffer.offset(i.wrapping_add(3) as isize) as u32) << 24; + inst |= (*buffer.offset((i + 1) as isize) as u32) << 8; + inst |= (*buffer.offset((i + 2) as isize) as u32) << 16; + inst |= (*buffer.offset((i + 3) as isize) as u32) << 24; if inst & 0xe80 != 0 { inst2 = read32le(buffer.offset(i as isize).offset(4)); if (inst << 8 ^ inst2.wrapping_sub(3)) & 0xf8003 != 0 { - i = i.wrapping_add((6 - 2) as size_t); + i += 6 - 2; current_block_23 = 12517898123489920830; } else { let mut addr_0: u32 = inst & 0xfffff000; @@ -172,7 +172,7 @@ unsafe extern "C" fn riscv_decode( } else { let inst2_rs1: u32 = inst >> 27; if inst.wrapping_sub(0x3117) << 18 >= inst2_rs1 & 0x1d { - i = i.wrapping_add((4 - 2) as size_t); + i += 4 - 2; current_block_23 = 12517898123489920830; } else { let mut addr_1: u32 = read32be(buffer.offset(i as isize).offset(4)); @@ -187,11 +187,11 @@ unsafe extern "C" fn riscv_decode( _ => { write32le(buffer.offset(i as isize), inst); write32le(buffer.offset(i as isize).offset(4), inst2); - i = i.wrapping_add((8 - 2) as size_t); + i += 8 - 2; } } } - i = i.wrapping_add(2); + i += 2; } i } diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 931ee9bb..a3448d3b 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -47,7 +47,7 @@ unsafe fn call_filter( buffer, size, ) as size_t; - (*coder).now_pos = ((*coder).now_pos as size_t).wrapping_add(filtered) as u32; + (*coder).now_pos = ((*coder).now_pos as size_t + filtered) as u32; filtered } unsafe extern "C" fn simple_code( @@ -82,8 +82,8 @@ unsafe extern "C" fn simple_code( } } (*coder).filtered = 0; - let out_avail: size_t = out_size.wrapping_sub(*out_pos); - let buf_avail: size_t = (*coder).size.wrapping_sub((*coder).pos); + let out_avail: size_t = out_size - *out_pos; + let buf_avail: size_t = (*coder).size - (*coder).pos; if out_avail > buf_avail || buf_avail == 0 { let out_start: size_t = *out_pos; if buf_avail > 0 { @@ -94,26 +94,26 @@ unsafe extern "C" fn simple_code( buf_avail, ); } - *out_pos = (*out_pos).wrapping_add(buf_avail); + *out_pos += buf_avail; let ret: lzma_ret = copy_or_code( coder, allocator, in_0, in_pos, in_size, out, out_pos, out_size, action, ); if ret != LZMA_OK { return ret; } - let size: size_t = (*out_pos).wrapping_sub(out_start); + let size: size_t = *out_pos - out_start; let filtered: size_t = if size == 0 { 0 } else { call_filter(coder, out.offset(out_start as isize), size) as size_t }; - let unfiltered: size_t = size.wrapping_sub(filtered); + let unfiltered: size_t = size - filtered; (*coder).pos = 0; (*coder).size = unfiltered; if (*coder).end_was_reached { (*coder).size = 0; } else if unfiltered > 0 { - *out_pos = (*out_pos).wrapping_sub(unfiltered); + *out_pos -= unfiltered; core::ptr::copy_nonoverlapping( out.offset(*out_pos as isize) as *const u8, ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, @@ -127,7 +127,7 @@ unsafe extern "C" fn simple_code( ::core::ptr::addr_of_mut!((*coder).buffer) as *mut u8, buf_avail, ); - (*coder).size = (*coder).size.wrapping_sub((*coder).pos); + (*coder).size -= (*coder).pos; (*coder).pos = 0; } if (*coder).size > 0 { @@ -199,8 +199,7 @@ pub unsafe fn lzma_simple_coder_init( let mut coder: *mut lzma_simple_coder = (*next).coder as *mut lzma_simple_coder; if coder.is_null() { coder = crate::alloc::internal_alloc_bytes( - (core::mem::size_of::()) - .wrapping_add((2_usize).wrapping_mul(unfiltered_max)), + core::mem::size_of::() + 2 * unfiltered_max, allocator, ) as *mut lzma_simple_coder; if coder.is_null() { @@ -246,7 +245,7 @@ pub unsafe fn lzma_simple_coder_init( set_out_limit: None, }; (*coder).filter = filter; - (*coder).allocated = (2_usize).wrapping_mul(unfiltered_max); + (*coder).allocated = 2 * unfiltered_max; if simple_size > 0 { (*coder).simple = crate::alloc::internal_alloc_bytes(simple_size, allocator); if (*coder).simple.is_null() { @@ -259,7 +258,7 @@ pub unsafe fn lzma_simple_coder_init( if !(*filters).options.is_null() { let simple: *const lzma_options_bcj = (*filters).options as *const lzma_options_bcj; (*coder).now_pos = (*simple).start_offset; - if (*coder).now_pos & alignment.wrapping_sub(1) != 0 { + if (*coder).now_pos & (alignment - 1) != 0 { return LZMA_OPTIONS_ERROR; } } else { diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index f336eb13..ded772c2 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -11,14 +11,14 @@ unsafe extern "C" fn sparc_code( i = 0; while i < size { if *buffer.offset(i as isize) == 0x40 - && *buffer.offset(i.wrapping_add(1) as isize) & 0xc0 == 0 + && *buffer.offset((i + 1) as isize) & 0xc0 == 0 || *buffer.offset(i as isize) == 0x7f - && *buffer.offset(i.wrapping_add(1) as isize) & 0xc0 == 0xc0 + && *buffer.offset((i + 1) as isize) & 0xc0 == 0xc0 { let mut src: u32 = (*buffer.offset(i as isize) as u32) << 24 - | (*buffer.offset(i.wrapping_add(1) as isize) as u32) << 16 - | (*buffer.offset(i.wrapping_add(2) as isize) as u32) << 8 - | *buffer.offset(i.wrapping_add(3) as isize) as u32; + | (*buffer.offset((i + 1) as isize) as u32) << 16 + | (*buffer.offset((i + 2) as isize) as u32) << 8 + | *buffer.offset((i + 3) as isize) as u32; src <<= 2; let mut dest: u32 = 0; if is_encoder { @@ -30,11 +30,11 @@ unsafe extern "C" fn sparc_code( dest = 0u32.wrapping_sub(dest >> 22 & 1) << 22 & 0x3fffffff | dest & 0x3fffff | 0x40000000; *buffer.offset(i as isize) = (dest >> 24) as u8; - *buffer.offset(i.wrapping_add(1) as isize) = (dest >> 16) as u8; - *buffer.offset(i.wrapping_add(2) as isize) = (dest >> 8) as u8; - *buffer.offset(i.wrapping_add(3) as isize) = dest as u8; + *buffer.offset((i + 1) as isize) = (dest >> 16) as u8; + *buffer.offset((i + 2) as isize) = (dest >> 8) as u8; + *buffer.offset((i + 3) as isize) = dest as u8; } - i = i.wrapping_add(4); + i += 4; } i } diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index 2a6ab151..b8225011 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -22,7 +22,7 @@ unsafe extern "C" fn x86_code( if now_pos.wrapping_sub(prev_pos) > 5 { prev_pos = now_pos.wrapping_sub(5); } - let limit: size_t = size.wrapping_sub(5); + let limit: size_t = size - 5; let mut buffer_pos: size_t = 0; while buffer_pos <= limit { let mut b: u8 = *buffer.offset(buffer_pos as isize); @@ -43,12 +43,12 @@ unsafe extern "C" fn x86_code( i += 1; } } - b = *buffer.offset(buffer_pos.wrapping_add(4) as isize); + b = *buffer.offset((buffer_pos + 4) as isize); if (b == 0 || b == 0xff) && prev_mask >> 1 <= 4 && prev_mask >> 1 != 3 { let mut src: u32 = (b as u32) << 24 - | (*buffer.offset(buffer_pos.wrapping_add(3) as isize) as u32) << 16 - | (*buffer.offset(buffer_pos.wrapping_add(2) as isize) as u32) << 8 - | *buffer.offset(buffer_pos.wrapping_add(1) as isize) as u32; + | (*buffer.offset((buffer_pos + 3) as isize) as u32) << 16 + | (*buffer.offset((buffer_pos + 2) as isize) as u32) << 8 + | *buffer.offset((buffer_pos + 1) as isize) as u32; let mut dest: u32 = 0; loop { if is_encoder { @@ -69,12 +69,12 @@ unsafe extern "C" fn x86_code( src = dest ^ (1u32 << (32u32).wrapping_sub(i_0.wrapping_mul(8))).wrapping_sub(1); } - *buffer.offset(buffer_pos.wrapping_add(4) as isize) = + *buffer.offset((buffer_pos + 4) as isize) = !(dest >> 24 & 1).wrapping_sub(1) as u8; - *buffer.offset(buffer_pos.wrapping_add(3) as isize) = (dest >> 16) as u8; - *buffer.offset(buffer_pos.wrapping_add(2) as isize) = (dest >> 8) as u8; - *buffer.offset(buffer_pos.wrapping_add(1) as isize) = dest as u8; - buffer_pos = buffer_pos.wrapping_add(5); + *buffer.offset((buffer_pos + 3) as isize) = (dest >> 16) as u8; + *buffer.offset((buffer_pos + 2) as isize) = (dest >> 8) as u8; + *buffer.offset((buffer_pos + 1) as isize) = dest as u8; + buffer_pos += 5; prev_mask = 0; } else { buffer_pos += 1; From 7eabd20cb55b294860257b50627b0ddee1087e47 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 17:34:54 +0900 Subject: [PATCH 28/51] Replace wrapping arithmetic with plain ops in lz_encoder_mf and lzma2_encoder --- liblzma-rs/src/lz/lz_encoder_mf.rs | 58 +++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 40f5892d..d9f7fb77 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -13,21 +13,21 @@ pub unsafe fn lzma_mf_find( let count: u32 = (*mf).find.unwrap()(mf, matches) as u32; let mut len_best: u32 = 0; if count > 0 { - len_best = (*matches.offset(count.wrapping_sub(1) as isize)).len; + len_best = (*matches.offset((count - 1) as isize)).len; if len_best == (*mf).nice_len { - let mut limit: u32 = mf_avail(mf).wrapping_add(1); + let mut limit: u32 = mf_avail(mf) + 1; if limit > (*mf).match_len_max { limit = (*mf).match_len_max; } let p1: *const u8 = mf_ptr(mf).offset(-1); let p2: *const u8 = p1 - .offset(-((*matches.offset(count.wrapping_sub(1) as isize)).dist as isize)) + .offset(-((*matches.offset((count - 1) as isize)).dist as isize)) .offset(-1); len_best = lzma_memcmplen(p1, p2, len_best, limit); } } *count_ptr = count; - (*mf).read_ahead = (*mf).read_ahead.wrapping_add(1); + (*mf).read_ahead += 1; len_best } pub const EMPTY_HASH_VALUE: u32 = 0; @@ -64,15 +64,15 @@ unsafe fn move_pos(mf: *mut lzma_mf) { if (*mf).cyclic_pos == (*mf).cyclic_size { (*mf).cyclic_pos = 0; } - (*mf).read_pos = (*mf).read_pos.wrapping_add(1); + (*mf).read_pos += 1; if (*mf).read_pos.wrapping_add((*mf).offset) == 4294967295 { normalize(mf); } } #[inline(always)] unsafe fn move_pending(mf: *mut lzma_mf) { - (*mf).read_pos = (*mf).read_pos.wrapping_add(1); - (*mf).pending = (*mf).pending.wrapping_add(1); + (*mf).read_pos += 1; + (*mf).pending += 1; } #[inline] unsafe fn hc_find_func( @@ -91,7 +91,7 @@ unsafe fn hc_find_func( loop { let delta: u32 = pos.wrapping_sub(cur_match); let old_depth = depth; - depth = depth.wrapping_sub(1); + depth -= 1; if old_depth == 0 || delta >= cyclic_size { return matches; } @@ -107,7 +107,7 @@ unsafe fn hc_find_func( if len_best < len { len_best = len; (*matches).len = len; - (*matches).dist = delta.wrapping_sub(1); + (*matches).dist = delta - 1; matches = matches.offset(1); if len == len_limit { return matches; @@ -134,16 +134,16 @@ pub unsafe extern "C" fn lzma_mf_hc3_find(mf: *mut lzma_mf, matches: *mut lzma_m let delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); let cur_match: u32 = *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); + .offset((FIX_3_HASH_SIZE as u32 + hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + .offset((FIX_3_HASH_SIZE as u32 + hash_value) as isize) = pos; let mut len_best: u32 = 2; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); (*matches).len = len_best; - (*matches).dist = delta2.wrapping_sub(1); + (*matches).dist = delta2 - 1; matches_count = 1; if len_best == len_limit { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; @@ -180,11 +180,11 @@ pub unsafe extern "C" fn lzma_mf_hc3_skip(mf: *mut lzma_mf, mut amount: u32) { let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let cur_match: u32 = *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); + .offset((FIX_3_HASH_SIZE as u32 + hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + .offset((FIX_3_HASH_SIZE as u32 + hash_value) as isize) = pos; *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); } @@ -216,34 +216,34 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m let delta3: u32 = pos.wrapping_sub( *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize), + .offset((FIX_3_HASH_SIZE as u32 + hash_3_value) as isize), ); let cur_match: u32 = *(*mf) .hash - .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize); + .offset((FIX_4_HASH_SIZE as u32 + hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize) = pos; + .offset((FIX_3_HASH_SIZE as u32 + hash_3_value) as isize) = pos; *(*mf) .hash - .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + .offset((FIX_4_HASH_SIZE as u32 + hash_value) as isize) = pos; let mut len_best: u32 = 1; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = 2; (*matches).len = 2; - (*matches).dist = delta2.wrapping_sub(1); + (*matches).dist = delta2 - 1; matches_count = 1; } if delta2 != delta3 && delta3 < (*mf).cyclic_size && *cur.offset(-(delta3 as isize)) == *cur { len_best = 3; - (*matches.offset(matches_count as isize)).dist = delta3.wrapping_sub(1); + (*matches.offset(matches_count as isize)).dist = delta3 - 1; matches_count += 1; delta2 = delta3; } if matches_count != 0 { len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); - (*matches.offset(matches_count.wrapping_sub(1) as isize)).len = len_best; + (*matches.offset((matches_count - 1) as isize)).len = len_best; if len_best == len_limit { *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); @@ -286,14 +286,14 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { & (*mf).hash_mask; let cur_match: u32 = *(*mf) .hash - .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize); + .offset((FIX_4_HASH_SIZE as u32 + hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_3_value) as isize) = pos; + .offset((FIX_3_HASH_SIZE as u32 + hash_3_value) as isize) = pos; *(*mf) .hash - .offset((FIX_4_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + .offset((FIX_4_HASH_SIZE as u32 + hash_value) as isize) = pos; *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); } @@ -505,16 +505,16 @@ pub unsafe extern "C" fn lzma_mf_bt3_find(mf: *mut lzma_mf, matches: *mut lzma_m let delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); let cur_match: u32 = *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); + .offset((FIX_3_HASH_SIZE as u32 + hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + .offset((FIX_3_HASH_SIZE as u32 + hash_value) as isize) = pos; let mut len_best: u32 = 2; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = lzma_memcmplen(cur, cur.offset(-(delta2 as isize)), len_best, len_limit); (*matches).len = len_best; - (*matches).dist = delta2.wrapping_sub(1); + (*matches).dist = delta2 - 1; matches_count = 1; if len_best == len_limit { bt_skip_func( @@ -570,11 +570,11 @@ pub unsafe extern "C" fn lzma_mf_bt3_skip(mf: *mut lzma_mf, mut amount: u32) { let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8) & (*mf).hash_mask; let cur_match: u32 = *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize); + .offset((FIX_3_HASH_SIZE as u32 + hash_value) as isize); *(*mf).hash.offset(hash_2_value as isize) = pos; *(*mf) .hash - .offset((FIX_3_HASH_SIZE as u32).wrapping_add(hash_value) as isize) = pos; + .offset((FIX_3_HASH_SIZE as u32 + hash_value) as isize) = pos; bt_skip_func( len_limit, pos, From 0f5c9c42bbfa2b0201b90af240d8012ae17b23d0 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 17:49:16 +0900 Subject: [PATCH 29/51] Replace wrapping arithmetic with plain ops in common, lz, lzma_encoder, and simple modules --- liblzma-rs/src/common/auto_decoder.rs | 6 +- liblzma-rs/src/common/block_buffer_encoder.rs | 45 +- liblzma-rs/src/common/block_decoder.rs | 5 +- liblzma-rs/src/common/block_encoder.rs | 5 +- liblzma-rs/src/common/block_header_decoder.rs | 4 +- liblzma-rs/src/common/block_header_encoder.rs | 5 +- liblzma-rs/src/common/common.rs | 20 +- liblzma-rs/src/common/file_info.rs | 110 +- liblzma-rs/src/common/filter_common.rs | 10 +- liblzma-rs/src/common/filter_decoder.rs | 10 +- liblzma-rs/src/common/filter_encoder.rs | 28 +- liblzma-rs/src/common/filter_flags_encoder.rs | 5 +- liblzma-rs/src/common/index.rs | 157 +- liblzma-rs/src/common/index_encoder.rs | 5 +- liblzma-rs/src/common/lzip_decoder.rs | 9 +- liblzma-rs/src/common/microlzma_decoder.rs | 4 +- liblzma-rs/src/common/outqueue.rs | 15 +- liblzma-rs/src/common/stream_decoder.rs | 6 +- liblzma-rs/src/common/stream_decoder_mt.rs | 141 +- liblzma-rs/src/common/stream_encoder_mt.rs | 35 +- liblzma-rs/src/common/string_conversion.rs | 30 +- liblzma-rs/src/lz/lz_encoder_mf.rs | 6 +- liblzma-rs/src/lzma/lzma_decoder.rs | 1655 ++++++++--------- liblzma-rs/src/lzma/lzma_encoder.rs | 114 +- liblzma-rs/src/lzma/lzma_encoder_presets.rs | 5 +- liblzma-rs/src/simple/arm64.rs | 12 +- liblzma-rs/src/simple/ia64.rs | 4 +- liblzma-rs/src/simple/powerpc.rs | 4 +- liblzma-rs/src/simple/riscv.rs | 15 +- liblzma-rs/src/simple/simple_coder.rs | 6 +- liblzma-rs/src/simple/sparc.rs | 6 +- liblzma-rs/src/simple/x86.rs | 15 +- liblzma-rs/src/types.rs | 13 +- 33 files changed, 1064 insertions(+), 1446 deletions(-) diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 457acd96..639e417d 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -231,11 +231,7 @@ unsafe extern "C" fn auto_decoder_init( (*coder).sequence = SEQ_INIT; LZMA_OK } -pub unsafe fn lzma_auto_decoder( - strm: *mut lzma_stream, - memlimit: u64, - flags: u32, -) -> lzma_ret { +pub unsafe fn lzma_auto_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/block_buffer_encoder.rs b/liblzma-rs/src/common/block_buffer_encoder.rs index f5239327..1c9a8381 100644 --- a/liblzma-rs/src/common/block_buffer_encoder.rs +++ b/liblzma-rs/src/common/block_buffer_encoder.rs @@ -14,15 +14,15 @@ extern "C" fn lzma2_bound(uncompressed_size: u64) -> u64 { if (COMPRESSED_SIZE_MAX as u64).wrapping_sub(overhead) < uncompressed_size { return 0; } - uncompressed_size.wrapping_add(overhead) + uncompressed_size + overhead } pub fn lzma_block_buffer_bound64(uncompressed_size: u64) -> u64 { let mut lzma2_size: u64 = lzma2_bound(uncompressed_size); if lzma2_size == 0 { return 0; } - lzma2_size = lzma2_size.wrapping_add(3) & !(3); - (HEADERS_BOUND as u64).wrapping_add(lzma2_size) + lzma2_size = (lzma2_size + 3) & !(3); + HEADERS_BOUND as u64 + lzma2_size } pub fn lzma_block_buffer_bound(uncompressed_size: size_t) -> size_t { let ret: u64 = lzma_block_buffer_bound64(uncompressed_size as u64); @@ -75,8 +75,8 @@ unsafe fn block_encode_uncompressed( (*block).filters = filters_orig; return LZMA_PROG_ERROR; } - if (out_size.wrapping_sub(*out_pos) as lzma_vli) - < ((*block).header_size as lzma_vli).wrapping_add((*block).compressed_size) + if ((out_size - *out_pos) as lzma_vli) + < (*block).header_size as lzma_vli + (*block).compressed_size { (*block).filters = filters_orig; return LZMA_BUF_ERROR; @@ -86,29 +86,29 @@ unsafe fn block_encode_uncompressed( return LZMA_PROG_ERROR; } (*block).filters = filters_orig; - *out_pos = (*out_pos).wrapping_add((*block).header_size as size_t); + *out_pos += (*block).header_size as size_t; let mut in_pos: size_t = 0; let mut control: u8 = 0x1 as u8; while in_pos < in_size { *out.offset(*out_pos as isize) = control; *out_pos += 1; control = 0x2 as u8; - let copy_size: size_t = if in_size.wrapping_sub(in_pos) < (1u32 << 16) as size_t { - in_size.wrapping_sub(in_pos) + let copy_size: size_t = if in_size - in_pos < (1u32 << 16) as size_t { + in_size - in_pos } else { (1u32 << 16) as size_t }; - *out.offset(*out_pos as isize) = (copy_size.wrapping_sub(1) >> 8) as u8; + *out.offset(*out_pos as isize) = ((copy_size - 1) >> 8) as u8; *out_pos += 1; - *out.offset(*out_pos as isize) = (copy_size.wrapping_sub(1) & 0xff) as u8; + *out.offset(*out_pos as isize) = ((copy_size - 1) & 0xff) as u8; *out_pos += 1; core::ptr::copy_nonoverlapping( in_0.offset(in_pos as isize) as *const u8, out.offset(*out_pos as isize) as *mut u8, copy_size, ); - in_pos = in_pos.wrapping_add(copy_size); - *out_pos = (*out_pos).wrapping_add(copy_size); + in_pos += copy_size; + *out_pos += copy_size; } *out.offset(*out_pos as isize) = 0; *out_pos += 1; @@ -127,13 +127,13 @@ unsafe fn block_encode_normal( if ret_ != LZMA_OK { return ret_; } - if out_size.wrapping_sub(*out_pos) <= (*block).header_size as size_t { + if out_size - *out_pos <= (*block).header_size as size_t { return LZMA_BUF_ERROR; } let out_start: size_t = *out_pos; - *out_pos = (*out_pos).wrapping_add((*block).header_size as size_t); - if out_size.wrapping_sub(*out_pos) as lzma_vli > (*block).compressed_size { - out_size = (*out_pos as lzma_vli).wrapping_add((*block).compressed_size) as size_t; + *out_pos += (*block).header_size as size_t; + if (out_size - *out_pos) as lzma_vli > (*block).compressed_size { + out_size = (*out_pos as lzma_vli + (*block).compressed_size) as size_t; } let mut raw_encoder: lzma_next_coder = lzma_next_coder_s { coder: core::ptr::null_mut(), @@ -168,9 +168,8 @@ unsafe fn block_encode_normal( } lzma_next_end(::core::ptr::addr_of_mut!(raw_encoder), allocator); if ret == LZMA_STREAM_END { - (*block).compressed_size = (*out_pos) - .wrapping_sub(out_start.wrapping_add((*block).header_size as size_t)) - as lzma_vli; + (*block).compressed_size = + (*out_pos - (out_start + (*block).header_size as size_t)) as lzma_vli; ret = lzma_block_header_encode(block, out.offset(out_start as isize)); if ret != LZMA_OK { ret = LZMA_PROG_ERROR; @@ -210,12 +209,12 @@ unsafe fn block_buffer_encode( if lzma_check_is_supported((*block).check) == 0 { return LZMA_UNSUPPORTED_CHECK; } - out_size = out_size.wrapping_sub(out_size.wrapping_sub(*out_pos) & 3); + out_size -= (out_size - *out_pos) & 3; let check_size: size_t = lzma_check_size((*block).check) as size_t; - if out_size.wrapping_sub(*out_pos) <= check_size { + if out_size - *out_pos <= check_size { return LZMA_BUF_ERROR; } - out_size = out_size.wrapping_sub(check_size); + out_size -= check_size; (*block).uncompressed_size = in_size as lzma_vli; (*block).compressed_size = lzma2_bound(in_size as u64) as lzma_vli; if (*block).compressed_size == 0 { @@ -264,7 +263,7 @@ unsafe fn block_buffer_encode( out.offset(*out_pos as isize) as *mut u8, check_size, ); - *out_pos = (*out_pos).wrapping_add(check_size); + *out_pos += check_size; } LZMA_OK } diff --git a/liblzma-rs/src/common/block_decoder.rs b/liblzma-rs/src/common/block_decoder.rs index 21fb8792..90ea969e 100644 --- a/liblzma-rs/src/common/block_decoder.rs +++ b/liblzma-rs/src/common/block_decoder.rs @@ -276,10 +276,7 @@ pub unsafe extern "C" fn lzma_block_decoder_init( (*block).filters, ) } -pub unsafe fn lzma_block_decoder( - strm: *mut lzma_stream, - block: *mut lzma_block, -) -> lzma_ret { +pub unsafe fn lzma_block_decoder(strm: *mut lzma_stream, block: *mut lzma_block) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/block_encoder.rs b/liblzma-rs/src/common/block_encoder.rs index f6adb42a..25c6ac1f 100644 --- a/liblzma-rs/src/common/block_encoder.rs +++ b/liblzma-rs/src/common/block_encoder.rs @@ -243,10 +243,7 @@ pub unsafe extern "C" fn lzma_block_encoder_init( (*block).filters, ) } -pub unsafe fn lzma_block_encoder( - strm: *mut lzma_stream, - block: *mut lzma_block, -) -> lzma_ret { +pub unsafe fn lzma_block_encoder(strm: *mut lzma_stream, block: *mut lzma_block) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/block_header_decoder.rs b/liblzma-rs/src/common/block_header_decoder.rs index 10bf695a..11f63431 100644 --- a/liblzma-rs/src/common/block_header_decoder.rs +++ b/liblzma-rs/src/common/block_header_decoder.rs @@ -18,9 +18,7 @@ pub unsafe fn lzma_block_header_decode( (*block).version = 1; } (*block).ignore_check = false as lzma_bool; - if (*in_0 as u32 + 1) * 4 != (*block).header_size - || (*block).check > LZMA_CHECK_ID_MAX - { + if (*in_0 as u32 + 1) * 4 != (*block).header_size || (*block).check > LZMA_CHECK_ID_MAX { return LZMA_PROG_ERROR; } let in_size: size_t = ((*block).header_size - 4) as size_t; diff --git a/liblzma-rs/src/common/block_header_encoder.rs b/liblzma-rs/src/common/block_header_encoder.rs index 9a286490..f7ff43e4 100644 --- a/liblzma-rs/src/common/block_header_encoder.rs +++ b/liblzma-rs/src/common/block_header_encoder.rs @@ -41,10 +41,7 @@ pub unsafe fn lzma_block_header_size(block: *mut lzma_block) -> lzma_ret { (*block).header_size = (size + 3) & !(3); LZMA_OK } -pub unsafe fn lzma_block_header_encode( - block: *const lzma_block, - out: *mut u8, -) -> lzma_ret { +pub unsafe fn lzma_block_header_encode(block: *const lzma_block, out: *mut u8) -> lzma_ret { if lzma_block_unpadded_size(block) == 0 || !((*block).uncompressed_size <= LZMA_VLI_MAX || (*block).uncompressed_size == LZMA_VLI_UNKNOWN) diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index bdae8801..b5b5024b 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -78,10 +78,7 @@ pub fn lzma_version_number() -> u32 { pub fn lzma_version_string() -> *const c_char { crate::c_str!("5.8.2") } -pub unsafe fn lzma_alloc( - mut size: size_t, - allocator: *const lzma_allocator, -) -> *mut c_void { +pub unsafe fn lzma_alloc(mut size: size_t, allocator: *const lzma_allocator) -> *mut c_void { if size == 0 { size = 1; } @@ -93,10 +90,7 @@ pub unsafe fn lzma_alloc( } ptr } -pub unsafe fn lzma_alloc_zero( - mut size: size_t, - allocator: *const lzma_allocator, -) -> *mut c_void { +pub unsafe fn lzma_alloc_zero(mut size: size_t, allocator: *const lzma_allocator) -> *mut c_void { if size == 0 { size = 1; } @@ -185,10 +179,7 @@ pub unsafe fn lzma_next_filter_update( reversed_filters, ) } -pub unsafe fn lzma_next_end( - next: *mut lzma_next_coder, - allocator: *const lzma_allocator, -) { +pub unsafe fn lzma_next_end(next: *mut lzma_next_coder, allocator: *const lzma_allocator) { if (*next).init != 0 { if (*next).end.is_some() { (*next).end.unwrap()((*next).coder, allocator); @@ -466,10 +457,7 @@ pub fn lzma_memlimit_get(strm: *const lzma_stream) -> u64 { old_memlimit }; } -pub unsafe fn lzma_memlimit_set( - strm: *mut lzma_stream, - mut new_memlimit: u64, -) -> lzma_ret { +pub unsafe fn lzma_memlimit_set(strm: *mut lzma_stream, mut new_memlimit: u64) -> lzma_ret { let mut old_memlimit: u64 = 0; let mut memusage: u64 = 0; if strm.is_null() || (*strm).internal.is_null() || (*(*strm).internal).next.memconfig.is_none() diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 26513320..45210909 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -41,14 +41,14 @@ unsafe fn fill_temp( in_pos: *mut size_t, in_size: size_t, ) -> bool { - (*coder).file_cur_pos = (*coder).file_cur_pos.wrapping_add(lzma_bufcpy( + (*coder).file_cur_pos += lzma_bufcpy( in_0, in_pos, in_size, ::core::ptr::addr_of_mut!((*coder).temp) as *mut u8, ::core::ptr::addr_of_mut!((*coder).temp_pos), (*coder).temp_size, - ) as u64); + ) as u64; (*coder).temp_pos < (*coder).temp_size } unsafe fn seek_to_pos( @@ -58,15 +58,11 @@ unsafe fn seek_to_pos( in_pos: *mut size_t, in_size: size_t, ) -> bool { - let pos_min: u64 = (*coder) - .file_cur_pos - .wrapping_sub((*in_pos).wrapping_sub(in_start) as u64); - let pos_max: u64 = (*coder) - .file_cur_pos - .wrapping_add(in_size.wrapping_sub(*in_pos) as u64); + let pos_min: u64 = (*coder).file_cur_pos - (*in_pos - in_start) as u64; + let pos_max: u64 = (*coder).file_cur_pos + (in_size - *in_pos) as u64; let mut external_seek_needed: bool = false; if target_pos >= pos_min && target_pos <= pos_max { - *in_pos = (*in_pos).wrapping_add(target_pos.wrapping_sub((*coder).file_cur_pos) as size_t); + *in_pos += (target_pos - (*coder).file_cur_pos) as size_t; external_seek_needed = false; } else { *(*coder).external_seek_pos = target_pos; @@ -86,22 +82,16 @@ unsafe fn reverse_seek( return LZMA_DATA_ERROR; } (*coder).temp_pos = 0; - if (*coder) - .file_target_pos - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64) + if ((*coder).file_target_pos - LZMA_STREAM_HEADER_SIZE as u64) < core::mem::size_of::<[u8; 8192]>() as u64 { - (*coder).temp_size = (*coder) - .file_target_pos - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64) as size_t; + (*coder).temp_size = ((*coder).file_target_pos - LZMA_STREAM_HEADER_SIZE as u64) as size_t; } else { (*coder).temp_size = core::mem::size_of::<[u8; 8192]>() as size_t; } if seek_to_pos( coder, - (*coder) - .file_target_pos - .wrapping_sub((*coder).temp_size as u64), + (*coder).file_target_pos - (*coder).temp_size as u64, in_start, in_pos, in_size, @@ -146,13 +136,9 @@ unsafe fn decode_index( 0, LZMA_RUN, ); - (*coder).index_remaining = (*coder) - .index_remaining - .wrapping_sub((*in_pos).wrapping_sub(in_start) as lzma_vli); + (*coder).index_remaining -= (*in_pos - in_start) as lzma_vli; if update_file_cur_pos { - (*coder).file_cur_pos = (*coder) - .file_cur_pos - .wrapping_add((*in_pos).wrapping_sub(in_start) as u64); + (*coder).file_cur_pos += (*in_pos - in_start) as u64; } ret } @@ -169,11 +155,8 @@ unsafe extern "C" fn file_info_decode( ) -> lzma_ret { let coder: *mut lzma_file_info_coder = coder_ptr as *mut lzma_file_info_coder; let in_start: size_t = *in_pos; - if (*coder).file_size.wrapping_sub((*coder).file_cur_pos) - < in_size.wrapping_sub(in_start) as u64 - { - in_size = - in_start.wrapping_add((*coder).file_size.wrapping_sub((*coder).file_cur_pos) as size_t); + if (*coder).file_size - (*coder).file_cur_pos < (in_size - in_start) as u64 { + in_size = in_start + ((*coder).file_size - (*coder).file_cur_pos) as size_t; } loop { let mut current_block_142: u64; @@ -241,11 +224,8 @@ unsafe extern "C" fn file_info_decode( ::core::ptr::addr_of_mut!((*coder).temp) as *mut u8, (*coder).temp_size, ) as size_t; - (*coder).stream_padding = (*coder) - .stream_padding - .wrapping_add(new_padding as lzma_vli); - (*coder).file_target_pos = - (*coder).file_target_pos.wrapping_sub(new_padding as u64); + (*coder).stream_padding += new_padding as lzma_vli; + (*coder).file_target_pos -= new_padding as u64; if new_padding == (*coder).temp_size { (*coder).sequence = SEQ_PADDING_SEEK; current_block_142 = 13014351284863956202; @@ -254,7 +234,7 @@ unsafe extern "C" fn file_info_decode( return LZMA_DATA_ERROR; } (*coder).sequence = SEQ_FOOTER; - (*coder).temp_size = (*coder).temp_size.wrapping_sub(new_padding); + (*coder).temp_size -= new_padding; (*coder).temp_pos = (*coder).temp_size; if (*coder).temp_size < LZMA_STREAM_HEADER_SIZE as size_t { let ret__1: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); @@ -272,12 +252,8 @@ unsafe extern "C" fn file_info_decode( if fill_temp(coder, in_0, in_pos, in_size) { return LZMA_OK; } - (*coder).file_target_pos = (*coder) - .file_target_pos - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64); - (*coder).temp_size = (*coder) - .temp_size - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); + (*coder).file_target_pos -= LZMA_STREAM_HEADER_SIZE as u64; + (*coder).temp_size -= LZMA_STREAM_HEADER_SIZE as size_t; let ret__2: lzma_ret = hide_format_error(lzma_stream_footer_decode( ::core::ptr::addr_of_mut!((*coder).footer_flags), (::core::ptr::addr_of_mut!((*coder).temp) as *mut u8) @@ -287,20 +263,15 @@ unsafe extern "C" fn file_info_decode( return ret__2; } if (*coder).file_target_pos - < (*coder) - .footer_flags - .backward_size - .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) + < (*coder).footer_flags.backward_size + LZMA_STREAM_HEADER_SIZE as lzma_vli { return LZMA_DATA_ERROR; } - (*coder).file_target_pos = (*coder) - .file_target_pos - .wrapping_sub((*coder).footer_flags.backward_size as u64); + (*coder).file_target_pos -= (*coder).footer_flags.backward_size as u64; (*coder).sequence = SEQ_INDEX_INIT; if (*coder).temp_size as lzma_vli >= (*coder).footer_flags.backward_size { - (*coder).temp_pos = ((*coder).temp_size as lzma_vli) - .wrapping_sub((*coder).footer_flags.backward_size) + (*coder).temp_pos = ((*coder).temp_size as lzma_vli + - (*coder).footer_flags.backward_size) as size_t; } else { (*coder).temp_pos = 0; @@ -326,7 +297,7 @@ unsafe extern "C" fn file_info_decode( ::core::ptr::addr_of_mut!((*coder).index_decoder), allocator, ::core::ptr::addr_of_mut!((*coder).this_index), - (*coder).memlimit.wrapping_sub(memused), + (*coder).memlimit - memused, ); if ret__3 != LZMA_OK { return ret__3; @@ -351,8 +322,8 @@ unsafe extern "C" fn file_info_decode( ); } else { let mut in_stop: size_t = in_size; - if in_size.wrapping_sub(*in_pos) as lzma_vli > (*coder).index_remaining { - in_stop = (*in_pos).wrapping_add((*coder).index_remaining as size_t); + if (in_size - *in_pos) as lzma_vli > (*coder).index_remaining { + in_stop = *in_pos + (*coder).index_remaining as size_t; } ret = decode_index(coder, allocator, in_0, in_pos, in_stop, true); } @@ -370,30 +341,27 @@ unsafe extern "C" fn file_info_decode( } _ => return ret, } - let seek_amount: u64 = (lzma_index_total_size((*coder).this_index) as u64) - .wrapping_add(LZMA_STREAM_HEADER_SIZE as u64); + let seek_amount: u64 = lzma_index_total_size((*coder).this_index) as u64 + + LZMA_STREAM_HEADER_SIZE as u64; if (*coder).file_target_pos < seek_amount { return LZMA_DATA_ERROR; } - (*coder).file_target_pos = (*coder).file_target_pos.wrapping_sub(seek_amount); + (*coder).file_target_pos -= seek_amount; if (*coder).file_target_pos == 0 { (*coder).header_flags = (*coder).first_header_flags; (*coder).sequence = SEQ_HEADER_COMPARE; current_block_142 = 13014351284863956202; } else { (*coder).sequence = SEQ_HEADER_DECODE; - (*coder).file_target_pos = (*coder) - .file_target_pos - .wrapping_add(LZMA_STREAM_HEADER_SIZE as u64); + (*coder).file_target_pos += LZMA_STREAM_HEADER_SIZE as u64; if (*coder).temp_size != 0 - && ((*coder).temp_size as lzma_vli) - .wrapping_sub((*coder).footer_flags.backward_size) + && (*coder).temp_size as lzma_vli - (*coder).footer_flags.backward_size >= seek_amount { - (*coder).temp_pos = ((*coder).temp_size as lzma_vli) - .wrapping_sub((*coder).footer_flags.backward_size) - .wrapping_sub(seek_amount as lzma_vli) - .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) + (*coder).temp_pos = ((*coder).temp_size as lzma_vli + - (*coder).footer_flags.backward_size + - seek_amount as lzma_vli + + LZMA_STREAM_HEADER_SIZE as lzma_vli) as size_t; (*coder).temp_size = (*coder).temp_pos; } else { @@ -412,12 +380,8 @@ unsafe extern "C" fn file_info_decode( if fill_temp(coder, in_0, in_pos, in_size) { return LZMA_OK; } - (*coder).file_target_pos = (*coder) - .file_target_pos - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as u64); - (*coder).temp_size = (*coder) - .temp_size - .wrapping_sub(LZMA_STREAM_HEADER_SIZE as size_t); + (*coder).file_target_pos -= LZMA_STREAM_HEADER_SIZE as u64; + (*coder).temp_size -= LZMA_STREAM_HEADER_SIZE as size_t; (*coder).temp_pos = (*coder).temp_size; let ret__5: lzma_ret = hide_format_error(lzma_stream_header_decode( ::core::ptr::addr_of_mut!((*coder).header_flags), @@ -505,7 +469,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( return LZMA_PROG_ERROR; } } - *memusage = combined_index_memusage.wrapping_add(this_index_memusage); + *memusage = combined_index_memusage + this_index_memusage; if *memusage == 0 { *memusage = lzma_index_memusage(1, 0); } @@ -515,7 +479,7 @@ unsafe extern "C" fn file_info_decoder_memconfig( return LZMA_MEMLIMIT_ERROR; } if (*coder).this_index.is_null() && (*coder).sequence == SEQ_INDEX_DECODE { - let idec_new_memlimit: u64 = new_memlimit.wrapping_sub(combined_index_memusage); + let idec_new_memlimit: u64 = new_memlimit - combined_index_memusage; let mut dummy1: u64 = 0; let mut dummy2: u64 = 0; if (*coder).index_decoder.memconfig.unwrap()( diff --git a/liblzma-rs/src/common/filter_common.rs b/liblzma-rs/src/common/filter_common.rs index 41d7cf9b..2c39b69f 100644 --- a/liblzma-rs/src/common/filter_common.rs +++ b/liblzma-rs/src/common/filter_common.rs @@ -178,10 +178,7 @@ pub unsafe fn lzma_filters_copy( } }; } -pub unsafe fn lzma_filters_free( - filters: *mut lzma_filter, - allocator: *const lzma_allocator, -) { +pub unsafe fn lzma_filters_free(filters: *mut lzma_filter, allocator: *const lzma_allocator) { if filters.is_null() { return; } @@ -196,10 +193,7 @@ pub unsafe fn lzma_filters_free( i += 1; } } -pub unsafe fn lzma_validate_chain( - filters: *const lzma_filter, - count: *mut size_t, -) -> lzma_ret { +pub unsafe fn lzma_validate_chain(filters: *const lzma_filter, count: *mut size_t) -> lzma_ret { if filters.is_null() || (*filters).id == LZMA_VLI_UNKNOWN { return LZMA_PROG_ERROR; } diff --git a/liblzma-rs/src/common/filter_decoder.rs b/liblzma-rs/src/common/filter_decoder.rs index e27cc17b..fa841b36 100644 --- a/liblzma-rs/src/common/filter_decoder.rs +++ b/liblzma-rs/src/common/filter_decoder.rs @@ -284,9 +284,8 @@ static decoders: [lzma_filter_decoder; 12] = [ ]; extern "C" fn decoder_find(id: lzma_vli) -> *const lzma_filter_decoder { let mut i: size_t = 0; - while i - < core::mem::size_of::<[lzma_filter_decoder; 12]>() - / core::mem::size_of::() + while i < core::mem::size_of::<[lzma_filter_decoder; 12]>() + / core::mem::size_of::() { if decoders[i as usize].id == id { return &decoders[i as usize]; @@ -314,10 +313,7 @@ pub unsafe fn lzma_raw_decoder_init( false, ) } -pub unsafe fn lzma_raw_decoder( - strm: *mut lzma_stream, - options: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_raw_decoder(strm: *mut lzma_stream, options: *const lzma_filter) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/filter_encoder.rs b/liblzma-rs/src/common/filter_encoder.rs index 78fd092f..82deffa9 100644 --- a/liblzma-rs/src/common/filter_encoder.rs +++ b/liblzma-rs/src/common/filter_encoder.rs @@ -261,9 +261,8 @@ static encoders: [lzma_filter_encoder; 12] = [ ]; extern "C" fn encoder_find(id: lzma_vli) -> *const lzma_filter_encoder { let mut i: size_t = 0; - while i - < core::mem::size_of::<[lzma_filter_encoder; 12]>() - / core::mem::size_of::() + while i < core::mem::size_of::<[lzma_filter_encoder; 12]>() + / core::mem::size_of::() { if encoders[i as usize].id == id { return &encoders[i as usize]; @@ -278,10 +277,7 @@ extern "C" fn coder_find(id: lzma_vli) -> *const lzma_filter_coder { pub fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool { !encoder_find(id).is_null() as lzma_bool } -pub unsafe fn lzma_filters_update( - strm: *mut lzma_stream, - filters: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_filters_update(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { if (*(*strm).internal).next.update.is_none() { return LZMA_PROG_ERROR; } @@ -298,8 +294,7 @@ pub unsafe fn lzma_filters_update( }; 5]; let mut i: size_t = 0; while i < count { - reversed_filters[count - i - 1] = - *filters.offset(i as isize); + reversed_filters[count - i - 1] = *filters.offset(i as isize); i += 1; } reversed_filters[count as usize].id = LZMA_VLI_UNKNOWN; @@ -323,10 +318,7 @@ pub unsafe fn lzma_raw_encoder_init( true, ) } -pub unsafe fn lzma_raw_encoder( - strm: *mut lzma_stream, - filters: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_raw_encoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; @@ -379,10 +371,7 @@ pub unsafe fn lzma_mt_block_size(filters: *const lzma_filter) -> u64 { max } } -pub unsafe fn lzma_properties_size( - size: *mut u32, - filter: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret { let fe: *const lzma_filter_encoder = encoder_find((*filter).id) as *const lzma_filter_encoder; if fe.is_null() { return if (*filter).id <= LZMA_VLI_MAX { @@ -397,10 +386,7 @@ pub unsafe fn lzma_properties_size( } (*fe).props_size_get.unwrap()(size, (*filter).options) } -pub unsafe fn lzma_properties_encode( - filter: *const lzma_filter, - props: *mut u8, -) -> lzma_ret { +pub unsafe fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret { let fe: *const lzma_filter_encoder = encoder_find((*filter).id) as *const lzma_filter_encoder; if fe.is_null() { return LZMA_PROG_ERROR; diff --git a/liblzma-rs/src/common/filter_flags_encoder.rs b/liblzma-rs/src/common/filter_flags_encoder.rs index 6a5d02ac..cf96a80f 100644 --- a/liblzma-rs/src/common/filter_flags_encoder.rs +++ b/liblzma-rs/src/common/filter_flags_encoder.rs @@ -1,9 +1,6 @@ use crate::common::filter_encoder::{lzma_properties_encode, lzma_properties_size}; use crate::types::*; -pub unsafe fn lzma_filter_flags_size( - size: *mut u32, - filter: *const lzma_filter, -) -> lzma_ret { +pub unsafe fn lzma_filter_flags_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret { if (*filter).id >= LZMA_FILTER_RESERVED_START { return LZMA_PROG_ERROR; } diff --git a/liblzma-rs/src/common/index.rs b/liblzma-rs/src/common/index.rs index 0df8debe..079c06bc 100644 --- a/liblzma-rs/src/common/index.rs +++ b/liblzma-rs/src/common/index.rs @@ -119,7 +119,7 @@ unsafe fn index_tree_append(tree: *mut index_tree, mut node: *mut index_tree_nod (*node).parent = (*tree).rightmost; (*node).left = core::ptr::null_mut(); (*node).right = core::ptr::null_mut(); - (*tree).count = (*tree).count.wrapping_add(1); + (*tree).count += 1; if (*tree).root.is_null() { (*tree).root = node; (*tree).leftmost = node; @@ -130,7 +130,7 @@ unsafe fn index_tree_append(tree: *mut index_tree, mut node: *mut index_tree_nod (*tree).rightmost = node; let mut up: u32 = (*tree).count ^ 1 << bsr32((*tree).count); if up != 0 { - up = ctz32((*tree).count).wrapping_add(2); + up = ctz32((*tree).count) + 2; loop { node = (*node).parent; up -= 1; @@ -312,9 +312,9 @@ pub fn lzma_index_total_size(i: *const lzma_index) -> lzma_vli { pub fn lzma_index_stream_size(i: *const lzma_index) -> lzma_vli { unsafe { (LZMA_STREAM_HEADER_SIZE as lzma_vli) - .wrapping_add((*i).total_size) - .wrapping_add(index_size((*i).record_count, (*i).index_list_size)) - .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) + + (*i).total_size + + index_size((*i).record_count, (*i).index_list_size) + + LZMA_STREAM_HEADER_SIZE as lzma_vli } } unsafe fn index_file_size( @@ -383,10 +383,7 @@ pub unsafe fn lzma_index_stream_flags( (*s).stream_flags = *stream_flags; LZMA_OK } -pub unsafe fn lzma_index_stream_padding( - i: *mut lzma_index, - stream_padding: lzma_vli, -) -> lzma_ret { +pub unsafe fn lzma_index_stream_padding(i: *mut lzma_index, stream_padding: lzma_vli) -> lzma_ret { if i.is_null() || stream_padding > LZMA_VLI_MAX || stream_padding & 3 != 0 { return LZMA_PROG_ERROR; } @@ -431,7 +428,7 @@ pub unsafe fn lzma_index_append( .uncompressed_sum }; let index_list_size_add: u32 = - (lzma_vli_size(unpadded_size) as u32).wrapping_add(lzma_vli_size(uncompressed_size) as u32); + lzma_vli_size(unpadded_size) as u32 + lzma_vli_size(uncompressed_size) as u32; if uncompressed_base.wrapping_add(uncompressed_size) > LZMA_VLI_MAX { return LZMA_DATA_ERROR; } @@ -457,14 +454,12 @@ pub unsafe fn lzma_index_append( { return LZMA_DATA_ERROR; } - if !g.is_null() && (*g).last.wrapping_add(1) < (*g).allocated { - (*g).last = (*g).last.wrapping_add(1); + if !g.is_null() && (*g).last + 1 < (*g).allocated { + (*g).last += 1; } else { g = lzma_alloc( - (core::mem::size_of::()).wrapping_add( - (*i).prealloc - .wrapping_mul(core::mem::size_of::()), - ), + core::mem::size_of::() + + (*i).prealloc * core::mem::size_of::(), allocator, ) as *mut index_group; if g.is_null() { @@ -475,26 +470,22 @@ pub unsafe fn lzma_index_append( (*i).prealloc = INDEX_GROUP_SIZE as size_t; (*g).node.uncompressed_base = uncompressed_base; (*g).node.compressed_base = compressed_base; - (*g).number_base = (*s).record_count.wrapping_add(1); + (*g).number_base = (*s).record_count + 1; index_tree_append( ::core::ptr::addr_of_mut!((*s).groups), ::core::ptr::addr_of_mut!((*g).node), ); } (*(::core::ptr::addr_of_mut!((*g).records) as *mut index_record).offset((*g).last as isize)) - .uncompressed_sum = uncompressed_base.wrapping_add(uncompressed_size); + .uncompressed_sum = uncompressed_base + uncompressed_size; (*(::core::ptr::addr_of_mut!((*g).records) as *mut index_record).offset((*g).last as isize)) - .unpadded_sum = compressed_base.wrapping_add(unpadded_size); - (*s).record_count = (*s).record_count.wrapping_add(1); - (*s).index_list_size = (*s) - .index_list_size - .wrapping_add(index_list_size_add as lzma_vli); - (*i).total_size = (*i).total_size.wrapping_add(vli_ceil4(unpadded_size)); - (*i).uncompressed_size = (*i).uncompressed_size.wrapping_add(uncompressed_size); - (*i).record_count = (*i).record_count.wrapping_add(1); - (*i).index_list_size = (*i) - .index_list_size - .wrapping_add(index_list_size_add as lzma_vli); + .unpadded_sum = compressed_base + unpadded_size; + (*s).record_count += 1; + (*s).index_list_size += index_list_size_add as lzma_vli; + (*i).total_size += vli_ceil4(unpadded_size); + (*i).uncompressed_size += uncompressed_size; + (*i).record_count += 1; + (*i).index_list_size += index_list_size_add as lzma_vli; LZMA_OK } unsafe fn index_cat_helper(info: *const index_cat_info, this: *mut index_stream) { @@ -503,15 +494,10 @@ unsafe fn index_cat_helper(info: *const index_cat_info, this: *mut index_stream) if !left.is_null() { index_cat_helper(info, left); } - (*this).node.uncompressed_base = (*this) - .node - .uncompressed_base - .wrapping_add((*info).uncompressed_size); - (*this).node.compressed_base = (*this).node.compressed_base.wrapping_add((*info).file_size); - (*this).number = (*this).number.wrapping_add((*info).stream_number_add); - (*this).block_number_base = (*this) - .block_number_base - .wrapping_add((*info).block_number_add); + (*this).node.uncompressed_base += (*info).uncompressed_size; + (*this).node.compressed_base += (*info).file_size; + (*this).number += (*info).stream_number_add; + (*this).block_number_base += (*info).block_number_add; index_tree_append((*info).streams, ::core::ptr::addr_of_mut!((*this).node)); if !right.is_null() { index_cat_helper(info, right); @@ -543,28 +529,23 @@ pub unsafe fn lzma_index_cat( } let s: *mut index_stream = (*dest).streams.rightmost as *mut index_stream; let g: *mut index_group = (*s).groups.rightmost as *mut index_group; - if !g.is_null() && (*g).last.wrapping_add(1) < (*g).allocated { + if !g.is_null() && (*g).last + 1 < (*g).allocated { let newg: *mut index_group = lzma_alloc( - (core::mem::size_of::()).wrapping_add( - (*g).last - .wrapping_add(1) - .wrapping_mul(core::mem::size_of::()), - ), + core::mem::size_of::() + + ((*g).last + 1) * core::mem::size_of::(), allocator, ) as *mut index_group; if newg.is_null() { return LZMA_MEM_ERROR; } (*newg).node = (*g).node; - (*newg).allocated = (*g).last.wrapping_add(1); + (*newg).allocated = (*g).last + 1; (*newg).last = (*g).last; (*newg).number_base = (*g).number_base; core::ptr::copy_nonoverlapping( ::core::ptr::addr_of_mut!((*g).records) as *const u8, ::core::ptr::addr_of_mut!((*newg).records) as *mut u8, - (*newg) - .allocated - .wrapping_mul(core::mem::size_of::()), + (*newg).allocated * core::mem::size_of::(), ); if !(*g).node.parent.is_null() { (*(*g).node.parent).right = ::core::ptr::addr_of_mut!((*newg).node); @@ -588,12 +569,10 @@ pub unsafe fn lzma_index_cat( ::core::ptr::addr_of!(info), (*src).streams.root as *mut index_stream, ); - (*dest).uncompressed_size = (*dest) - .uncompressed_size - .wrapping_add((*src).uncompressed_size); - (*dest).total_size = (*dest).total_size.wrapping_add((*src).total_size); - (*dest).record_count = (*dest).record_count.wrapping_add((*src).record_count); - (*dest).index_list_size = (*dest).index_list_size.wrapping_add((*src).index_list_size); + (*dest).uncompressed_size += (*src).uncompressed_size; + (*dest).total_size += (*src).total_size; + (*dest).record_count += (*src).record_count; + (*dest).index_list_size += (*src).index_list_size; (*dest).checks |= (*src).checks; lzma_free(src as *mut c_void, allocator); LZMA_OK @@ -623,11 +602,9 @@ unsafe fn index_dup_stream( return dest; } let destg: *mut index_group = lzma_alloc( - (core::mem::size_of::() as lzma_vli).wrapping_add( - (*src) - .record_count - .wrapping_mul(core::mem::size_of::() as lzma_vli), - ) as size_t, + (core::mem::size_of::() as lzma_vli + + (*src).record_count * core::mem::size_of::() as lzma_vli) + as size_t, allocator, ) as *mut index_group; if destg.is_null() { @@ -638,7 +615,7 @@ unsafe fn index_dup_stream( (*destg).node.compressed_base = 0; (*destg).number_base = 1; (*destg).allocated = (*src).record_count as size_t; - (*destg).last = (*src).record_count.wrapping_sub(1) as size_t; + (*destg).last = ((*src).record_count - 1) as size_t; let mut srcg: *const index_group = (*src).groups.leftmost as *const index_group; let mut i: size_t = 0; loop { @@ -646,12 +623,9 @@ unsafe fn index_dup_stream( ::core::ptr::addr_of!((*srcg).records) as *const u8, (::core::ptr::addr_of_mut!((*destg).records) as *mut index_record).offset(i as isize) as *mut u8, - (*srcg) - .last - .wrapping_add(1) - .wrapping_mul(core::mem::size_of::()), + ((*srcg).last + 1) * core::mem::size_of::(), ); - i = i.wrapping_add((*srcg).last.wrapping_add(1)); + i += (*srcg).last + 1; srcg = index_tree_next(::core::ptr::addr_of!((*srcg).node)) as *const index_group; if srcg.is_null() { break; @@ -729,37 +703,31 @@ unsafe fn iter_set_info(iter: *mut lzma_index_iter) { (*iter).stream.padding = (*stream).stream_padding; if (*stream).groups.rightmost.is_null() { (*iter).stream.compressed_size = - index_size(0, 0).wrapping_add((2 * LZMA_STREAM_HEADER_SIZE) as lzma_vli); + index_size(0, 0) + (2 * LZMA_STREAM_HEADER_SIZE) as lzma_vli; (*iter).stream.uncompressed_size = 0; } else { let g: *const index_group = (*stream).groups.rightmost as *const index_group; - (*iter).stream.compressed_size = ((2 * LZMA_STREAM_HEADER_SIZE) as lzma_vli) - .wrapping_add(index_size( - (*stream).record_count, - (*stream).index_list_size, - )) - .wrapping_add(vli_ceil4( + (*iter).stream.compressed_size = (2 * LZMA_STREAM_HEADER_SIZE) as lzma_vli + + index_size((*stream).record_count, (*stream).index_list_size) + + vli_ceil4( (*(::core::ptr::addr_of!((*g).records) as *const index_record) .offset((*g).last as isize)) .unpadded_sum, - )); + ); (*iter).stream.uncompressed_size = (*(::core::ptr::addr_of!((*g).records) as *const index_record) .offset((*g).last as isize)) .uncompressed_sum; } if !group.is_null() { - (*iter).block.number_in_stream = (*group).number_base.wrapping_add(record as lzma_vli); - (*iter).block.number_in_file = (*iter) - .block - .number_in_stream - .wrapping_add((*stream).block_number_base); + (*iter).block.number_in_stream = (*group).number_base + record as lzma_vli; + (*iter).block.number_in_file = (*iter).block.number_in_stream + (*stream).block_number_base; (*iter).block.compressed_stream_offset = if record == 0 { (*group).node.compressed_base } else { vli_ceil4( (*(::core::ptr::addr_of!((*group).records) as *const index_record) - .offset(record.wrapping_sub(1) as isize)) + .offset((record - 1) as isize)) .unpadded_sum, ) }; @@ -767,32 +735,25 @@ unsafe fn iter_set_info(iter: *mut lzma_index_iter) { (*group).node.uncompressed_base } else { (*(::core::ptr::addr_of!((*group).records) as *const index_record) - .offset(record.wrapping_sub(1) as isize)) + .offset((record - 1) as isize)) .uncompressed_sum }; (*iter).block.uncompressed_size = (*(::core::ptr::addr_of!((*group).records) as *const index_record) .offset(record as isize)) .uncompressed_sum - .wrapping_sub((*iter).block.uncompressed_stream_offset); + - (*iter).block.uncompressed_stream_offset; (*iter).block.unpadded_size = (*(::core::ptr::addr_of!((*group).records) as *const index_record) .offset(record as isize)) .unpadded_sum - .wrapping_sub((*iter).block.compressed_stream_offset); + - (*iter).block.compressed_stream_offset; (*iter).block.total_size = vli_ceil4((*iter).block.unpadded_size); - (*iter).block.compressed_stream_offset = (*iter) - .block - .compressed_stream_offset - .wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli); - (*iter).block.compressed_file_offset = (*iter) - .block - .compressed_stream_offset - .wrapping_add((*iter).stream.compressed_offset); - (*iter).block.uncompressed_file_offset = (*iter) - .block - .uncompressed_stream_offset - .wrapping_add((*iter).stream.uncompressed_offset); + (*iter).block.compressed_stream_offset += LZMA_STREAM_HEADER_SIZE as lzma_vli; + (*iter).block.compressed_file_offset = + (*iter).block.compressed_stream_offset + (*iter).stream.compressed_offset; + (*iter).block.uncompressed_file_offset = + (*iter).block.uncompressed_stream_offset + (*iter).stream.uncompressed_offset; } } pub unsafe fn lzma_index_iter_init(iter: *mut lzma_index_iter, i: *const lzma_index) { @@ -879,7 +840,7 @@ pub unsafe fn lzma_index_iter_next( break; } } else if (*(::core::ptr::addr_of!((*group).records) as *const index_record) - .offset(record.wrapping_sub(1) as isize)) + .offset((record - 1) as isize)) .uncompressed_sum != (*(::core::ptr::addr_of!((*group).records) as *const index_record) .offset(record as isize)) @@ -904,18 +865,18 @@ pub unsafe fn lzma_index_iter_locate( } let stream: *const index_stream = index_tree_locate(::core::ptr::addr_of!((*i).streams), target) as *const index_stream; - target = target.wrapping_sub((*stream).node.uncompressed_base); + target -= (*stream).node.uncompressed_base; let group: *const index_group = index_tree_locate(::core::ptr::addr_of!((*stream).groups), target) as *const index_group; let mut left: size_t = 0; let mut right: size_t = (*group).last; while left < right { - let pos: size_t = left.wrapping_add(right.wrapping_sub(left).wrapping_div(2)); + let pos: size_t = left + (right - left) / 2; if (*(::core::ptr::addr_of!((*group).records) as *const index_record).offset(pos as isize)) .uncompressed_sum <= target { - left = pos.wrapping_add(1); + left = pos + 1; } else { right = pos; } diff --git a/liblzma-rs/src/common/index_encoder.rs b/liblzma-rs/src/common/index_encoder.rs index 494bf5fd..e71ad6e2 100644 --- a/liblzma-rs/src/common/index_encoder.rs +++ b/liblzma-rs/src/common/index_encoder.rs @@ -221,10 +221,7 @@ pub unsafe extern "C" fn lzma_index_encoder_init( index_encoder_reset((*next).coder as *mut lzma_index_coder, i); LZMA_OK } -pub unsafe fn lzma_index_encoder( - strm: *mut lzma_stream, - i: *const lzma_index, -) -> lzma_ret { +pub unsafe fn lzma_index_encoder(strm: *mut lzma_stream, i: *const lzma_index) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/lzip_decoder.rs b/liblzma-rs/src/common/lzip_decoder.rs index 3d2ed156..e74bd324 100644 --- a/liblzma-rs/src/common/lzip_decoder.rs +++ b/liblzma-rs/src/common/lzip_decoder.rs @@ -135,8 +135,7 @@ unsafe extern "C" fn lzip_decode( if b2log < 12 || b2log > 29 || b2log == 12 && fracnum > 0 { return LZMA_DATA_ERROR; } - (*coder).options.dict_size = - (1u32 << b2log) - (fracnum << (b2log - 4)); + (*coder).options.dict_size = (1u32 << b2log) - (fracnum << (b2log - 4)); (*coder).options.preset_dict = core::ptr::null(); (*coder).options.lc = LZIP_LC; (*coder).options.lp = LZIP_LP; @@ -384,11 +383,7 @@ pub unsafe extern "C" fn lzma_lzip_decoder_init( (*coder).pos = 0; LZMA_OK } -pub unsafe fn lzma_lzip_decoder( - strm: *mut lzma_stream, - memlimit: u64, - flags: u32, -) -> lzma_ret { +pub unsafe fn lzma_lzip_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/microlzma_decoder.rs b/liblzma-rs/src/common/microlzma_decoder.rs index e879c688..a29d2c9b 100644 --- a/liblzma-rs/src/common/microlzma_decoder.rs +++ b/liblzma-rs/src/common/microlzma_decoder.rs @@ -26,9 +26,7 @@ unsafe extern "C" fn microlzma_decode( if (in_size - *in_pos) as u64 > (*coder).comp_size { in_size = *in_pos + (*coder).comp_size as size_t; } - if !(*coder).uncomp_size_is_exact - && (out_size - *out_pos) as lzma_vli > (*coder).uncomp_size - { + if !(*coder).uncomp_size_is_exact && (out_size - *out_pos) as lzma_vli > (*coder).uncomp_size { out_size = *out_pos + (*coder).uncomp_size as size_t; } if !(*coder).props_decoded { diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index c73286d3..dd9d29cd 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -20,20 +20,14 @@ unsafe fn move_head_to_cache(outq: *mut lzma_outq, allocator: *const lzma_alloca (*outq).bufs_in_use -= 1; (*outq).mem_in_use -= lzma_outq_outbuf_memusage((*buf).allocated); } -unsafe fn free_one_cached_buffer( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, -) { +unsafe fn free_one_cached_buffer(outq: *mut lzma_outq, allocator: *const lzma_allocator) { let buf: *mut lzma_outbuf = (*outq).cache; (*outq).cache = (*buf).next; (*outq).bufs_allocated -= 1; (*outq).mem_allocated -= lzma_outq_outbuf_memusage((*buf).allocated); crate::alloc::internal_free(buf as *mut c_void, allocator); } -pub unsafe fn lzma_outq_clear_cache( - outq: *mut lzma_outq, - allocator: *const lzma_allocator, -) { +pub unsafe fn lzma_outq_clear_cache(outq: *mut lzma_outq, allocator: *const lzma_allocator) { while !(*outq).cache.is_null() { free_one_cached_buffer(outq, allocator); } @@ -101,10 +95,7 @@ pub unsafe fn lzma_outq_prealloc_buf( (*outq).mem_allocated += alloc_size as u64; LZMA_OK } -pub unsafe fn lzma_outq_get_buf( - outq: *mut lzma_outq, - worker: *mut c_void, -) -> *mut lzma_outbuf { +pub unsafe fn lzma_outq_get_buf(outq: *mut lzma_outq, worker: *mut c_void) -> *mut lzma_outbuf { let buf: *mut lzma_outbuf = (*outq).cache; (*outq).cache = (*buf).next; (*buf).next = core::ptr::null_mut(); diff --git a/liblzma-rs/src/common/stream_decoder.rs b/liblzma-rs/src/common/stream_decoder.rs index 97b7772d..e8663905 100644 --- a/liblzma-rs/src/common/stream_decoder.rs +++ b/liblzma-rs/src/common/stream_decoder.rs @@ -450,11 +450,7 @@ pub unsafe extern "C" fn lzma_stream_decoder_init( (*coder).first_stream = true; stream_decoder_reset(coder, allocator) } -pub unsafe fn lzma_stream_decoder( - strm: *mut lzma_stream, - memlimit: u64, - flags: u32, -) -> lzma_ret { +pub unsafe fn lzma_stream_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index df957f08..dc5a14db 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -143,8 +143,8 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { } mythread_mutex_unlock(::core::ptr::addr_of_mut!((*thr).mutex)); let chunk_size: size_t = 16384; - if in_filled.wrapping_sub((*thr).in_pos) > chunk_size { - in_filled = (*thr).in_pos.wrapping_add(chunk_size); + if in_filled - (*thr).in_pos > chunk_size { + in_filled = (*thr).in_pos + chunk_size; } ret = (*thr).block_decoder.code.unwrap()( (*thr).block_decoder.coder, @@ -216,12 +216,8 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { { let mut mythread_j_458: c_uint = 0; while mythread_j_458 == 0 { - (*(*thr).coder).progress_in = (*(*thr).coder) - .progress_in - .wrapping_add((*thr).in_pos as u64); - (*(*thr).coder).progress_out = (*(*thr).coder) - .progress_out - .wrapping_add((*thr).out_pos as u64); + (*(*thr).coder).progress_in += (*thr).in_pos as u64; + (*(*thr).coder).progress_out += (*thr).out_pos as u64; (*thr).progress_in = 0; (*thr).progress_out = 0; (*(*thr).outbuf).pos = (*thr).out_pos; @@ -233,13 +229,9 @@ unsafe extern "C" fn worker_decoder(thr_ptr: *mut c_void) -> *mut c_void { (*(*thr).coder).thread_error = ret; } if ret == LZMA_STREAM_END { - (*(*thr).coder).mem_in_use = (*(*thr).coder) - .mem_in_use - .wrapping_sub((*thr).in_size as u64); - (*(*thr).coder).mem_in_use = - (*(*thr).coder).mem_in_use.wrapping_sub((*thr).mem_filters); - (*(*thr).coder).mem_cached = - (*(*thr).coder).mem_cached.wrapping_add((*thr).mem_filters); + (*(*thr).coder).mem_in_use -= (*thr).in_size as u64; + (*(*thr).coder).mem_in_use -= (*thr).mem_filters; + (*(*thr).coder).mem_cached += (*thr).mem_filters; (*thr).next = (*(*thr).coder).threads_free; (*(*thr).coder).threads_free = thr; } @@ -363,7 +355,7 @@ unsafe fn initialize_new_thread( { mythread_cond_destroy(::core::ptr::addr_of_mut!((*thr).cond)); } else { - (*coder).threads_initialized = (*coder).threads_initialized.wrapping_add(1); + (*coder).threads_initialized += 1; (*coder).thr = thr; return LZMA_OK; } @@ -372,10 +364,7 @@ unsafe fn initialize_new_thread( } LZMA_MEM_ERROR } -unsafe fn get_thread( - coder: *mut lzma_stream_coder, - allocator: *const lzma_allocator, -) -> lzma_ret { +unsafe fn get_thread(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) -> lzma_ret { let mut mythread_i_608: c_uint = 0; while if mythread_i_608 != 0 { mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); @@ -390,9 +379,7 @@ unsafe fn get_thread( if !(*coder).threads_free.is_null() { (*coder).thr = (*coder).threads_free; (*coder).threads_free = (*(*coder).threads_free).next; - (*coder).mem_cached = (*coder) - .mem_cached - .wrapping_sub((*(*coder).thr).mem_filters); + (*coder).mem_cached -= (*(*coder).thr).mem_filters; } mythread_j_608 = 1; } @@ -476,10 +463,7 @@ unsafe fn read_output_and_wait( } } if !input_is_possible.is_null() - && (*coder) - .memlimit_threading - .wrapping_sub((*coder).mem_in_use) - .wrapping_sub((*coder).outq.mem_in_use) + && (*coder).memlimit_threading - (*coder).mem_in_use - (*coder).outq.mem_in_use >= (*coder).mem_next_block && lzma_outq_has_buf(::core::ptr::addr_of_mut!((*coder).outq)) && ((*coder).threads_initialized < (*coder).threads_max @@ -554,9 +538,7 @@ unsafe fn decode_block_header( if *in_0.offset(*in_pos as isize) == INDEX_INDICATOR { return LZMA_RET_INTERNAL2; } - (*coder).block_options.header_size = (*in_0.offset(*in_pos as isize) as u32) - .wrapping_add(1) - .wrapping_mul(4); + (*coder).block_options.header_size = ((*in_0.offset(*in_pos as isize) as u32) + 1) * 4; } lzma_bufcpy( in_0, @@ -586,9 +568,8 @@ unsafe fn decode_block_header( } extern "C" fn comp_blk_size(coder: *const lzma_stream_coder) -> size_t { unsafe { - vli_ceil4((*coder).block_options.compressed_size) - .wrapping_add(lzma_check_size((*coder).stream_flags.check) as lzma_vli) - as size_t + (vli_ceil4((*coder).block_options.compressed_size) + + lzma_check_size((*coder).stream_flags.check) as lzma_vli) as size_t } } extern "C" fn is_direct_mode_needed(size: lzma_vli) -> bool { @@ -639,9 +620,7 @@ unsafe extern "C" fn stream_decode_mt( ::core::ptr::addr_of_mut!((*coder).pos), LZMA_STREAM_HEADER_SIZE as size_t, ); - (*coder).progress_in = (*coder) - .progress_in - .wrapping_add((*in_pos).wrapping_sub(in_old) as u64); + (*coder).progress_in += (*in_pos - in_old) as u64; if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { return LZMA_OK; } @@ -794,12 +773,8 @@ unsafe extern "C" fn stream_decode_mt( out_size, action, ); - (*coder).progress_in = (*coder) - .progress_in - .wrapping_add((*in_pos).wrapping_sub(in_old_1) as u64); - (*coder).progress_out = (*coder) - .progress_out - .wrapping_add((*out_pos).wrapping_sub(out_old) as u64); + (*coder).progress_in += (*in_pos - in_old_1) as u64; + (*coder).progress_out += (*out_pos - out_old) as u64; if ret_4 != LZMA_STREAM_END { return ret_4; } @@ -817,9 +792,7 @@ unsafe extern "C" fn stream_decode_mt( 7149356873433890176 => { let in_old_0: size_t = *in_pos; let ret_0: lzma_ret = decode_block_header(coder, allocator, in_0, in_pos, in_size); - (*coder).progress_in = (*coder) - .progress_in - .wrapping_add((*in_pos).wrapping_sub(in_old_0) as u64); + (*coder).progress_in += (*in_pos - in_old_0) as u64; if ret_0 == LZMA_OK { if action == LZMA_FINISH && (*coder).fail_fast { threads_stop(coder); @@ -873,9 +846,7 @@ unsafe extern "C" fn stream_decode_mt( let in_old_2: size_t = *in_pos; let ret_5: lzma_ret = lzma_index_hash_decode((*coder).index_hash, in_0, in_pos, in_size); - (*coder).progress_in = (*coder) - .progress_in - .wrapping_add((*in_pos).wrapping_sub(in_old_2) as u64); + (*coder).progress_in += (*in_pos - in_old_2) as u64; if ret_5 != LZMA_STREAM_END { return ret_5; } @@ -913,16 +884,15 @@ unsafe extern "C" fn stream_decode_mt( current_block_239 = 11639917216603986996; } else { (*coder).mem_next_in = comp_blk_size(coder) as u64; - let mem_buffers: u64 = - (*coder).mem_next_in.wrapping_add(lzma_outq_outbuf_memusage( + let mem_buffers: u64 = (*coder).mem_next_in + + lzma_outq_outbuf_memusage( (*coder).block_options.uncompressed_size as size_t, - ) as u64); + ) as u64; if (UINT64_MAX).wrapping_sub(mem_buffers) < (*coder).mem_next_filters { (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; current_block_239 = 11639917216603986996; } else { - (*coder).mem_next_block = - (*coder).mem_next_filters.wrapping_add(mem_buffers); + (*coder).mem_next_block = (*coder).mem_next_filters + mem_buffers; if (*coder).mem_next_block > (*coder).memlimit_threading { (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; current_block_239 = 11639917216603986996; @@ -961,9 +931,7 @@ unsafe extern "C" fn stream_decode_mt( ::core::ptr::addr_of_mut!((*coder).pos), LZMA_STREAM_HEADER_SIZE as size_t, ); - (*coder).progress_in = (*coder) - .progress_in - .wrapping_add((*in_pos).wrapping_sub(in_old_3) as u64); + (*coder).progress_in += (*in_pos - in_old_3) as u64; if (*coder).pos < LZMA_STREAM_HEADER_SIZE as size_t { return LZMA_OK; } @@ -1032,13 +1000,13 @@ unsafe extern "C" fn stream_decode_mt( if *in_0.offset(*in_pos as isize) != 0 { break; } - *in_pos = (*in_pos).wrapping_add(1); - (*coder).progress_in = (*coder).progress_in.wrapping_add(1); - (*coder).pos = (*coder).pos.wrapping_add(1) & 3; + *in_pos += 1; + (*coder).progress_in += 1; + (*coder).pos = ((*coder).pos + 1) & 3; } if (*coder).pos != 0 { - *in_pos = (*in_pos).wrapping_add(1); - (*coder).progress_in = (*coder).progress_in.wrapping_add(1); + *in_pos += 1; + (*coder).progress_in += 1; return LZMA_DATA_ERROR; } let ret__7: lzma_ret = stream_decoder_reset(coder, allocator); @@ -1091,14 +1059,8 @@ unsafe extern "C" fn stream_decode_mt( } mythread_i_1347 = 1; } - let mem_max: u64 = (*coder) - .memlimit_threading - .wrapping_sub((*coder).mem_next_block); - if mem_in_use - .wrapping_add(mem_cached) - .wrapping_add((*coder).outq.mem_allocated) - > mem_max - { + let mem_max: u64 = (*coder).memlimit_threading - (*coder).mem_next_block; + if mem_in_use + mem_cached + (*coder).outq.mem_allocated > mem_max { lzma_outq_clear_cache2( ::core::ptr::addr_of_mut!((*coder).outq), allocator, @@ -1107,10 +1069,7 @@ unsafe extern "C" fn stream_decode_mt( } let mut mem_freed: u64 = 0; if !thr.is_null() - && mem_in_use - .wrapping_add(mem_cached) - .wrapping_add((*coder).outq.mem_in_use) - > mem_max + && mem_in_use + mem_cached + (*coder).outq.mem_in_use > mem_max { if (*thr).mem_filters <= (*coder).mem_next_filters { thr = (*thr).next; @@ -1120,7 +1079,7 @@ unsafe extern "C" fn stream_decode_mt( ::core::ptr::addr_of_mut!((*thr).block_decoder), allocator, ); - mem_freed = mem_freed.wrapping_add((*thr).mem_filters); + mem_freed += (*thr).mem_filters; (*thr).mem_filters = 0; thr = (*thr).next; } @@ -1136,10 +1095,8 @@ unsafe extern "C" fn stream_decode_mt( { let mut mythread_j_1410: c_uint = 0; while mythread_j_1410 == 0 { - (*coder).mem_cached = (*coder).mem_cached.wrapping_sub(mem_freed); - (*coder).mem_in_use = (*coder).mem_in_use.wrapping_add( - (*coder).mem_next_in.wrapping_add((*coder).mem_next_filters), - ); + (*coder).mem_cached -= mem_freed; + (*coder).mem_in_use += (*coder).mem_next_in + (*coder).mem_next_filters; mythread_j_1410 = 1; } mythread_i_1410 = 1; @@ -1238,10 +1195,8 @@ unsafe extern "C" fn stream_decode_mt( match current_block_239 { 7728257318064351663 => { if action == LZMA_FINISH && (*coder).fail_fast { - let in_avail: size_t = in_size.wrapping_sub(*in_pos); - let in_needed: size_t = (*(*coder).thr) - .in_size - .wrapping_sub((*(*coder).thr).in_filled); + let in_avail: size_t = in_size - *in_pos; + let in_needed: size_t = (*(*coder).thr).in_size - (*(*coder).thr).in_filled; if in_avail < in_needed { threads_stop(coder); return LZMA_DATA_ERROR; @@ -1340,11 +1295,10 @@ unsafe extern "C" fn stream_decoder_mt_memconfig( { let mut mythread_j_1829: c_uint = 0; while mythread_j_1829 == 0 { - *memusage = (*coder) - .mem_direct_mode - .wrapping_add((*coder).mem_in_use) - .wrapping_add((*coder).mem_cached) - .wrapping_add((*coder).outq.mem_allocated); + *memusage = (*coder).mem_direct_mode + + (*coder).mem_in_use + + (*coder).mem_cached + + (*coder).outq.mem_allocated; mythread_j_1829 = 1; } mythread_i_1829 = 1; @@ -1397,12 +1351,8 @@ unsafe extern "C" fn stream_decoder_mt_get_progress( { let mut mythread_j_1867: c_uint = 0; while mythread_j_1867 == 0 { - *progress_in = (*progress_in).wrapping_add( - (*(*coder).threads.offset(i as isize)).progress_in as u64, - ); - *progress_out = (*progress_out).wrapping_add( - (*(*coder).threads.offset(i as isize)).progress_out as u64, - ); + *progress_in += (*(*coder).threads.offset(i as isize)).progress_in as u64; + *progress_out += (*(*coder).threads.offset(i as isize)).progress_out as u64; mythread_j_1867 = 1; } mythread_i_1867 = 1; @@ -1578,10 +1528,7 @@ unsafe extern "C" fn stream_decoder_mt_init( } stream_decoder_reset(coder, allocator) } -pub unsafe fn lzma_stream_decoder_mt( - strm: *mut lzma_stream, - options: *const lzma_mt, -) -> lzma_ret { +pub unsafe fn lzma_stream_decoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 49260e59..d1b41c45 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -170,8 +170,8 @@ unsafe fn worker_encode( }) as lzma_action; static mut in_chunk_max: size_t = 16384; let mut in_limit: size_t = in_size; - if in_size.wrapping_sub(in_pos) > in_chunk_max { - in_limit = in_pos.wrapping_add(in_chunk_max); + if in_size - in_pos > in_chunk_max { + in_limit = in_pos + in_chunk_max; action = LZMA_RUN; } ret = (*thr).block_encoder.code.unwrap()( @@ -325,11 +325,8 @@ unsafe extern "C" fn worker_start(thr_ptr: *mut c_void) -> *mut c_void { (*(*thr).outbuf).pos = out_pos; (*(*thr).outbuf).finished = true; } - (*(*thr).coder).progress_in = (*(*thr).coder) - .progress_in - .wrapping_add((*(*thr).outbuf).uncompressed_size as u64); - (*(*thr).coder).progress_out = - (*(*thr).coder).progress_out.wrapping_add(out_pos as u64); + (*(*thr).coder).progress_in += (*(*thr).outbuf).uncompressed_size as u64; + (*(*thr).coder).progress_out += out_pos as u64; (*thr).progress_in = 0; (*thr).progress_out = 0; (*thr).next = (*(*thr).coder).threads_free; @@ -489,7 +486,7 @@ unsafe fn initialize_new_thread( { mythread_cond_destroy(::core::ptr::addr_of_mut!((*thr).cond)); } else { - (*coder).threads_initialized = (*coder).threads_initialized.wrapping_add(1); + (*coder).threads_initialized += 1; (*coder).thr = thr; return LZMA_OK; } @@ -499,10 +496,7 @@ unsafe fn initialize_new_thread( crate::alloc::internal_free((*thr).in_0 as *mut c_void, allocator); LZMA_MEM_ERROR } -unsafe fn get_thread( - coder: *mut lzma_stream_coder, - allocator: *const lzma_allocator, -) -> lzma_ret { +unsafe fn get_thread(coder: *mut lzma_stream_coder, allocator: *const lzma_allocator) -> lzma_ret { if !lzma_outq_has_buf(::core::ptr::addr_of_mut!((*coder).outq)) { return LZMA_OK; } @@ -844,10 +838,8 @@ unsafe extern "C" fn stream_encode_mt( return ret_; } (*coder).sequence = SEQ_INDEX; - (*coder).progress_out = (*coder).progress_out.wrapping_add( - lzma_index_size((*coder).index).wrapping_add(LZMA_STREAM_HEADER_SIZE as lzma_vli) - as u64, - ); + (*coder).progress_out += + (lzma_index_size((*coder).index) + LZMA_STREAM_HEADER_SIZE as lzma_vli) as u64; current_block_53 = 7301844830188010456; } if current_block_53 == 7301844830188010456 { @@ -1024,10 +1016,8 @@ unsafe extern "C" fn get_progress( { let mut mythread_j_1015: c_uint = 0; while mythread_j_1015 == 0 { - *progress_in = (*progress_in) - .wrapping_add((*(*coder).threads.offset(i as isize)).progress_in); - *progress_out = (*progress_out) - .wrapping_add((*(*coder).threads.offset(i as isize)).progress_out); + *progress_in += (*(*coder).threads.offset(i as isize)).progress_in; + *progress_out += (*(*coder).threads.offset(i as isize)).progress_out; mythread_j_1015 = 1; } mythread_i_1015 = 1; @@ -1271,10 +1261,7 @@ unsafe extern "C" fn stream_encoder_mt_init( (*coder).progress_out = LZMA_STREAM_HEADER_SIZE as u64; LZMA_OK } -pub unsafe fn lzma_stream_encoder_mt( - strm: *mut lzma_stream, - options: *const lzma_mt, -) -> lzma_ret { +pub unsafe fn lzma_stream_encoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret { let ret_: lzma_ret = lzma_strm_init(strm); if ret_ != LZMA_OK { return ret_; diff --git a/liblzma-rs/src/common/string_conversion.rs b/liblzma-rs/src/common/string_conversion.rs index 635e2240..b78093f9 100644 --- a/liblzma-rs/src/common/string_conversion.rs +++ b/liblzma-rs/src/common/string_conversion.rs @@ -94,14 +94,14 @@ unsafe fn str_finish( } unsafe fn str_append_str(str: *mut lzma_str, s: *const c_char) { let len: size_t = strlen(s) as size_t; - let limit: size_t = ((STR_ALLOC_SIZE - 1) as size_t).wrapping_sub((*str).pos); + let limit: size_t = (STR_ALLOC_SIZE - 1) as size_t - (*str).pos; let copy_size: size_t = if len < limit { len } else { limit }; core::ptr::copy_nonoverlapping( s as *const u8, (*str).buf.offset((*str).pos as isize) as *mut u8, copy_size, ); - (*str).pos = (*str).pos.wrapping_add(copy_size); + (*str).pos += copy_size; } unsafe fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) { if v == 0 { @@ -119,9 +119,8 @@ unsafe fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) if use_byte_suffix { while v & 1023 == 0 && suf - < (core::mem::size_of::<[[c_char; 4]; 4]>()) - .wrapping_div(core::mem::size_of::<[c_char; 4]>()) - .wrapping_sub(1) + < core::mem::size_of::<[[c_char; 4]; 4]>() / core::mem::size_of::<[c_char; 4]>() + - 1 { v >>= 10; suf += 1; @@ -129,11 +128,11 @@ unsafe fn str_append_u32(str: *mut lzma_str, mut v: u32, use_byte_suffix: bool) } let mut buf: [c_char; 16] = core::mem::transmute::<[u8; 16], [c_char; 16]>(*b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); - let mut pos: size_t = (core::mem::size_of::<[c_char; 16]>()).wrapping_sub(1); + let mut pos: size_t = core::mem::size_of::<[c_char; 16]>() - 1; loop { pos -= 1; - buf[pos as usize] = ('0' as i32 as u32).wrapping_add(v.wrapping_rem(10)) as c_char; - v = v.wrapping_div(10); + buf[pos as usize] = ('0' as i32 as u32 + v % 10) as c_char; + v /= 10; if v == 0 { break; } @@ -174,8 +173,7 @@ extern "C" fn parse_bcj( str_end, filter_options, ::core::ptr::addr_of!(bcj_optmap) as *const option_map, - (core::mem::size_of::<[option_map; 1]>()) - .wrapping_div(core::mem::size_of::()), + core::mem::size_of::<[option_map; 1]>() / core::mem::size_of::(), ) }; } @@ -321,7 +319,7 @@ unsafe extern "C" fn parse_lzma12( str_end, filter_options, ::core::ptr::addr_of!(lzma12_optmap) as *const option_map, - (core::mem::size_of::<[option_map; 9]>()).wrapping_div(core::mem::size_of::()), + core::mem::size_of::<[option_map; 9]>() / core::mem::size_of::(), ); if !errmsg.is_null() { return errmsg; @@ -717,9 +715,8 @@ unsafe fn parse_filter( return crate::c_str!("Unknown filter name"); } let mut i: size_t = 0; - while i - < (core::mem::size_of::<[filter_codec_def; 11]>()) - .wrapping_div(core::mem::size_of::()) + while i < core::mem::size_of::<[filter_codec_def; 11]>() + / core::mem::size_of::() { if memcmp( *str as *const c_void, @@ -891,8 +888,7 @@ unsafe fn str_to_filters( core::ptr::copy_nonoverlapping( ::core::ptr::addr_of_mut!(temp_filters) as *const u8, filters as *mut u8, - i_0.wrapping_add(1) - .wrapping_mul(core::mem::size_of::()), + (i_0 + 1) * core::mem::size_of::(), ); return core::ptr::null(); } @@ -902,7 +898,7 @@ unsafe fn str_to_filters( } loop { let old_i = i_0; - i_0 = i_0.wrapping_sub(1); + i_0 -= 1; if old_i == 0 { break; } diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index d9f7fb77..37542652 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -5,11 +5,7 @@ pub const HASH_3_MASK: c_uint = HASH_3_SIZE.wrapping_sub(1); pub const FIX_3_HASH_SIZE: c_uint = 1u32 << 10; pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); #[inline] -pub unsafe fn lzma_mf_find( - mf: *mut lzma_mf, - count_ptr: *mut u32, - matches: *mut lzma_match, -) -> u32 { +pub unsafe fn lzma_mf_find(mf: *mut lzma_mf, count_ptr: *mut u32, matches: *mut lzma_match) -> u32 { let count: u32 = (*mf).find.unwrap()(mf, matches) as u32; let mut len_best: u32 = 0; if count > 0 { diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 246c82d0..3bf8b4d1 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -78,18 +78,18 @@ unsafe fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { *(*dict).buf.offset( (*dict) .pos - .wrapping_sub(distance as size_t) - .wrapping_sub(1) - .wrapping_add(if (distance as size_t) < (*dict).pos { + - (distance as size_t) + - (1) + + (if (distance as size_t) < (*dict).pos { 0 } else { - (*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t) + (*dict).size - LZ_DICT_REPEAT_MAX as size_t }) as isize, ) } #[inline] unsafe fn dict_get0(dict: *const lzma_dict) -> u8 { - *(*dict).buf.offset((*dict).pos.wrapping_sub(1) as isize) + *(*dict).buf.offset((*dict).pos - 1 as isize) } #[inline] unsafe fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bool { @@ -97,22 +97,22 @@ unsafe fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bo } #[inline] unsafe fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut u32) -> bool { - let dict_avail: size_t = (*dict).limit.wrapping_sub((*dict).pos); + let dict_avail: size_t = (*dict).limit - (*dict).pos; let mut left: u32 = (if dict_avail < *len as size_t { dict_avail } else { *len as size_t }) as u32; - *len = (*len).wrapping_sub(left); - let mut back: size_t = (*dict).pos.wrapping_sub(distance as size_t).wrapping_sub(1); + *len -= left; + let mut back: size_t = (*dict).pos - distance as size_t - 1; if distance as size_t >= (*dict).pos { - back = back.wrapping_add((*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t)); + back = back + ((*dict).size - LZ_DICT_REPEAT_MAX as size_t); } if distance < left { loop { *(*dict).buf.offset((*dict).pos as isize) = *(*dict).buf.offset(back as isize); back += 1; - (*dict).pos = (*dict).pos.wrapping_add(1); + (*dict).pos = (*dict).pos + 1; left -= 1; if left == 0 { break; @@ -124,19 +124,19 @@ unsafe fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut u32) -> boo (*dict).buf.offset((*dict).pos as isize) as *mut u8, left as size_t, ); - (*dict).pos = (*dict).pos.wrapping_add(left as size_t); + (*dict).pos = (*dict).pos + left as size_t; } if !(*dict).has_wrapped { - (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); + (*dict).full = (*dict).pos - LZ_DICT_INIT_POS as size_t; } *len != 0 } #[inline] unsafe fn dict_put(dict: *mut lzma_dict, byte: u8) { *(*dict).buf.offset((*dict).pos as isize) = byte; - (*dict).pos = (*dict).pos.wrapping_add(1); + (*dict).pos = (*dict).pos + 1; if !(*dict).has_wrapped { - (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); + (*dict).full = (*dict).pos - LZ_DICT_INIT_POS as size_t; } } #[inline] @@ -163,8 +163,8 @@ unsafe fn rc_read_init( return LZMA_DATA_ERROR; } (*rc).code = (*rc).code << 8 | *in_0.offset(*in_pos as isize) as u32; - *in_pos = (*in_pos).wrapping_add(1); - (*rc).init_bytes_left = (*rc).init_bytes_left.wrapping_sub(1); + *in_pos += 1; + (*rc).init_bytes_left -= 1; } LZMA_STREAM_END } @@ -215,9 +215,9 @@ unsafe extern "C" fn lzma_decode( let mut eopm_is_valid: bool = (*coder).uncompressed_size == LZMA_VLI_UNKNOWN; let mut might_finish_without_eopm: bool = false; if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN - && (*coder).uncompressed_size <= dict.limit.wrapping_sub(dict.pos) as lzma_vli + && (*coder).uncompressed_size <= dict.limit - dict.pos as lzma_vli { - dict.limit = dict.pos.wrapping_add((*coder).uncompressed_size as size_t); + dict.limit = dict.pos + (*coder).uncompressed_size as size_t; might_finish_without_eopm = true; } match (*coder).sequence { @@ -310,14 +310,13 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).rep_len_decoder.choice as u32); + * ((*coder).rep_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).rep_len_decoder.choice as u32) - >> RC_MOVE_BITS, - ) as probability; + (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.choice as u32) + >> RC_MOVE_BITS + )) as probability; probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( (*coder).rep_len_decoder.low ) @@ -327,8 +326,8 @@ unsafe extern "C" fn lzma_decode( limit = LEN_LOW_SYMBOLS; len = MATCH_LEN_MIN; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.choice = (*coder).rep_len_decoder.choice - ((*coder).rep_len_decoder.choice >> RC_MOVE_BITS); current_block = 6834592846991627977; @@ -349,22 +348,20 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep2[state as usize] as u32); + * ((*coder).is_rep2[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep2[state as usize] as u32) - >> RC_MOVE_BITS, - ) as probability; + (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep2[state as usize] as u32) + >> RC_MOVE_BITS + )) as probability; let distance_3: u32 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance_3; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep2[state as usize] = (*coder).is_rep2[state as usize] - ((*coder).is_rep2[state as usize] >> RC_MOVE_BITS); let distance_4: u32 = rep3; @@ -388,21 +385,19 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep1[state as usize] as u32); + * ((*coder).is_rep1[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep1[state as usize] as u32) - >> RC_MOVE_BITS, - ) as probability; + (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep1[state as usize] as u32) + >> RC_MOVE_BITS + )) as probability; let distance_2: u32 = rep1; rep1 = rep0; rep0 = distance_2; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep1[state as usize] = (*coder).is_rep1[state as usize] - ((*coder).is_rep1[state as usize] >> RC_MOVE_BITS); current_block = 3996983927318648760; @@ -435,17 +430,16 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep0_long[state as usize][pos_state as usize] as u32); + * ((*coder).is_rep0_long[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0_long[state as usize][pos_state as usize] = - ((*coder).is_rep0_long[state as usize][pos_state as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).is_rep0_long[state as usize][pos_state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep0_long[state as usize][pos_state as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; state = (if state < LIT_STATES { STATE_LIT_SHORTREP } else { @@ -454,8 +448,8 @@ unsafe extern "C" fn lzma_decode( current_block = 5341942013764523046; continue; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep0_long[state as usize][pos_state as usize] = (*coder) .is_rep0_long[state as usize][pos_state as usize] - ((*coder).is_rep0_long[state as usize][pos_state as usize] @@ -476,20 +470,18 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep0[state as usize] as u32); + * ((*coder).is_rep0[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep0[state as usize] as u32) - >> RC_MOVE_BITS, - ) as probability; + (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep0[state as usize] as u32) + >> RC_MOVE_BITS + )) as probability; current_block = 1698084742280242340; continue; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep0[state as usize] = (*coder).is_rep0[state as usize] - ((*coder).is_rep0[state as usize] >> RC_MOVE_BITS); current_block = 11808118301119257848; @@ -509,14 +501,13 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep[state as usize] as u32); + * ((*coder).is_rep[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).is_rep[state as usize] as u32) - >> RC_MOVE_BITS, - ) as probability; + (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep[state as usize] as u32) + >> RC_MOVE_BITS + )) as probability; state = (if state < LIT_STATES { STATE_LIT_MATCH } else { @@ -528,8 +519,8 @@ unsafe extern "C" fn lzma_decode( current_block = 1138292997408115650; continue; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); if dict_is_distance_valid(::core::ptr::addr_of_mut!(dict), 0) { @@ -574,31 +565,30 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32); + * ((*coder).pos_align[offset + symbol as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[offset.wrapping_add(symbol) as usize] = - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability; + (*coder).pos_align[offset + symbol as usize] = + ((*coder).pos_align[offset + symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - + (*coder).pos_align[offset + symbol as usize] as u32, + ) >> RC_MOVE_BITS + )) as probability; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[offset.wrapping_add(symbol) as usize] = (*coder).pos_align - [offset.wrapping_add(symbol) as usize] - - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] + rc.range -= rc_bound; + rc.code -= rc_bound; + (*coder).pos_align[offset + symbol as usize] = (*coder).pos_align + [offset + symbol as usize] + - ((*coder).pos_align[offset + symbol as usize] >> RC_MOVE_BITS); - symbol = symbol.wrapping_add(offset); + symbol += offset; } offset <<= 1; if offset < ALIGN_SIZE { current_block = 10510472849010538284; continue; } - rep0 = rep0.wrapping_add(symbol); + rep0 += symbol; if rep0 == UINT32_MAX { current_block = 12043253436139097694; } else { @@ -621,7 +611,7 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code.wrapping_sub(rc.range); rc_bound = 0u32.wrapping_sub(rc.code >> 31); rc.code = rc.code.wrapping_add(rc.range & rc_bound); - rep0 = (rep0 << 1).wrapping_add(rc_bound.wrapping_add(1)); + rep0 = (rep0 << 1) + (rc_bound.wrapping_add(1)); limit -= 1; if limit > 0 { current_block = 15418612220330286504; @@ -646,22 +636,21 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); - rep0 = (rep0 as u32).wrapping_add(1u32 << offset) as u32; + symbol = (symbol << 1) | 1; + rep0 += 1u32 << offset; } offset += 1; if offset < limit { @@ -683,32 +672,31 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if symbol < DIST_SLOTS { current_block = 4174862988780014241; continue; } - symbol = symbol.wrapping_sub(DIST_SLOTS); + symbol -= DIST_SLOTS; if symbol < DIST_MODEL_START { rep0 = symbol; } else { - limit = (symbol >> 1).wrapping_sub(1); - rep0 = (2u32).wrapping_add(symbol & 1); + limit = (symbol >> 1) - 1; + rep0 = 2 + (symbol & 1); if symbol < DIST_MODEL_END { rep0 <<= limit; probs = (::core::ptr::addr_of_mut!((*coder).pos_special) @@ -721,7 +709,7 @@ unsafe extern "C" fn lzma_decode( current_block = 617447976488552541; continue; } else { - limit = limit.wrapping_sub(ALIGN_BITS); + limit -= ALIGN_BITS; current_block = 15418612220330286504; continue; } @@ -741,32 +729,31 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if symbol < limit { current_block = 592696588731961849; continue; } - len = len.wrapping_add(symbol.wrapping_sub(limit)); + len += (symbol - limit); probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).dist_slot) as *mut [probability; 64]) .offset( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN) + len - MATCH_LEN_MIN } else { (DIST_STATES - 1) as u32 }) as isize, @@ -788,15 +775,13 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).match_len_decoder.choice2 as u32); + * ((*coder).match_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice2 = ((*coder).match_len_decoder.choice2 as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).match_len_decoder.choice2 as u32) - >> RC_MOVE_BITS, - ) as probability; + (*coder).match_len_decoder.choice2 = ((*coder).match_len_decoder.choice2 as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.choice2 as u32) + >> RC_MOVE_BITS + )) as probability; probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( (*coder).match_len_decoder.mid ) @@ -806,8 +791,8 @@ unsafe extern "C" fn lzma_decode( limit = LEN_MID_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.choice2 = (*coder).match_len_decoder.choice2 - ((*coder).match_len_decoder.choice2 >> RC_MOVE_BITS); probs = ::core::ptr::addr_of_mut!((*coder).match_len_decoder.high) @@ -830,15 +815,13 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).match_len_decoder.choice as u32); + * ((*coder).match_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).match_len_decoder.choice as u32) - >> RC_MOVE_BITS, - ) as probability; + (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.choice as u32) + >> RC_MOVE_BITS + )) as probability; probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( (*coder).match_len_decoder.low ) @@ -848,8 +831,8 @@ unsafe extern "C" fn lzma_decode( limit = LEN_LOW_SYMBOLS; len = MATCH_LEN_MIN; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.choice = (*coder).match_len_decoder.choice - ((*coder).match_len_decoder.choice >> RC_MOVE_BITS); current_block = 13912927785247575907; @@ -868,7 +851,7 @@ unsafe extern "C" fn lzma_decode( } 18125716024132132232 => { let match_bit: u32 = len & offset; - let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol); + let subcoder_index: u32 = offset + match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_LITERAL_MATCHED; @@ -881,23 +864,22 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(subcoder_index as isize) as u32); + * (*probs.offset(subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(subcoder_index as isize) = - (*probs.offset(subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(subcoder_index as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(subcoder_index as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; offset &= !match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(subcoder_index as isize) -= *probs.offset(subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; offset &= match_bit; } len <<= 1; @@ -946,23 +928,20 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); + * ((*coder).is_match[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_match[state as usize][pos_state as usize] = ((*coder).is_match [state as usize][pos_state as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_match[state as usize][pos_state as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; probs = (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability) .offset( - (3_usize).wrapping_mul( - ((dict.pos << 8).wrapping_add( + 3 * ( + ((dict.pos << 8) + ( dict_get0(::core::ptr::addr_of_mut!(dict)) as size_t, ) & literal_mask as size_t) << literal_context_bits, @@ -973,15 +952,15 @@ unsafe extern "C" fn lzma_decode( state = if state <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT } else { - state.wrapping_sub(3) + state - 3 }; current_block = 13844743919235296534; continue; } else { state = if state <= STATE_LIT_SHORTREP { - state.wrapping_sub(3) + state - 3 } else { - state.wrapping_sub(6) + state - 6 }; len = (dict_get(::core::ptr::addr_of_mut!(dict), rep0) as u32) << 1; offset = 0x100; @@ -989,8 +968,8 @@ unsafe extern "C" fn lzma_decode( continue; } } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_match[state as usize][pos_state as usize] = (*coder).is_match [state as usize][pos_state as usize] - ((*coder).is_match[state as usize][pos_state as usize] >> RC_MOVE_BITS); @@ -1011,21 +990,20 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if symbol < (1 << 8) as u32 { current_block = 13844743919235296534; @@ -1048,27 +1026,26 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if symbol < limit { current_block = 2467942631393454738; continue; } - len = len.wrapping_add(symbol.wrapping_sub(limit)); + len += (symbol - limit); current_block = 17340485688450593529; continue; } @@ -1098,15 +1075,13 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).rep_len_decoder.choice2 as u32); + * ((*coder).rep_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).rep_len_decoder.choice2 as u32) - >> RC_MOVE_BITS, - ) as probability; + (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.choice2 as u32) + >> RC_MOVE_BITS + )) as probability; probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( (*coder).rep_len_decoder.mid ) @@ -1116,8 +1091,8 @@ unsafe extern "C" fn lzma_decode( limit = LEN_MID_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.choice2 = (*coder).rep_len_decoder.choice2 - ((*coder).rep_len_decoder.choice2 >> RC_MOVE_BITS); probs = ::core::ptr::addr_of_mut!((*coder).rep_len_decoder.high) @@ -1150,23 +1125,20 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); + * ((*coder).is_match[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_match[state as usize][pos_state as usize] = ((*coder).is_match [state as usize][pos_state as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_match[state as usize][pos_state as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; probs = (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability) .offset( - (3_usize).wrapping_mul( - ((dict.pos << 8).wrapping_add( + 3 * ( + ((dict.pos << 8) + ( dict_get0(::core::ptr::addr_of_mut!(dict)) as size_t, ) & literal_mask as size_t) << literal_context_bits, @@ -1176,7 +1148,7 @@ unsafe extern "C" fn lzma_decode( state = if state <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT } else { - state.wrapping_sub(3) + state - 3 }; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -1185,22 +1157,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1208,22 +1179,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1231,22 +1201,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1254,22 +1223,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1277,22 +1245,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1300,22 +1267,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1323,22 +1289,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1346,28 +1311,27 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } } else { state = if state <= STATE_LIT_SHORTREP { - state.wrapping_sub(3) + state - 3 } else { - state.wrapping_sub(6) + state - 6 }; let mut t_match_byte: u32 = dict_get(::core::ptr::addr_of_mut!(dict), rep0) as u32; @@ -1377,233 +1341,233 @@ unsafe extern "C" fn lzma_decode( symbol = 1; t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + t_subcoder_index = t_offset + t_match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + * (*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(t_subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + t_subcoder_index = t_offset + t_match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + * (*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(t_subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + t_subcoder_index = t_offset + t_match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + * (*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(t_subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + t_subcoder_index = t_offset + t_match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + * (*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(t_subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + t_subcoder_index = t_offset + t_match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + * (*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(t_subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + t_subcoder_index = t_offset + t_match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + * (*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(t_subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + t_subcoder_index = t_offset + t_match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + * (*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(t_subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); + t_subcoder_index = t_offset + t_match_bit + symbol; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); + * (*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(t_subcoder_index as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS, - ) as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; t_offset &= t_match_bit; } } dict_put(::core::ptr::addr_of_mut!(dict), symbol as u8); } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_match[state as usize][pos_state as usize] = (*coder).is_match [state as usize][pos_state as usize] - ((*coder).is_match[state as usize][pos_state as usize] >> RC_MOVE_BITS); @@ -1613,15 +1577,14 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep[state as usize] as u32); + * ((*coder).is_rep[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep[state as usize] = - ((*coder).is_rep[state as usize] as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep[state as usize] as u32) - >> RC_MOVE_BITS, - ) as probability; + ((*coder).is_rep[state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep[state as usize] as u32) + >> RC_MOVE_BITS + )) as probability; state = (if state < LIT_STATES { STATE_LIT_MATCH } else { @@ -1637,129 +1600,119 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).match_len_decoder.choice as u32); + * ((*coder).match_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.choice = - ((*coder).match_len_decoder.choice as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).match_len_decoder.choice as u32) - >> RC_MOVE_BITS, - ) as probability; + ((*coder).match_len_decoder.choice as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.choice as u32) + >> RC_MOVE_BITS + )) as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } - symbol = symbol.wrapping_add((-(1_i32 << 3) + 2) as u32); + symbol = symbol + ((-(1_i32 << 3) + 2) as u32); len = symbol; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.choice = (*coder).match_len_decoder.choice - ((*coder).match_len_decoder.choice >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { @@ -1768,15 +1721,15 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).match_len_decoder.choice2 as u32); + * ((*coder).match_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.choice2 = - ((*coder).match_len_decoder.choice2 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.choice2 as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.choice2 as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -1784,10 +1737,10 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -1795,20 +1748,17 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] @@ -1816,17 +1766,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -1834,20 +1784,17 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] @@ -1855,17 +1802,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -1873,20 +1820,17 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] @@ -1894,13 +1838,13 @@ unsafe extern "C" fn lzma_decode( - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } - symbol = symbol.wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); + symbol = symbol + ((-(1_i32 << 3) + 2 + (1 << 3)) as u32); len = symbol; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.choice2 = (*coder).match_len_decoder.choice2 - ((*coder).match_len_decoder.choice2 >> RC_MOVE_BITS); @@ -1910,235 +1854,227 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).match_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).match_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).match_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).match_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).match_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).match_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).match_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).match_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).match_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } symbol = symbol - .wrapping_add((-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32); + + ((-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32); len = symbol; } } @@ -2148,7 +2084,7 @@ unsafe extern "C" fn lzma_decode( as *mut [probability; 64]) .offset( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN) + len - MATCH_LEN_MIN } else { (DIST_STATES - 1) as u32 }) as isize, @@ -2160,22 +2096,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2183,22 +2118,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2206,22 +2140,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2229,22 +2162,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2252,22 +2184,21 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2275,29 +2206,28 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub(*probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS, - ) as probability; + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } - symbol = symbol.wrapping_add(-(1_i32 << 6) as u32); + symbol = symbol + (-(1_i32 << 6) as u32); if symbol < DIST_MODEL_START { rep0 = symbol; } else { - limit = (symbol >> 1).wrapping_sub(1); - rep0 = (2u32).wrapping_add(symbol & 1); + limit = (symbol >> 1) - 1; + rep0 = 2 + (symbol & 1); if symbol < DIST_MODEL_END { rep0 <<= limit; probs = (::core::ptr::addr_of_mut!((*coder).pos_special) @@ -2314,24 +2244,24 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul(*probs.offset(symbol as isize) as u32); + * (*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + (*probs.offset(symbol as isize) as u32 + ( + (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32, ) >> RC_MOVE_BITS, ) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1).wrapping_add(1); - rep0 = rep0.wrapping_add(offset); + symbol = (symbol << 1) | 1; + rep0 += offset; } offset <<= 1; limit -= 1; @@ -2340,9 +2270,9 @@ unsafe extern "C" fn lzma_decode( } } } else { - limit = limit.wrapping_sub(ALIGN_BITS); + limit -= ALIGN_BITS; loop { - rep0 = (rep0 << 1).wrapping_add(1); + rep0 = (rep0 << 1) + (1); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; @@ -2365,29 +2295,26 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).pos_align[symbol.wrapping_add(1) as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).pos_align[symbol + (1) as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol.wrapping_add(1) as usize] = ((*coder) + (*coder).pos_align[symbol + (1) as usize] = ((*coder) .pos_align - [symbol.wrapping_add(1) as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align[symbol.wrapping_add(1) as usize] + [symbol + (1) as usize] + as u32 + ( + (RC_BIT_MODEL_TOTAL - + (*coder).pos_align[symbol + (1) as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[symbol.wrapping_add(1) as usize] = - (*coder).pos_align[symbol.wrapping_add(1) as usize] - - ((*coder).pos_align[symbol.wrapping_add(1) as usize] + rc.range -= rc_bound; + rc.code -= rc_bound; + (*coder).pos_align[symbol + (1) as usize] = + (*coder).pos_align[symbol + (1) as usize] + - ((*coder).pos_align[symbol + (1) as usize] >> RC_MOVE_BITS); symbol += 1; } @@ -2396,95 +2323,86 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).pos_align[symbol.wrapping_add(2) as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).pos_align[symbol + (2) as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol.wrapping_add(2) as usize] = ((*coder) + (*coder).pos_align[symbol + (2) as usize] = ((*coder) .pos_align - [symbol.wrapping_add(2) as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align[symbol.wrapping_add(2) as usize] + [symbol + (2) as usize] + as u32 + ( + (RC_BIT_MODEL_TOTAL - + (*coder).pos_align[symbol + (2) as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[symbol.wrapping_add(2) as usize] = - (*coder).pos_align[symbol.wrapping_add(2) as usize] - - ((*coder).pos_align[symbol.wrapping_add(2) as usize] + rc.range -= rc_bound; + rc.code -= rc_bound; + (*coder).pos_align[symbol + (2) as usize] = + (*coder).pos_align[symbol + (2) as usize] + - ((*coder).pos_align[symbol + (2) as usize] >> RC_MOVE_BITS); - symbol = symbol.wrapping_add(2); + symbol = symbol + (2); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).pos_align[symbol.wrapping_add(4) as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).pos_align[symbol + (4) as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol.wrapping_add(4) as usize] = ((*coder) + (*coder).pos_align[symbol + (4) as usize] = ((*coder) .pos_align - [symbol.wrapping_add(4) as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align[symbol.wrapping_add(4) as usize] + [symbol + (4) as usize] + as u32 + ( + (RC_BIT_MODEL_TOTAL - + (*coder).pos_align[symbol + (4) as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[symbol.wrapping_add(4) as usize] = - (*coder).pos_align[symbol.wrapping_add(4) as usize] - - ((*coder).pos_align[symbol.wrapping_add(4) as usize] + rc.range -= rc_bound; + rc.code -= rc_bound; + (*coder).pos_align[symbol + (4) as usize] = + (*coder).pos_align[symbol + (4) as usize] + - ((*coder).pos_align[symbol + (4) as usize] >> RC_MOVE_BITS); - symbol = symbol.wrapping_add(4); + symbol = symbol + (4); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).pos_align[symbol.wrapping_add(8) as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).pos_align[symbol + (8) as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol.wrapping_add(8) as usize] = ((*coder) + (*coder).pos_align[symbol + (8) as usize] = ((*coder) .pos_align - [symbol.wrapping_add(8) as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( - (*coder).pos_align[symbol.wrapping_add(8) as usize] + [symbol + (8) as usize] + as u32 + ( + (RC_BIT_MODEL_TOTAL - + (*coder).pos_align[symbol + (8) as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); - (*coder).pos_align[symbol.wrapping_add(8) as usize] = - (*coder).pos_align[symbol.wrapping_add(8) as usize] - - ((*coder).pos_align[symbol.wrapping_add(8) as usize] + rc.range -= rc_bound; + rc.code -= rc_bound; + (*coder).pos_align[symbol + (8) as usize] = + (*coder).pos_align[symbol + (8) as usize] + - ((*coder).pos_align[symbol + (8) as usize] >> RC_MOVE_BITS); - symbol = symbol.wrapping_add(8); + symbol = symbol + (8); } - rep0 = rep0.wrapping_add(symbol); + rep0 += symbol; if rep0 == UINT32_MAX { break; } @@ -2497,8 +2415,8 @@ unsafe extern "C" fn lzma_decode( continue 'c_9380; } } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); if !dict_is_distance_valid(::core::ptr::addr_of_mut!(dict), 0) { @@ -2512,37 +2430,35 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep0[state as usize] as u32); + * ((*coder).is_rep0[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0[state as usize] = - ((*coder).is_rep0[state as usize] as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).is_rep0[state as usize] as u32) - >> RC_MOVE_BITS, - ) as probability + ((*coder).is_rep0[state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep0[state as usize] as u32) + >> RC_MOVE_BITS + )) as probability as probability; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).is_rep0_long[state as usize][pos_state as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder).is_rep0_long[state as usize][pos_state as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep0_long[state as usize] [pos_state as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; state = (if state < LIT_STATES { STATE_LIT_SHORTREP @@ -2555,8 +2471,8 @@ unsafe extern "C" fn lzma_decode( ); continue; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep0_long[state as usize][pos_state as usize] = (*coder).is_rep0_long[state as usize][pos_state as usize] - ((*coder).is_rep0_long[state as usize] @@ -2564,8 +2480,8 @@ unsafe extern "C" fn lzma_decode( >> RC_MOVE_BITS); } } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep0[state as usize] = (*coder).is_rep0[state as usize] - ((*coder).is_rep0[state as usize] >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { @@ -2574,22 +2490,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep1[state as usize] as u32); + * ((*coder).is_rep1[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep1[state as usize] = - ((*coder).is_rep1[state as usize] as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).is_rep1[state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep1[state as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; let distance: u32 = rep1; rep1 = rep0; rep0 = distance; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep1[state as usize] = (*coder).is_rep1 [state as usize] - ((*coder).is_rep1[state as usize] >> RC_MOVE_BITS); @@ -2599,24 +2515,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).is_rep2[state as usize] as u32); + * ((*coder).is_rep2[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep2[state as usize] = - ((*coder).is_rep2[state as usize] as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).is_rep2[state as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).is_rep2[state as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; let distance_0: u32 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance_0; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).is_rep2[state as usize] = (*coder).is_rep2 [state as usize] - ((*coder).is_rep2[state as usize] >> RC_MOVE_BITS); @@ -2640,15 +2554,14 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).rep_len_decoder.choice as u32); + * ((*coder).rep_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.choice = - ((*coder).rep_len_decoder.choice as u32).wrapping_add( - RC_BIT_MODEL_TOTAL - .wrapping_sub((*coder).rep_len_decoder.choice as u32) - >> RC_MOVE_BITS, - ) as probability + ((*coder).rep_len_decoder.choice as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.choice as u32) + >> RC_MOVE_BITS + )) as probability as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -2656,10 +2569,10 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2667,19 +2580,18 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] @@ -2687,17 +2599,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2705,19 +2617,18 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] @@ -2725,17 +2636,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2743,19 +2654,18 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] @@ -2763,13 +2673,13 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } - symbol = symbol.wrapping_add((-(1_i32 << 3) + 2) as u32); + symbol = symbol + ((-(1_i32 << 3) + 2) as u32); len = symbol; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.choice = (*coder).rep_len_decoder.choice - ((*coder).rep_len_decoder.choice >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { @@ -2778,15 +2688,15 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - .wrapping_mul((*coder).rep_len_decoder.choice2 as u32); + * ((*coder).rep_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.choice2 = - ((*coder).rep_len_decoder.choice2 as u32).wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.choice2 as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.choice2 as u32, - ) >> RC_MOVE_BITS, - ) as probability + ) >> RC_MOVE_BITS + )) as probability as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -2794,10 +2704,10 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2805,20 +2715,17 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] @@ -2826,17 +2733,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2844,20 +2751,17 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] @@ -2865,17 +2769,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32, + as u32 ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2883,20 +2787,17 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] @@ -2904,14 +2805,14 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } symbol = - symbol.wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); + symbol + ((-(1_i32 << 3) + 2 + (1 << 3)) as u32); len = symbol; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.choice2 = (*coder).rep_len_decoder.choice2 - ((*coder).rep_len_decoder.choice2 >> RC_MOVE_BITS); @@ -2921,251 +2822,227 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).rep_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).rep_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).rep_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).rep_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).rep_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).rep_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).rep_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( - (*coder).rep_len_decoder.high[symbol as usize] as u32, + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + (*coder).rep_len_decoder.high[symbol as usize] as u32 ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32) - .wrapping_add( - RC_BIT_MODEL_TOTAL.wrapping_sub( + ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( + (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS, - ) - as probability - as probability; + ) >> RC_MOVE_BITS + )) as probability; symbol <<= 1; } else { - rc.range = rc.range.wrapping_sub(rc_bound); - rc.code = rc.code.wrapping_sub(rc_bound); + rc.range -= rc_bound; + rc.code -= rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1).wrapping_add(1); + symbol = (symbol << 1) | 1; } - symbol = symbol.wrapping_add( - (-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32, + symbol = symbol + ( + (-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32 ); len = symbol; } @@ -3228,7 +3105,7 @@ unsafe extern "C" fn lzma_decode( if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN { (*coder).uncompressed_size = (*coder) .uncompressed_size - .wrapping_sub(dict.pos.wrapping_sub(dict_start) as lzma_vli); + - (dict.pos - dict_start as lzma_vli); if (*coder).uncompressed_size == 0 && ret_0 == LZMA_OK && ((*coder).sequence == SEQ_LITERAL_WRITE @@ -3258,20 +3135,20 @@ unsafe extern "C" fn lzma_decoder_uncompressed( unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_void) { let coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; let options: *const lzma_options_lzma = opt as *const lzma_options_lzma; - (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; + (*coder).pos_mask = ((1u32 << (*options).pb) - 1) as u32; literal_init( ::core::ptr::addr_of_mut!((*coder).literal) as *mut probability, (*options).lc, (*options).lp, ); (*coder).literal_context_bits = (*options).lc; - (*coder).literal_mask = (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); + (*coder).literal_mask = (0x100u32 << (*options).lp) - (0x100 >> (*options).lc); (*coder).state = STATE_LIT_LIT; (*coder).rep0 = 0; (*coder).rep1 = 0; (*coder).rep2 = 0; (*coder).rep3 = 0; - (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; + (*coder).pos_mask = ((1u32 << (*options).pb) - 1) as u32; (*coder).rc.range = UINT32_MAX; (*coder).rc.code = 0; (*coder).rc.init_bytes_left = 5; @@ -3410,7 +3287,7 @@ unsafe extern "C" fn lzma_decoder_init( if (*opt).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; } - uncomp_size = ((*opt).ext_size_low as u64).wrapping_add(((*opt).ext_size_high as u64) << 32) + uncomp_size = ((*opt).ext_size_low as u64) + (((*opt).ext_size_high as u64) << 32) as lzma_vli; allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 || uncomp_size == LZMA_VLI_UNKNOWN; @@ -3457,16 +3334,16 @@ pub unsafe fn lzma_lzma_lclppb_decode( return true; } (*options).pb = (byte / (9 * 5)) as u32; - byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9u32).wrapping_mul(5)) as u8; + byte = ((byte as u32) - (*options).pb * 9 * 5) as u8; (*options).lp = (byte / 9) as u32; - (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9)); - (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX + (*options).lc = (byte as u32) - (*options).lp * 9; + (*options).lc + (*options).lp > LZMA_LCLP_MAX } pub extern "C" fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64 { return unsafe { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; (core::mem::size_of::() as u64) - .wrapping_add(lzma_lz_decoder_memusage((*opt).dict_size as size_t)) + + (lzma_lz_decoder_memusage((*opt).dict_size as size_t)) }; } pub extern "C" fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64 { diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 19583bf5..510132e8 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -20,7 +20,7 @@ unsafe fn rc_forget(rc: *mut lzma_range_encoder) { unsafe fn rc_bit(rc: *mut lzma_range_encoder, prob: *mut probability, bit: u32) { (*rc).symbols[(*rc).count as usize] = bit as rc_symbol; (*rc).probs[(*rc).count as usize] = prob; - (*rc).count = (*rc).count.wrapping_add(1); + (*rc).count += 1; } #[inline] unsafe fn rc_bittree( @@ -38,7 +38,7 @@ unsafe fn rc_bittree( probs.offset(model_index as isize) as *mut probability, bit, ); - model_index = (model_index << 1).wrapping_add(bit); + model_index = (model_index << 1) + bit; if bit_count == 0 { break; } @@ -60,7 +60,7 @@ unsafe fn rc_bittree_reverse( probs.offset(model_index as isize) as *mut probability, bit, ); - model_index = (model_index << 1).wrapping_add(bit); + model_index = (model_index << 1) + bit; bit_count -= 1; if bit_count == 0 { break; @@ -72,7 +72,7 @@ unsafe fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) loop { bit_count -= 1; (*rc).symbols[(*rc).count as usize] = - (RC_DIRECT_0 as u32).wrapping_add(value >> bit_count & 1) as rc_symbol; + ((RC_DIRECT_0 as u32) + (value >> bit_count & 1)) as rc_symbol; (*rc).count += 1; if bit_count == 0 { break; @@ -101,7 +101,7 @@ unsafe fn rc_shift_low( return true; } *out.offset(*out_pos as isize) = (*rc).cache.wrapping_add(((*rc).low >> 32) as u8); - *out_pos = (*out_pos).wrapping_add(1); + *out_pos += 1; (*rc).out_total = (*rc).out_total.wrapping_add(1); (*rc).cache = 0xff; (*rc).cache_size = (*rc).cache_size.wrapping_sub(1); @@ -128,7 +128,7 @@ unsafe fn rc_shift_low_dummy( if *out_pos == out_size { return true; } - *out_pos = (*out_pos).wrapping_add(1); + *out_pos += 1; *cache = 0xff; *cache_size = (*cache_size).wrapping_sub(1); if *cache_size == 0 { @@ -302,17 +302,14 @@ unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u3 .offset((*mf).read_pos.wrapping_sub((*mf).read_ahead) as isize); let subcoder: *mut probability = (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability).offset( - (3u32).wrapping_mul( - ((position << 8).wrapping_add( - *(*mf).buffer.offset( - (*mf) - .read_pos - .wrapping_sub((*mf).read_ahead) - .wrapping_sub(1) as isize, - ) as u32, - ) & (*coder).literal_mask) - << (*coder).literal_context_bits, - ) as isize, + (3u32 + * (((position << 8) + + *(*mf) + .buffer + .offset(((*mf).read_pos - (*mf).read_ahead - 1) as isize) + as u32) + & (*coder).literal_mask) + << (*coder).literal_context_bits) as isize, ); if ((*coder).state as u32) < LIT_STATES { (*coder).state = (if (*coder).state <= STATE_SHORTREP_LIT_LIT { @@ -349,25 +346,27 @@ unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u3 } #[inline(always)] unsafe fn length_prices_row(lc: *mut lzma_length_encoder, pos_state: u32) -> *mut u32 { - ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).prices) as *mut [u32; 272]) - .add(pos_state as usize)) as *mut u32 + ::core::ptr::addr_of_mut!( + *(::core::ptr::addr_of_mut!((*lc).prices) as *mut [u32; 272]).add(pos_state as usize) + ) as *mut u32 } #[inline(always)] unsafe fn length_low_probs(lc: *mut lzma_length_encoder, pos_state: u32) -> *mut probability { - ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).low) as *mut [probability; 8]) - .add(pos_state as usize)) as *mut probability + ::core::ptr::addr_of_mut!( + *(::core::ptr::addr_of_mut!((*lc).low) as *mut [probability; 8]).add(pos_state as usize) + ) as *mut probability } #[inline(always)] unsafe fn length_mid_probs(lc: *mut lzma_length_encoder, pos_state: u32) -> *mut probability { - ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*lc).mid) as *mut [probability; 8]) - .add(pos_state as usize)) as *mut probability + ::core::ptr::addr_of_mut!( + *(::core::ptr::addr_of_mut!((*lc).mid) as *mut [probability; 8]).add(pos_state as usize) + ) as *mut probability } #[inline(always)] unsafe fn is_match_prob(coder: *mut lzma_lzma1_encoder, pos_state: u32) -> *mut probability { - (::core::ptr::addr_of_mut!( - *(::core::ptr::addr_of_mut!((*coder).is_match) as *mut [probability; 16]) - .add((*coder).state as usize) - ) as *mut probability) + (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_match) + as *mut [probability; 16]) + .add((*coder).state as usize)) as *mut probability) .add(pos_state as usize) } #[inline(always)] @@ -437,12 +436,7 @@ unsafe fn length( } } #[inline] -unsafe fn match_0( - coder: *mut lzma_lzma1_encoder, - pos_state: u32, - distance: u32, - len: u32, -) { +unsafe fn match_0(coder: *mut lzma_lzma1_encoder, pos_state: u32, distance: u32, len: u32) { (*coder).state = (if ((*coder).state as u32) < LIT_STATES { STATE_LIT_MATCH } else { @@ -587,15 +581,31 @@ unsafe fn encode_symbol( ) { let pos_state: u32 = position & (*coder).pos_mask; if back == UINT32_MAX { - rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_match_prob(coder, pos_state), 0); + rc_bit( + ::core::ptr::addr_of_mut!((*coder).rc), + is_match_prob(coder, pos_state), + 0, + ); literal(coder, mf, position); } else { - rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_match_prob(coder, pos_state), 1); + rc_bit( + ::core::ptr::addr_of_mut!((*coder).rc), + is_match_prob(coder, pos_state), + 1, + ); if back < REPS { - rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_rep_prob(coder), 1); + rc_bit( + ::core::ptr::addr_of_mut!((*coder).rc), + is_rep_prob(coder), + 1, + ); rep_match(coder, pos_state, back, len); } else { - rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_rep_prob(coder), 0); + rc_bit( + ::core::ptr::addr_of_mut!((*coder).rc), + is_rep_prob(coder), + 0, + ); match_0(coder, pos_state, back - REPS, len); } } @@ -609,7 +619,11 @@ unsafe fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool } else { mf_skip(mf, 1); (*mf).read_ahead = 0; - rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_match_prob(coder, 0), 0); + rc_bit( + ::core::ptr::addr_of_mut!((*coder).rc), + is_match_prob(coder, 0), + 0, + ); rc_bittree( ::core::ptr::addr_of_mut!((*coder).rc), ::core::ptr::addr_of_mut!((*coder).literal) as *mut probability, @@ -623,8 +637,16 @@ unsafe fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool } unsafe fn encode_eopm(coder: *mut lzma_lzma1_encoder, position: u32) { let pos_state: u32 = position & (*coder).pos_mask; - rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_match_prob(coder, pos_state), 1); - rc_bit(::core::ptr::addr_of_mut!((*coder).rc), is_rep_prob(coder), 0); + rc_bit( + ::core::ptr::addr_of_mut!((*coder).rc), + is_match_prob(coder, pos_state), + 1, + ); + rc_bit( + ::core::ptr::addr_of_mut!((*coder).rc), + is_rep_prob(coder), + 0, + ); match_0(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN); } pub const LOOP_INPUT_MAX: u32 = OPTS + 1; @@ -702,9 +724,7 @@ pub unsafe fn lzma_lzma_encode( ); } encode_symbol(coder, mf, back, len, (*coder).uncomp_size as u32); - if (*coder).out_limit != 0 - && rc_encode_dummy(rc, (*coder).out_limit) - { + if (*coder).out_limit != 0 && rc_encode_dummy(rc, (*coder).out_limit) { rc_forget(rc); break; } @@ -1009,17 +1029,13 @@ pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { ::core::ptr::addr_of_mut!(lz_options), options as *const lzma_options_lzma, ); - let lz_memusage: u64 = - lzma_lz_encoder_memusage(::core::ptr::addr_of_mut!(lz_options)) as u64; + let lz_memusage: u64 = lzma_lz_encoder_memusage(::core::ptr::addr_of_mut!(lz_options)) as u64; if lz_memusage == UINT64_MAX { return UINT64_MAX; } (core::mem::size_of::() as u64).wrapping_add(lz_memusage) } -pub unsafe fn lzma_lzma_lclppb_encode( - options: *const lzma_options_lzma, - byte: *mut u8, -) -> bool { +pub unsafe fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool { if !is_lclppb_valid(options) { return true; } diff --git a/liblzma-rs/src/lzma/lzma_encoder_presets.rs b/liblzma-rs/src/lzma/lzma_encoder_presets.rs index 41643f43..098a8363 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_presets.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_presets.rs @@ -3,10 +3,7 @@ pub const LZMA_LC_DEFAULT: u32 = 3; pub const LZMA_LP_DEFAULT: u32 = 0; pub const LZMA_PB_DEFAULT: u32 = 2; pub const LZMA_PRESET_LEVEL_MASK: c_uint = 0x1f; -pub unsafe fn lzma_lzma_preset( - options: *mut lzma_options_lzma, - preset: u32, -) -> lzma_bool { +pub unsafe fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool { let level: u32 = preset & LZMA_PRESET_LEVEL_MASK as u32; let flags: u32 = preset & !(LZMA_PRESET_LEVEL_MASK as u32); let supported_flags: u32 = LZMA_PRESET_EXTREME as u32; diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index c24d1339..fd46043c 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -69,11 +69,7 @@ pub unsafe extern "C" fn lzma_simple_arm64_encoder_init( ) -> lzma_ret { arm64_coder_init(next, allocator, filters, true) } -pub unsafe fn lzma_bcj_arm64_encode( - mut start_offset: u32, - buf: *mut u8, - size: size_t, -) -> size_t { +pub unsafe fn lzma_bcj_arm64_encode(mut start_offset: u32, buf: *mut u8, size: size_t) -> size_t { start_offset = (start_offset & !3u32) as u32; arm64_code(core::ptr::null_mut(), start_offset, true, buf, size) } @@ -84,11 +80,7 @@ pub unsafe extern "C" fn lzma_simple_arm64_decoder_init( ) -> lzma_ret { arm64_coder_init(next, allocator, filters, false) } -pub unsafe fn lzma_bcj_arm64_decode( - mut start_offset: u32, - buf: *mut u8, - size: size_t, -) -> size_t { +pub unsafe fn lzma_bcj_arm64_decode(mut start_offset: u32, buf: *mut u8, size: size_t) -> size_t { start_offset = (start_offset & !3u32) as u32; arm64_code(core::ptr::null_mut(), start_offset, false, buf, size) } diff --git a/liblzma-rs/src/simple/ia64.rs b/liblzma-rs/src/simple/ia64.rs index 3f41e62c..aa8a2dfa 100644 --- a/liblzma-rs/src/simple/ia64.rs +++ b/liblzma-rs/src/simple/ia64.rs @@ -25,9 +25,7 @@ unsafe extern "C" fn ia64_code( let mut instruction: u64 = 0; let mut j: size_t = 0; while j < 6 { - instruction += - (*buffer.offset((i + j + byte_pos) as isize) as u64) - << (8 * j); + instruction += (*buffer.offset((i + j + byte_pos) as isize) as u64) << (8 * j); j += 1; } let mut inst_norm: u64 = instruction >> bit_res; diff --git a/liblzma-rs/src/simple/powerpc.rs b/liblzma-rs/src/simple/powerpc.rs index b4cf4a58..573672b1 100644 --- a/liblzma-rs/src/simple/powerpc.rs +++ b/liblzma-rs/src/simple/powerpc.rs @@ -10,9 +10,7 @@ unsafe extern "C" fn powerpc_code( let mut i: size_t = 0; i = 0; while i < size { - if *buffer.offset(i as isize) >> 2 == 0x12 - && *buffer.offset((i + 3) as isize) & 3 == 1 - { + if *buffer.offset(i as isize) >> 2 == 0x12 && *buffer.offset((i + 3) as isize) & 3 == 1 { let src: u32 = (*buffer.offset(i as isize) as u32 & 3) << 24 | (*buffer.offset((i + 1) as isize) as u32) << 16 | (*buffer.offset((i + 2) as isize) as u32) << 8 diff --git a/liblzma-rs/src/simple/riscv.rs b/liblzma-rs/src/simple/riscv.rs index 514cac08..ccbacc7c 100644 --- a/liblzma-rs/src/simple/riscv.rs +++ b/liblzma-rs/src/simple/riscv.rs @@ -113,11 +113,7 @@ pub unsafe extern "C" fn lzma_simple_riscv_encoder_init( true, ) } -pub unsafe fn lzma_bcj_riscv_encode( - mut start_offset: u32, - buf: *mut u8, - size: size_t, -) -> size_t { +pub unsafe fn lzma_bcj_riscv_encode(mut start_offset: u32, buf: *mut u8, size: size_t) -> size_t { start_offset = (start_offset & !1u32) as u32; riscv_encode(core::ptr::null_mut(), start_offset, true, buf, size) } @@ -148,8 +144,7 @@ unsafe extern "C" fn riscv_decode( *buffer.offset((i + 1) as isize) = (b1 & 0xf | addr >> 8 & 0xf0) as u8; *buffer.offset((i + 2) as isize) = (addr >> 16 & 0xf | addr >> 7 & 0x10 | addr << 4 & 0xe0) as u8; - *buffer.offset((i + 3) as isize) = - (addr >> 4 & 0x7f | addr >> 13 & 0x80) as u8; + *buffer.offset((i + 3) as isize) = (addr >> 4 & 0x7f | addr >> 13 & 0x80) as u8; i += 4 - 2; } } else if inst & 0x7f == 0x17 { @@ -213,11 +208,7 @@ pub unsafe extern "C" fn lzma_simple_riscv_decoder_init( false, ) } -pub unsafe fn lzma_bcj_riscv_decode( - mut start_offset: u32, - buf: *mut u8, - size: size_t, -) -> size_t { +pub unsafe fn lzma_bcj_riscv_decode(mut start_offset: u32, buf: *mut u8, size: size_t) -> size_t { start_offset = (start_offset & !1u32) as u32; riscv_decode(core::ptr::null_mut(), start_offset, false, buf, size) } diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index a3448d3b..20c7564c 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -35,11 +35,7 @@ unsafe fn copy_or_code( } LZMA_OK } -unsafe fn call_filter( - coder: *mut lzma_simple_coder, - buffer: *mut u8, - size: size_t, -) -> size_t { +unsafe fn call_filter(coder: *mut lzma_simple_coder, buffer: *mut u8, size: size_t) -> size_t { let filtered: size_t = (*coder).filter.unwrap()( (*coder).simple, (*coder).now_pos, diff --git a/liblzma-rs/src/simple/sparc.rs b/liblzma-rs/src/simple/sparc.rs index ded772c2..84be333a 100644 --- a/liblzma-rs/src/simple/sparc.rs +++ b/liblzma-rs/src/simple/sparc.rs @@ -10,10 +10,8 @@ unsafe extern "C" fn sparc_code( let mut i: size_t = 0; i = 0; while i < size { - if *buffer.offset(i as isize) == 0x40 - && *buffer.offset((i + 1) as isize) & 0xc0 == 0 - || *buffer.offset(i as isize) == 0x7f - && *buffer.offset((i + 1) as isize) & 0xc0 == 0xc0 + if *buffer.offset(i as isize) == 0x40 && *buffer.offset((i + 1) as isize) & 0xc0 == 0 + || *buffer.offset(i as isize) == 0x7f && *buffer.offset((i + 1) as isize) & 0xc0 == 0xc0 { let mut src: u32 = (*buffer.offset(i as isize) as u32) << 24 | (*buffer.offset((i + 1) as isize) as u32) << 16 diff --git a/liblzma-rs/src/simple/x86.rs b/liblzma-rs/src/simple/x86.rs index b8225011..41bca8a3 100644 --- a/liblzma-rs/src/simple/x86.rs +++ b/liblzma-rs/src/simple/x86.rs @@ -69,8 +69,7 @@ unsafe extern "C" fn x86_code( src = dest ^ (1u32 << (32u32).wrapping_sub(i_0.wrapping_mul(8))).wrapping_sub(1); } - *buffer.offset((buffer_pos + 4) as isize) = - !(dest >> 24 & 1).wrapping_sub(1) as u8; + *buffer.offset((buffer_pos + 4) as isize) = !(dest >> 24 & 1).wrapping_sub(1) as u8; *buffer.offset((buffer_pos + 3) as isize) = (dest >> 16) as u8; *buffer.offset((buffer_pos + 2) as isize) = (dest >> 8) as u8; *buffer.offset((buffer_pos + 1) as isize) = dest as u8; @@ -124,11 +123,7 @@ pub unsafe extern "C" fn lzma_simple_x86_encoder_init( ) -> lzma_ret { x86_coder_init(next, allocator, filters, true) } -pub unsafe fn lzma_bcj_x86_encode( - start_offset: u32, - buf: *mut u8, - size: size_t, -) -> size_t { +pub unsafe fn lzma_bcj_x86_encode(start_offset: u32, buf: *mut u8, size: size_t) -> size_t { let mut simple: lzma_simple_x86 = lzma_simple_x86 { prev_mask: 0, prev_pos: (-5_i32) as u32, @@ -148,11 +143,7 @@ pub unsafe extern "C" fn lzma_simple_x86_decoder_init( ) -> lzma_ret { x86_coder_init(next, allocator, filters, false) } -pub unsafe fn lzma_bcj_x86_decode( - start_offset: u32, - buf: *mut u8, - size: size_t, -) -> size_t { +pub unsafe fn lzma_bcj_x86_decode(start_offset: u32, buf: *mut u8, size: size_t) -> size_t { let mut simple: lzma_simple_x86 = lzma_simple_x86 { prev_mask: 0, prev_pos: (-5_i32) as u32, diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index af16c498..0cdb5ded 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -860,12 +860,7 @@ pub unsafe fn mf_skip(mf: *mut lzma_mf, amount: u32) { } } #[inline(always)] -pub unsafe fn lzma_memcmplen( - buf1: *const u8, - buf2: *const u8, - mut len: u32, - limit: u32, -) -> u32 { +pub unsafe fn lzma_memcmplen(buf1: *const u8, buf2: *const u8, mut len: u32, limit: u32) -> u32 { debug_assert!(len <= limit); debug_assert!(limit <= u32::MAX / 2); @@ -921,11 +916,7 @@ pub fn rc_bit_1_price(prob: probability) -> u32 { } } #[inline] -pub unsafe fn rc_bittree_price( - probs: *const probability, - bit_levels: u32, - mut symbol: u32, -) -> u32 { +pub unsafe fn rc_bittree_price(probs: *const probability, bit_levels: u32, mut symbol: u32) -> u32 { let mut price: u32 = 0; symbol = (symbol as u32).wrapping_add(1u32 << bit_levels) as u32; loop { From b83cc58e4a6a53ade18b370803b481a721f7e34f Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 21:42:13 +0900 Subject: [PATCH 30/51] perf: match C memcmplen fast path --- liblzma-rs/src/types.rs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 0cdb5ded..7c120213 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -868,20 +868,34 @@ pub unsafe fn lzma_memcmplen(buf1: *const u8, buf2: *const u8, mut len: u32, lim target_endian = "little", any(target_arch = "aarch64", target_arch = "x86_64") ))] - while len + 8 <= limit { - let lhs = core::ptr::read_unaligned(buf1.add(len as usize) as *const u64); - let rhs = core::ptr::read_unaligned(buf2.add(len as usize) as *const u64); - let diff = lhs.wrapping_sub(rhs); - if diff != 0 { - return core::cmp::min(len + (diff.trailing_zeros() >> 3), limit); + { + while len < limit { + let lhs = core::ptr::read_unaligned(buf1.add(len as usize) as *const u64); + let rhs = core::ptr::read_unaligned(buf2.add(len as usize) as *const u64); + let diff = lhs.wrapping_sub(rhs); + if diff != 0 { + return core::cmp::min(len + (diff.trailing_zeros() >> 3), limit); + } + len += 8; } - len += 8; + limit } + #[cfg(not(all( + target_endian = "little", + any(target_arch = "aarch64", target_arch = "x86_64") + )))] while len < limit && *buf1.offset(len as isize) == *buf2.offset(len as isize) { len += 1; } - len + + #[cfg(not(all( + target_endian = "little", + any(target_arch = "aarch64", target_arch = "x86_64") + )))] + { + len + } } #[inline] pub unsafe fn get_dist_slot(dist: u32) -> u32 { From c5503392bedce3fe0239cc06d83ffeff8b3bf75d Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 21:49:15 +0900 Subject: [PATCH 31/51] perf: simplify optimum fast encoder path --- .../src/lzma/lzma_encoder_optimum_fast.rs | 95 +++++++++---------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 3b35df44..50295032 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -1,4 +1,15 @@ +use crate::lzma::lzma_encoder::MATCH_LEN_MAX; use crate::types::*; + +#[inline(always)] +unsafe fn not_equal_16(a: *const u8, b: *const u8) -> bool { + core::ptr::read_unaligned(a as *const u16) != core::ptr::read_unaligned(b as *const u16) +} + +#[inline(always)] +fn change_pair(small_dist: u32, big_dist: u32) -> bool { + (big_dist >> 7) > small_dist +} pub unsafe fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, @@ -15,16 +26,12 @@ pub unsafe fn lzma_lzma_optimum_fast( ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, ); } else { + debug_assert!((*mf).read_ahead == 1); len_main = (*coder).longest_match_length; matches_count = (*coder).matches_count; } let mut buf: *const u8 = mf_ptr(mf).offset(-1); - let buf_avail: u32 = - if mf_avail(mf).wrapping_add(1) < (2 + ((1 << 3) + (1 << 3) + (1 << 8)) - 1) as u32 { - (mf_avail(mf) as u32).wrapping_add(1) - } else { - (2 + ((1 << 3) + (1 << 3) + (1 << 8)) - 1) as u32 - }; + let buf_avail: u32 = core::cmp::min(mf_avail(mf) + 1, MATCH_LEN_MAX); if buf_avail < 2 { *back_res = UINT32_MAX; *len_res = 1; @@ -35,57 +42,54 @@ pub unsafe fn lzma_lzma_optimum_fast( let mut i: u32 = 0; while i < REPS { let buf_back: *const u8 = buf.offset(-((*coder).reps[i as usize] as isize)).offset(-1); - if *buf == *buf_back && *buf.offset(1) == *buf_back.offset(1) { - let len: u32 = lzma_memcmplen(buf, buf_back, 2, buf_avail) as u32; - if len >= nice_len { - *back_res = i; - *len_res = len; - mf_skip(mf, len.wrapping_sub(1)); - return; - } - if len > rep_len { - rep_index = i; - rep_len = len; - } + if not_equal_16(buf, buf_back) { + i += 1; + continue; + } + let len: u32 = lzma_memcmplen(buf, buf_back, 2, buf_avail) as u32; + if len >= nice_len { + *back_res = i; + *len_res = len; + mf_skip(mf, len - 1); + return; + } + if len > rep_len { + rep_index = i; + rep_len = len; } i += 1; } if len_main >= nice_len { - *back_res = (*coder).matches[matches_count.wrapping_sub(1) as usize] + *back_res = (*coder).matches[(matches_count - 1) as usize] .dist - .wrapping_add(REPS); + + REPS; *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(1)); + mf_skip(mf, len_main - 1); return; } let mut back_main: u32 = 0; if len_main >= 2 { - back_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].dist; - while matches_count > 1 - && len_main - == (*coder).matches[matches_count.wrapping_sub(2) as usize] - .len - .wrapping_add(1) - { - if back_main >> 7 <= (*coder).matches[matches_count.wrapping_sub(2) as usize].dist { + back_main = (*coder).matches[(matches_count - 1) as usize].dist; + while matches_count > 1 && len_main == (*coder).matches[(matches_count - 2) as usize].len + 1 { + if !change_pair((*coder).matches[(matches_count - 2) as usize].dist, back_main) { break; } matches_count -= 1; - len_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].len; - back_main = (*coder).matches[matches_count.wrapping_sub(1) as usize].dist; + len_main = (*coder).matches[(matches_count - 1) as usize].len; + back_main = (*coder).matches[(matches_count - 1) as usize].dist; } if len_main == 2 && back_main >= 0x80 { len_main = 1; } } if rep_len >= 2 { - if rep_len.wrapping_add(1) >= len_main - || rep_len.wrapping_add(2) >= len_main && back_main > 1 << 9 - || rep_len.wrapping_add(3) >= len_main && back_main > 1 << 15 + if rep_len + 1 >= len_main + || rep_len + 2 >= len_main && back_main > 1 << 9 + || rep_len + 3 >= len_main && back_main > 1 << 15 { *back_res = rep_index; *len_res = rep_len; - mf_skip(mf, rep_len.wrapping_sub(1)); + mf_skip(mf, rep_len - 1); return; } } @@ -100,14 +104,13 @@ pub unsafe fn lzma_lzma_optimum_fast( ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, ); if (*coder).longest_match_length >= 2 { - let new_dist: u32 = (*coder).matches[(*coder).matches_count.wrapping_sub(1) as usize].dist; + let new_dist: u32 = (*coder).matches[((*coder).matches_count - 1) as usize].dist; if (*coder).longest_match_length >= len_main && new_dist < back_main - || (*coder).longest_match_length == len_main.wrapping_add(1) - && !(new_dist >> 7 > back_main) - || (*coder).longest_match_length > len_main.wrapping_add(1) - || (*coder).longest_match_length.wrapping_add(1) >= len_main + || (*coder).longest_match_length == len_main + 1 && !change_pair(back_main, new_dist) + || (*coder).longest_match_length > len_main + 1 + || (*coder).longest_match_length + 1 >= len_main && len_main >= 3 - && back_main >> 7 > new_dist + && change_pair(new_dist, back_main) { *back_res = UINT32_MAX; *len_res = 1; @@ -115,11 +118,7 @@ pub unsafe fn lzma_lzma_optimum_fast( } } buf = buf.offset(1); - let limit: u32 = if 2 > len_main.wrapping_sub(1) { - 2 - } else { - len_main.wrapping_sub(1) - }; + let limit: u32 = core::cmp::max(2, len_main - 1); let mut i_0: u32 = 0; while i_0 < REPS { if memcmp( @@ -135,7 +134,7 @@ pub unsafe fn lzma_lzma_optimum_fast( } i_0 += 1; } - *back_res = back_main.wrapping_add(REPS); + *back_res = back_main + REPS; *len_res = len_main; - mf_skip(mf, len_main.wrapping_sub(2)); + mf_skip(mf, len_main - 2); } From 64978f6b76ef12c1243e24f492e022060ad4e333 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 21:53:25 +0900 Subject: [PATCH 32/51] Revert broken lzma_decoder.rs from previous commit --- liblzma-rs/src/lzma/lzma_decoder.rs | 1655 ++++++++++++++------------- 1 file changed, 889 insertions(+), 766 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 3bf8b4d1..246c82d0 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -78,18 +78,18 @@ unsafe fn dict_get(dict: *const lzma_dict, distance: u32) -> u8 { *(*dict).buf.offset( (*dict) .pos - - (distance as size_t) - - (1) - + (if (distance as size_t) < (*dict).pos { + .wrapping_sub(distance as size_t) + .wrapping_sub(1) + .wrapping_add(if (distance as size_t) < (*dict).pos { 0 } else { - (*dict).size - LZ_DICT_REPEAT_MAX as size_t + (*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t) }) as isize, ) } #[inline] unsafe fn dict_get0(dict: *const lzma_dict) -> u8 { - *(*dict).buf.offset((*dict).pos - 1 as isize) + *(*dict).buf.offset((*dict).pos.wrapping_sub(1) as isize) } #[inline] unsafe fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bool { @@ -97,22 +97,22 @@ unsafe fn dict_is_distance_valid(dict: *const lzma_dict, distance: size_t) -> bo } #[inline] unsafe fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut u32) -> bool { - let dict_avail: size_t = (*dict).limit - (*dict).pos; + let dict_avail: size_t = (*dict).limit.wrapping_sub((*dict).pos); let mut left: u32 = (if dict_avail < *len as size_t { dict_avail } else { *len as size_t }) as u32; - *len -= left; - let mut back: size_t = (*dict).pos - distance as size_t - 1; + *len = (*len).wrapping_sub(left); + let mut back: size_t = (*dict).pos.wrapping_sub(distance as size_t).wrapping_sub(1); if distance as size_t >= (*dict).pos { - back = back + ((*dict).size - LZ_DICT_REPEAT_MAX as size_t); + back = back.wrapping_add((*dict).size.wrapping_sub(LZ_DICT_REPEAT_MAX as size_t)); } if distance < left { loop { *(*dict).buf.offset((*dict).pos as isize) = *(*dict).buf.offset(back as isize); back += 1; - (*dict).pos = (*dict).pos + 1; + (*dict).pos = (*dict).pos.wrapping_add(1); left -= 1; if left == 0 { break; @@ -124,19 +124,19 @@ unsafe fn dict_repeat(dict: *mut lzma_dict, distance: u32, len: *mut u32) -> boo (*dict).buf.offset((*dict).pos as isize) as *mut u8, left as size_t, ); - (*dict).pos = (*dict).pos + left as size_t; + (*dict).pos = (*dict).pos.wrapping_add(left as size_t); } if !(*dict).has_wrapped { - (*dict).full = (*dict).pos - LZ_DICT_INIT_POS as size_t; + (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); } *len != 0 } #[inline] unsafe fn dict_put(dict: *mut lzma_dict, byte: u8) { *(*dict).buf.offset((*dict).pos as isize) = byte; - (*dict).pos = (*dict).pos + 1; + (*dict).pos = (*dict).pos.wrapping_add(1); if !(*dict).has_wrapped { - (*dict).full = (*dict).pos - LZ_DICT_INIT_POS as size_t; + (*dict).full = (*dict).pos.wrapping_sub(LZ_DICT_INIT_POS as size_t); } } #[inline] @@ -163,8 +163,8 @@ unsafe fn rc_read_init( return LZMA_DATA_ERROR; } (*rc).code = (*rc).code << 8 | *in_0.offset(*in_pos as isize) as u32; - *in_pos += 1; - (*rc).init_bytes_left -= 1; + *in_pos = (*in_pos).wrapping_add(1); + (*rc).init_bytes_left = (*rc).init_bytes_left.wrapping_sub(1); } LZMA_STREAM_END } @@ -215,9 +215,9 @@ unsafe extern "C" fn lzma_decode( let mut eopm_is_valid: bool = (*coder).uncompressed_size == LZMA_VLI_UNKNOWN; let mut might_finish_without_eopm: bool = false; if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN - && (*coder).uncompressed_size <= dict.limit - dict.pos as lzma_vli + && (*coder).uncompressed_size <= dict.limit.wrapping_sub(dict.pos) as lzma_vli { - dict.limit = dict.pos + (*coder).uncompressed_size as size_t; + dict.limit = dict.pos.wrapping_add((*coder).uncompressed_size as size_t); might_finish_without_eopm = true; } match (*coder).sequence { @@ -310,13 +310,14 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).rep_len_decoder.choice as u32); + .wrapping_mul((*coder).rep_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.choice as u32) - >> RC_MOVE_BITS - )) as probability; + (*coder).rep_len_decoder.choice = ((*coder).rep_len_decoder.choice as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).rep_len_decoder.choice as u32) + >> RC_MOVE_BITS, + ) as probability; probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( (*coder).rep_len_decoder.low ) @@ -326,8 +327,8 @@ unsafe extern "C" fn lzma_decode( limit = LEN_LOW_SYMBOLS; len = MATCH_LEN_MIN; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.choice = (*coder).rep_len_decoder.choice - ((*coder).rep_len_decoder.choice >> RC_MOVE_BITS); current_block = 6834592846991627977; @@ -348,20 +349,22 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep2[state as usize] as u32); + .wrapping_mul((*coder).is_rep2[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).is_rep2[state as usize] as u32) - >> RC_MOVE_BITS - )) as probability; + (*coder).is_rep2[state as usize] = ((*coder).is_rep2[state as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).is_rep2[state as usize] as u32) + >> RC_MOVE_BITS, + ) as probability; let distance_3: u32 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance_3; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep2[state as usize] = (*coder).is_rep2[state as usize] - ((*coder).is_rep2[state as usize] >> RC_MOVE_BITS); let distance_4: u32 = rep3; @@ -385,19 +388,21 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep1[state as usize] as u32); + .wrapping_mul((*coder).is_rep1[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).is_rep1[state as usize] as u32) - >> RC_MOVE_BITS - )) as probability; + (*coder).is_rep1[state as usize] = ((*coder).is_rep1[state as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).is_rep1[state as usize] as u32) + >> RC_MOVE_BITS, + ) as probability; let distance_2: u32 = rep1; rep1 = rep0; rep0 = distance_2; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep1[state as usize] = (*coder).is_rep1[state as usize] - ((*coder).is_rep1[state as usize] >> RC_MOVE_BITS); current_block = 3996983927318648760; @@ -430,16 +435,17 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep0_long[state as usize][pos_state as usize] as u32); + .wrapping_mul((*coder).is_rep0_long[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0_long[state as usize][pos_state as usize] = - ((*coder).is_rep0_long[state as usize][pos_state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).is_rep0_long[state as usize][pos_state as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_rep0_long[state as usize][pos_state as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; state = (if state < LIT_STATES { STATE_LIT_SHORTREP } else { @@ -448,8 +454,8 @@ unsafe extern "C" fn lzma_decode( current_block = 5341942013764523046; continue; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep0_long[state as usize][pos_state as usize] = (*coder) .is_rep0_long[state as usize][pos_state as usize] - ((*coder).is_rep0_long[state as usize][pos_state as usize] @@ -470,18 +476,20 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep0[state as usize] as u32); + .wrapping_mul((*coder).is_rep0[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).is_rep0[state as usize] as u32) - >> RC_MOVE_BITS - )) as probability; + (*coder).is_rep0[state as usize] = ((*coder).is_rep0[state as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).is_rep0[state as usize] as u32) + >> RC_MOVE_BITS, + ) as probability; current_block = 1698084742280242340; continue; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep0[state as usize] = (*coder).is_rep0[state as usize] - ((*coder).is_rep0[state as usize] >> RC_MOVE_BITS); current_block = 11808118301119257848; @@ -501,13 +509,14 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep[state as usize] as u32); + .wrapping_mul((*coder).is_rep[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).is_rep[state as usize] as u32) - >> RC_MOVE_BITS - )) as probability; + (*coder).is_rep[state as usize] = ((*coder).is_rep[state as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub((*coder).is_rep[state as usize] as u32) + >> RC_MOVE_BITS, + ) as probability; state = (if state < LIT_STATES { STATE_LIT_MATCH } else { @@ -519,8 +528,8 @@ unsafe extern "C" fn lzma_decode( current_block = 1138292997408115650; continue; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); if dict_is_distance_valid(::core::ptr::addr_of_mut!(dict), 0) { @@ -565,30 +574,31 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).pos_align[offset + symbol as usize] as u32); + .wrapping_mul((*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[offset + symbol as usize] = - ((*coder).pos_align[offset + symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - - (*coder).pos_align[offset + symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + (*coder).pos_align[offset.wrapping_add(symbol) as usize] = + ((*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[offset.wrapping_add(symbol) as usize] as u32, + ) >> RC_MOVE_BITS, + ) as probability; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; - (*coder).pos_align[offset + symbol as usize] = (*coder).pos_align - [offset + symbol as usize] - - ((*coder).pos_align[offset + symbol as usize] + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).pos_align[offset.wrapping_add(symbol) as usize] = (*coder).pos_align + [offset.wrapping_add(symbol) as usize] + - ((*coder).pos_align[offset.wrapping_add(symbol) as usize] >> RC_MOVE_BITS); - symbol += offset; + symbol = symbol.wrapping_add(offset); } offset <<= 1; if offset < ALIGN_SIZE { current_block = 10510472849010538284; continue; } - rep0 += symbol; + rep0 = rep0.wrapping_add(symbol); if rep0 == UINT32_MAX { current_block = 12043253436139097694; } else { @@ -611,7 +621,7 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code.wrapping_sub(rc.range); rc_bound = 0u32.wrapping_sub(rc.code >> 31); rc.code = rc.code.wrapping_add(rc.range & rc_bound); - rep0 = (rep0 << 1) + (rc_bound.wrapping_add(1)); + rep0 = (rep0 << 1).wrapping_add(rc_bound.wrapping_add(1)); limit -= 1; if limit > 0 { current_block = 15418612220330286504; @@ -636,21 +646,22 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; - rep0 += 1u32 << offset; + symbol = (symbol << 1).wrapping_add(1); + rep0 = (rep0 as u32).wrapping_add(1u32 << offset) as u32; } offset += 1; if offset < limit { @@ -672,31 +683,32 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if symbol < DIST_SLOTS { current_block = 4174862988780014241; continue; } - symbol -= DIST_SLOTS; + symbol = symbol.wrapping_sub(DIST_SLOTS); if symbol < DIST_MODEL_START { rep0 = symbol; } else { - limit = (symbol >> 1) - 1; - rep0 = 2 + (symbol & 1); + limit = (symbol >> 1).wrapping_sub(1); + rep0 = (2u32).wrapping_add(symbol & 1); if symbol < DIST_MODEL_END { rep0 <<= limit; probs = (::core::ptr::addr_of_mut!((*coder).pos_special) @@ -709,7 +721,7 @@ unsafe extern "C" fn lzma_decode( current_block = 617447976488552541; continue; } else { - limit -= ALIGN_BITS; + limit = limit.wrapping_sub(ALIGN_BITS); current_block = 15418612220330286504; continue; } @@ -729,31 +741,32 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if symbol < limit { current_block = 592696588731961849; continue; } - len += (symbol - limit); + len = len.wrapping_add(symbol.wrapping_sub(limit)); probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).dist_slot) as *mut [probability; 64]) .offset( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len - MATCH_LEN_MIN + len.wrapping_sub(MATCH_LEN_MIN) } else { (DIST_STATES - 1) as u32 }) as isize, @@ -775,13 +788,15 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).match_len_decoder.choice2 as u32); + .wrapping_mul((*coder).match_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice2 = ((*coder).match_len_decoder.choice2 as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.choice2 as u32) - >> RC_MOVE_BITS - )) as probability; + (*coder).match_len_decoder.choice2 = ((*coder).match_len_decoder.choice2 as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).match_len_decoder.choice2 as u32) + >> RC_MOVE_BITS, + ) as probability; probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( (*coder).match_len_decoder.mid ) @@ -791,8 +806,8 @@ unsafe extern "C" fn lzma_decode( limit = LEN_MID_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.choice2 = (*coder).match_len_decoder.choice2 - ((*coder).match_len_decoder.choice2 >> RC_MOVE_BITS); probs = ::core::ptr::addr_of_mut!((*coder).match_len_decoder.high) @@ -815,13 +830,15 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).match_len_decoder.choice as u32); + .wrapping_mul((*coder).match_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.choice as u32) - >> RC_MOVE_BITS - )) as probability; + (*coder).match_len_decoder.choice = ((*coder).match_len_decoder.choice as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).match_len_decoder.choice as u32) + >> RC_MOVE_BITS, + ) as probability; probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( (*coder).match_len_decoder.low ) @@ -831,8 +848,8 @@ unsafe extern "C" fn lzma_decode( limit = LEN_LOW_SYMBOLS; len = MATCH_LEN_MIN; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.choice = (*coder).match_len_decoder.choice - ((*coder).match_len_decoder.choice >> RC_MOVE_BITS); current_block = 13912927785247575907; @@ -851,7 +868,7 @@ unsafe extern "C" fn lzma_decode( } 18125716024132132232 => { let match_bit: u32 = len & offset; - let subcoder_index: u32 = offset + match_bit + symbol; + let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { if rc_in_ptr == rc_in_end { (*coder).sequence = SEQ_LITERAL_MATCHED; @@ -864,22 +881,23 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(subcoder_index as isize) = - (*probs.offset(subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(subcoder_index as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(subcoder_index as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; offset &= !match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(subcoder_index as isize) -= *probs.offset(subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); offset &= match_bit; } len <<= 1; @@ -928,20 +946,23 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_match[state as usize][pos_state as usize] as u32); + .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_match[state as usize][pos_state as usize] = ((*coder).is_match [state as usize][pos_state as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_match[state as usize][pos_state as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; probs = (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability) .offset( - 3 * ( - ((dict.pos << 8) + ( + (3_usize).wrapping_mul( + ((dict.pos << 8).wrapping_add( dict_get0(::core::ptr::addr_of_mut!(dict)) as size_t, ) & literal_mask as size_t) << literal_context_bits, @@ -952,15 +973,15 @@ unsafe extern "C" fn lzma_decode( state = if state <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT } else { - state - 3 + state.wrapping_sub(3) }; current_block = 13844743919235296534; continue; } else { state = if state <= STATE_LIT_SHORTREP { - state - 3 + state.wrapping_sub(3) } else { - state - 6 + state.wrapping_sub(6) }; len = (dict_get(::core::ptr::addr_of_mut!(dict), rep0) as u32) << 1; offset = 0x100; @@ -968,8 +989,8 @@ unsafe extern "C" fn lzma_decode( continue; } } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_match[state as usize][pos_state as usize] = (*coder).is_match [state as usize][pos_state as usize] - ((*coder).is_match[state as usize][pos_state as usize] >> RC_MOVE_BITS); @@ -990,20 +1011,21 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if symbol < (1 << 8) as u32 { current_block = 13844743919235296534; @@ -1026,26 +1048,27 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; - *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + *probs.offset(symbol as isize) = (*probs.offset(symbol as isize) as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if symbol < limit { current_block = 2467942631393454738; continue; } - len += (symbol - limit); + len = len.wrapping_add(symbol.wrapping_sub(limit)); current_block = 17340485688450593529; continue; } @@ -1075,13 +1098,15 @@ unsafe extern "C" fn lzma_decode( } } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).rep_len_decoder.choice2 as u32); + .wrapping_mul((*coder).rep_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.choice2 as u32) - >> RC_MOVE_BITS - )) as probability; + (*coder).rep_len_decoder.choice2 = ((*coder).rep_len_decoder.choice2 as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).rep_len_decoder.choice2 as u32) + >> RC_MOVE_BITS, + ) as probability; probs = ::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!( (*coder).rep_len_decoder.mid ) @@ -1091,8 +1116,8 @@ unsafe extern "C" fn lzma_decode( limit = LEN_MID_SYMBOLS; len = (MATCH_LEN_MIN + LEN_LOW_SYMBOLS) as u32; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.choice2 = (*coder).rep_len_decoder.choice2 - ((*coder).rep_len_decoder.choice2 >> RC_MOVE_BITS); probs = ::core::ptr::addr_of_mut!((*coder).rep_len_decoder.high) @@ -1125,20 +1150,23 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_match[state as usize][pos_state as usize] as u32); + .wrapping_mul((*coder).is_match[state as usize][pos_state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_match[state as usize][pos_state as usize] = ((*coder).is_match [state as usize][pos_state as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_match[state as usize][pos_state as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; probs = (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability) .offset( - 3 * ( - ((dict.pos << 8) + ( + (3_usize).wrapping_mul( + ((dict.pos << 8).wrapping_add( dict_get0(::core::ptr::addr_of_mut!(dict)) as size_t, ) & literal_mask as size_t) << literal_context_bits, @@ -1148,7 +1176,7 @@ unsafe extern "C" fn lzma_decode( state = if state <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT } else { - state - 3 + state.wrapping_sub(3) }; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -1157,21 +1185,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1179,21 +1208,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1201,21 +1231,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1223,21 +1254,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1245,21 +1277,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1267,21 +1300,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1289,21 +1323,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -1311,27 +1346,28 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } } else { state = if state <= STATE_LIT_SHORTREP { - state - 3 + state.wrapping_sub(3) } else { - state - 6 + state.wrapping_sub(6) }; let mut t_match_byte: u32 = dict_get(::core::ptr::addr_of_mut!(dict), rep0) as u32; @@ -1341,233 +1377,233 @@ unsafe extern "C" fn lzma_decode( symbol = 1; t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset + t_match_bit + symbol; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(t_subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset + t_match_bit + symbol; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(t_subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset + t_match_bit + symbol; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(t_subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset + t_match_bit + symbol; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(t_subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset + t_match_bit + symbol; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(t_subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset + t_match_bit + symbol; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(t_subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset + t_match_bit + symbol; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(t_subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } t_match_byte <<= 1; t_match_bit = t_match_byte & t_offset; - t_subcoder_index = t_offset + t_match_bit + symbol; + t_subcoder_index = t_offset.wrapping_add(t_match_bit).wrapping_add(symbol); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(t_subcoder_index as isize) as u32); + .wrapping_mul(*probs.offset(t_subcoder_index as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(t_subcoder_index as isize) = - (*probs.offset(t_subcoder_index as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(t_subcoder_index as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(t_subcoder_index as isize) as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; t_offset &= !t_match_bit; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(t_subcoder_index as isize) -= *probs.offset(t_subcoder_index as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); t_offset &= t_match_bit; } } dict_put(::core::ptr::addr_of_mut!(dict), symbol as u8); } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_match[state as usize][pos_state as usize] = (*coder).is_match [state as usize][pos_state as usize] - ((*coder).is_match[state as usize][pos_state as usize] >> RC_MOVE_BITS); @@ -1577,14 +1613,15 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep[state as usize] as u32); + .wrapping_mul((*coder).is_rep[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep[state as usize] = - ((*coder).is_rep[state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).is_rep[state as usize] as u32) - >> RC_MOVE_BITS - )) as probability; + ((*coder).is_rep[state as usize] as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).is_rep[state as usize] as u32) + >> RC_MOVE_BITS, + ) as probability; state = (if state < LIT_STATES { STATE_LIT_MATCH } else { @@ -1600,119 +1637,129 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).match_len_decoder.choice as u32); + .wrapping_mul((*coder).match_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.choice = - ((*coder).match_len_decoder.choice as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).match_len_decoder.choice as u32) - >> RC_MOVE_BITS - )) as probability; + ((*coder).match_len_decoder.choice as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).match_len_decoder.choice as u32) + >> RC_MOVE_BITS, + ) as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.low[pos_state as usize][symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = ((*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.low [pos_state as usize][symbol as usize] - ((*coder).match_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol + ((-(1_i32 << 3) + 2) as u32); + symbol = symbol.wrapping_add((-(1_i32 << 3) + 2) as u32); len = symbol; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.choice = (*coder).match_len_decoder.choice - ((*coder).match_len_decoder.choice >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { @@ -1721,15 +1768,15 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).match_len_decoder.choice2 as u32); + .wrapping_mul((*coder).match_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.choice2 = - ((*coder).match_len_decoder.choice2 as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.choice2 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.choice2 as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -1737,10 +1784,10 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -1748,17 +1795,20 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] @@ -1766,17 +1816,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -1784,17 +1834,20 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] @@ -1802,17 +1855,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -1820,17 +1873,20 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).match_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).match_len_decoder.mid [pos_state as usize] @@ -1838,13 +1894,13 @@ unsafe extern "C" fn lzma_decode( - ((*coder).match_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol + ((-(1_i32 << 3) + 2 + (1 << 3)) as u32); + symbol = symbol.wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); len = symbol; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.choice2 = (*coder).match_len_decoder.choice2 - ((*coder).match_len_decoder.choice2 >> RC_MOVE_BITS); @@ -1854,227 +1910,235 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).match_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).match_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).match_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).match_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).match_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).match_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).match_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).match_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).match_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).match_len_decoder.high[symbol as usize] = - ((*coder).match_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).match_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).match_len_decoder.high[symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).match_len_decoder.high[symbol as usize] = (*coder).match_len_decoder.high[symbol as usize] - ((*coder).match_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } symbol = symbol - + ((-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32); + .wrapping_add((-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32); len = symbol; } } @@ -2084,7 +2148,7 @@ unsafe extern "C" fn lzma_decode( as *mut [probability; 64]) .offset( (if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len - MATCH_LEN_MIN + len.wrapping_sub(MATCH_LEN_MIN) } else { (DIST_STATES - 1) as u32 }) as isize, @@ -2096,21 +2160,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2118,21 +2183,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2140,21 +2206,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2162,21 +2229,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2184,21 +2252,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; @@ -2206,28 +2275,29 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - *probs.offset(symbol as isize) as u32) - >> RC_MOVE_BITS - )) as probability; + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub(*probs.offset(symbol as isize) as u32) + >> RC_MOVE_BITS, + ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol + (-(1_i32 << 6) as u32); + symbol = symbol.wrapping_add(-(1_i32 << 6) as u32); if symbol < DIST_MODEL_START { rep0 = symbol; } else { - limit = (symbol >> 1) - 1; - rep0 = 2 + (symbol & 1); + limit = (symbol >> 1).wrapping_sub(1); + rep0 = (2u32).wrapping_add(symbol & 1); if symbol < DIST_MODEL_END { rep0 <<= limit; probs = (::core::ptr::addr_of_mut!((*coder).pos_special) @@ -2244,24 +2314,24 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * (*probs.offset(symbol as isize) as u32); + .wrapping_mul(*probs.offset(symbol as isize) as u32); if rc.code < rc_bound { rc.range = rc_bound; *probs.offset(symbol as isize) = - (*probs.offset(symbol as isize) as u32 + ( - (RC_BIT_MODEL_TOTAL - + (*probs.offset(symbol as isize) as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( *probs.offset(symbol as isize) as u32, ) >> RC_MOVE_BITS, ) as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); *probs.offset(symbol as isize) -= *probs.offset(symbol as isize) >> RC_MOVE_BITS; - symbol = (symbol << 1) | 1; - rep0 += offset; + symbol = (symbol << 1).wrapping_add(1); + rep0 = rep0.wrapping_add(offset); } offset <<= 1; limit -= 1; @@ -2270,9 +2340,9 @@ unsafe extern "C" fn lzma_decode( } } } else { - limit -= ALIGN_BITS; + limit = limit.wrapping_sub(ALIGN_BITS); loop { - rep0 = (rep0 << 1) + (1); + rep0 = (rep0 << 1).wrapping_add(1); if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; @@ -2295,26 +2365,29 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).pos_align[symbol + (1) as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).pos_align[symbol.wrapping_add(1) as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol + (1) as usize] = ((*coder) + (*coder).pos_align[symbol.wrapping_add(1) as usize] = ((*coder) .pos_align - [symbol + (1) as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - - (*coder).pos_align[symbol + (1) as usize] + [symbol.wrapping_add(1) as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[symbol.wrapping_add(1) as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; - (*coder).pos_align[symbol + (1) as usize] = - (*coder).pos_align[symbol + (1) as usize] - - ((*coder).pos_align[symbol + (1) as usize] + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).pos_align[symbol.wrapping_add(1) as usize] = + (*coder).pos_align[symbol.wrapping_add(1) as usize] + - ((*coder).pos_align[symbol.wrapping_add(1) as usize] >> RC_MOVE_BITS); symbol += 1; } @@ -2323,86 +2396,95 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).pos_align[symbol + (2) as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).pos_align[symbol.wrapping_add(2) as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol + (2) as usize] = ((*coder) + (*coder).pos_align[symbol.wrapping_add(2) as usize] = ((*coder) .pos_align - [symbol + (2) as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - - (*coder).pos_align[symbol + (2) as usize] + [symbol.wrapping_add(2) as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[symbol.wrapping_add(2) as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; - (*coder).pos_align[symbol + (2) as usize] = - (*coder).pos_align[symbol + (2) as usize] - - ((*coder).pos_align[symbol + (2) as usize] + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).pos_align[symbol.wrapping_add(2) as usize] = + (*coder).pos_align[symbol.wrapping_add(2) as usize] + - ((*coder).pos_align[symbol.wrapping_add(2) as usize] >> RC_MOVE_BITS); - symbol = symbol + (2); + symbol = symbol.wrapping_add(2); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).pos_align[symbol + (4) as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).pos_align[symbol.wrapping_add(4) as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol + (4) as usize] = ((*coder) + (*coder).pos_align[symbol.wrapping_add(4) as usize] = ((*coder) .pos_align - [symbol + (4) as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - - (*coder).pos_align[symbol + (4) as usize] + [symbol.wrapping_add(4) as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[symbol.wrapping_add(4) as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; - (*coder).pos_align[symbol + (4) as usize] = - (*coder).pos_align[symbol + (4) as usize] - - ((*coder).pos_align[symbol + (4) as usize] + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).pos_align[symbol.wrapping_add(4) as usize] = + (*coder).pos_align[symbol.wrapping_add(4) as usize] + - ((*coder).pos_align[symbol.wrapping_add(4) as usize] >> RC_MOVE_BITS); - symbol = symbol + (4); + symbol = symbol.wrapping_add(4); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).pos_align[symbol + (8) as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).pos_align[symbol.wrapping_add(8) as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; - (*coder).pos_align[symbol + (8) as usize] = ((*coder) + (*coder).pos_align[symbol.wrapping_add(8) as usize] = ((*coder) .pos_align - [symbol + (8) as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - - (*coder).pos_align[symbol + (8) as usize] + [symbol.wrapping_add(8) as usize] + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( + (*coder).pos_align[symbol.wrapping_add(8) as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; - (*coder).pos_align[symbol + (8) as usize] = - (*coder).pos_align[symbol + (8) as usize] - - ((*coder).pos_align[symbol + (8) as usize] + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); + (*coder).pos_align[symbol.wrapping_add(8) as usize] = + (*coder).pos_align[symbol.wrapping_add(8) as usize] + - ((*coder).pos_align[symbol.wrapping_add(8) as usize] >> RC_MOVE_BITS); - symbol = symbol + (8); + symbol = symbol.wrapping_add(8); } - rep0 += symbol; + rep0 = rep0.wrapping_add(symbol); if rep0 == UINT32_MAX { break; } @@ -2415,8 +2497,8 @@ unsafe extern "C" fn lzma_decode( continue 'c_9380; } } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep[state as usize] = (*coder).is_rep[state as usize] - ((*coder).is_rep[state as usize] >> RC_MOVE_BITS); if !dict_is_distance_valid(::core::ptr::addr_of_mut!(dict), 0) { @@ -2430,35 +2512,37 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep0[state as usize] as u32); + .wrapping_mul((*coder).is_rep0[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0[state as usize] = - ((*coder).is_rep0[state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).is_rep0[state as usize] as u32) - >> RC_MOVE_BITS - )) as probability + ((*coder).is_rep0[state as usize] as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).is_rep0[state as usize] as u32) + >> RC_MOVE_BITS, + ) as probability as probability; if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).is_rep0_long[state as usize][pos_state as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep0_long[state as usize][pos_state as usize] = ((*coder).is_rep0_long[state as usize][pos_state as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_rep0_long[state as usize] [pos_state as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; state = (if state < LIT_STATES { STATE_LIT_SHORTREP @@ -2471,8 +2555,8 @@ unsafe extern "C" fn lzma_decode( ); continue; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep0_long[state as usize][pos_state as usize] = (*coder).is_rep0_long[state as usize][pos_state as usize] - ((*coder).is_rep0_long[state as usize] @@ -2480,8 +2564,8 @@ unsafe extern "C" fn lzma_decode( >> RC_MOVE_BITS); } } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep0[state as usize] = (*coder).is_rep0[state as usize] - ((*coder).is_rep0[state as usize] >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { @@ -2490,22 +2574,22 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep1[state as usize] as u32); + .wrapping_mul((*coder).is_rep1[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep1[state as usize] = - ((*coder).is_rep1[state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).is_rep1[state as usize] as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_rep1[state as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; let distance: u32 = rep1; rep1 = rep0; rep0 = distance; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep1[state as usize] = (*coder).is_rep1 [state as usize] - ((*coder).is_rep1[state as usize] >> RC_MOVE_BITS); @@ -2515,22 +2599,24 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).is_rep2[state as usize] as u32); + .wrapping_mul((*coder).is_rep2[state as usize] as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).is_rep2[state as usize] = - ((*coder).is_rep2[state as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).is_rep2[state as usize] as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).is_rep2[state as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; let distance_0: u32 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance_0; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).is_rep2[state as usize] = (*coder).is_rep2 [state as usize] - ((*coder).is_rep2[state as usize] >> RC_MOVE_BITS); @@ -2554,14 +2640,15 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).rep_len_decoder.choice as u32); + .wrapping_mul((*coder).rep_len_decoder.choice as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.choice = - ((*coder).rep_len_decoder.choice as u32 + ( - (RC_BIT_MODEL_TOTAL - (*coder).rep_len_decoder.choice as u32) - >> RC_MOVE_BITS - )) as probability + ((*coder).rep_len_decoder.choice as u32).wrapping_add( + RC_BIT_MODEL_TOTAL + .wrapping_sub((*coder).rep_len_decoder.choice as u32) + >> RC_MOVE_BITS, + ) as probability as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -2569,10 +2656,10 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2580,18 +2667,19 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] @@ -2599,17 +2687,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2617,18 +2705,19 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] @@ -2636,17 +2725,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2654,18 +2743,19 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.low [pos_state as usize] @@ -2673,13 +2763,13 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.low[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol + ((-(1_i32 << 3) + 2) as u32); + symbol = symbol.wrapping_add((-(1_i32 << 3) + 2) as u32); len = symbol; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.choice = (*coder).rep_len_decoder.choice - ((*coder).rep_len_decoder.choice >> RC_MOVE_BITS); if rc.range < RC_TOP_VALUE as u32 { @@ -2688,15 +2778,15 @@ unsafe extern "C" fn lzma_decode( rc_in_ptr = rc_in_ptr.offset(1); } rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) - * ((*coder).rep_len_decoder.choice2 as u32); + .wrapping_mul((*coder).rep_len_decoder.choice2 as u32); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.choice2 = - ((*coder).rep_len_decoder.choice2 as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.choice2 as u32).wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.choice2 as u32, - ) >> RC_MOVE_BITS - )) as probability + ) >> RC_MOVE_BITS, + ) as probability as probability; symbol = 1; if rc.range < RC_TOP_VALUE as u32 { @@ -2704,10 +2794,10 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2715,17 +2805,20 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] @@ -2733,17 +2826,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2751,17 +2844,20 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] @@ -2769,17 +2865,17 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] - as u32 + as u32, ); if rc.code < rc_bound { rc.range = rc_bound; @@ -2787,17 +2883,20 @@ unsafe extern "C" fn lzma_decode( [symbol as usize] = ((*coder).rep_len_decoder.mid [pos_state as usize] [symbol as usize] - as u32 + ( - (RC_BIT_MODEL_TOTAL - + as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] = (*coder).rep_len_decoder.mid [pos_state as usize] @@ -2805,14 +2904,14 @@ unsafe extern "C" fn lzma_decode( - ((*coder).rep_len_decoder.mid[pos_state as usize] [symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } symbol = - symbol + ((-(1_i32 << 3) + 2 + (1 << 3)) as u32); + symbol.wrapping_add((-(1_i32 << 3) + 2 + (1 << 3)) as u32); len = symbol; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.choice2 = (*coder).rep_len_decoder.choice2 - ((*coder).rep_len_decoder.choice2 >> RC_MOVE_BITS); @@ -2822,227 +2921,251 @@ unsafe extern "C" fn lzma_decode( rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).rep_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).rep_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).rep_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).rep_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).rep_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).rep_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).rep_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } if rc.range < RC_TOP_VALUE as u32 { rc.range <<= RC_SHIFT_BITS; rc.code = rc.code << RC_SHIFT_BITS | *rc_in_ptr as u32; rc_in_ptr = rc_in_ptr.offset(1); } - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * ( - (*coder).rep_len_decoder.high[symbol as usize] as u32 + rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul( + (*coder).rep_len_decoder.high[symbol as usize] as u32, ); if rc.code < rc_bound { rc.range = rc_bound; (*coder).rep_len_decoder.high[symbol as usize] = - ((*coder).rep_len_decoder.high[symbol as usize] as u32 + ( - (RC_BIT_MODEL_TOTAL - + ((*coder).rep_len_decoder.high[symbol as usize] as u32) + .wrapping_add( + RC_BIT_MODEL_TOTAL.wrapping_sub( (*coder).rep_len_decoder.high [symbol as usize] as u32, - ) >> RC_MOVE_BITS - )) as probability; + ) >> RC_MOVE_BITS, + ) + as probability + as probability; symbol <<= 1; } else { - rc.range -= rc_bound; - rc.code -= rc_bound; + rc.range = rc.range.wrapping_sub(rc_bound); + rc.code = rc.code.wrapping_sub(rc_bound); (*coder).rep_len_decoder.high[symbol as usize] = (*coder).rep_len_decoder.high[symbol as usize] - ((*coder).rep_len_decoder.high[symbol as usize] >> RC_MOVE_BITS); - symbol = (symbol << 1) | 1; + symbol = (symbol << 1).wrapping_add(1); } - symbol = symbol + ( - (-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32 + symbol = symbol.wrapping_add( + (-(1_i32 << 8) + 2 + (1 << 3) + (1 << 3)) as u32, ); len = symbol; } @@ -3105,7 +3228,7 @@ unsafe extern "C" fn lzma_decode( if (*coder).uncompressed_size != LZMA_VLI_UNKNOWN { (*coder).uncompressed_size = (*coder) .uncompressed_size - - (dict.pos - dict_start as lzma_vli); + .wrapping_sub(dict.pos.wrapping_sub(dict_start) as lzma_vli); if (*coder).uncompressed_size == 0 && ret_0 == LZMA_OK && ((*coder).sequence == SEQ_LITERAL_WRITE @@ -3135,20 +3258,20 @@ unsafe extern "C" fn lzma_decoder_uncompressed( unsafe extern "C" fn lzma_decoder_reset(coder_ptr: *mut c_void, opt: *const c_void) { let coder: *mut lzma_lzma1_decoder = coder_ptr as *mut lzma_lzma1_decoder; let options: *const lzma_options_lzma = opt as *const lzma_options_lzma; - (*coder).pos_mask = ((1u32 << (*options).pb) - 1) as u32; + (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; literal_init( ::core::ptr::addr_of_mut!((*coder).literal) as *mut probability, (*options).lc, (*options).lp, ); (*coder).literal_context_bits = (*options).lc; - (*coder).literal_mask = (0x100u32 << (*options).lp) - (0x100 >> (*options).lc); + (*coder).literal_mask = (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); (*coder).state = STATE_LIT_LIT; (*coder).rep0 = 0; (*coder).rep1 = 0; (*coder).rep2 = 0; (*coder).rep3 = 0; - (*coder).pos_mask = ((1u32 << (*options).pb) - 1) as u32; + (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; (*coder).rc.range = UINT32_MAX; (*coder).rc.code = 0; (*coder).rc.init_bytes_left = 5; @@ -3287,7 +3410,7 @@ unsafe extern "C" fn lzma_decoder_init( if (*opt).ext_flags & !(LZMA_LZMA1EXT_ALLOW_EOPM as u32) != 0 { return LZMA_OPTIONS_ERROR; } - uncomp_size = ((*opt).ext_size_low as u64) + (((*opt).ext_size_high as u64) << 32) + uncomp_size = ((*opt).ext_size_low as u64).wrapping_add(((*opt).ext_size_high as u64) << 32) as lzma_vli; allow_eopm = (*opt).ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM as u32 != 0 || uncomp_size == LZMA_VLI_UNKNOWN; @@ -3334,16 +3457,16 @@ pub unsafe fn lzma_lzma_lclppb_decode( return true; } (*options).pb = (byte / (9 * 5)) as u32; - byte = ((byte as u32) - (*options).pb * 9 * 5) as u8; + byte = (byte as u32).wrapping_sub((*options).pb.wrapping_mul(9u32).wrapping_mul(5)) as u8; (*options).lp = (byte / 9) as u32; - (*options).lc = (byte as u32) - (*options).lp * 9; - (*options).lc + (*options).lp > LZMA_LCLP_MAX + (*options).lc = (byte as u32).wrapping_sub((*options).lp.wrapping_mul(9)); + (*options).lc.wrapping_add((*options).lp) > LZMA_LCLP_MAX } pub extern "C" fn lzma_lzma_decoder_memusage_nocheck(options: *const c_void) -> u64 { return unsafe { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; (core::mem::size_of::() as u64) - + (lzma_lz_decoder_memusage((*opt).dict_size as size_t)) + .wrapping_add(lzma_lz_decoder_memusage((*opt).dict_size as size_t)) }; } pub extern "C" fn lzma_lzma_decoder_memusage(options: *const c_void) -> u64 { From 360c6aec34d5c288c8488d8cce897096d6fa9521 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 21:53:50 +0900 Subject: [PATCH 33/51] Replace wrapping ops with plain arithmetic in lzma encoder modules --- liblzma-rs/src/lzma/lzma2_encoder.rs | 71 +++----- liblzma-rs/src/lzma/lzma_encoder.rs | 75 ++++----- .../src/lzma/lzma_encoder_optimum_normal.rs | 154 +++++++++--------- 3 files changed, 132 insertions(+), 168 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 5db83958..8d936c8f 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -25,10 +25,7 @@ pub const SEQ_LZMA_ENCODE: lzma2_encoder_seq = 1; pub const SEQ_INIT: lzma2_encoder_seq = 0; #[inline] unsafe fn mf_unencoded(mf: *const lzma_mf) -> u32 { - (*mf) - .write_pos - .wrapping_sub((*mf).read_pos) - .wrapping_add((*mf).read_ahead) + (*mf).write_pos - (*mf).read_pos + (*mf).read_ahead } #[inline] unsafe fn mf_read( @@ -38,7 +35,7 @@ unsafe fn mf_read( out_size: size_t, left: *mut size_t, ) { - let out_avail: size_t = out_size.wrapping_sub(*out_pos); + let out_avail: size_t = out_size - *out_pos; let copy_size: size_t = if out_avail < *left { out_avail } else { *left }; core::ptr::copy_nonoverlapping( (*mf) @@ -48,8 +45,8 @@ unsafe fn mf_read( out.offset(*out_pos as isize) as *mut u8, copy_size, ); - *out_pos = (*out_pos).wrapping_add(copy_size); - *left = (*left).wrapping_sub(copy_size); + *out_pos += copy_size; + *left -= copy_size; } pub const LZMA2_UNCOMPRESSED_MAX: c_uint = 1u32 << 21; pub const LZMA2_HEADER_MAX: u32 = 6; @@ -71,15 +68,15 @@ unsafe fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { } } (*coder).buf_pos = pos; - let mut size: size_t = (*coder).uncompressed_size.wrapping_sub(1); + let mut size: size_t = (*coder).uncompressed_size - 1; (*coder).buf[pos as usize] = - ((*coder).buf[pos as usize] as size_t).wrapping_add(size >> 16) as u8; + ((*coder).buf[pos as usize] as size_t + (size >> 16)) as u8; pos += 1; (*coder).buf[pos as usize] = (size >> 8 & 0xff) as u8; pos += 1; (*coder).buf[pos as usize] = (size & 0xff) as u8; pos += 1; - size = (*coder).compressed_size.wrapping_sub(1); + size = (*coder).compressed_size - 1; (*coder).buf[pos as usize] = (size >> 8) as u8; pos += 1; (*coder).buf[pos as usize] = (size & 0xff) as u8; @@ -93,9 +90,7 @@ unsafe fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { (*coder).need_properties = false; (*coder).need_state_reset = false; (*coder).need_dictionary_reset = false; - (*coder).compressed_size = (*coder) - .compressed_size - .wrapping_add(LZMA2_HEADER_MAX as size_t); + (*coder).compressed_size += LZMA2_HEADER_MAX as size_t; } unsafe fn lzma2_header_uncompressed(coder: *mut lzma_lzma2_coder) { if (*coder).need_dictionary_reset { @@ -104,8 +99,8 @@ unsafe fn lzma2_header_uncompressed(coder: *mut lzma_lzma2_coder) { (*coder).buf[0] = 2; } (*coder).need_dictionary_reset = false; - (*coder).buf[1] = ((*coder).uncompressed_size.wrapping_sub(1) >> 8) as u8; - (*coder).buf[2] = ((*coder).uncompressed_size.wrapping_sub(1) & 0xff) as u8; + (*coder).buf[1] = ((*coder).uncompressed_size - 1 >> 8) as u8; + (*coder).buf[2] = ((*coder).uncompressed_size - 1 & 0xff) as u8; (*coder).buf_pos = 0; } unsafe extern "C" fn lzma2_encode( @@ -189,20 +184,15 @@ unsafe extern "C" fn lzma2_encode( current_block_45 = 11743904203796629665; } 2979737022853876585 => { - let left: u32 = (LZMA2_UNCOMPRESSED_MAX as size_t) - .wrapping_sub((*coder).uncompressed_size) - as u32; + let left: u32 = + ((LZMA2_UNCOMPRESSED_MAX as size_t) - (*coder).uncompressed_size) as u32; let mut limit: u32 = 0; if left < (*mf).match_len_max { limit = 0; } else { - limit = (*mf) - .read_pos - .wrapping_sub((*mf).read_ahead) - .wrapping_add(left) - .wrapping_sub((*mf).match_len_max); + limit = (*mf).read_pos - (*mf).read_ahead + left - (*mf).match_len_max; } - let read_start: u32 = (*mf).read_pos.wrapping_sub((*mf).read_ahead); + let read_start: u32 = (*mf).read_pos - (*mf).read_ahead; let ret: lzma_ret = lzma_lzma_encode( (*coder).lzma as *mut lzma_lzma1_encoder, mf, @@ -212,19 +202,13 @@ unsafe extern "C" fn lzma2_encode( LZMA2_CHUNK_MAX as size_t, limit, ); - (*coder).uncompressed_size = (*coder).uncompressed_size.wrapping_add( - (*mf) - .read_pos - .wrapping_sub((*mf).read_ahead) - .wrapping_sub(read_start) as size_t, - ); + (*coder).uncompressed_size += + ((*mf).read_pos - (*mf).read_ahead - read_start) as size_t; if ret != LZMA_STREAM_END { return LZMA_OK; } if (*coder).compressed_size >= (*coder).uncompressed_size { - (*coder).uncompressed_size = (*coder) - .uncompressed_size - .wrapping_add((*mf).read_ahead as size_t); + (*coder).uncompressed_size += (*mf).read_ahead as size_t; (*mf).read_ahead = 0; lzma2_header_uncompressed(coder); (*coder).need_state_reset = true; @@ -278,7 +262,7 @@ unsafe extern "C" fn lzma2_encoder_options_update( { if (*opt).lc > LZMA_LCLP_MAX || (*opt).lp > LZMA_LCLP_MAX - || (*opt).lc.wrapping_add((*opt).lp) > LZMA_LCLP_MAX + || (*opt).lc + (*opt).lp > LZMA_LCLP_MAX || (*opt).pb > LZMA_PB_MAX { return LZMA_OPTIONS_ERROR; @@ -343,13 +327,8 @@ unsafe extern "C" fn lzma2_encoder_init( if ret_ != LZMA_OK { return ret_; } - if (*lz_options) - .before_size - .wrapping_add((*lz_options).dict_size) - < LZMA2_CHUNK_MAX as size_t - { - (*lz_options).before_size = - (LZMA2_CHUNK_MAX as size_t).wrapping_sub((*lz_options).dict_size); + if (*lz_options).before_size + (*lz_options).dict_size < LZMA2_CHUNK_MAX as size_t { + (*lz_options).before_size = (LZMA2_CHUNK_MAX as size_t) - (*lz_options).dict_size; } LZMA_OK } @@ -379,7 +358,7 @@ pub extern "C" fn lzma_lzma2_encoder_memusage(options: *const c_void) -> u64 { if lzma_mem == UINT64_MAX { return UINT64_MAX; } - (core::mem::size_of::() as u64).wrapping_add(lzma_mem) + (core::mem::size_of::() as u64) + lzma_mem } pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { if options.is_null() { @@ -400,19 +379,19 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *m if d == UINT32_MAX { *out = 40; } else { - *out = get_dist_slot(d.wrapping_add(1)).wrapping_sub(24) as u8; + *out = (get_dist_slot(d + 1) - 24) as u8; } LZMA_OK } pub unsafe extern "C" fn lzma_lzma2_block_size(options: *const c_void) -> u64 { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; if (*opt).dict_size < LZMA_DICT_SIZE_MIN as u32 - || (*opt).dict_size > (1u32 << 30).wrapping_add(1 << 29) + || (*opt).dict_size > (1u32 << 30) + (1 << 29) { return UINT64_MAX; } - if ((*opt).dict_size as u64).wrapping_mul(3) > 1 << 20 { - ((*opt).dict_size as u64).wrapping_mul(3) + if ((*opt).dict_size as u64) * 3 > 1 << 20 { + ((*opt).dict_size as u64) * 3 } else { 1 << 20 } diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 510132e8..57365b97 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -102,16 +102,16 @@ unsafe fn rc_shift_low( } *out.offset(*out_pos as isize) = (*rc).cache.wrapping_add(((*rc).low >> 32) as u8); *out_pos += 1; - (*rc).out_total = (*rc).out_total.wrapping_add(1); + (*rc).out_total += 1; (*rc).cache = 0xff; - (*rc).cache_size = (*rc).cache_size.wrapping_sub(1); + (*rc).cache_size -= 1; if (*rc).cache_size == 0 { break; } } (*rc).cache = ((*rc).low >> 24 & 0xff as u64) as u8; } - (*rc).cache_size = (*rc).cache_size.wrapping_add(1); + (*rc).cache_size += 1; (*rc).low = ((*rc).low & 0xffffff as u64) << RC_SHIFT_BITS; false } @@ -130,14 +130,14 @@ unsafe fn rc_shift_low_dummy( } *out_pos += 1; *cache = 0xff; - *cache_size = (*cache_size).wrapping_sub(1); + *cache_size -= 1; if *cache_size == 0 { break; } } *cache = (*low >> 24 & 0xff as u64) as u8; } - *cache_size = (*cache_size).wrapping_add(1); + *cache_size += 1; *low = (*low & 0xffffff as u64) << RC_SHIFT_BITS; false } @@ -186,7 +186,7 @@ unsafe fn rc_encode( if rc_shift_low(rc, out, out_pos, out_size) { return true; } - (*rc).pos = (*rc).pos.wrapping_add(1); + (*rc).pos += 1; if (*rc).pos >= (*rc).count { break; } @@ -196,7 +196,7 @@ unsafe fn rc_encode( } _ => {} } - (*rc).pos = (*rc).pos.wrapping_add(1); + (*rc).pos += 1; } (*rc).count = 0; (*rc).pos = 0; @@ -265,7 +265,7 @@ unsafe fn rc_encode_dummy(rc: *const lzma_range_encoder, out_limit: u64) -> bool } #[inline] unsafe fn rc_pending(rc: *const lzma_range_encoder) -> u64 { - (*rc).cache_size.wrapping_add(5).wrapping_sub(1) + (*rc).cache_size + 5 - 1 } pub const LEN_SYMBOLS: u32 = LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS; pub const MATCH_LEN_MAX: u32 = MATCH_LEN_MIN + LEN_SYMBOLS - 1; @@ -277,11 +277,11 @@ unsafe fn literal_matched( mut symbol: u32, ) { let mut offset: u32 = 0x100; - symbol = (symbol as u32).wrapping_add(1u32 << 8) as u32; + symbol = (symbol as u32 + (1u32 << 8)) as u32; loop { match_byte <<= 1; let match_bit: u32 = match_byte & offset; - let subcoder_index: u32 = offset.wrapping_add(match_bit).wrapping_add(symbol >> 8); + let subcoder_index: u32 = offset + match_bit + (symbol >> 8); let bit: u32 = symbol >> 7 & 1; rc_bit( rc, @@ -299,7 +299,7 @@ unsafe fn literal_matched( unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u32) { let cur_byte: u8 = *(*mf) .buffer - .offset((*mf).read_pos.wrapping_sub((*mf).read_ahead) as isize); + .offset(((*mf).read_pos - (*mf).read_ahead) as isize); let subcoder: *mut probability = (::core::ptr::addr_of_mut!((*coder).literal) as *mut probability).offset( (3u32 @@ -315,7 +315,7 @@ unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u3 (*coder).state = (if (*coder).state <= STATE_SHORTREP_LIT_LIT { STATE_LIT_LIT } else { - ((*coder).state as u32).wrapping_sub(3) + (*coder).state as u32 - 3 }) as lzma_lzma_state; rc_bittree( ::core::ptr::addr_of_mut!((*coder).rc), @@ -325,16 +325,12 @@ unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u3 ); } else { (*coder).state = (if (*coder).state <= STATE_LIT_SHORTREP { - ((*coder).state as u32).wrapping_sub(3) + (*coder).state as u32 - 3 } else { - ((*coder).state as u32).wrapping_sub(6) + (*coder).state as u32 - 6 }) as lzma_lzma_state; let match_byte: u8 = *(*mf).buffer.offset( - (*mf) - .read_pos - .wrapping_sub((*coder).reps[0]) - .wrapping_sub(1) - .wrapping_sub((*mf).read_ahead) as isize, + ((*mf).read_pos - (*coder).reps[0] - 1 - (*mf).read_ahead) as isize, ); literal_matched( ::core::ptr::addr_of_mut!((*coder).rc), @@ -451,7 +447,7 @@ unsafe fn match_0(coder: *mut lzma_lzma1_encoder, pos_state: u32, distance: u32, ); let dist_slot: u32 = get_dist_slot(distance) as u32; let dist_state: u32 = if len < (DIST_STATES + MATCH_LEN_MIN) as u32 { - len.wrapping_sub(MATCH_LEN_MIN) + len - MATCH_LEN_MIN } else { (DIST_STATES - 1) as u32 }; @@ -464,9 +460,9 @@ unsafe fn match_0(coder: *mut lzma_lzma1_encoder, pos_state: u32, distance: u32, dist_slot, ); if dist_slot >= DIST_MODEL_START { - let footer_bits: u32 = (dist_slot >> 1).wrapping_sub(1); + let footer_bits: u32 = (dist_slot >> 1) - 1; let base: u32 = (2 | dist_slot & 1) << footer_bits; - let dist_reduced: u32 = distance.wrapping_sub(base); + let dist_reduced: u32 = distance - base; if dist_slot < DIST_MODEL_END { rc_bittree_reverse( ::core::ptr::addr_of_mut!((*coder).rc), @@ -481,7 +477,7 @@ unsafe fn match_0(coder: *mut lzma_lzma1_encoder, pos_state: u32, distance: u32, rc_direct( ::core::ptr::addr_of_mut!((*coder).rc), dist_reduced >> ALIGN_BITS, - footer_bits.wrapping_sub(ALIGN_BITS), + footer_bits - ALIGN_BITS, ); rc_bittree_reverse( ::core::ptr::addr_of_mut!((*coder).rc), @@ -489,14 +485,14 @@ unsafe fn match_0(coder: *mut lzma_lzma1_encoder, pos_state: u32, distance: u32, ALIGN_BITS, dist_reduced & ALIGN_MASK, ); - (*coder).align_price_count = (*coder).align_price_count.wrapping_add(1); + (*coder).align_price_count += 1; } } (*coder).reps[3] = (*coder).reps[2]; (*coder).reps[2] = (*coder).reps[1]; (*coder).reps[1] = (*coder).reps[0]; (*coder).reps[0] = distance; - (*coder).match_price_count = (*coder).match_price_count.wrapping_add(1); + (*coder).match_price_count += 1; } #[inline] unsafe fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, rep: u32, len: u32) { @@ -541,7 +537,7 @@ unsafe fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, rep: u32, le ::core::ptr::addr_of_mut!((*coder).rc), (::core::ptr::addr_of_mut!((*coder).is_rep2) as *mut probability) .offset((*coder).state as isize) as *mut probability, - rep.wrapping_sub(2), + rep - 2, ); if rep == 3 { (*coder).reps[3] = (*coder).reps[2]; @@ -630,7 +626,7 @@ unsafe fn encode_init(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf) -> bool 8, *(*mf).buffer as u32, ); - (*coder).uncomp_size = (*coder).uncomp_size.wrapping_add(1); + (*coder).uncomp_size += 1; } (*coder).is_initialized = true; true @@ -836,9 +832,9 @@ pub unsafe fn lzma_lzma_encoder_reset( if !is_options_valid(options) { return LZMA_OPTIONS_ERROR; } - (*coder).pos_mask = (1u32 << (*options).pb).wrapping_sub(1) as u32; + (*coder).pos_mask = ((1u32 << (*options).pb) - 1) as u32; (*coder).literal_context_bits = (*options).lc; - (*coder).literal_mask = (0x100u32 << (*options).lp).wrapping_sub(0x100 >> (*options).lc); + (*coder).literal_mask = (0x100u32 << (*options).lp) - (0x100 >> (*options).lc); rc_reset(::core::ptr::addr_of_mut!((*coder).rc)); (*coder).state = STATE_LIT_LIT; let mut i: size_t = 0; @@ -896,8 +892,8 @@ pub unsafe fn lzma_lzma_encoder_reset( 1 << (*options).pb, (*coder).fast_mode, ); - (*coder).match_price_count = UINT32_MAX.wrapping_div(2); - (*coder).align_price_count = UINT32_MAX.wrapping_div(2); + (*coder).match_price_count = UINT32_MAX / 2; + (*coder).align_price_count = UINT32_MAX / 2; (*coder).opts_end_index = 0; (*coder).opts_current_index = 0; LZMA_OK @@ -923,23 +919,23 @@ pub unsafe fn lzma_lzma_encoder_create( } 2 => { (*coder).fast_mode = false; - if (*options).dict_size > (1u32 << 30).wrapping_add(1 << 29) { + if (*options).dict_size > (1u32 << 30) + (1 << 29) { return LZMA_OPTIONS_ERROR; } let mut log_size: u32 = 0; while 1 << log_size < (*options).dict_size { log_size += 1; } - (*coder).dist_table_size = log_size.wrapping_mul(2); + (*coder).dist_table_size = log_size * 2; let nice_len: u32 = if mf_get_hash_bytes((*options).mf) > (*options).nice_len { mf_get_hash_bytes((*options).mf) as u32 } else { (*options).nice_len }; (*coder).match_len_encoder.table_size = - nice_len.wrapping_add(1u32).wrapping_sub(MATCH_LEN_MIN); + nice_len + 1 - MATCH_LEN_MIN; (*coder).rep_len_encoder.table_size = - nice_len.wrapping_add(1u32).wrapping_sub(MATCH_LEN_MIN); + nice_len + 1 - MATCH_LEN_MIN; } _ => return LZMA_OPTIONS_ERROR, } @@ -1033,18 +1029,13 @@ pub extern "C" fn lzma_lzma_encoder_memusage(options: *const c_void) -> u64 { if lz_memusage == UINT64_MAX { return UINT64_MAX; } - (core::mem::size_of::() as u64).wrapping_add(lz_memusage) + (core::mem::size_of::() as u64) + lz_memusage } pub unsafe fn lzma_lzma_lclppb_encode(options: *const lzma_options_lzma, byte: *mut u8) -> bool { if !is_lclppb_valid(options) { return true; } - *byte = (*options) - .pb - .wrapping_mul(5) - .wrapping_add((*options).lp) - .wrapping_mul(9) - .wrapping_add((*options).lc) as u8; + *byte = (((*options).pb * 5 + (*options).lp) * 9 + (*options).lc) as u8; false } pub unsafe extern "C" fn lzma_lzma_props_encode(options: *const c_void, out: *mut u8) -> lzma_ret { diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 7c1971ff..abc1795b 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -589,7 +589,7 @@ unsafe fn helper2( } else { state = (*opts.add(pos_prev as usize)).state; } - if pos_prev == cur.wrapping_sub(1) { + if pos_prev == cur - 1 { if (*opts.add(cur as usize)).back_prev == 0 { state = update_short_rep_state(state); } else { @@ -615,7 +615,7 @@ unsafe fn helper2( let mut i: u32 = 0; i = 1; while i <= pos { - *reps.offset(i as isize) = *prev_backs.add(i.wrapping_sub(1) as usize); + *reps.offset(i as isize) = *prev_backs.add((i - 1) as usize); i += 1; } while i < REPS { @@ -623,11 +623,11 @@ unsafe fn helper2( i += 1; } } else { - *reps = pos.wrapping_sub(REPS); + *reps = pos - REPS; let prev_backs = optimal_backs_ptr(opts.add(pos_prev as usize)); let mut i_0: u32 = 1; while i_0 < REPS { - *reps.offset(i_0 as isize) = *prev_backs.add(i_0.wrapping_sub(1) as usize); + *reps.offset(i_0 as isize) = *prev_backs.add((i_0 - 1) as usize); i_0 += 1; } } @@ -644,16 +644,16 @@ unsafe fn helper2( let match_byte: u8 = *buf.offset(-(*reps as isize)).offset(-1); let pos_state: u32 = position & (*coder).pos_mask; let cur_and_1_price: u32 = cur_price - .wrapping_add(rc_bit_0_price(match_prob(coder, state, pos_state)) as u32) - .wrapping_add(get_literal_price( + + rc_bit_0_price(match_prob(coder, state, pos_state)) as u32 + + get_literal_price( coder, position, *buf.offset(-1) as u32, !is_literal_state(state), match_byte as u32, current_byte as u32, - ) as u32); - let next_opt = &mut *opts.add(cur.wrapping_add(1) as usize); + ) as u32; + let next_opt = &mut *opts.add((cur + 1) as usize); let mut next_is_literal: bool = false; if cur_and_1_price < next_opt.price { next_opt.price = cur_and_1_price; @@ -662,12 +662,12 @@ unsafe fn helper2( next_is_literal = true; } let match_price: u32 = - cur_price.wrapping_add(rc_bit_1_price(match_prob(coder, state, pos_state)) as u32); + cur_price + rc_bit_1_price(match_prob(coder, state, pos_state)) as u32; let rep_match_price: u32 = - match_price.wrapping_add(rc_bit_1_price(is_rep_prob(coder, state)) as u32); + match_price + rc_bit_1_price(is_rep_prob(coder, state)) as u32; if match_byte == current_byte && !(next_opt.pos_prev < cur && next_opt.back_prev == 0) { let short_rep_price: u32 = - rep_match_price.wrapping_add(get_short_rep_price(coder, state, pos_state) as u32); + rep_match_price + get_short_rep_price(coder, state, pos_state) as u32; if short_rep_price <= next_opt.price { next_opt.price = short_rep_price; next_opt.pos_prev = cur; @@ -685,34 +685,34 @@ unsafe fn helper2( }; if !next_is_literal && match_byte != current_byte { let buf_back: *const u8 = buf.offset(-(*reps as isize)).offset(-1); - let limit: u32 = if buf_avail_full < nice_len.wrapping_add(1) { + let limit: u32 = if buf_avail_full < nice_len + 1 { buf_avail_full } else { - nice_len.wrapping_add(1) + nice_len + 1 }; - let len_test: u32 = (lzma_memcmplen(buf, buf_back, 1, limit) as u32).wrapping_sub(1); + let len_test: u32 = (lzma_memcmplen(buf, buf_back, 1, limit) as u32) - 1; if len_test >= 2 { let state_2: lzma_lzma_state = update_literal_state(state); - let pos_state_next: u32 = position.wrapping_add(1) & (*coder).pos_mask; + let pos_state_next: u32 = (position + 1) & (*coder).pos_mask; let next_rep_match_price: u32 = cur_and_1_price - .wrapping_add(rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32) - .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2)) as u32); - let offset: u32 = cur.wrapping_add(1u32).wrapping_add(len_test); + + rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32 + + rc_bit_1_price(is_rep_prob(coder, state_2)) as u32; + let offset: u32 = cur + 1 + len_test; while len_end < offset { len_end += 1; (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } - let cur_and_len_price: u32 = next_rep_match_price.wrapping_add(get_rep_price( + let cur_and_len_price: u32 = next_rep_match_price + get_rep_price( coder, 0, len_test, state_2, pos_state_next, - ) as u32); + ) as u32; let opt = opts.add(offset as usize); if cur_and_len_price < (*opt).price { (*opt).price = cur_and_len_price; - (*opt).pos_prev = cur.wrapping_add(1); + (*opt).pos_prev = cur + 1; (*opt).back_prev = 0; (*opt).prev_1_is_literal = true; (*opt).prev_2 = false; @@ -727,20 +727,20 @@ unsafe fn helper2( .offset(-1); if !not_equal_16(buf, buf_back_0) { let mut len_test_0: u32 = lzma_memcmplen(buf, buf_back_0, 2, buf_avail); - while len_end < cur.wrapping_add(len_test_0) { + while len_end < cur + len_test_0 { len_end += 1; (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } let len_test_temp: u32 = len_test_0; let price: u32 = rep_match_price - .wrapping_add(get_pure_rep_price(coder, rep_index, state, pos_state) as u32); + + get_pure_rep_price(coder, rep_index, state, pos_state) as u32; loop { - let cur_and_len_price_0: u32 = price.wrapping_add(get_len_price( + let cur_and_len_price_0: u32 = price + get_len_price( ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), len_test_0, pos_state, - ) as u32); - let opt = opts.add(cur.wrapping_add(len_test_0) as usize); + ) as u32; + let opt = opts.add((cur + len_test_0) as usize); if cur_and_len_price_0 < (*opt).price { (*opt).price = cur_and_len_price_0; (*opt).pos_prev = cur; @@ -754,18 +754,18 @@ unsafe fn helper2( } len_test_0 = len_test_temp; if rep_index == 0 { - start_len = len_test_0.wrapping_add(1); + start_len = len_test_0 + 1; } - let mut len_test_2: u32 = len_test_0.wrapping_add(1); - let limit_0: u32 = if buf_avail_full < len_test_2.wrapping_add(nice_len) { + let mut len_test_2: u32 = len_test_0 + 1; + let limit_0: u32 = if buf_avail_full < len_test_2 + nice_len { buf_avail_full } else { - len_test_2.wrapping_add(nice_len) + len_test_2 + nice_len }; if len_test_2 < limit_0 { len_test_2 = lzma_memcmplen(buf, buf_back_0, len_test_2, limit_0); } - len_test_2 = len_test_2.wrapping_sub(len_test_0.wrapping_add(1)); + len_test_2 -= len_test_0 + 1; if len_test_2 >= 2 { consider_literal_after_rep( coder, @@ -797,8 +797,8 @@ unsafe fn helper2( } if new_len >= start_len { let normal_match_price: u32 = - match_price.wrapping_add(rc_bit_0_price(is_rep_prob(coder, state)) as u32); - while len_end < cur.wrapping_add(new_len) { + match_price + rc_bit_0_price(is_rep_prob(coder, state)) as u32; + while len_end < cur + new_len { len_end += 1; (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } @@ -810,26 +810,26 @@ unsafe fn helper2( loop { let cur_back: u32 = (*matches.add(i_2 as usize)).dist; let cur_and_len_price_2: u32 = normal_match_price - .wrapping_add(get_dist_len_price(coder, cur_back, len_test_1, pos_state)); - let opt = opts.add(cur.wrapping_add(len_test_1) as usize); + + get_dist_len_price(coder, cur_back, len_test_1, pos_state); + let opt = opts.add((cur + len_test_1) as usize); if cur_and_len_price_2 < (*opt).price { (*opt).price = cur_and_len_price_2; (*opt).pos_prev = cur; - (*opt).back_prev = cur_back.wrapping_add(REPS); + (*opt).back_prev = cur_back + REPS; (*opt).prev_1_is_literal = false; } if len_test_1 == (*matches.add(i_2 as usize)).len { let buf_back_1: *const u8 = buf.offset(-(cur_back as isize)).offset(-1); - let mut len_test_2_0: u32 = len_test_1.wrapping_add(1); - let limit_1: u32 = if buf_avail_full < len_test_2_0.wrapping_add(nice_len) { + let mut len_test_2_0: u32 = len_test_1 + 1; + let limit_1: u32 = if buf_avail_full < len_test_2_0 + nice_len { buf_avail_full } else { - len_test_2_0.wrapping_add(nice_len) + len_test_2_0 + nice_len }; if len_test_2_0 < limit_1 { len_test_2_0 = lzma_memcmplen(buf, buf_back_1, len_test_2_0, limit_1); } - len_test_2_0 = len_test_2_0.wrapping_sub(len_test_1.wrapping_add(1)); + len_test_2_0 -= len_test_1 + 1; if len_test_2_0 >= 2 { consider_literal_after_match( coder, @@ -875,46 +875,43 @@ unsafe fn consider_literal_after_rep( ) { let mut state_2: lzma_lzma_state = state; state_2 = update_long_rep_state(state_2); - let mut pos_state_next: u32 = position.wrapping_add(len_test) & (*coder).pos_mask; + let mut pos_state_next: u32 = (position + len_test) & (*coder).pos_mask; let cur_and_len_literal_price: u32 = price - .wrapping_add(get_len_price( + + get_len_price( ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), len_test, pos_state, - ) as u32) - .wrapping_add(rc_bit_0_price(match_prob(coder, state_2, pos_state_next)) as u32) - .wrapping_add(get_literal_price( + ) as u32 + + rc_bit_0_price(match_prob(coder, state_2, pos_state_next)) as u32 + + get_literal_price( coder, - position.wrapping_add(len_test), - *buf.offset(len_test.wrapping_sub(1) as isize) as u32, + position + len_test, + *buf.offset((len_test - 1) as isize) as u32, true, *buf_back.offset(len_test as isize) as u32, *buf.offset(len_test as isize) as u32, - ) as u32); + ) as u32; state_2 = update_literal_state(state_2); - pos_state_next = position.wrapping_add(len_test).wrapping_add(1) & (*coder).pos_mask; + pos_state_next = (position + len_test + 1) & (*coder).pos_mask; let next_rep_match_price: u32 = cur_and_len_literal_price - .wrapping_add(rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32) - .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2)) as u32); - let offset: u32 = cur - .wrapping_add(len_test) - .wrapping_add(1) - .wrapping_add(len_test_2); + + rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32 + + rc_bit_1_price(is_rep_prob(coder, state_2)) as u32; + let offset: u32 = cur + len_test + 1 + len_test_2; while *len_end < offset { *len_end += 1; (*opts.add(*len_end as usize)).price = RC_INFINITY_PRICE as u32; } - let cur_and_len_price: u32 = next_rep_match_price.wrapping_add(get_rep_price( + let cur_and_len_price: u32 = next_rep_match_price + get_rep_price( coder, 0, len_test_2, state_2, pos_state_next, - ) as u32); + ) as u32; let opt = opts.add(offset as usize); if cur_and_len_price < (*opt).price { (*opt).price = cur_and_len_price; - (*opt).pos_prev = cur.wrapping_add(len_test).wrapping_add(1); + (*opt).pos_prev = cur + len_test + 1; (*opt).back_prev = 0; (*opt).prev_1_is_literal = true; (*opt).prev_2 = true; @@ -940,46 +937,43 @@ unsafe fn consider_literal_after_match( ) { let mut state_2: lzma_lzma_state = state; state_2 = update_match_state(state_2); - let mut pos_state_next: u32 = position.wrapping_add(len_test) & (*coder).pos_mask; + let mut pos_state_next: u32 = (position + len_test) & (*coder).pos_mask; let cur_and_len_literal_price: u32 = cur_and_len_price - .wrapping_add(rc_bit_0_price(match_prob(coder, state_2, pos_state_next)) as u32) - .wrapping_add(get_literal_price( + + rc_bit_0_price(match_prob(coder, state_2, pos_state_next)) as u32 + + get_literal_price( coder, - position.wrapping_add(len_test), - *buf.offset(len_test.wrapping_sub(1) as isize) as u32, + position + len_test, + *buf.offset((len_test - 1) as isize) as u32, true, *buf_back.offset(len_test as isize) as u32, *buf.offset(len_test as isize) as u32, - ) as u32); + ) as u32; state_2 = update_literal_state(state_2); - pos_state_next = pos_state_next.wrapping_add(1) & (*coder).pos_mask; + pos_state_next = (pos_state_next + 1) & (*coder).pos_mask; let next_rep_match_price: u32 = cur_and_len_literal_price - .wrapping_add(rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32) - .wrapping_add(rc_bit_1_price(is_rep_prob(coder, state_2)) as u32); - let offset: u32 = cur - .wrapping_add(len_test) - .wrapping_add(1) - .wrapping_add(len_test_2); + + rc_bit_1_price(match_prob(coder, state_2, pos_state_next)) as u32 + + rc_bit_1_price(is_rep_prob(coder, state_2)) as u32; + let offset: u32 = cur + len_test + 1 + len_test_2; while *len_end < offset { *len_end += 1; (*opts.add(*len_end as usize)).price = RC_INFINITY_PRICE as u32; } - let cur_and_len_price = next_rep_match_price.wrapping_add(get_rep_price( + let cur_and_len_price = next_rep_match_price + get_rep_price( coder, 0, len_test_2, state_2, pos_state_next, - )); + ); let opt = opts.add(offset as usize); if cur_and_len_price < (*opt).price { (*opt).price = cur_and_len_price; - (*opt).pos_prev = cur.wrapping_add(len_test).wrapping_add(1); + (*opt).pos_prev = cur + len_test + 1; (*opt).back_prev = 0; (*opt).prev_1_is_literal = true; (*opt).prev_2 = true; (*opt).pos_prev_2 = cur; - (*opt).back_prev_2 = cur_back.wrapping_add(REPS); + (*opt).back_prev_2 = cur_back + REPS; } } pub unsafe fn lzma_lzma_optimum_normal( @@ -993,7 +987,7 @@ pub unsafe fn lzma_lzma_optimum_normal( let matches = matches_ptr(coder); if (*coder).opts_end_index != (*coder).opts_current_index { let opt = opts.add((*coder).opts_current_index as usize); - *len_res = (*opt).pos_prev.wrapping_sub((*coder).opts_current_index); + *len_res = (*opt).pos_prev - (*coder).opts_current_index; *back_res = (*opt).back_prev; (*coder).opts_current_index = (*opt).pos_prev; return; @@ -1027,13 +1021,13 @@ pub unsafe fn lzma_lzma_optimum_normal( ::core::ptr::addr_of_mut!(reps) as *mut u32, mf_ptr(mf).offset(-1), len_end, - position.wrapping_add(cur), + position + cur, cur, (*mf).nice_len, - if mf_avail(mf).wrapping_add(1) < (((1 << 12) - 1) as u32).wrapping_sub(cur) { - mf_avail(mf).wrapping_add(1) + if mf_avail(mf) + 1 < ((1 << 12) - 1) as u32 - cur { + mf_avail(mf) + 1 } else { - (((1 << 12) - 1) as u32).wrapping_sub(cur) + ((1 << 12) - 1) as u32 - cur }, ); cur += 1; From a97d2bff5252285abb879f20a949cae9e70d0eb6 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 21:58:15 +0900 Subject: [PATCH 34/51] perf: outline optimum normal helper2 --- liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index abc1795b..4761b0ec 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -556,7 +556,7 @@ unsafe fn helper1( } len_end } -#[inline] +#[inline(never)] unsafe fn helper2( coder: *mut lzma_lzma1_encoder, reps: *mut u32, From 5b8d1fc9ea9b6bfe234e7f4b3155db9c3706c21e Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 22:01:49 +0900 Subject: [PATCH 35/51] perf: outline lzma encode out-limit path --- liblzma-rs/src/lzma/lzma_encoder.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 57365b97..c5b1b72b 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -668,6 +668,16 @@ unsafe fn finish_lzma_stream( } LZMA_STREAM_END } +#[cold] +#[inline(never)] +unsafe fn out_limit_reached(coder: *mut lzma_lzma1_encoder) -> bool { + let rc = ::core::ptr::addr_of_mut!((*coder).rc); + if (*coder).out_limit == 0 || !rc_encode_dummy(rc, (*coder).out_limit) { + return false; + } + rc_forget(rc); + true +} pub unsafe fn lzma_lzma_encode( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, @@ -720,8 +730,7 @@ pub unsafe fn lzma_lzma_encode( ); } encode_symbol(coder, mf, back, len, (*coder).uncomp_size as u32); - if (*coder).out_limit != 0 && rc_encode_dummy(rc, (*coder).out_limit) { - rc_forget(rc); + if out_limit_reached(coder) { break; } (*coder).uncomp_size += len as u64; From 4ccb742b2dcde9b5868d1e1936d4f3e71ad3e220 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 22:13:11 +0900 Subject: [PATCH 36/51] perf: outline lzma decoder resume dispatch --- liblzma-rs/src/lzma/lzma_decoder.rs | 100 ++++++++-------------------- 1 file changed, 29 insertions(+), 71 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index 246c82d0..f301e3a0 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -168,6 +168,34 @@ unsafe fn rc_read_init( } LZMA_STREAM_END } +#[inline(never)] +fn resume_block_for_sequence(sequence: lzma_decoder_seq) -> u64 { + match sequence { + 0 | 1 => 5979571030476392895, + 2 => 13844743919235296534, + 3 => 18125716024132132232, + 4 => 10535798129821001304, + 5 => 3469750012682708893, + 6 => 1138292997408115650, + 7 => 13912927785247575907, + 8 => 592696588731961849, + 9 => 4174862988780014241, + 10 => 617447976488552541, + 11 => 15418612220330286504, + 12 => 10510472849010538284, + 13 => 7073645523065812117, + 14 => 4420799852307653083, + 16 => 1698084742280242340, + 15 => 5341942013764523046, + 17 => 11808118301119257848, + 18 => 3996983927318648760, + 19 => 12043352250568755004, + 20 => 6834592846991627977, + 21 => 2467942631393454738, + 22 => 17340485688450593529, + _ => 4609795085482299213, + } +} unsafe extern "C" fn lzma_decode( coder_ptr: *mut c_void, dictptr: *mut lzma_dict, @@ -220,77 +248,7 @@ unsafe extern "C" fn lzma_decode( dict.limit = dict.pos.wrapping_add((*coder).uncompressed_size as size_t); might_finish_without_eopm = true; } - match (*coder).sequence { - 0 | 1 => { - current_block = 5979571030476392895; - } - 2 => { - current_block = 13844743919235296534; - } - 3 => { - current_block = 18125716024132132232; - } - 4 => { - current_block = 10535798129821001304; - } - 5 => { - current_block = 3469750012682708893; - } - 6 => { - current_block = 1138292997408115650; - } - 7 => { - current_block = 13912927785247575907; - } - 8 => { - current_block = 592696588731961849; - } - 9 => { - current_block = 4174862988780014241; - } - 10 => { - current_block = 617447976488552541; - } - 11 => { - current_block = 15418612220330286504; - } - 12 => { - current_block = 10510472849010538284; - } - 13 => { - current_block = 7073645523065812117; - } - 14 => { - current_block = 4420799852307653083; - } - 16 => { - current_block = 1698084742280242340; - } - 15 => { - current_block = 5341942013764523046; - } - 17 => { - current_block = 11808118301119257848; - } - 18 => { - current_block = 3996983927318648760; - } - 19 => { - current_block = 12043352250568755004; - } - 20 => { - current_block = 6834592846991627977; - } - 21 => { - current_block = 2467942631393454738; - } - 22 => { - current_block = 17340485688450593529; - } - _ => { - current_block = 4609795085482299213; - } - } + current_block = resume_block_for_sequence((*coder).sequence); 'c_9380: loop { match current_block { 4609795085482299213 => { From 553001a34e6d382860a07a571894d8d1eccd3c8e Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 22:42:54 +0900 Subject: [PATCH 37/51] perf: remove optimum fast bounds checks --- .../src/lzma/lzma_encoder_optimum_fast.rs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index 50295032..d343bd08 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -10,6 +10,13 @@ unsafe fn not_equal_16(a: *const u8, b: *const u8) -> bool { fn change_pair(small_dist: u32, big_dist: u32) -> bool { (big_dist >> 7) > small_dist } + +#[inline(always)] +unsafe fn coder_match(coder: *const lzma_lzma1_encoder, index: u32) -> *const lzma_match { + debug_assert!((index as usize) < (*coder).matches.len()); + (::core::ptr::addr_of!((*coder).matches) as *const lzma_match).add(index as usize) +} + pub unsafe fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, @@ -60,23 +67,21 @@ pub unsafe fn lzma_lzma_optimum_fast( i += 1; } if len_main >= nice_len { - *back_res = (*coder).matches[(matches_count - 1) as usize] - .dist - + REPS; + *back_res = (*coder_match(coder, matches_count - 1)).dist + REPS; *len_res = len_main; mf_skip(mf, len_main - 1); return; } let mut back_main: u32 = 0; if len_main >= 2 { - back_main = (*coder).matches[(matches_count - 1) as usize].dist; - while matches_count > 1 && len_main == (*coder).matches[(matches_count - 2) as usize].len + 1 { - if !change_pair((*coder).matches[(matches_count - 2) as usize].dist, back_main) { + back_main = (*coder_match(coder, matches_count - 1)).dist; + while matches_count > 1 && len_main == (*coder_match(coder, matches_count - 2)).len + 1 { + if !change_pair((*coder_match(coder, matches_count - 2)).dist, back_main) { break; } matches_count -= 1; - len_main = (*coder).matches[(matches_count - 1) as usize].len; - back_main = (*coder).matches[(matches_count - 1) as usize].dist; + len_main = (*coder_match(coder, matches_count - 1)).len; + back_main = (*coder_match(coder, matches_count - 1)).dist; } if len_main == 2 && back_main >= 0x80 { len_main = 1; @@ -104,7 +109,7 @@ pub unsafe fn lzma_lzma_optimum_fast( ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, ); if (*coder).longest_match_length >= 2 { - let new_dist: u32 = (*coder).matches[((*coder).matches_count - 1) as usize].dist; + let new_dist: u32 = (*coder_match(coder, (*coder).matches_count - 1)).dist; if (*coder).longest_match_length >= len_main && new_dist < back_main || (*coder).longest_match_length == len_main + 1 && !change_pair(back_main, new_dist) || (*coder).longest_match_length > len_main + 1 From a598dc0aac568f303574639226716a9dbb1ab5b6 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 20 Mar 2026 22:46:09 +0900 Subject: [PATCH 38/51] perf: trim length price updates --- liblzma-rs/src/lzma/lzma_encoder.rs | 7 ++++++- liblzma-rs/src/types.rs | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index c5b1b72b..5a5fd6e3 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -359,6 +359,11 @@ unsafe fn length_mid_probs(lc: *mut lzma_length_encoder, pos_state: u32) -> *mut ) as *mut probability } #[inline(always)] +unsafe fn length_counter(lc: *mut lzma_length_encoder, pos_state: u32) -> *mut u32 { + debug_assert!((pos_state as usize) < (*lc).counters.len()); + (::core::ptr::addr_of_mut!((*lc).counters) as *mut u32).add(pos_state as usize) +} +#[inline(always)] unsafe fn is_match_prob(coder: *mut lzma_lzma1_encoder, pos_state: u32) -> *mut probability { (::core::ptr::addr_of_mut!(*(::core::ptr::addr_of_mut!((*coder).is_match) as *mut [probability; 16]) @@ -371,7 +376,7 @@ unsafe fn is_rep_prob(coder: *mut lzma_lzma1_encoder) -> *mut probability { } unsafe fn length_update_prices(lc: *mut lzma_length_encoder, pos_state: u32) { let table_size: u32 = (*lc).table_size; - (*lc).counters[pos_state as usize] = table_size; + *length_counter(lc, pos_state) = table_size; let a0: u32 = rc_bit_0_price((*lc).choice) as u32; let a1: u32 = rc_bit_1_price((*lc).choice) as u32; let b0: u32 = a1 + rc_bit_0_price((*lc).choice2) as u32; diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index 7c120213..ad3778ea 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -910,23 +910,29 @@ pub unsafe fn get_dist_slot(dist: u32) -> u32 { .wrapping_add((2 * (0 + 2 * (FASTPOS_BITS - 1))) as u32) } #[inline] +unsafe fn rc_price_at(index: u32) -> u32 { + debug_assert!((index as usize) < 128); + *(::core::ptr::addr_of!(lzma_rc_prices) as *const u8).add(index as usize) as u32 +} +#[inline] pub fn rc_bit_price(prob: probability, bit: u32) -> u32 { unsafe { - lzma_rc_prices[((prob as u32 - ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) - >> RC_MOVE_REDUCING_BITS) as usize] as u32 + rc_price_at( + ((prob as u32 ^ 0u32.wrapping_sub(bit) & (RC_BIT_MODEL_TOTAL as u32).wrapping_sub(1)) + >> RC_MOVE_REDUCING_BITS) as u32, + ) } } #[inline] pub fn rc_bit_0_price(prob: probability) -> u32 { - unsafe { lzma_rc_prices[(prob >> RC_MOVE_REDUCING_BITS) as usize] as u32 } + unsafe { rc_price_at((prob >> RC_MOVE_REDUCING_BITS) as u32) } } #[inline] pub fn rc_bit_1_price(prob: probability) -> u32 { unsafe { - lzma_rc_prices - [((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as usize] - as u32 + rc_price_at( + ((prob as u32 ^ RC_BIT_MODEL_TOTAL.wrapping_sub(1)) >> RC_MOVE_REDUCING_BITS) as u32, + ) } } #[inline] From b58049a64fea7ec917e660f87d53dc5ff046754c Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sat, 21 Mar 2026 00:40:22 +0900 Subject: [PATCH 39/51] perf: remove range encoder bounds checks --- liblzma-rs/src/lzma/lzma_encoder.rs | 65 +++++++++++++++++++---------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 5a5fd6e3..9b96dd45 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -18,10 +18,31 @@ unsafe fn rc_forget(rc: *mut lzma_range_encoder) { } #[inline] unsafe fn rc_bit(rc: *mut lzma_range_encoder, prob: *mut probability, bit: u32) { - (*rc).symbols[(*rc).count as usize] = bit as rc_symbol; - (*rc).probs[(*rc).count as usize] = prob; + *rc_symbol_slot_mut(rc, (*rc).count) = bit as rc_symbol; + *rc_prob_slot_mut(rc, (*rc).count) = prob; (*rc).count += 1; } + +#[inline(always)] +unsafe fn rc_symbol_slot_mut(rc: *mut lzma_range_encoder, index: size_t) -> *mut rc_symbol { + debug_assert!(index < 53); + (::core::ptr::addr_of_mut!((*rc).symbols) as *mut rc_symbol).add(index) +} + +#[inline(always)] +unsafe fn rc_prob_slot_mut( + rc: *mut lzma_range_encoder, + index: size_t, +) -> *mut *mut probability { + debug_assert!(index < 53); + (::core::ptr::addr_of_mut!((*rc).probs) as *mut *mut probability).add(index) +} + +#[inline(always)] +unsafe fn coder_rep_slot_mut(coder: *mut lzma_lzma1_encoder, index: usize) -> *mut u32 { + debug_assert!(index < REPS as usize); + (::core::ptr::addr_of_mut!((*coder).reps) as *mut u32).add(index) +} #[inline] unsafe fn rc_bittree( rc: *mut lzma_range_encoder, @@ -71,8 +92,8 @@ unsafe fn rc_bittree_reverse( unsafe fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) { loop { bit_count -= 1; - (*rc).symbols[(*rc).count as usize] = - ((RC_DIRECT_0 as u32) + (value >> bit_count & 1)) as rc_symbol; + *rc_symbol_slot_mut(rc, (*rc).count) = ((RC_DIRECT_0 as u32) + (value >> bit_count & 1)) + as rc_symbol; (*rc).count += 1; if bit_count == 0 { break; @@ -83,7 +104,7 @@ unsafe fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) unsafe fn rc_flush(rc: *mut lzma_range_encoder) { let mut i: size_t = 0; while i < 5 { - (*rc).symbols[(*rc).count as usize] = RC_FLUSH; + *rc_symbol_slot_mut(rc, (*rc).count) = RC_FLUSH; (*rc).count += 1; i += 1; } @@ -155,23 +176,23 @@ unsafe fn rc_encode( } (*rc).range <<= RC_SHIFT_BITS; } - match (*rc).symbols[(*rc).pos as usize] { + match *rc_symbol_slot_mut(rc, (*rc).pos) { 0 => { - let mut prob: probability = *(*rc).probs[(*rc).pos as usize]; + let mut prob: probability = **rc_prob_slot_mut(rc, (*rc).pos); (*rc).range = ((*rc).range >> RC_BIT_MODEL_TOTAL_BITS).wrapping_mul(prob as u32); prob = (prob as u32) .wrapping_add(RC_BIT_MODEL_TOTAL.wrapping_sub(prob as u32) >> RC_MOVE_BITS) as probability; - *(*rc).probs[(*rc).pos as usize] = prob; + **rc_prob_slot_mut(rc, (*rc).pos) = prob; } 1 => { - let mut prob_0: probability = *(*rc).probs[(*rc).pos as usize]; + let mut prob_0: probability = **rc_prob_slot_mut(rc, (*rc).pos); let bound: u32 = (prob_0 as u32).wrapping_mul((*rc).range >> RC_BIT_MODEL_TOTAL_BITS); (*rc).low = (*rc).low.wrapping_add(bound as u64); (*rc).range = (*rc).range.wrapping_sub(bound); prob_0 -= prob_0 >> RC_MOVE_BITS; - *(*rc).probs[(*rc).pos as usize] = prob_0; + **rc_prob_slot_mut(rc, (*rc).pos) = prob_0; } 2 => { (*rc).range >>= 1; @@ -329,9 +350,9 @@ unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u3 } else { (*coder).state as u32 - 6 }) as lzma_lzma_state; - let match_byte: u8 = *(*mf).buffer.offset( - ((*mf).read_pos - (*coder).reps[0] - 1 - (*mf).read_ahead) as isize, - ); + let match_byte: u8 = *(*mf) + .buffer + .offset(((*mf).read_pos - *coder_rep_slot_mut(coder, 0) - 1 - (*mf).read_ahead) as isize); literal_matched( ::core::ptr::addr_of_mut!((*coder).rc), subcoder, @@ -493,10 +514,10 @@ unsafe fn match_0(coder: *mut lzma_lzma1_encoder, pos_state: u32, distance: u32, (*coder).align_price_count += 1; } } - (*coder).reps[3] = (*coder).reps[2]; - (*coder).reps[2] = (*coder).reps[1]; - (*coder).reps[1] = (*coder).reps[0]; - (*coder).reps[0] = distance; + *coder_rep_slot_mut(coder, 3) = *coder_rep_slot_mut(coder, 2); + *coder_rep_slot_mut(coder, 2) = *coder_rep_slot_mut(coder, 1); + *coder_rep_slot_mut(coder, 1) = *coder_rep_slot_mut(coder, 0); + *coder_rep_slot_mut(coder, 0) = distance; (*coder).match_price_count += 1; } #[inline] @@ -517,7 +538,7 @@ unsafe fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, rep: u32, le (len != 1) as u32, ); } else { - let distance: u32 = (*coder).reps[rep as usize]; + let distance: u32 = *coder_rep_slot_mut(coder, rep as usize); rc_bit( ::core::ptr::addr_of_mut!((*coder).rc), (::core::ptr::addr_of_mut!((*coder).is_rep0) as *mut probability) @@ -545,12 +566,12 @@ unsafe fn rep_match(coder: *mut lzma_lzma1_encoder, pos_state: u32, rep: u32, le rep - 2, ); if rep == 3 { - (*coder).reps[3] = (*coder).reps[2]; + *coder_rep_slot_mut(coder, 3) = *coder_rep_slot_mut(coder, 2); } - (*coder).reps[2] = (*coder).reps[1]; + *coder_rep_slot_mut(coder, 2) = *coder_rep_slot_mut(coder, 1); } - (*coder).reps[1] = (*coder).reps[0]; - (*coder).reps[0] = distance; + *coder_rep_slot_mut(coder, 1) = *coder_rep_slot_mut(coder, 0); + *coder_rep_slot_mut(coder, 0) = distance; } if len == 1 { (*coder).state = (if ((*coder).state as u32) < LIT_STATES { From c9e49b29ce22f5020fb14025ce9ac45af5d5935b Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sat, 21 Mar 2026 00:43:38 +0900 Subject: [PATCH 40/51] perf: hoist optimum-fast match finder callbacks --- liblzma-rs/src/lz/lz_encoder_mf.rs | 12 ++++++- .../src/lzma/lzma_encoder_optimum_fast.rs | 36 +++++++++++++++---- liblzma-rs/src/types.rs | 13 +++++-- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 37542652..42d520be 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -6,7 +6,17 @@ pub const FIX_3_HASH_SIZE: c_uint = 1u32 << 10; pub const FIX_4_HASH_SIZE: c_uint = HASH_2_SIZE.wrapping_add(HASH_3_SIZE); #[inline] pub unsafe fn lzma_mf_find(mf: *mut lzma_mf, count_ptr: *mut u32, matches: *mut lzma_match) -> u32 { - let count: u32 = (*mf).find.unwrap()(mf, matches) as u32; + lzma_mf_find_raw(mf, count_ptr, matches, (*mf).find.unwrap()) +} + +#[inline(always)] +pub unsafe fn lzma_mf_find_raw( + mf: *mut lzma_mf, + count_ptr: *mut u32, + matches: *mut lzma_match, + find: unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32, +) -> u32 { + let count: u32 = find(mf, matches) as u32; let mut len_best: u32 = 0; if count > 0 { len_best = (*matches.offset((count - 1) as isize)).len; diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs index d343bd08..d1baa1b1 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_fast.rs @@ -17,20 +17,43 @@ unsafe fn coder_match(coder: *const lzma_lzma1_encoder, index: u32) -> *const lz (::core::ptr::addr_of!((*coder).matches) as *const lzma_match).add(index as usize) } +#[inline(always)] +unsafe fn mf_find_callback( + mf: *const lzma_mf, +) -> unsafe extern "C" fn(*mut lzma_mf, *mut lzma_match) -> u32 { + debug_assert!((*mf).find.is_some()); + match (*mf).find { + Some(find) => find, + None => core::hint::unreachable_unchecked(), + } +} + +#[inline(always)] +unsafe fn mf_skip_callback(mf: *const lzma_mf) -> unsafe extern "C" fn(*mut lzma_mf, u32) -> () { + debug_assert!((*mf).skip.is_some()); + match (*mf).skip { + Some(skip) => skip, + None => core::hint::unreachable_unchecked(), + } +} + pub unsafe fn lzma_lzma_optimum_fast( coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, back_res: *mut u32, len_res: *mut u32, ) { + let mf_find = mf_find_callback(mf); + let mf_skip = mf_skip_callback(mf); let nice_len: u32 = (*mf).nice_len; let mut len_main: u32 = 0; let mut matches_count: u32 = 0; if (*mf).read_ahead == 0 { - len_main = lzma_mf_find( + len_main = lzma_mf_find_raw( mf, ::core::ptr::addr_of_mut!(matches_count), ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, + mf_find, ); } else { debug_assert!((*mf).read_ahead == 1); @@ -57,7 +80,7 @@ pub unsafe fn lzma_lzma_optimum_fast( if len >= nice_len { *back_res = i; *len_res = len; - mf_skip(mf, len - 1); + mf_skip_raw(mf, len - 1, mf_skip); return; } if len > rep_len { @@ -69,7 +92,7 @@ pub unsafe fn lzma_lzma_optimum_fast( if len_main >= nice_len { *back_res = (*coder_match(coder, matches_count - 1)).dist + REPS; *len_res = len_main; - mf_skip(mf, len_main - 1); + mf_skip_raw(mf, len_main - 1, mf_skip); return; } let mut back_main: u32 = 0; @@ -94,7 +117,7 @@ pub unsafe fn lzma_lzma_optimum_fast( { *back_res = rep_index; *len_res = rep_len; - mf_skip(mf, rep_len - 1); + mf_skip_raw(mf, rep_len - 1, mf_skip); return; } } @@ -103,10 +126,11 @@ pub unsafe fn lzma_lzma_optimum_fast( *len_res = 1; return; } - (*coder).longest_match_length = lzma_mf_find( + (*coder).longest_match_length = lzma_mf_find_raw( mf, ::core::ptr::addr_of_mut!((*coder).matches_count), ::core::ptr::addr_of_mut!((*coder).matches) as *mut lzma_match, + mf_find, ); if (*coder).longest_match_length >= 2 { let new_dist: u32 = (*coder_match(coder, (*coder).matches_count - 1)).dist; @@ -141,5 +165,5 @@ pub unsafe fn lzma_lzma_optimum_fast( } *back_res = back_main + REPS; *len_res = len_main; - mf_skip(mf, len_main - 2); + mf_skip_raw(mf, len_main - 2, mf_skip); } diff --git a/liblzma-rs/src/types.rs b/liblzma-rs/src/types.rs index ad3778ea..dd2b6f13 100644 --- a/liblzma-rs/src/types.rs +++ b/liblzma-rs/src/types.rs @@ -854,8 +854,17 @@ pub unsafe fn mf_avail(mf: *const lzma_mf) -> u32 { } #[inline] pub unsafe fn mf_skip(mf: *mut lzma_mf, amount: u32) { + mf_skip_raw(mf, amount, (*mf).skip.unwrap()); +} + +#[inline(always)] +pub unsafe fn mf_skip_raw( + mf: *mut lzma_mf, + amount: u32, + skip: unsafe extern "C" fn(*mut lzma_mf, u32) -> (), +) { if amount != 0 { - (*mf).skip.unwrap()(mf, amount); + skip(mf, amount); (*mf).read_ahead = (*mf).read_ahead.wrapping_add(amount); } } @@ -1129,7 +1138,7 @@ pub use crate::common::vli_decoder::lzma_vli_decode; pub use crate::common::vli_encoder::lzma_vli_encode; pub use crate::common::vli_size::lzma_vli_size; pub use crate::delta::delta_common::{lzma_delta_coder_init, lzma_delta_coder_memusage}; -pub use crate::lz::lz_encoder_mf::lzma_mf_find; +pub use crate::lz::lz_encoder_mf::{lzma_mf_find, lzma_mf_find_raw}; pub use crate::lzma::fastpos_table::lzma_fastpos; pub use crate::lzma::lzma_decoder::{ lzma_lzma_decoder_init, lzma_lzma_decoder_memusage_nocheck, lzma_lzma_lclppb_decode, From 67ba55d0aa45a576d5fc2af21349ab90a55067d0 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Mar 2026 12:57:20 +0900 Subject: [PATCH 41/51] perf: trim hc4 match finder indexing --- liblzma-rs/src/lz/lz_encoder_mf.rs | 56 +++++++++++++----------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/liblzma-rs/src/lz/lz_encoder_mf.rs b/liblzma-rs/src/lz/lz_encoder_mf.rs index 42d520be..66c89056 100644 --- a/liblzma-rs/src/lz/lz_encoder_mf.rs +++ b/liblzma-rs/src/lz/lz_encoder_mf.rs @@ -218,22 +218,19 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m let hash_value: u32 = (temp ^ (*cur.offset(2) as u32) << 8 ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) & (*mf).hash_mask; - let mut delta2: u32 = pos.wrapping_sub(*(*mf).hash.offset(hash_2_value as isize)); - let delta3: u32 = pos.wrapping_sub( - *(*mf) - .hash - .offset((FIX_3_HASH_SIZE as u32 + hash_3_value) as isize), - ); - let cur_match: u32 = *(*mf) - .hash - .offset((FIX_4_HASH_SIZE as u32 + hash_value) as isize); - *(*mf).hash.offset(hash_2_value as isize) = pos; - *(*mf) - .hash - .offset((FIX_3_HASH_SIZE as u32 + hash_3_value) as isize) = pos; - *(*mf) - .hash - .offset((FIX_4_HASH_SIZE as u32 + hash_value) as isize) = pos; + let hash = (*mf).hash; + let son = (*mf).son; + let cyclic_pos = (*mf).cyclic_pos; + let depth = (*mf).depth; + let cyclic_size = (*mf).cyclic_size; + let hash_3_index = FIX_3_HASH_SIZE as u32 + hash_3_value; + let hash_4_index = FIX_4_HASH_SIZE as u32 + hash_value; + let mut delta2: u32 = pos.wrapping_sub(*hash.offset(hash_2_value as isize)); + let delta3: u32 = pos.wrapping_sub(*hash.offset(hash_3_index as isize)); + let cur_match: u32 = *hash.offset(hash_4_index as isize); + *hash.offset(hash_2_value as isize) = pos; + *hash.offset(hash_3_index as isize) = pos; + *hash.offset(hash_4_index as isize) = pos; let mut len_best: u32 = 1; if delta2 < (*mf).cyclic_size && *cur.offset(-(delta2 as isize)) == *cur { len_best = 2; @@ -251,7 +248,7 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m len_best = lzma_memcmplen(cur.offset(-(delta2 as isize)), cur, len_best, len_limit); (*matches.offset((matches_count - 1) as isize)).len = len_best; if len_best == len_limit { - *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; + *son.offset(cyclic_pos as isize) = cur_match; move_pos(mf); return matches_count; } @@ -264,10 +261,10 @@ pub unsafe extern "C" fn lzma_mf_hc4_find(mf: *mut lzma_mf, matches: *mut lzma_m pos, cur, cur_match, - (*mf).depth, - (*mf).son, - (*mf).cyclic_pos, - (*mf).cyclic_size, + depth, + son, + cyclic_pos, + cyclic_size, matches.offset(matches_count as isize), len_best, ) @@ -290,16 +287,13 @@ pub unsafe extern "C" fn lzma_mf_hc4_skip(mf: *mut lzma_mf, mut amount: u32) { ^ (*cur.offset(2) as u32) << 8 ^ lzma_crc32_table[0][*cur.offset(3) as usize] << 5) & (*mf).hash_mask; - let cur_match: u32 = *(*mf) - .hash - .offset((FIX_4_HASH_SIZE as u32 + hash_value) as isize); - *(*mf).hash.offset(hash_2_value as isize) = pos; - *(*mf) - .hash - .offset((FIX_3_HASH_SIZE as u32 + hash_3_value) as isize) = pos; - *(*mf) - .hash - .offset((FIX_4_HASH_SIZE as u32 + hash_value) as isize) = pos; + let hash = (*mf).hash; + let hash_3_index = FIX_3_HASH_SIZE as u32 + hash_3_value; + let hash_4_index = FIX_4_HASH_SIZE as u32 + hash_value; + let cur_match: u32 = *hash.offset(hash_4_index as isize); + *hash.offset(hash_2_value as isize) = pos; + *hash.offset(hash_3_index as isize) = pos; + *hash.offset(hash_4_index as isize) = pos; *(*mf).son.offset((*mf).cyclic_pos as isize) = cur_match; move_pos(mf); } From 6a4d50eda416f761c261f7233f02ce8db0489c8a Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Mar 2026 22:48:12 +0900 Subject: [PATCH 42/51] refactor: outline stream encoder update branches --- liblzma-rs/src/common/stream_encoder.rs | 61 ++++++++++++++++--------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/liblzma-rs/src/common/stream_encoder.rs b/liblzma-rs/src/common/stream_encoder.rs index 1e267dbe..42e03b76 100644 --- a/liblzma-rs/src/common/stream_encoder.rs +++ b/liblzma-rs/src/common/stream_encoder.rs @@ -201,6 +201,39 @@ unsafe extern "C" fn stream_encoder_end(coder_ptr: *mut c_void, allocator: *cons ); crate::alloc::internal_free(coder as *mut c_void, allocator); } +#[inline(never)] +unsafe fn stream_encoder_update_before_block( + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + temp_ptr: *mut lzma_filter, + filters_ptr: *mut lzma_filter, +) -> lzma_ret { + (*coder).block_encoder_is_initialized = false; + (*coder).block_options.filters = temp_ptr; + let ret = block_encoder_init(coder, allocator); + (*coder).block_options.filters = filters_ptr; + if ret != LZMA_OK { + return ret; + } + (*coder).block_encoder_is_initialized = true; + LZMA_OK +} + +#[inline(never)] +unsafe fn stream_encoder_update_mid_block( + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + filters: *const lzma_filter, + reversed_filters: *const lzma_filter, +) -> lzma_ret { + (*coder).block_encoder.update.unwrap()( + (*coder).block_encoder.coder, + allocator, + filters, + reversed_filters, + ) +} + unsafe extern "C" fn stream_encoder_update( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -218,30 +251,16 @@ unsafe extern "C" fn stream_encoder_update( if ret_ != LZMA_OK { return ret_; } - if (*coder).sequence <= SEQ_BLOCK_INIT { - (*coder).block_encoder_is_initialized = false; - (*coder).block_options.filters = temp_ptr; - let ret = block_encoder_init(coder, allocator); - (*coder).block_options.filters = filters_ptr; - if ret != LZMA_OK { - lzma_filters_free(temp_ptr, allocator); - return ret; - } - (*coder).block_encoder_is_initialized = true; + let ret = if (*coder).sequence <= SEQ_BLOCK_INIT { + stream_encoder_update_before_block(coder, allocator, temp_ptr, filters_ptr) } else if (*coder).sequence <= SEQ_BLOCK_ENCODE { - let ret = (*coder).block_encoder.update.unwrap()( - (*coder).block_encoder.coder, - allocator, - filters, - reversed_filters, - ); - if ret != LZMA_OK { - lzma_filters_free(temp_ptr, allocator); - return ret; - } + stream_encoder_update_mid_block(coder, allocator, filters, reversed_filters) } else { + LZMA_PROG_ERROR + }; + if ret != LZMA_OK { lzma_filters_free(temp_ptr, allocator); - return LZMA_PROG_ERROR; + return ret; } lzma_filters_free(filters_ptr, allocator); From 62835e8631023c4360e2e88fc79cca69c46eb03f Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Mar 2026 22:52:04 +0900 Subject: [PATCH 43/51] refactor: outline stream encoder mt init branches --- liblzma-rs/src/common/stream_encoder_mt.rs | 200 ++++++++++++--------- 1 file changed, 111 insertions(+), 89 deletions(-) diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index d1b41c45..999b2c6a 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -1029,6 +1029,104 @@ unsafe extern "C" fn get_progress( mythread_i_1010 = 1; } } +#[inline(never)] +unsafe fn stream_encoder_mt_create_coder( + next: *mut lzma_next_coder, + allocator: *const lzma_allocator, +) -> *mut lzma_stream_coder { + let coder = crate::alloc::internal_alloc_object::(allocator); + if coder.is_null() { + return core::ptr::null_mut(); + } + (*next).coder = coder as *mut c_void; + if mythread_mutex_init(::core::ptr::addr_of_mut!((*coder).mutex)) != 0 { + crate::alloc::internal_free(coder as *mut c_void, allocator); + (*next).coder = core::ptr::null_mut(); + return core::ptr::null_mut(); + } + if mythread_cond_init(::core::ptr::addr_of_mut!((*coder).cond)) != 0 { + mythread_mutex_destroy(::core::ptr::addr_of_mut!((*coder).mutex)); + crate::alloc::internal_free(coder as *mut c_void, allocator); + (*next).coder = core::ptr::null_mut(); + return core::ptr::null_mut(); + } + (*next).code = Some( + stream_encode_mt + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const u8, + *mut size_t, + size_t, + *mut u8, + *mut size_t, + size_t, + lzma_action, + ) -> lzma_ret, + ); + (*next).end = + Some(stream_encoder_mt_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator)); + (*next).get_progress = + Some(get_progress as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> ()); + (*next).update = Some( + stream_encoder_mt_update + as unsafe extern "C" fn( + *mut c_void, + *const lzma_allocator, + *const lzma_filter, + *const lzma_filter, + ) -> lzma_ret, + ); + (*coder).filters[0].id = LZMA_VLI_UNKNOWN; + (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; + (*coder).index_encoder = lzma_next_coder_s { + coder: core::ptr::null_mut(), + id: LZMA_VLI_UNKNOWN, + init: 0, + code: None, + end: None, + get_progress: None, + get_check: None, + memconfig: None, + update: None, + set_out_limit: None, + }; + (*coder).index = core::ptr::null_mut(); + core::ptr::write_bytes( + ::core::ptr::addr_of_mut!((*coder).outq) as *mut u8, + 0 as u8, + core::mem::size_of::(), + ); + (*coder).threads = core::ptr::null_mut(); + (*coder).threads_max = 0; + (*coder).threads_initialized = 0; + coder +} + +#[inline(never)] +unsafe fn stream_encoder_mt_prepare_threads( + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + threads: u32, +) -> lzma_ret { + if (*coder).threads_max != threads { + threads_end(coder, allocator); + (*coder).threads = core::ptr::null_mut(); + (*coder).threads_max = 0; + (*coder).threads_initialized = 0; + (*coder).threads_free = core::ptr::null_mut(); + (*coder).threads = + crate::alloc::internal_alloc_array::(threads as size_t, allocator); + if (*coder).threads.is_null() { + return LZMA_MEM_ERROR; + } + (*coder).threads_max = threads; + } else { + threads_stop(coder, true); + } + LZMA_OK +} + unsafe extern "C" fn stream_encoder_mt_init( next: *mut lzma_next_coder, allocator: *const lzma_allocator, @@ -1127,103 +1225,27 @@ unsafe extern "C" fn stream_encoder_mt_init( } let mut coder: *mut lzma_stream_coder = (*next).coder as *mut lzma_stream_coder; if coder.is_null() { - coder = crate::alloc::internal_alloc_object::(allocator); + coder = stream_encoder_mt_create_coder(next, allocator); if coder.is_null() { return LZMA_MEM_ERROR; } - (*next).coder = coder as *mut c_void; - if mythread_mutex_init(::core::ptr::addr_of_mut!((*coder).mutex)) != 0 { - crate::alloc::internal_free(coder as *mut c_void, allocator); - (*next).coder = core::ptr::null_mut(); - return LZMA_MEM_ERROR; - } - if mythread_cond_init(::core::ptr::addr_of_mut!((*coder).cond)) != 0 { - mythread_mutex_destroy(::core::ptr::addr_of_mut!((*coder).mutex)); - crate::alloc::internal_free(coder as *mut c_void, allocator); - (*next).coder = core::ptr::null_mut(); - return LZMA_MEM_ERROR; - } - (*next).code = Some( - stream_encode_mt - as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const u8, - *mut size_t, - size_t, - *mut u8, - *mut size_t, - size_t, - lzma_action, - ) -> lzma_ret, - ); - (*next).end = Some( - stream_encoder_mt_end as unsafe extern "C" fn(*mut c_void, *const lzma_allocator) -> (), - ); - (*next).get_progress = - Some(get_progress as unsafe extern "C" fn(*mut c_void, *mut u64, *mut u64) -> ()); - (*next).update = Some( - stream_encoder_mt_update - as unsafe extern "C" fn( - *mut c_void, - *const lzma_allocator, - *const lzma_filter, - *const lzma_filter, - ) -> lzma_ret, - ); - (*coder).filters[0].id = LZMA_VLI_UNKNOWN; - (*coder).filters_cache[0].id = LZMA_VLI_UNKNOWN; - (*coder).index_encoder = lzma_next_coder_s { - coder: core::ptr::null_mut(), - id: LZMA_VLI_UNKNOWN, - init: 0, - code: None, - end: None, - get_progress: None, - get_check: None, - memconfig: None, - update: None, - set_out_limit: None, - }; - (*coder).index = core::ptr::null_mut(); - core::ptr::write_bytes( - ::core::ptr::addr_of_mut!((*coder).outq) as *mut u8, - 0 as u8, - core::mem::size_of::(), - ); - (*coder).threads = core::ptr::null_mut(); - (*coder).threads_max = 0; - (*coder).threads_initialized = 0; } (*coder).sequence = SEQ_STREAM_HEADER; (*coder).block_size = block_size as size_t; (*coder).outbuf_alloc_size = outbuf_size_max as size_t; (*coder).thread_error = LZMA_OK; (*coder).thr = core::ptr::null_mut(); - if (*coder).threads_max != (*options).threads { - threads_end(coder, allocator); - (*coder).threads = core::ptr::null_mut(); - (*coder).threads_max = 0; - (*coder).threads_initialized = 0; - (*coder).threads_free = core::ptr::null_mut(); - (*coder).threads = crate::alloc::internal_alloc_array::( - (*options).threads as size_t, - allocator, - ); - if (*coder).threads.is_null() { - return LZMA_MEM_ERROR; - } - (*coder).threads_max = (*options).threads; - } else { - threads_stop(coder, true); + let ret__0: lzma_ret = stream_encoder_mt_prepare_threads(coder, allocator, (*options).threads); + if ret__0 != LZMA_OK { + return ret__0; } - let ret__0: lzma_ret = lzma_outq_init( + let ret__1: lzma_ret = lzma_outq_init( ::core::ptr::addr_of_mut!((*coder).outq), allocator, (*options).threads, ); - if ret__0 != LZMA_OK { - return ret__0; + if ret__1 != LZMA_OK { + return ret__1; } (*coder).timeout = (*options).timeout; lzma_filters_free( @@ -1234,13 +1256,13 @@ unsafe extern "C" fn stream_encoder_mt_init( ::core::ptr::addr_of_mut!((*coder).filters_cache) as *mut lzma_filter, allocator, ); - let ret__1: lzma_ret = lzma_filters_copy( + let ret__2: lzma_ret = lzma_filters_copy( filters, ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, allocator, ); - if ret__1 != LZMA_OK { - return ret__1; + if ret__2 != LZMA_OK { + return ret__2; } lzma_index_end((*coder).index, allocator); (*coder).index = lzma_index_init(allocator); @@ -1249,12 +1271,12 @@ unsafe extern "C" fn stream_encoder_mt_init( } (*coder).stream_flags.version = 0; (*coder).stream_flags.check = (*options).check; - let ret__2: lzma_ret = lzma_stream_header_encode( + let ret__3: lzma_ret = lzma_stream_header_encode( ::core::ptr::addr_of_mut!((*coder).stream_flags), ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, ); - if ret__2 != LZMA_OK { - return ret__2; + if ret__3 != LZMA_OK { + return ret__3; } (*coder).header_pos = 0; (*coder).progress_in = 0; From a7ea1dc381f2452c70f910fdfa1ee6f82c736b3a Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Mar 2026 22:55:50 +0900 Subject: [PATCH 44/51] refactor: outline stream encoder mt phases --- liblzma-rs/src/common/stream_encoder_mt.rs | 286 ++++++++++++--------- 1 file changed, 163 insertions(+), 123 deletions(-) diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index 999b2c6a..f1f83eac 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -709,6 +709,151 @@ unsafe fn wait_for_work( } timed_out } + +#[inline(never)] +unsafe fn stream_encode_mt_blocks( + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + in_0: *const u8, + in_pos: *mut size_t, + in_size: size_t, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + action: lzma_action, +) -> lzma_ret { + let mut unpadded_size: lzma_vli = 0; + let mut uncompressed_size: lzma_vli = 0; + let mut ret: lzma_ret = LZMA_OK; + let mut has_blocked: bool = false; + let mut wait_abs: mythread_condtime = timespec { + tv_sec: 0 as __darwin_time_t, + tv_nsec: 0, + }; + loop { + let mut mythread_i_747: c_uint = 0; + while if mythread_i_747 != 0 { + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); + 0 + } else { + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); + 1 + } != 0 + { + let mut mythread_j_747: c_uint = 0; + while mythread_j_747 == 0 { + ret = (*coder).thread_error; + if ret != LZMA_OK { + break; + } + ret = lzma_outq_read( + ::core::ptr::addr_of_mut!((*coder).outq), + allocator, + out, + out_pos, + out_size, + ::core::ptr::addr_of_mut!(unpadded_size), + ::core::ptr::addr_of_mut!(uncompressed_size), + ); + mythread_j_747 = 1; + } + mythread_i_747 = 1; + } + if ret == LZMA_STREAM_END { + ret = lzma_index_append((*coder).index, allocator, unpadded_size, uncompressed_size); + if ret != LZMA_OK { + threads_stop(coder, false); + return ret; + } + if *out_pos < out_size { + continue; + } + } + if ret != LZMA_OK { + threads_stop(coder, false); + return ret; + } + ret = stream_encode_in(coder, allocator, in_0, in_pos, in_size, action); + if ret != LZMA_OK { + threads_stop(coder, false); + return ret; + } + if *in_pos == in_size { + if action == LZMA_RUN { + return LZMA_OK; + } + if action == LZMA_FULL_BARRIER { + return LZMA_STREAM_END; + } + if lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { + if action == LZMA_FINISH { + break; + } + if action == LZMA_FULL_FLUSH { + return LZMA_STREAM_END; + } + } + } + if *out_pos == out_size { + return LZMA_OK; + } + if wait_for_work( + coder, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), + *in_pos < in_size, + ) { + return LZMA_RET_INTERNAL1; + } + } + let ret_: lzma_ret = lzma_index_encoder_init( + ::core::ptr::addr_of_mut!((*coder).index_encoder), + allocator, + (*coder).index, + ); + if ret_ != LZMA_OK { + return ret_; + } + (*coder).sequence = SEQ_INDEX; + (*coder).progress_out += + (lzma_index_size((*coder).index) + LZMA_STREAM_HEADER_SIZE as lzma_vli) as u64; + LZMA_STREAM_END +} + +#[inline(never)] +unsafe fn stream_encode_mt_index( + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, +) -> lzma_ret { + let ret: lzma_ret = (*coder).index_encoder.code.unwrap()( + (*coder).index_encoder.coder, + allocator, + core::ptr::null(), + core::ptr::null_mut(), + 0, + out, + out_pos, + out_size, + LZMA_RUN, + ); + if ret != LZMA_STREAM_END { + return ret; + } + (*coder).stream_flags.backward_size = lzma_index_size((*coder).index); + if lzma_stream_footer_encode( + ::core::ptr::addr_of_mut!((*coder).stream_flags), + ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, + ) != LZMA_OK + { + return LZMA_PROG_ERROR; + } + (*coder).sequence = SEQ_STREAM_FOOTER; + LZMA_STREAM_END +} + unsafe extern "C" fn stream_encode_mt( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -721,8 +866,8 @@ unsafe extern "C" fn stream_encode_mt( action: lzma_action, ) -> lzma_ret { let coder: *mut lzma_stream_coder = coder_ptr as *mut lzma_stream_coder; - let mut current_block_53: u64 = match (*coder).sequence { - 0 => { + match (*coder).sequence { + SEQ_STREAM_HEADER => { lzma_bufcpy( ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, ::core::ptr::addr_of_mut!((*coder).header_pos), @@ -736,136 +881,31 @@ unsafe extern "C" fn stream_encode_mt( } (*coder).header_pos = 0; (*coder).sequence = SEQ_BLOCK; - 18046538441878631153 } - 1 => 18046538441878631153, - 2 => 7301844830188010456, - 3 => 8365064614624041636, + SEQ_BLOCK | SEQ_INDEX | SEQ_STREAM_FOOTER => {} _ => return LZMA_PROG_ERROR, - }; - if current_block_53 == 18046538441878631153 { - let mut unpadded_size: lzma_vli = 0; - let mut uncompressed_size: lzma_vli = 0; - let mut ret: lzma_ret = LZMA_OK; - let mut has_blocked: bool = false; - let mut wait_abs: mythread_condtime = timespec { - tv_sec: 0 as __darwin_time_t, - tv_nsec: 0, - }; - loop { - let mut mythread_i_747: c_uint = 0; - while if mythread_i_747 != 0 { - mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); - 0 - } else { - mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); - 1 - } != 0 - { - let mut mythread_j_747: c_uint = 0; - while mythread_j_747 == 0 { - ret = (*coder).thread_error; - if ret != LZMA_OK { - break; - } - ret = lzma_outq_read( - ::core::ptr::addr_of_mut!((*coder).outq), - allocator, - out, - out_pos, - out_size, - ::core::ptr::addr_of_mut!(unpadded_size), - ::core::ptr::addr_of_mut!(uncompressed_size), - ); - mythread_j_747 = 1; - } - mythread_i_747 = 1; - } - if ret == LZMA_STREAM_END { - ret = - lzma_index_append((*coder).index, allocator, unpadded_size, uncompressed_size); - if ret != LZMA_OK { - threads_stop(coder, false); - return ret; - } - if *out_pos < out_size { - continue; - } - } - if ret != LZMA_OK { - threads_stop(coder, false); - return ret; - } - ret = stream_encode_in(coder, allocator, in_0, in_pos, in_size, action); - if ret != LZMA_OK { - threads_stop(coder, false); - return ret; - } - if *in_pos == in_size { - if action == LZMA_RUN { - return LZMA_OK; - } - if action == LZMA_FULL_BARRIER { - return LZMA_STREAM_END; - } - if lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { - if action == LZMA_FINISH { - break; - } - if action == LZMA_FULL_FLUSH { - return LZMA_STREAM_END; - } - } - } - if *out_pos == out_size { - return LZMA_OK; - } - if wait_for_work( - coder, - ::core::ptr::addr_of_mut!(wait_abs), - ::core::ptr::addr_of_mut!(has_blocked), - *in_pos < in_size, - ) { - return LZMA_RET_INTERNAL1; - } - } - let ret_: lzma_ret = lzma_index_encoder_init( - ::core::ptr::addr_of_mut!((*coder).index_encoder), - allocator, - (*coder).index, - ); - if ret_ != LZMA_OK { - return ret_; - } - (*coder).sequence = SEQ_INDEX; - (*coder).progress_out += - (lzma_index_size((*coder).index) + LZMA_STREAM_HEADER_SIZE as lzma_vli) as u64; - current_block_53 = 7301844830188010456; - } - if current_block_53 == 7301844830188010456 { - let ret_0: lzma_ret = (*coder).index_encoder.code.unwrap()( - (*coder).index_encoder.coder, + } + if (*coder).sequence == SEQ_BLOCK { + let ret: lzma_ret = stream_encode_mt_blocks( + coder, allocator, - core::ptr::null(), - core::ptr::null_mut(), - 0, + in_0, + in_pos, + in_size, out, out_pos, out_size, - LZMA_RUN, + action, ); - if ret_0 != LZMA_STREAM_END { - return ret_0; + if ret != LZMA_STREAM_END { + return ret; } - (*coder).stream_flags.backward_size = lzma_index_size((*coder).index); - if lzma_stream_footer_encode( - ::core::ptr::addr_of_mut!((*coder).stream_flags), - ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, - ) != LZMA_OK - { - return LZMA_PROG_ERROR; + } + if (*coder).sequence == SEQ_INDEX { + let ret: lzma_ret = stream_encode_mt_index(coder, allocator, out, out_pos, out_size); + if ret != LZMA_STREAM_END { + return ret; } - (*coder).sequence = SEQ_STREAM_FOOTER; } lzma_bufcpy( ::core::ptr::addr_of_mut!((*coder).header) as *mut u8, From 4f43dc1ee59304d1426b8b6e581cededbc052928 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Fri, 27 Mar 2026 22:59:59 +0900 Subject: [PATCH 45/51] refactor: simplify file info decode state machine --- liblzma-rs/src/common/file_info.rs | 190 +++++++++++------------------ 1 file changed, 69 insertions(+), 121 deletions(-) diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index 45210909..ad2668f5 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -159,64 +159,35 @@ unsafe extern "C" fn file_info_decode( in_size = in_start + ((*coder).file_size - (*coder).file_cur_pos) as size_t; } loop { - let mut current_block_142: u64; match (*coder).sequence { - 0 => { + SEQ_MAGIC_BYTES => { if (*coder).file_size < LZMA_STREAM_HEADER_SIZE as u64 { return LZMA_FORMAT_ERROR; } if fill_temp(coder, in_0, in_pos, in_size) { return LZMA_OK; } - let ret_: lzma_ret = lzma_stream_header_decode( + let ret: lzma_ret = lzma_stream_header_decode( ::core::ptr::addr_of_mut!((*coder).first_header_flags), ::core::ptr::addr_of_mut!((*coder).temp) as *mut u8, ); - if ret_ != LZMA_OK { - return ret_; + if ret != LZMA_OK { + return ret; } if (*coder).file_size > LZMA_VLI_MAX as u64 || (*coder).file_size & 3 != 0 { return LZMA_DATA_ERROR; } (*coder).file_target_pos = (*coder).file_size; - current_block_142 = 10445208204442080639; + (*coder).sequence = SEQ_PADDING_SEEK; } - 1 => { - current_block_142 = 10445208204442080639; - } - 2 => { - current_block_142 = 13242334135786603907; - } - 3 => { - current_block_142 = 9626344630975045425; - } - 4 => { - current_block_142 = 9376024032952078885; - } - 5 => { - current_block_142 = 16203797167131938757; - } - 6 => { - current_block_142 = 1317013834825322123; - } - 7 => { - current_block_142 = 6010056518000876263; - } - _ => return LZMA_PROG_ERROR, - } - match current_block_142 { - 10445208204442080639 => { + SEQ_PADDING_SEEK => { (*coder).sequence = SEQ_PADDING_DECODE; - let ret__0: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); - if ret__0 != LZMA_OK { - return ret__0; + let ret: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); + if ret != LZMA_OK { + return ret; } - current_block_142 = 13242334135786603907; } - _ => {} - } - match current_block_142 { - 13242334135786603907 => { + SEQ_PADDING_DECODE => { if fill_temp(coder, in_0, in_pos, in_size) { return LZMA_OK; } @@ -228,39 +199,34 @@ unsafe extern "C" fn file_info_decode( (*coder).file_target_pos -= new_padding as u64; if new_padding == (*coder).temp_size { (*coder).sequence = SEQ_PADDING_SEEK; - current_block_142 = 13014351284863956202; - } else { - if (*coder).stream_padding & 3 != 0 { - return LZMA_DATA_ERROR; - } - (*coder).sequence = SEQ_FOOTER; - (*coder).temp_size -= new_padding; - (*coder).temp_pos = (*coder).temp_size; - if (*coder).temp_size < LZMA_STREAM_HEADER_SIZE as size_t { - let ret__1: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); - if ret__1 != LZMA_OK { - return ret__1; - } + continue; + } + if (*coder).stream_padding & 3 != 0 { + return LZMA_DATA_ERROR; + } + (*coder).sequence = SEQ_FOOTER; + (*coder).temp_size -= new_padding; + (*coder).temp_pos = (*coder).temp_size; + if (*coder).temp_size < LZMA_STREAM_HEADER_SIZE as size_t { + let ret: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); + if ret != LZMA_OK { + return ret; } - current_block_142 = 9626344630975045425; } } - _ => {} - } - match current_block_142 { - 9626344630975045425 => { + SEQ_FOOTER => { if fill_temp(coder, in_0, in_pos, in_size) { return LZMA_OK; } (*coder).file_target_pos -= LZMA_STREAM_HEADER_SIZE as u64; (*coder).temp_size -= LZMA_STREAM_HEADER_SIZE as size_t; - let ret__2: lzma_ret = hide_format_error(lzma_stream_footer_decode( + let ret: lzma_ret = hide_format_error(lzma_stream_footer_decode( ::core::ptr::addr_of_mut!((*coder).footer_flags), (::core::ptr::addr_of_mut!((*coder).temp) as *mut u8) .offset((*coder).temp_size as isize), )); - if ret__2 != LZMA_OK { - return ret__2; + if ret != LZMA_OK { + return ret; } if (*coder).file_target_pos < (*coder).footer_flags.backward_size + LZMA_STREAM_HEADER_SIZE as lzma_vli @@ -280,12 +246,8 @@ unsafe extern "C" fn file_info_decode( return LZMA_SEEK_NEEDED; } } - current_block_142 = 9376024032952078885; } - _ => {} - } - match current_block_142 { - 9376024032952078885 => { + SEQ_INDEX_INIT => { let mut memused: u64 = 0; if !(*coder).combined_index.is_null() { memused = lzma_index_memused((*coder).combined_index); @@ -293,56 +255,51 @@ unsafe extern "C" fn file_info_decode( return LZMA_PROG_ERROR; } } - let ret__3: lzma_ret = lzma_index_decoder_init( + let ret: lzma_ret = lzma_index_decoder_init( ::core::ptr::addr_of_mut!((*coder).index_decoder), allocator, ::core::ptr::addr_of_mut!((*coder).this_index), (*coder).memlimit - memused, ); - if ret__3 != LZMA_OK { - return ret__3; + if ret != LZMA_OK { + return ret; } (*coder).index_remaining = (*coder).footer_flags.backward_size; (*coder).sequence = SEQ_INDEX_DECODE; - current_block_142 = 16203797167131938757; } - _ => {} - } - match current_block_142 { - 16203797167131938757 => { - let mut ret: lzma_ret = LZMA_OK; - if (*coder).temp_size != 0 { - ret = decode_index( + SEQ_INDEX_DECODE => { + let ret: lzma_ret = if (*coder).temp_size != 0 { + decode_index( coder, allocator, ::core::ptr::addr_of_mut!((*coder).temp) as *mut u8, ::core::ptr::addr_of_mut!((*coder).temp_pos), (*coder).temp_size, false, - ); + ) } else { let mut in_stop: size_t = in_size; if (in_size - *in_pos) as lzma_vli > (*coder).index_remaining { in_stop = *in_pos + (*coder).index_remaining as size_t; } - ret = decode_index(coder, allocator, in_0, in_pos, in_stop, true); - } + decode_index(coder, allocator, in_0, in_pos, in_stop, true) + }; match ret { - 0 => { + LZMA_OK => { if (*coder).index_remaining == 0 { return LZMA_DATA_ERROR; } return LZMA_OK; } - 1 => { + LZMA_STREAM_END => { if (*coder).index_remaining != 0 { return LZMA_DATA_ERROR; } } _ => return ret, } - let seek_amount: u64 = lzma_index_total_size((*coder).this_index) as u64 - + LZMA_STREAM_HEADER_SIZE as u64; + let seek_amount: u64 = + lzma_index_total_size((*coder).this_index) as u64 + LZMA_STREAM_HEADER_SIZE as u64; if (*coder).file_target_pos < seek_amount { return LZMA_DATA_ERROR; } @@ -350,60 +307,51 @@ unsafe extern "C" fn file_info_decode( if (*coder).file_target_pos == 0 { (*coder).header_flags = (*coder).first_header_flags; (*coder).sequence = SEQ_HEADER_COMPARE; - current_block_142 = 13014351284863956202; + continue; + } + (*coder).sequence = SEQ_HEADER_DECODE; + (*coder).file_target_pos += LZMA_STREAM_HEADER_SIZE as u64; + if (*coder).temp_size != 0 + && (*coder).temp_size as lzma_vli - (*coder).footer_flags.backward_size + >= seek_amount + { + (*coder).temp_pos = ((*coder).temp_size as lzma_vli + - (*coder).footer_flags.backward_size + - seek_amount as lzma_vli + + LZMA_STREAM_HEADER_SIZE as lzma_vli) + as size_t; + (*coder).temp_size = (*coder).temp_pos; } else { - (*coder).sequence = SEQ_HEADER_DECODE; - (*coder).file_target_pos += LZMA_STREAM_HEADER_SIZE as u64; - if (*coder).temp_size != 0 - && (*coder).temp_size as lzma_vli - (*coder).footer_flags.backward_size - >= seek_amount - { - (*coder).temp_pos = ((*coder).temp_size as lzma_vli - - (*coder).footer_flags.backward_size - - seek_amount as lzma_vli - + LZMA_STREAM_HEADER_SIZE as lzma_vli) - as size_t; - (*coder).temp_size = (*coder).temp_pos; - } else { - let ret__4: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); - if ret__4 != LZMA_OK { - return ret__4; - } + let ret_seek: lzma_ret = reverse_seek(coder, in_start, in_pos, in_size); + if ret_seek != LZMA_OK { + return ret_seek; } - current_block_142 = 1317013834825322123; } } - _ => {} - } - match current_block_142 { - 1317013834825322123 => { + SEQ_HEADER_DECODE => { if fill_temp(coder, in_0, in_pos, in_size) { return LZMA_OK; } (*coder).file_target_pos -= LZMA_STREAM_HEADER_SIZE as u64; (*coder).temp_size -= LZMA_STREAM_HEADER_SIZE as size_t; (*coder).temp_pos = (*coder).temp_size; - let ret__5: lzma_ret = hide_format_error(lzma_stream_header_decode( + let ret: lzma_ret = hide_format_error(lzma_stream_header_decode( ::core::ptr::addr_of_mut!((*coder).header_flags), (::core::ptr::addr_of_mut!((*coder).temp) as *mut u8) .offset((*coder).temp_size as isize), )); - if ret__5 != LZMA_OK { - return ret__5; + if ret != LZMA_OK { + return ret; } (*coder).sequence = SEQ_HEADER_COMPARE; - current_block_142 = 6010056518000876263; } - _ => {} - } - match current_block_142 { - 6010056518000876263 => { - let ret__6: lzma_ret = lzma_stream_flags_compare( + SEQ_HEADER_COMPARE => { + let ret: lzma_ret = lzma_stream_flags_compare( ::core::ptr::addr_of_mut!((*coder).header_flags), ::core::ptr::addr_of_mut!((*coder).footer_flags), ); - if ret__6 != LZMA_OK { - return ret__6; + if ret != LZMA_OK { + return ret; } if lzma_index_stream_flags( (*coder).this_index, @@ -419,10 +367,10 @@ unsafe extern "C" fn file_info_decode( } (*coder).stream_padding = 0; if !(*coder).combined_index.is_null() { - let ret__7: lzma_ret = + let ret: lzma_ret = lzma_index_cat((*coder).this_index, (*coder).combined_index, allocator); - if ret__7 != LZMA_OK { - return ret__7; + if ret != LZMA_OK { + return ret; } } (*coder).combined_index = (*coder).this_index; @@ -439,7 +387,7 @@ unsafe extern "C" fn file_info_decode( SEQ_PADDING_SEEK }) as file_info_seq; } - _ => {} + _ => return LZMA_PROG_ERROR, } } } From bcf3589046f92e9bb16ec0e7889328acb349fb82 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 29 Mar 2026 01:33:18 +0900 Subject: [PATCH 46/51] refactor: outline stream decoder mt init phases --- liblzma-rs/src/common/file_info.rs | 4 +- liblzma-rs/src/common/stream_decoder_mt.rs | 479 +++++++++--------- liblzma-rs/src/common/stream_encoder_mt.rs | 10 +- liblzma-rs/src/lzma/lzma2_encoder.rs | 7 +- liblzma-rs/src/lzma/lzma_decoder.rs | 5 +- liblzma-rs/src/lzma/lzma_encoder.rs | 21 +- .../src/lzma/lzma_encoder_optimum_normal.rs | 52 +- 7 files changed, 284 insertions(+), 294 deletions(-) diff --git a/liblzma-rs/src/common/file_info.rs b/liblzma-rs/src/common/file_info.rs index ad2668f5..e9429322 100644 --- a/liblzma-rs/src/common/file_info.rs +++ b/liblzma-rs/src/common/file_info.rs @@ -298,8 +298,8 @@ unsafe extern "C" fn file_info_decode( } _ => return ret, } - let seek_amount: u64 = - lzma_index_total_size((*coder).this_index) as u64 + LZMA_STREAM_HEADER_SIZE as u64; + let seek_amount: u64 = lzma_index_total_size((*coder).this_index) as u64 + + LZMA_STREAM_HEADER_SIZE as u64; if (*coder).file_target_pos < seek_amount { return LZMA_DATA_ERROR; } diff --git a/liblzma-rs/src/common/stream_decoder_mt.rs b/liblzma-rs/src/common/stream_decoder_mt.rs index dc5a14db..b4875254 100644 --- a/liblzma-rs/src/common/stream_decoder_mt.rs +++ b/liblzma-rs/src/common/stream_decoder_mt.rs @@ -587,6 +587,243 @@ unsafe fn stream_decoder_reset( (*coder).pos = 0; LZMA_OK } + +#[inline(never)] +unsafe fn stream_decode_mt_block_init( + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + wait_abs: *mut mythread_condtime, + has_blocked: *mut bool, +) -> Option { + if (*coder).mem_next_filters > (*coder).memlimit_stop { + let ret: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + core::ptr::null_mut(), + true, + wait_abs, + has_blocked, + ); + if ret != LZMA_OK { + return Some(ret); + } + if !lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { + return Some(LZMA_OK); + } + return Some(LZMA_MEMLIMIT_ERROR); + } + if is_direct_mode_needed((*coder).block_options.compressed_size) + || is_direct_mode_needed((*coder).block_options.uncompressed_size) + { + (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; + return None; + } + (*coder).mem_next_in = comp_blk_size(coder) as u64; + let mem_buffers: u64 = (*coder).mem_next_in + + lzma_outq_outbuf_memusage((*coder).block_options.uncompressed_size as size_t) as u64; + if (UINT64_MAX).wrapping_sub(mem_buffers) < (*coder).mem_next_filters { + (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; + return None; + } + (*coder).mem_next_block = (*coder).mem_next_filters + mem_buffers; + if (*coder).mem_next_block > (*coder).memlimit_threading { + (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; + return None; + } + lzma_next_end(::core::ptr::addr_of_mut!((*coder).block_decoder), allocator); + (*coder).mem_direct_mode = 0; + let ret: lzma_ret = lzma_index_hash_append( + (*coder).index_hash, + lzma_block_unpadded_size(::core::ptr::addr_of_mut!((*coder).block_options)), + (*coder).block_options.uncompressed_size, + ); + if ret != LZMA_OK { + (*coder).pending_error = ret; + (*coder).sequence = SEQ_ERROR; + return None; + } + (*coder).sequence = SEQ_BLOCK_THR_INIT; + None +} + +#[inline(never)] +unsafe fn stream_decode_mt_thread_init( + coder: *mut lzma_stream_coder, + allocator: *const lzma_allocator, + out: *mut u8, + out_pos: *mut size_t, + out_size: size_t, + wait_abs: *mut mythread_condtime, + has_blocked: *mut bool, +) -> Option { + let mut block_can_start: bool = false; + let ret: lzma_ret = read_output_and_wait( + coder, + allocator, + out, + out_pos, + out_size, + ::core::ptr::addr_of_mut!(block_can_start), + true, + wait_abs, + has_blocked, + ); + if ret != LZMA_OK { + return Some(ret); + } + if (*coder).pending_error != LZMA_OK { + (*coder).sequence = SEQ_ERROR; + return None; + } + if !block_can_start { + return Some(LZMA_OK); + } + let mut mem_in_use: u64 = 0; + let mut mem_cached: u64 = 0; + let mut thr: *mut worker_thread = core::ptr::null_mut(); + let mut mythread_i_1347: c_uint = 0; + while if mythread_i_1347 != 0 { + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); + 0 + } else { + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); + 1 + } != 0 + { + let mut mythread_j_1347: c_uint = 0; + while mythread_j_1347 == 0 { + mem_in_use = (*coder).mem_in_use; + mem_cached = (*coder).mem_cached; + thr = (*coder).threads_free; + mythread_j_1347 = 1; + } + mythread_i_1347 = 1; + } + let mem_max: u64 = (*coder).memlimit_threading - (*coder).mem_next_block; + if mem_in_use + mem_cached + (*coder).outq.mem_allocated > mem_max { + lzma_outq_clear_cache2( + ::core::ptr::addr_of_mut!((*coder).outq), + allocator, + (*coder).block_options.uncompressed_size as size_t, + ); + } + let mut mem_freed: u64 = 0; + if !thr.is_null() && mem_in_use + mem_cached + (*coder).outq.mem_in_use > mem_max { + if (*thr).mem_filters <= (*coder).mem_next_filters { + thr = (*thr).next; + } + while !thr.is_null() { + lzma_next_end(::core::ptr::addr_of_mut!((*thr).block_decoder), allocator); + mem_freed += (*thr).mem_filters; + (*thr).mem_filters = 0; + thr = (*thr).next; + } + } + let mut mythread_i_1410: c_uint = 0; + while if mythread_i_1410 != 0 { + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); + 0 + } else { + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); + 1 + } != 0 + { + let mut mythread_j_1410: c_uint = 0; + while mythread_j_1410 == 0 { + (*coder).mem_cached -= mem_freed; + (*coder).mem_in_use += (*coder).mem_next_in + (*coder).mem_next_filters; + mythread_j_1410 = 1; + } + mythread_i_1410 = 1; + } + let mut ret: lzma_ret = lzma_outq_prealloc_buf( + ::core::ptr::addr_of_mut!((*coder).outq), + allocator, + (*coder).block_options.uncompressed_size as size_t, + ); + if ret != LZMA_OK { + threads_stop(coder); + return Some(ret); + } + ret = get_thread(coder, allocator); + if ret != LZMA_OK { + threads_stop(coder); + return Some(ret); + } + (*(*coder).thr).mem_filters = (*coder).mem_next_filters; + (*(*coder).thr).block_options = (*coder).block_options; + ret = lzma_block_decoder_init( + ::core::ptr::addr_of_mut!((*(*coder).thr).block_decoder), + allocator, + ::core::ptr::addr_of_mut!((*(*coder).thr).block_options), + ); + lzma_filters_free( + ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, + allocator, + ); + (*(*coder).thr).block_options.filters = core::ptr::null_mut(); + if ret != LZMA_OK { + (*coder).pending_error = ret; + (*coder).sequence = SEQ_ERROR; + return None; + } + (*(*coder).thr).in_size = (*coder).mem_next_in as size_t; + (*(*coder).thr).in_0 = + crate::alloc::internal_alloc_bytes((*(*coder).thr).in_size, allocator) as *mut u8; + if (*(*coder).thr).in_0.is_null() { + threads_stop(coder); + return Some(LZMA_MEM_ERROR); + } + (*(*coder).thr).outbuf = lzma_outq_get_buf( + ::core::ptr::addr_of_mut!((*coder).outq), + (*coder).thr as *mut c_void, + ); + let mut mythread_i_1478: c_uint = 0; + while if mythread_i_1478 != 0 { + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); + 0 + } else { + mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); + 1 + } != 0 + { + let mut mythread_j_1478: c_uint = 0; + while mythread_j_1478 == 0 { + (*(*coder).thr).state = THR_RUN; + mythread_cond_signal(::core::ptr::addr_of_mut!((*(*coder).thr).cond)); + mythread_j_1478 = 1; + } + mythread_i_1478 = 1; + } + let mut mythread_i_1486: c_uint = 0; + while if mythread_i_1486 != 0 { + mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); + 0 + } else { + mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); + 1 + } != 0 + { + let mut mythread_j_1486: c_uint = 0; + while mythread_j_1486 == 0 { + lzma_outq_enable_partial_output( + ::core::ptr::addr_of_mut!((*coder).outq), + Some(worker_enable_partial_update as unsafe extern "C" fn(*mut c_void) -> ()), + ); + mythread_j_1486 = 1; + } + mythread_i_1486 = 1; + } + (*coder).sequence = SEQ_BLOCK_THR_RUN; + None +} + unsafe extern "C" fn stream_decode_mt( coder_ptr: *mut c_void, allocator: *const lzma_allocator, @@ -857,69 +1094,18 @@ unsafe extern "C" fn stream_decode_mt( } match current_block_239 { 3123434771885419771 => { - if (*coder).mem_next_filters > (*coder).memlimit_stop { - let ret__0: lzma_ret = read_output_and_wait( - coder, - allocator, - out, - out_pos, - out_size, - core::ptr::null_mut(), - true, - ::core::ptr::addr_of_mut!(wait_abs), - ::core::ptr::addr_of_mut!(has_blocked), - ); - if ret__0 != LZMA_OK { - return ret__0; - } - if !lzma_outq_is_empty(::core::ptr::addr_of_mut!((*coder).outq)) { - return LZMA_OK; - } - return LZMA_MEMLIMIT_ERROR; - } - if is_direct_mode_needed((*coder).block_options.compressed_size) - || is_direct_mode_needed((*coder).block_options.uncompressed_size) - { - (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; - current_block_239 = 11639917216603986996; - } else { - (*coder).mem_next_in = comp_blk_size(coder) as u64; - let mem_buffers: u64 = (*coder).mem_next_in - + lzma_outq_outbuf_memusage( - (*coder).block_options.uncompressed_size as size_t, - ) as u64; - if (UINT64_MAX).wrapping_sub(mem_buffers) < (*coder).mem_next_filters { - (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; - current_block_239 = 11639917216603986996; - } else { - (*coder).mem_next_block = (*coder).mem_next_filters + mem_buffers; - if (*coder).mem_next_block > (*coder).memlimit_threading { - (*coder).sequence = SEQ_BLOCK_DIRECT_INIT; - current_block_239 = 11639917216603986996; - } else { - lzma_next_end( - ::core::ptr::addr_of_mut!((*coder).block_decoder), - allocator, - ); - (*coder).mem_direct_mode = 0; - let ret_1: lzma_ret = lzma_index_hash_append( - (*coder).index_hash, - lzma_block_unpadded_size(::core::ptr::addr_of_mut!( - (*coder).block_options - )), - (*coder).block_options.uncompressed_size, - ); - if ret_1 != LZMA_OK { - (*coder).pending_error = ret_1; - (*coder).sequence = SEQ_ERROR; - current_block_239 = 11639917216603986996; - } else { - (*coder).sequence = SEQ_BLOCK_THR_INIT; - current_block_239 = 11441799814184323368; - } - } - } + if let Some(ret) = stream_decode_mt_block_init( + coder, + allocator, + out, + out_pos, + out_size, + ::core::ptr::addr_of_mut!(wait_abs), + ::core::ptr::addr_of_mut!(has_blocked), + ) { + return ret; } + continue; } 15174413556390356007 => { let in_old_3: size_t = *in_pos; @@ -1016,179 +1202,18 @@ unsafe extern "C" fn stream_decode_mt( current_block_239 = 11639917216603986996; } 11441799814184323368 => { - let mut block_can_start: bool = false; - let ret__1: lzma_ret = read_output_and_wait( + if let Some(ret) = stream_decode_mt_thread_init( coder, allocator, out, out_pos, out_size, - ::core::ptr::addr_of_mut!(block_can_start), - true, ::core::ptr::addr_of_mut!(wait_abs), ::core::ptr::addr_of_mut!(has_blocked), - ); - if ret__1 != LZMA_OK { - return ret__1; - } - if (*coder).pending_error != LZMA_OK { - (*coder).sequence = SEQ_ERROR; - current_block_239 = 11639917216603986996; - } else { - if !block_can_start { - return LZMA_OK; - } - let mut mem_in_use: u64 = 0; - let mut mem_cached: u64 = 0; - let mut thr: *mut worker_thread = core::ptr::null_mut(); - let mut mythread_i_1347: c_uint = 0; - while if mythread_i_1347 != 0 { - mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); - 0 - } else { - mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); - 1 - } != 0 - { - let mut mythread_j_1347: c_uint = 0; - while mythread_j_1347 == 0 { - mem_in_use = (*coder).mem_in_use; - mem_cached = (*coder).mem_cached; - thr = (*coder).threads_free; - mythread_j_1347 = 1; - } - mythread_i_1347 = 1; - } - let mem_max: u64 = (*coder).memlimit_threading - (*coder).mem_next_block; - if mem_in_use + mem_cached + (*coder).outq.mem_allocated > mem_max { - lzma_outq_clear_cache2( - ::core::ptr::addr_of_mut!((*coder).outq), - allocator, - (*coder).block_options.uncompressed_size as size_t, - ); - } - let mut mem_freed: u64 = 0; - if !thr.is_null() - && mem_in_use + mem_cached + (*coder).outq.mem_in_use > mem_max - { - if (*thr).mem_filters <= (*coder).mem_next_filters { - thr = (*thr).next; - } - while !thr.is_null() { - lzma_next_end( - ::core::ptr::addr_of_mut!((*thr).block_decoder), - allocator, - ); - mem_freed += (*thr).mem_filters; - (*thr).mem_filters = 0; - thr = (*thr).next; - } - } - let mut mythread_i_1410: c_uint = 0; - while if mythread_i_1410 != 0 { - mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); - 0 - } else { - mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); - 1 - } != 0 - { - let mut mythread_j_1410: c_uint = 0; - while mythread_j_1410 == 0 { - (*coder).mem_cached -= mem_freed; - (*coder).mem_in_use += (*coder).mem_next_in + (*coder).mem_next_filters; - mythread_j_1410 = 1; - } - mythread_i_1410 = 1; - } - let mut ret_2: lzma_ret = lzma_outq_prealloc_buf( - ::core::ptr::addr_of_mut!((*coder).outq), - allocator, - (*coder).block_options.uncompressed_size as size_t, - ); - if ret_2 != LZMA_OK { - threads_stop(coder); - return ret_2; - } - ret_2 = get_thread(coder, allocator); - if ret_2 != LZMA_OK { - threads_stop(coder); - return ret_2; - } - (*(*coder).thr).mem_filters = (*coder).mem_next_filters; - (*(*coder).thr).block_options = (*coder).block_options; - ret_2 = lzma_block_decoder_init( - ::core::ptr::addr_of_mut!((*(*coder).thr).block_decoder), - allocator, - ::core::ptr::addr_of_mut!((*(*coder).thr).block_options), - ); - lzma_filters_free( - ::core::ptr::addr_of_mut!((*coder).filters) as *mut lzma_filter, - allocator, - ); - (*(*coder).thr).block_options.filters = core::ptr::null_mut(); - if ret_2 != LZMA_OK { - (*coder).pending_error = ret_2; - (*coder).sequence = SEQ_ERROR; - current_block_239 = 11639917216603986996; - } else { - (*(*coder).thr).in_size = (*coder).mem_next_in as size_t; - (*(*coder).thr).in_0 = - crate::alloc::internal_alloc_bytes((*(*coder).thr).in_size, allocator) - as *mut u8; - if (*(*coder).thr).in_0.is_null() { - threads_stop(coder); - return LZMA_MEM_ERROR; - } - (*(*coder).thr).outbuf = lzma_outq_get_buf( - ::core::ptr::addr_of_mut!((*coder).outq), - (*coder).thr as *mut c_void, - ); - let mut mythread_i_1478: c_uint = 0; - while if mythread_i_1478 != 0 { - mythread_mutex_unlock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); - 0 - } else { - mythread_mutex_lock(::core::ptr::addr_of_mut!((*(*coder).thr).mutex)); - 1 - } != 0 - { - let mut mythread_j_1478: c_uint = 0; - while mythread_j_1478 == 0 { - (*(*coder).thr).state = THR_RUN; - mythread_cond_signal(::core::ptr::addr_of_mut!( - (*(*coder).thr).cond - )); - mythread_j_1478 = 1; - } - mythread_i_1478 = 1; - } - let mut mythread_i_1486: c_uint = 0; - while if mythread_i_1486 != 0 { - mythread_mutex_unlock(::core::ptr::addr_of_mut!((*coder).mutex)); - 0 - } else { - mythread_mutex_lock(::core::ptr::addr_of_mut!((*coder).mutex)); - 1 - } != 0 - { - let mut mythread_j_1486: c_uint = 0; - while mythread_j_1486 == 0 { - lzma_outq_enable_partial_output( - ::core::ptr::addr_of_mut!((*coder).outq), - Some( - worker_enable_partial_update - as unsafe extern "C" fn(*mut c_void) -> (), - ), - ); - mythread_j_1486 = 1; - } - mythread_i_1486 = 1; - } - (*coder).sequence = SEQ_BLOCK_THR_RUN; - current_block_239 = 7728257318064351663; - } + ) { + return ret; } + continue; } _ => {} } diff --git a/liblzma-rs/src/common/stream_encoder_mt.rs b/liblzma-rs/src/common/stream_encoder_mt.rs index f1f83eac..dd919a16 100644 --- a/liblzma-rs/src/common/stream_encoder_mt.rs +++ b/liblzma-rs/src/common/stream_encoder_mt.rs @@ -887,15 +887,7 @@ unsafe extern "C" fn stream_encode_mt( } if (*coder).sequence == SEQ_BLOCK { let ret: lzma_ret = stream_encode_mt_blocks( - coder, - allocator, - in_0, - in_pos, - in_size, - out, - out_pos, - out_size, - action, + coder, allocator, in_0, in_pos, in_size, out, out_pos, out_size, action, ); if ret != LZMA_STREAM_END { return ret; diff --git a/liblzma-rs/src/lzma/lzma2_encoder.rs b/liblzma-rs/src/lzma/lzma2_encoder.rs index 8d936c8f..5b64b54f 100644 --- a/liblzma-rs/src/lzma/lzma2_encoder.rs +++ b/liblzma-rs/src/lzma/lzma2_encoder.rs @@ -69,8 +69,7 @@ unsafe fn lzma2_header_lzma(coder: *mut lzma_lzma2_coder) { } (*coder).buf_pos = pos; let mut size: size_t = (*coder).uncompressed_size - 1; - (*coder).buf[pos as usize] = - ((*coder).buf[pos as usize] as size_t + (size >> 16)) as u8; + (*coder).buf[pos as usize] = ((*coder).buf[pos as usize] as size_t + (size >> 16)) as u8; pos += 1; (*coder).buf[pos as usize] = (size >> 8 & 0xff) as u8; pos += 1; @@ -385,9 +384,7 @@ pub unsafe extern "C" fn lzma_lzma2_props_encode(options: *const c_void, out: *m } pub unsafe extern "C" fn lzma_lzma2_block_size(options: *const c_void) -> u64 { let opt: *const lzma_options_lzma = options as *const lzma_options_lzma; - if (*opt).dict_size < LZMA_DICT_SIZE_MIN as u32 - || (*opt).dict_size > (1u32 << 30) + (1 << 29) - { + if (*opt).dict_size < LZMA_DICT_SIZE_MIN as u32 || (*opt).dict_size > (1u32 << 30) + (1 << 29) { return UINT64_MAX; } if ((*opt).dict_size as u64) * 3 > 1 << 20 { diff --git a/liblzma-rs/src/lzma/lzma_decoder.rs b/liblzma-rs/src/lzma/lzma_decoder.rs index f301e3a0..18ee3558 100644 --- a/liblzma-rs/src/lzma/lzma_decoder.rs +++ b/liblzma-rs/src/lzma/lzma_decoder.rs @@ -3407,10 +3407,7 @@ pub unsafe extern "C" fn lzma_lzma_decoder_init( ), ) } -pub unsafe fn lzma_lzma_lclppb_decode( - options: *mut lzma_options_lzma, - mut byte: u8, -) -> bool { +pub unsafe fn lzma_lzma_lclppb_decode(options: *mut lzma_options_lzma, mut byte: u8) -> bool { if byte > (4 * 5 + 4) * 9 + 8 { return true; } diff --git a/liblzma-rs/src/lzma/lzma_encoder.rs b/liblzma-rs/src/lzma/lzma_encoder.rs index 9b96dd45..43588b40 100644 --- a/liblzma-rs/src/lzma/lzma_encoder.rs +++ b/liblzma-rs/src/lzma/lzma_encoder.rs @@ -30,10 +30,7 @@ unsafe fn rc_symbol_slot_mut(rc: *mut lzma_range_encoder, index: size_t) -> *mut } #[inline(always)] -unsafe fn rc_prob_slot_mut( - rc: *mut lzma_range_encoder, - index: size_t, -) -> *mut *mut probability { +unsafe fn rc_prob_slot_mut(rc: *mut lzma_range_encoder, index: size_t) -> *mut *mut probability { debug_assert!(index < 53); (::core::ptr::addr_of_mut!((*rc).probs) as *mut *mut probability).add(index) } @@ -92,8 +89,8 @@ unsafe fn rc_bittree_reverse( unsafe fn rc_direct(rc: *mut lzma_range_encoder, value: u32, mut bit_count: u32) { loop { bit_count -= 1; - *rc_symbol_slot_mut(rc, (*rc).count) = ((RC_DIRECT_0 as u32) + (value >> bit_count & 1)) - as rc_symbol; + *rc_symbol_slot_mut(rc, (*rc).count) = + ((RC_DIRECT_0 as u32) + (value >> bit_count & 1)) as rc_symbol; (*rc).count += 1; if bit_count == 0 { break; @@ -350,9 +347,9 @@ unsafe fn literal(coder: *mut lzma_lzma1_encoder, mf: *mut lzma_mf, position: u3 } else { (*coder).state as u32 - 6 }) as lzma_lzma_state; - let match_byte: u8 = *(*mf) - .buffer - .offset(((*mf).read_pos - *coder_rep_slot_mut(coder, 0) - 1 - (*mf).read_ahead) as isize); + let match_byte: u8 = *(*mf).buffer.offset( + ((*mf).read_pos - *coder_rep_slot_mut(coder, 0) - 1 - (*mf).read_ahead) as isize, + ); literal_matched( ::core::ptr::addr_of_mut!((*coder).rc), subcoder, @@ -967,10 +964,8 @@ pub unsafe fn lzma_lzma_encoder_create( } else { (*options).nice_len }; - (*coder).match_len_encoder.table_size = - nice_len + 1 - MATCH_LEN_MIN; - (*coder).rep_len_encoder.table_size = - nice_len + 1 - MATCH_LEN_MIN; + (*coder).match_len_encoder.table_size = nice_len + 1 - MATCH_LEN_MIN; + (*coder).rep_len_encoder.table_size = nice_len + 1 - MATCH_LEN_MIN; } _ => return LZMA_OPTIONS_ERROR, } diff --git a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs index 4761b0ec..a00b49f1 100644 --- a/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs +++ b/liblzma-rs/src/lzma/lzma_encoder_optimum_normal.rs @@ -661,10 +661,8 @@ unsafe fn helper2( make_literal(next_opt); next_is_literal = true; } - let match_price: u32 = - cur_price + rc_bit_1_price(match_prob(coder, state, pos_state)) as u32; - let rep_match_price: u32 = - match_price + rc_bit_1_price(is_rep_prob(coder, state)) as u32; + let match_price: u32 = cur_price + rc_bit_1_price(match_prob(coder, state, pos_state)) as u32; + let rep_match_price: u32 = match_price + rc_bit_1_price(is_rep_prob(coder, state)) as u32; if match_byte == current_byte && !(next_opt.pos_prev < cur && next_opt.back_prev == 0) { let short_rep_price: u32 = rep_match_price + get_short_rep_price(coder, state, pos_state) as u32; @@ -702,13 +700,8 @@ unsafe fn helper2( len_end += 1; (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } - let cur_and_len_price: u32 = next_rep_match_price + get_rep_price( - coder, - 0, - len_test, - state_2, - pos_state_next, - ) as u32; + let cur_and_len_price: u32 = next_rep_match_price + + get_rep_price(coder, 0, len_test, state_2, pos_state_next) as u32; let opt = opts.add(offset as usize); if cur_and_len_price < (*opt).price { (*opt).price = cur_and_len_price; @@ -732,14 +725,15 @@ unsafe fn helper2( (*opts.add(len_end as usize)).price = RC_INFINITY_PRICE as u32; } let len_test_temp: u32 = len_test_0; - let price: u32 = rep_match_price - + get_pure_rep_price(coder, rep_index, state, pos_state) as u32; + let price: u32 = + rep_match_price + get_pure_rep_price(coder, rep_index, state, pos_state) as u32; loop { - let cur_and_len_price_0: u32 = price + get_len_price( - ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), - len_test_0, - pos_state, - ) as u32; + let cur_and_len_price_0: u32 = price + + get_len_price( + ::core::ptr::addr_of_mut!((*coder).rep_len_encoder), + len_test_0, + pos_state, + ) as u32; let opt = opts.add((cur + len_test_0) as usize); if cur_and_len_price_0 < (*opt).price { (*opt).price = cur_and_len_price_0; @@ -809,8 +803,8 @@ unsafe fn helper2( let mut len_test_1: u32 = start_len; loop { let cur_back: u32 = (*matches.add(i_2 as usize)).dist; - let cur_and_len_price_2: u32 = normal_match_price - + get_dist_len_price(coder, cur_back, len_test_1, pos_state); + let cur_and_len_price_2: u32 = + normal_match_price + get_dist_len_price(coder, cur_back, len_test_1, pos_state); let opt = opts.add((cur + len_test_1) as usize); if cur_and_len_price_2 < (*opt).price { (*opt).price = cur_and_len_price_2; @@ -901,13 +895,8 @@ unsafe fn consider_literal_after_rep( *len_end += 1; (*opts.add(*len_end as usize)).price = RC_INFINITY_PRICE as u32; } - let cur_and_len_price: u32 = next_rep_match_price + get_rep_price( - coder, - 0, - len_test_2, - state_2, - pos_state_next, - ) as u32; + let cur_and_len_price: u32 = + next_rep_match_price + get_rep_price(coder, 0, len_test_2, state_2, pos_state_next) as u32; let opt = opts.add(offset as usize); if cur_and_len_price < (*opt).price { (*opt).price = cur_and_len_price; @@ -958,13 +947,8 @@ unsafe fn consider_literal_after_match( *len_end += 1; (*opts.add(*len_end as usize)).price = RC_INFINITY_PRICE as u32; } - let cur_and_len_price = next_rep_match_price + get_rep_price( - coder, - 0, - len_test_2, - state_2, - pos_state_next, - ); + let cur_and_len_price = + next_rep_match_price + get_rep_price(coder, 0, len_test_2, state_2, pos_state_next); let opt = opts.add(offset as usize); if cur_and_len_price < (*opt).price { (*opt).price = cur_and_len_price; From 28626a54c7fdadeb2fa0a412462a22b8eca5b3a6 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Tue, 31 Mar 2026 06:05:59 +0900 Subject: [PATCH 47/51] toolchain compatibility --- .github/workflows/main.yml | 2 +- liblzma-rs/src/common/auto_decoder.rs | 4 +++- liblzma-rs/src/common/block_buffer_decoder.rs | 4 +++- liblzma-rs/src/common/common.rs | 4 +++- liblzma-rs/src/common/filter_buffer_decoder.rs | 4 +++- liblzma-rs/src/common/filter_buffer_encoder.rs | 4 +++- liblzma-rs/src/common/microlzma_encoder.rs | 8 ++++++-- liblzma-rs/src/common/outqueue.rs | 4 +++- liblzma-rs/src/common/stream_buffer_decoder.rs | 8 ++++++-- liblzma-rs/src/lz/lz_decoder.rs | 4 +++- liblzma-rs/src/lz/lz_encoder.rs | 4 +++- liblzma-rs/src/simple/simple_coder.rs | 2 +- 12 files changed, 38 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee75d9b8..176c792d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: run: | cp Cargo.lock.msrv Cargo.lock - run: | - cargo test --no-default-features + cargo test --no-default-features --features rust-backend cargo clean -p liblzma -p liblzma-sys - run: | cargo test --features parallel diff --git a/liblzma-rs/src/common/auto_decoder.rs b/liblzma-rs/src/common/auto_decoder.rs index 639e417d..a46b44f0 100644 --- a/liblzma-rs/src/common/auto_decoder.rs +++ b/liblzma-rs/src/common/auto_decoder.rs @@ -70,7 +70,9 @@ unsafe extern "C" fn auto_decode( } match current_block_28 { 13935781298497728377 => { - let Some(code) = (*coder).next.code else { + let code = if let Some(code) = (*coder).next.code { + code + } else { return LZMA_PROG_ERROR; }; let ret: lzma_ret = code( diff --git a/liblzma-rs/src/common/block_buffer_decoder.rs b/liblzma-rs/src/common/block_buffer_decoder.rs index fe1e2a7f..e992d72c 100644 --- a/liblzma-rs/src/common/block_buffer_decoder.rs +++ b/liblzma-rs/src/common/block_buffer_decoder.rs @@ -33,7 +33,9 @@ pub unsafe fn lzma_block_buffer_decode( let mut ret: lzma_ret = lzma_block_decoder_init(::core::ptr::addr_of_mut!(block_decoder), allocator, block); if ret == LZMA_OK { - let Some(code) = block_decoder.code else { + let code = if let Some(code) = block_decoder.code { + code + } else { lzma_next_end(::core::ptr::addr_of_mut!(block_decoder), allocator); return LZMA_PROG_ERROR; }; diff --git a/liblzma-rs/src/common/common.rs b/liblzma-rs/src/common/common.rs index b5b5024b..cde83adb 100644 --- a/liblzma-rs/src/common/common.rs +++ b/liblzma-rs/src/common/common.rs @@ -169,7 +169,9 @@ pub unsafe fn lzma_next_filter_update( if (*reversed_filters).id == LZMA_VLI_UNKNOWN { return LZMA_OK; } - let Some(update) = (*next).update else { + let update = if let Some(update) = (*next).update { + update + } else { return LZMA_PROG_ERROR; }; update( diff --git a/liblzma-rs/src/common/filter_buffer_decoder.rs b/liblzma-rs/src/common/filter_buffer_decoder.rs index 9df37a2d..ebaf7e50 100644 --- a/liblzma-rs/src/common/filter_buffer_decoder.rs +++ b/liblzma-rs/src/common/filter_buffer_decoder.rs @@ -34,7 +34,9 @@ pub unsafe fn lzma_raw_buffer_decode( if ret_ != LZMA_OK { return ret_; } - let Some(code) = next.code else { + let code = if let Some(code) = next.code { + code + } else { lzma_next_end(::core::ptr::addr_of_mut!(next), allocator); return LZMA_PROG_ERROR; }; diff --git a/liblzma-rs/src/common/filter_buffer_encoder.rs b/liblzma-rs/src/common/filter_buffer_encoder.rs index 6b0cb1c8..f088a2ee 100644 --- a/liblzma-rs/src/common/filter_buffer_encoder.rs +++ b/liblzma-rs/src/common/filter_buffer_encoder.rs @@ -27,7 +27,9 @@ pub unsafe fn lzma_raw_buffer_encode( if ret_ != LZMA_OK { return ret_; } - let Some(code) = next.code else { + let code = if let Some(code) = next.code { + code + } else { lzma_next_end(::core::ptr::addr_of_mut!(next), allocator); return LZMA_PROG_ERROR; }; diff --git a/liblzma-rs/src/common/microlzma_encoder.rs b/liblzma-rs/src/common/microlzma_encoder.rs index 0e2e670f..207b9fde 100644 --- a/liblzma-rs/src/common/microlzma_encoder.rs +++ b/liblzma-rs/src/common/microlzma_encoder.rs @@ -20,10 +20,14 @@ unsafe extern "C" fn microlzma_encode( let out_start: size_t = *out_pos; let in_start: size_t = *in_pos; let mut uncomp_size: u64 = 0; - let Some(set_out_limit) = (*coder).lzma.set_out_limit else { + let set_out_limit = if let Some(set_out_limit) = (*coder).lzma.set_out_limit { + set_out_limit + } else { return LZMA_PROG_ERROR; }; - let Some(code) = (*coder).lzma.code else { + let code = if let Some(code) = (*coder).lzma.code { + code + } else { return LZMA_PROG_ERROR; }; if set_out_limit( diff --git a/liblzma-rs/src/common/outqueue.rs b/liblzma-rs/src/common/outqueue.rs index dd9d29cd..7f1c3e15 100644 --- a/liblzma-rs/src/common/outqueue.rs +++ b/liblzma-rs/src/common/outqueue.rs @@ -161,7 +161,9 @@ pub unsafe fn lzma_outq_enable_partial_output( outq: *mut lzma_outq, enable_partial_output: Option ()>, ) { - let Some(enable_partial_output) = enable_partial_output else { + let enable_partial_output = if let Some(enable_partial_output) = enable_partial_output { + enable_partial_output + } else { return; }; diff --git a/liblzma-rs/src/common/stream_buffer_decoder.rs b/liblzma-rs/src/common/stream_buffer_decoder.rs index ba12cf7f..36053c0d 100644 --- a/liblzma-rs/src/common/stream_buffer_decoder.rs +++ b/liblzma-rs/src/common/stream_buffer_decoder.rs @@ -41,7 +41,9 @@ pub unsafe fn lzma_stream_buffer_decode( flags, ); if ret == LZMA_OK { - let Some(code) = stream_decoder.code else { + let code = if let Some(code) = stream_decoder.code { + code + } else { lzma_next_end(::core::ptr::addr_of_mut!(stream_decoder), allocator); return LZMA_PROG_ERROR; }; @@ -71,7 +73,9 @@ pub unsafe fn lzma_stream_buffer_decode( } } else if ret == LZMA_MEMLIMIT_ERROR { let mut memusage: u64 = 0; - let Some(memconfig) = stream_decoder.memconfig else { + let memconfig = if let Some(memconfig) = stream_decoder.memconfig { + memconfig + } else { lzma_next_end(::core::ptr::addr_of_mut!(stream_decoder), allocator); return LZMA_PROG_ERROR; }; diff --git a/liblzma-rs/src/lz/lz_decoder.rs b/liblzma-rs/src/lz/lz_decoder.rs index c42acca2..1a4ede50 100644 --- a/liblzma-rs/src/lz/lz_decoder.rs +++ b/liblzma-rs/src/lz/lz_decoder.rs @@ -230,7 +230,9 @@ pub unsafe fn lzma_lz_decoder_init( preset_dict: core::ptr::null(), preset_dict_size: 0, }; - let Some(lz_init) = lz_init else { + let lz_init = if let Some(lz_init) = lz_init { + lz_init + } else { return LZMA_PROG_ERROR; }; let ret_: lzma_ret = lz_init( diff --git a/liblzma-rs/src/lz/lz_encoder.rs b/liblzma-rs/src/lz/lz_encoder.rs index ab355d65..7148d3ef 100644 --- a/liblzma-rs/src/lz/lz_encoder.rs +++ b/liblzma-rs/src/lz/lz_encoder.rs @@ -476,7 +476,9 @@ pub unsafe fn lzma_lz_encoder_init( preset_dict: core::ptr::null(), preset_dict_size: 0, }; - let Some(lz_init) = lz_init else { + let lz_init = if let Some(lz_init) = lz_init { + lz_init + } else { return LZMA_PROG_ERROR; }; let ret_: lzma_ret = lz_init( diff --git a/liblzma-rs/src/simple/simple_coder.rs b/liblzma-rs/src/simple/simple_coder.rs index 20c7564c..2c8bc11e 100644 --- a/liblzma-rs/src/simple/simple_coder.rs +++ b/liblzma-rs/src/simple/simple_coder.rs @@ -43,7 +43,7 @@ unsafe fn call_filter(coder: *mut lzma_simple_coder, buffer: *mut u8, size: size buffer, size, ) as size_t; - (*coder).now_pos = ((*coder).now_pos as size_t + filtered) as u32; + (*coder).now_pos = (*coder).now_pos.wrapping_add(filtered as u32); filtered } unsafe extern "C" fn simple_code( From 4c00fef347d28f8cebc7a91bcaa40c28e85a1cc7 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Tue, 31 Mar 2026 06:09:38 +0900 Subject: [PATCH 48/51] fix: restore wasm arm64 wrapping semantics --- Cargo.lock.msrv | 1 + liblzma-rs/src/simple/arm64.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv index 24df8a95..54c120f6 100644 --- a/Cargo.lock.msrv +++ b/Cargo.lock.msrv @@ -431,6 +431,7 @@ name = "liblzma-rs" version = "0.1.0" dependencies = [ "libc", + "memchr", ] [[package]] diff --git a/liblzma-rs/src/simple/arm64.rs b/liblzma-rs/src/simple/arm64.rs index fd46043c..f9f5c934 100644 --- a/liblzma-rs/src/simple/arm64.rs +++ b/liblzma-rs/src/simple/arm64.rs @@ -10,7 +10,7 @@ unsafe extern "C" fn arm64_code( let mut i: size_t = 0; i = 0; while i < size { - let mut pc: u32 = (now_pos as size_t + i) as u32; + let mut pc: u32 = now_pos.wrapping_add(i as u32); let mut instr: u32 = read32le(buffer.offset(i as isize)); if instr >> 26 == 0x25 { let src: u32 = instr; From f1391d6b5b35ff07372d45fbdce121f5949a782c Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Tue, 31 Mar 2026 06:20:13 +0900 Subject: [PATCH 49/51] ci: pin wasm bindgen and narrow emscripten tests --- .github/workflows/webassembly.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/webassembly.yml b/.github/workflows/webassembly.yml index 247c5b92..4ffcac0a 100644 --- a/.github/workflows/webassembly.yml +++ b/.github/workflows/webassembly.yml @@ -49,13 +49,13 @@ jobs: name: Run test run: | curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash - cargo binstall -y --force wasm-bindgen-cli + cargo binstall -y --force wasm-bindgen-cli@0.2.114 cargo test --locked --target ${{ matrix.target }} --features wasm --release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For ease GitHub API rate limits - name: Run test if: ${{ startsWith(matrix.target, 'wasm32-unknown-emscripten') }} run: | - cargo test --locked --target ${{ matrix.target }} --features wasm -- --skip standard_files + cargo test --locked --target ${{ matrix.target }} --lib --tests --features wasm -- --skip standard_files env: RUSTFLAGS: "-C link-args=-sINITIAL_MEMORY=128MB" From 7e764136e59c34b71b1dd48bc9384010a1233e3c Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Tue, 31 Mar 2026 06:27:28 +0900 Subject: [PATCH 50/51] build: upgrade wasm-bindgen stack --- .github/workflows/webassembly.yml | 2 +- Cargo.lock.msrv | 46 +++++++++++++++---------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.github/workflows/webassembly.yml b/.github/workflows/webassembly.yml index 4ffcac0a..b9e503e1 100644 --- a/.github/workflows/webassembly.yml +++ b/.github/workflows/webassembly.yml @@ -49,7 +49,7 @@ jobs: name: Run test run: | curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash - cargo binstall -y --force wasm-bindgen-cli@0.2.114 + cargo binstall -y --force wasm-bindgen-cli@0.2.115 cargo test --locked --target ${{ matrix.target }} --features wasm --release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For ease GitHub API rate limits diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv index 54c120f6..4561c938 100644 --- a/Cargo.lock.msrv +++ b/Cargo.lock.msrv @@ -396,10 +396,12 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.91" +version = "0.3.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +checksum = "cc4c90f45aa2e6eacbe8645f77fdea542ac97a494bcd117a67df9ff4d611f995" dependencies = [ + "cfg-if 1.0.4", + "futures-util", "once_cell", "wasm-bindgen", ] @@ -898,9 +900,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.114" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +checksum = "6523d69017b7633e396a89c5efab138161ed5aafcbc8d3e5c5a42ae38f50495a" dependencies = [ "cfg-if 1.0.4", "once_cell", @@ -911,23 +913,19 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.64" +version = "0.4.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" +checksum = "2d1faf851e778dfa54db7cd438b70758eba9755cb47403f3496edd7c8fc212f0" dependencies = [ - "cfg-if 1.0.4", - "futures-util", "js-sys", - "once_cell", "wasm-bindgen", - "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.114" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +checksum = "4e3a6c758eb2f701ed3d052ff5737f5bfe6614326ea7f3bbac7156192dc32e67" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -935,9 +933,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.114" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +checksum = "921de2737904886b52bcbb237301552d05969a6f9c40d261eb0533c8b055fedf" dependencies = [ "bumpalo", "proc-macro2", @@ -948,18 +946,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.114" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +checksum = "a93e946af942b58934c604527337bad9ae33ba1d5c6900bbb41c2c07c2364a93" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-bindgen-test" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6311c867385cc7d5602463b31825d454d0837a3aba7cdb5e56d5201792a3f7fe" +checksum = "1138411301a026d6662dc44e7076a74dbaa76a369312275eea5dee4d7dc68c7c" dependencies = [ "async-trait", "cast", @@ -979,9 +977,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67008cdde4769831958536b0f11b3bdd0380bde882be17fff9c2f34bb4549abd" +checksum = "186ddfe8383ba7ae7927bae3bb7343fd1f03ba2dbaf1474410f0d831131c269b" dependencies = [ "proc-macro2", "quote", @@ -990,15 +988,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-shared" -version = "0.2.114" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe29135b180b72b04c74aa97b2b4a2ef275161eff9a6c7955ea9eaedc7e1d4e" +checksum = "f032e076ceb8d36d5921c6cef5bf447f2ca2bbd5439ce1683d68d1c99cc2be16" [[package]] name = "web-sys" -version = "0.3.91" +version = "0.3.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" +checksum = "84cde8507f4d7cfcb1185b8cb5890c494ffea65edbe1ba82cfd63661c805ed94" dependencies = [ "js-sys", "wasm-bindgen", From 7b4db06f28c1e65683223e247cb0a49bbff6494f Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Wed, 1 Apr 2026 21:23:31 +0900 Subject: [PATCH 51/51] ci: fix emscripten wasm job --- .github/workflows/webassembly.yml | 2 +- liblzma-rs-sys/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/webassembly.yml b/.github/workflows/webassembly.yml index b9e503e1..a902a299 100644 --- a/.github/workflows/webassembly.yml +++ b/.github/workflows/webassembly.yml @@ -45,7 +45,7 @@ jobs: name: Run test run: | cargo test --locked --target ${{ matrix.target }} --features wasm - - if: ${{ endsWith(matrix.target, 'unknown') }} + - if: ${{ matrix.target == 'wasm32-unknown-unknown' }} name: Run test run: | curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash diff --git a/liblzma-rs-sys/Cargo.toml b/liblzma-rs-sys/Cargo.toml index 13df0d8f..c9b7be0c 100644 --- a/liblzma-rs-sys/Cargo.toml +++ b/liblzma-rs-sys/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" description = "liblzma-sys compatible API layer backed by pure Rust liblzma-rs" [lib] -crate-type = ["rlib", "staticlib", "cdylib"] +crate-type = ["rlib", "staticlib"] [features] default = ["bindgen"]